Commit 043bfca9 authored by Ioannis Tsafaras's avatar Ioannis Tsafaras
Browse files

Disable lambda application start/stop/undeploy buttons, when they are clicked

parent 60faa20c
......@@ -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);
......
......@@ -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,18 +12,21 @@ 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 (action)
start_stop_instance: function (action)
{
var instance = this.get('model.instance');
if (action === 'start') {
......@@ -46,8 +49,35 @@ export default Ember.Controller.extend({
}
}), 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) {
......@@ -57,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) {
......@@ -108,5 +139,6 @@ export default Ember.Controller.extend({
});
}
},
}
});
......@@ -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;
......@@ -28,7 +28,9 @@ var LambdaInstance = DS.Model.extend({
starting: DS.attr('boolean',
{ defaultValue: false }), // has a start request been sent?
stopping: DS.attr('boolean',
{ defaultValue: false }) // has a stop request been sent?
{ 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}}
......
......@@ -103,14 +103,14 @@
(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-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 (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}}
......@@ -393,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;">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment