Commit df778931 authored by Georgios Ouzounis's avatar Georgios Ouzounis
Browse files

Merge pull request #277 from ioantsaf/start-stop-disable-buttons

[Bug 10] Disable start/stop/undeploy buttons, when they are clicked
parents a04cd591 043bfca9
......@@ -42,6 +42,7 @@ module.exports = function(environment) {
ENV.refresh_interval = 6000;
ENV.redirect_delay = 3000;
ENV.message_dismiss = 4000;
ENV.button_delay = 10000;
if (environment === 'development') {
// ENV.APP.LOG_RESOLVER = true;
......
......@@ -11,14 +11,16 @@ export default Ember.Component.extend({
}
//send request to start application
var _this = this;
app.set('application_id', this.get("application-id"));
app.set('lambda_instance_id', this.get("instance-id"));
var application_id = this.get('application-id');
var instance_id = this.get('instance-id');
app.set('application_id', application_id);
app.set('lambda_instance_id', instance_id);
app.set('call', "start");
app.save().then(
function success() {
_this.set("request", true);
_this.set("message", "Your request to start the application was successfully sent to the server.");
_this.sendAction('action');
_this.sendAction('action', 'start', application_id, instance_id);
}).catch(
function failure() {
_this.set("failure", true);
......@@ -31,14 +33,16 @@ export default Ember.Component.extend({
}
//send request to stop application
var _this = this;
app.set('application_id', this.get("application-id"));
app.set('lambda_instance_id', this.get("instance-id"));
var application_id = this.get('application-id');
var instance_id = this.get('instance-id');
app.set('application_id', application_id);
app.set('lambda_instance_id', instance_id);
app.set('call', "stop");
app.save().then(
function success() {
_this.set("request", true);
_this.set("message", "Your request to stop the application was successfully sent to the server.");
_this.sendAction('action');
_this.sendAction('action', 'stop', application_id, instance_id);
}).catch(
function failure() {
_this.set("failure", true);
......
......@@ -12,13 +12,14 @@ export default Ember.Component.extend({
}
var _this = this;
//send request to start instance
instance.set('lambda_instance_id', this.get("instance-id"));
var lambda_instance_id = this.get('instance-id');
instance.set('lambda_instance_id', lambda_instance_id);
instance.set('action', "start");
instance.save().then(
function success() {
_this.set("request", true);
_this.set("message", "Your request to start the lambda-instance was successfully sent to the server.");
_this.sendAction('action');
_this.sendAction('action', 'start', lambda_instance_id);
}).catch(
function failure() {
_this.set("failure", true);
......@@ -30,6 +31,7 @@ export default Ember.Component.extend({
return false;
}
var _this = this;
var lambda_instance_id = this.get('instance-id');
if (this.get('check_apps'))
{
apps.forEach(function(item) {
......@@ -46,13 +48,13 @@ export default Ember.Component.extend({
//send request to stop instance
if (this.get("app_started")){
if (confirm("There is a deployed application currently running on this lambda-instance.\nAre you sure you want to stop this lambda instance?")) {
instance.set('lambda_instance_id', this.get("instance-id"));
instance.set('lambda_instance_id', lambda_instance_id);
instance.set('action', "stop");
instance.save().then(
function success() {
_this.set("request", true);
_this.set("message", "Your request to stop the lambda-instance was successfully sent to the server.");
_this.sendAction('action');
_this.sendAction('action', 'stop', lambda_instance_id);
}).catch(
function failure() {
_this.set("failure", true);
......@@ -60,13 +62,13 @@ export default Ember.Component.extend({
}
}
else {
instance.set('lambda_instance_id', this.get("instance-id"));
instance.set('lambda_instance_id', lambda_instance_id);
instance.set('action', "stop");
instance.save().then(
function success() {
_this.set("request", true);
_this.set("message", "Your request to stop the lambda-instance was successfully sent to the server.");
_this.sendAction('action');
_this.sendAction('action', 'stop', lambda_instance_id);
}).catch(
function failure() {
_this.set("failure", true);
......
......@@ -13,8 +13,11 @@ export default Ember.Controller.extend({
deployWait: false,
deployID: -1,
actions: {
withdraw: function(application_id, instance_id)
{
var instance = this.get('model.instances').findBy('id', instance_id);
instance.set('undeploying', true);
var _this = this;
Ember.run.later((function () {
_this.store.find('lambda-instance', instance_id).then(function (instance) {
......@@ -23,19 +26,37 @@ export default Ember.Controller.extend({
_this.set('request', false);
}), ENV.message_dismiss);
},
start_stop: function()
start_stop: function (action, application_id, instance_id)
{
var app_instance = this.get('model.instances').findBy('id', instance_id);
if (action === 'start') {
app_instance.set('starting', true);
}
else if (action === 'stop') {
app_instance.set('stopping', true);
}
var _this = this;
Ember.run.later((function () {
_this.set('request', false);
}), ENV.message_dismiss);
Ember.run.later((function () {
if (action === 'start') {
app_instance.set('starting', false);
}
else if (action === 'stop') {
app_instance.set('stopping', false);
}
}), ENV.button_delay);
},
close_alert: function()
{
var alert = document.getElementById('alert');
this.set('failed_delete', false);
alert.hidden=true;
},
delete_app: function(app_id) {
if (this.get('model.instances.length')) {
alert("The application is deployed on one or more lambda-instance(s).\nPlease undeploy it before deleting.");
......@@ -88,5 +109,6 @@ export default Ember.Controller.extend({
}
}
},
},
});
......@@ -12,27 +12,72 @@ export default Ember.Controller.extend({
deployWait: false,
deployID: -1,
actions: {
close_alert: function()
{
var alert = document.getElementById('alert');
alert.hidden=true;
this.set('failed_delete', false);
},
close_app_alert: function()
{
var alert = document.getElementById('app_alert');
alert.hidden=true;
},
start_stop: function()
start_stop_instance: function (action)
{
var instance = this.get('model.instance');
if (action === 'start') {
instance.set('starting', true);
}
else if (action === 'stop') {
instance.set('stopping', true);
}
var _this = this;
Ember.run.later((function () {
_this.set('request', false);
_this.set('app_request', false);
}), ENV.message_dismiss);
Ember.run.later((function () {
if (action === 'start') {
instance.set('starting', false);
}
else if (action === 'stop') {
instance.set('stopping', false);
}
}), ENV.button_delay);
},
start_stop_app: function (action, application_id)
{
var app = this.get('model.apps').findBy('id', application_id);
if (action === 'start') {
app.set('starting', true);
}
else if (action === 'stop') {
app.set('stopping', true);
}
var _this = this;
Ember.run.later((function () {
_this.set('request', false);
_this.set('app_request', false);
}), ENV.message_dismiss);
Ember.run.later((function () {
if (action === 'start') {
app.set('starting', false);
}
else if (action === 'stop') {
app.set('stopping', false);
}
}), ENV.button_delay);
},
withdraw: function(application_id)
{
var app = this.get('model.apps').findBy('id', application_id);
app.set('undeploying', true);
var _this = this;
Ember.run.later((function () {
_this.store.find('lambda-app', application_id).then(function (application) {
......@@ -42,6 +87,7 @@ export default Ember.Controller.extend({
_this.set('app_request', false);
}), ENV.message_dismiss);
},
delete_instance: function(instance_id) {
var running_warning = "";
this.get('model.apps').forEach(function (item) {
......@@ -93,5 +139,6 @@ export default Ember.Controller.extend({
});
}
},
}
});
......@@ -37,12 +37,27 @@ export default Ember.ArrayController.extend({
actions: {
start_stop: function()
start_stop: function (action, instance_id)
{
var instance = this.get('model').findBy('id', instance_id);
if (action === 'start') {
instance.set('starting', true);
}
else if (action === 'stop') {
instance.set('stopping', true);
}
var _this = this;
Ember.run.later((function () {
_this.set('request', false);
}), ENV.message_dismiss);
Ember.run.later((function () {
if (action === 'start') {
instance.set('starting', false);
}
else if (action === 'stop') {
instance.set('stopping', false);
}
}), ENV.button_delay);
},
delete_instance: function(instance_id) {
......
......@@ -14,6 +14,9 @@ export default Ember.Helper.helper(function (params) {
result = params[i] && result;
}
break;
case 'not':
result = !result;
break;
}
return result;
});
......@@ -14,7 +14,14 @@ var LambdaApp = DS.Model.extend({
started: DS.attr('boolean'),
deployed: DS.attr('boolean'),
execution_environment_name: DS.attr(),
deleting: DS.attr('boolean')
deleting: DS.attr('boolean',
{ defaultValue: false }),
starting: DS.attr('boolean',
{ defaultValue: false }),
stopping: DS.attr('boolean',
{ defaultValue: false }),
undeploying: DS.attr('boolean',
{ defaultValue: false })
});
export default LambdaApp;
......@@ -23,7 +23,14 @@ var LambdaInstance = DS.Model.extend({
running_app: DS.attr('boolean'), // is any app running on the lambda instance?
kafka_input_topics: DS.attr(), // kafka input topics of lambda instance
kafka_output_topics: DS.attr(), // kafka output topics of lambda instance
deleting: DS.attr('boolean') // has a delete request been sent?
deleting: DS.attr('boolean',
{ defaultValue: false }), // has a delete request been sent?
starting: DS.attr('boolean',
{ defaultValue: false }), // has a start request been sent?
stopping: DS.attr('boolean',
{ defaultValue: false }), // has a stop request been sent?
undeploying: DS.attr('boolean',
{ defaultValue: false }) // has an app undeploy request been sent?
});
export default LambdaInstance;
......@@ -282,11 +282,14 @@
<td>{{li.started_app}}</td>
<td>
{{#if (compare li.status_code '==' '0')}}
{{#if li.started_app}}
{{#if (logical-op 'and'
li.started_app
(logical-op 'not' li.stopping)
)}}
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action start=true disabled=true
tool-tip-message="it is started!"}}
tool-tip-message="it is started"}}
{{/tool-tip}}
</td>
<td style="padding-right: 5px;">
......@@ -295,12 +298,15 @@
{{/tool-tip}}
</td>
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action withdraw=true disabled=true
tool-tip-message="it is started!"}}
{{/tool-tip}}
{{#tool-tip}}
{{app-action withdraw=true disabled=true
tool-tip-message="it is started"}}
{{/tool-tip}}
</td>
{{else}}
{{else if (logical-op 'and'
(logical-op 'not' li.started_app)
(logical-op 'not' li.starting)
)}}
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action start=true app=model.app request=request application-id=model.application.id instance-id=li.id failure=failure message=message action="start_stop"}}
......@@ -309,15 +315,64 @@
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action stop=true disabled=true
tool-tip-message="it is already stopped!"}}
tool-tip-message="it is already stopped"}}
{{/tool-tip}}
</td>
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action withdraw=true app=model.app request=request application-id=model.application.id instance-id=li.id failure=failure message=message action="withdraw"}}
{{/tool-tip}}
</td>
{{#if li.undeploying}}
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action withdraw=true disabled=true
tool-tip-message="it is being undeployed"}}
{{/tool-tip}}
</td>
{{else}}
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action withdraw=true app=model.app request=request application-id=model.application.id instance-id=li.id failure=failure message=message action="withdraw"}}
{{/tool-tip}}
</td>
{{/if}}
{{else}}
{{#if li.starting}}
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action start=true disabled=true
tool-tip-message="it is starting"}}
{{/tool-tip}}
</td>
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action stop=true disabled=true
tool-tip-message="it is starting"}}
{{/tool-tip}}
</td>
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action withdraw=true disabled=true
tool-tip-message="it is starting"}}
{{/tool-tip}}
</td>
{{else}}
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action start=true disabled=true
tool-tip-message="it is stopping"}}
{{/tool-tip}}
</td>
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action stop=true disabled=true
tool-tip-message="it is stopping"}}
{{/tool-tip}}
</td>
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action withdraw=true disabled=true
tool-tip-message="it is stopping"}}
{{/tool-tip}}
</td>
{{/if}}
{{/if}}
{{else}}
<td style="padding-right: 5px;">
{{#tool-tip}}
......
......@@ -99,12 +99,18 @@
{{/tool-tip}}
{{/if}}
{{#tool-tip}}
{{#if (compare model.instance.status_code '==' '0')}}
{{instance-action apps=model.apps check_apps=true stop=true instance=model.instance_action failure=failure instance-id=model.instance.id request=request message=message action="start_stop"}}
{{#if (logical-op 'and'
(compare model.instance.status_code '==' '0')
(logical-op 'not' model.instance.stopping)
)}}
{{instance-action apps=model.apps check_apps=true stop=true instance=model.instance_action failure=failure instance-id=model.instance.id request=request message=message action="start_stop_instance"}}
{{instance-action start=true disabled=true status_message=model.instance.status_message}}
{{else if (compare model.instance.status_code '==' '1')}}
{{else if (logical-op 'and'
(compare model.instance.status_code '==' '1')
(logical-op 'not' model.instance.starting)
)}}
{{instance-action stop=true disabled=true status_message=model.instance.status_message}}
{{instance-action start=true instance=model.instance_action instance-id=model.instance.id failure=failure request=request message=message action="start_stop"}}
{{instance-action start=true instance=model.instance_action instance-id=model.instance.id failure=failure request=request message=message action="start_stop_instance"}}
{{else}}
{{instance-action stop=true disabled=true status_message=model.instance.status_message}}
{{instance-action start=true disabled=true status_message=model.instance.status_message}}
......@@ -387,41 +393,96 @@
<td>{{application.started}}</td>
<td>
{{#if (compare model.instance.status_code '==' '0')}}
{{#if application.started}}
{{#if (logical-op 'and'
application.started
(logical-op 'not' application.stopping)
)}}
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action start=true disabled=true
tool-tip-message="it is started!"}}
tool-tip-message="it is started"}}
{{/tool-tip}}
</td>
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action stop=true app=model.app application-id=application.id instance-id=model.instance.id request=app_request failure=app_failure message=message action="start_stop"}}
{{app-action stop=true app=model.app application-id=application.id instance-id=model.instance.id request=app_request failure=app_failure message=message action="start_stop_app"}}
{{/tool-tip}}
</td>
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action withdraw=true disabled=true
tool-tip-message="it is started!"}}
tool-tip-message="it is started"}}
{{/tool-tip}}
</td>
{{else}}
{{else if (logical-op 'and'
(logical-op 'not' application.started)
(logical-op 'not' application.starting)
)}}
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action start=true app=model.app application-id=application.id instance-id=model.instance.id request=app_request failure=app_failure message=message action="start_stop"}}
{{app-action start=true app=model.app application-id=application.id instance-id=model.instance.id request=app_request failure=app_failure message=message action="start_stop_app"}}
{{/tool-tip}}
</td>
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action stop=true disabled=true
tool-tip-message="it is already stopped!"}}
tool-tip-message="it is already stopped"}}
{{/tool-tip}}
</td>
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action withdraw=true app=model.app application-id=application.id instance-id=model.instance.id request=app_request failure=app_failure message=message action="withdraw"}}
{{/tool-tip}}
</td>
{{#if application.undeploying}}
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action withdraw=true disabled=true
tool-tip-message="it is being undeployed"}}
{{/tool-tip}}
</td>
{{else}}
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action withdraw=true app=model.app application-id=application.id instance-id=model.instance.id request=app_request failure=app_failure message=message action="withdraw"}}
{{/tool-tip}}
</td>
{{/if}}
{{else}}
{{#if application.starting}}
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action start=true disabled=true
tool-tip-message="it is starting"}}
{{/tool-tip}}
</td>
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action stop=true disabled=true
tool-tip-message="it is starting"}}
{{/tool-tip}}
</td>
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action withdraw=true disabled=true
tool-tip-message="it is starting"}}
{{/tool-tip}}
</td>
{{else}}
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action start=true disabled=true
tool-tip-message="it is stopping"}}
{{/tool-tip}}
</td>
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action stop=true disabled=true
tool-tip-message="it is stopping"}}
{{/tool-tip}}
</td>
<td style="padding-right: 5px;">
{{#tool-tip}}
{{app-action withdraw=true disabled=true
tool-tip-message="it is stopping"}}
{{/tool-tip}}
</td>
{{/if}}
{{/if}}
{{else}}
<td style="padding-right: 5px;">
......
......@@ -139,7 +139,10 @@
<a class="btn btn-info btn-xs" title="View Details" alt="View Details"><i class="fa fa-file-code-o"></i> Details</a>
{{/link-to}}
</td>
{{#if (compare lambda-instance.status_code '==' '0')}}
{{#if (logical-op 'and'
(compare lambda-instance.status_code '==' '0')
(logical-op 'not' lambda-instance.stopping)
)}}
<td style="padding-right: 5px;">
{{#tool-tip}}