Commit b8157eb2 authored by Ioannis Tsafaras's avatar Ioannis Tsafaras
Browse files

Merge pull request #215 from efikalti/ember-delete

Ember stop instance check
parents 9c5f80ba 9e97afe4
......@@ -30,13 +30,20 @@ export default Ember.Component.extend({
return false;
}
var _this = this;
//send request to stop instance
apps.forEach(function(item) {
if (item.get("started"))
if (this.get('check_apps'))
{
_this.set("app_started", true);
apps.forEach(function(item) {
if (item.get("started"))
{
_this.set("app_started", true);
}
});
}
});
else if (this.get("started_app"))
{
this.set("app_started", true);
}
//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"));
......
......@@ -59,14 +59,19 @@ export default Ember.Controller.extend({
}), 3000);
},
statusCode: {
500: function() {
404: function(xhr) {
_this.set('failed_delete', true);
_this.set('message', "Your request to delete the application was rejected.Please try again later when the status of the instance has changed.");
_this.set('message', xhr.responseJSON.errors[0].detail);
},
409: function(xhr) {
_this.set('failed_delete', true);
_this.set('message', xhr.responseJSON.errors[0].detail);
}
},
error: function(response) {
error: function(xhr) {
var error = 'Error ' + xhr.status + '. Your request to delete the application was rejected. Please try again later or after the status of the instance has changed.';
_this.set('failed_delete', true);
_this.set('message', response.responseJSON.errors[0].detail);
_this.set('message', error);
}
});
}
......
......@@ -57,14 +57,19 @@ export default Ember.ArrayController.extend({
}), 4000);
},
statusCode: {
500: function() {
404: function(xhr) {
_this.set('failed_delete', true);
_this.set('message', "Your request to delete the application was rejected.Please try again later when the status of the instance has changed.");
_this.set('message', xhr.responseJSON.errors[0].detail);
},
409: function(xhr) {
_this.set('failed_delete', true);
_this.set('message', xhr.responseJSON.errors[0].detail);
}
},
error: function(response) {
error: function(xhr) {
var error = 'Error ' + xhr.status + '. Your request to delete the application was rejected. Please try again later or after the status of the instance has changed.';
_this.set('failed_delete', true);
_this.set('message', response.responseJSON.errors[0].detail);
_this.set('message', error);
}
});
}
......
......@@ -63,14 +63,19 @@ export default Ember.Controller.extend({
}), 3000);
},
statusCode: {
500: function() {
404: function(xhr) {
_this.set('failed_delete', true);
_this.set('message', "Your request to delete the instance was rejected.Please try again later when the status of the instance has changed.");
_this.set('message', xhr.responseJSON.errors[0].detail);
},
409: function(xhr) {
_this.set('failed_delete', true);
_this.set('message', xhr.responseJSON.errors[0].detail);
}
},
error: function(response) {
error: function(xhr) {
var error = 'Error ' + xhr.status + '. Your request to delete the instance was rejected. Please try again later or after the status of the instance has changed.';
_this.set('failed_delete', true);
_this.set('message', response.responseJSON.errors[0].detail);
_this.set('message', error);
}
});
}
......
......@@ -64,14 +64,19 @@ export default Ember.ArrayController.extend({
}), 4000);
},
statusCode: {
500: function() {
404: function(xhr) {
_this.set('failed_delete', true);
_this.set('message', "Your request to delete the instance was rejected.Please try again later when the status of the instance has changed.");
_this.set('message', xhr.responseJSON.errors[0].detail);
},
409: function(xhr) {
_this.set('failed_delete', true);
_this.set('message', xhr.responseJSON.errors[0].detail);
}
},
error: function(response) {
error: function(xhr) {
var error = 'Error ' + xhr.status + '. Your request to delete the instance was rejected. Please try again later or after the status of the instance has changed.';
_this.set('failed_delete', true);
_this.set('message', response.responseJSON.errors[0].detail);
_this.set('message', error);
}
});
}
......
......@@ -19,7 +19,7 @@ var LambdaInstance = DS.Model.extend({
status_detail: DS.attr(), // status detail of lambda instance
status_failure_message: DS.attr(), // failure message
applications: DS.hasMany('lambda-app'), // deployed applications
started_app: DS.attr('boolean'), // is specific app started?
running_app: DS.attr('boolean'), // is specific app started?
kafka_topics: DS.attr() // kafka topics of lambda instance
});
......
......@@ -19,7 +19,6 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
var hash = {
instances: this.store.findAll('lambda-instance', params, { reload: true }),
apps: this.store.peekAll('lambda-app'),
};
if (this.store.peekAll('instance-action').get('length') === 0) {
hash.instance_action = this.store.createRecord('instance-action', {});
......@@ -31,7 +30,6 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
setupController: function(controller, model) {
controller.set('content', model.instances);
controller.set('instance_action', model.instance_action);
controller.set('apps', model.apps);
},
deactivate: function () {
......
......@@ -79,7 +79,7 @@
{{#tool-tip}}
{{#if (compare model.instance.status_code '==' '0')}}
{{instance-action start=true disabled=true status_message=model.instance.status_message}}
{{instance-action apps=model.apps 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"}}
{{else if (compare model.instance.status_code '==' '1')}}
{{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"}}
......
......@@ -137,7 +137,7 @@
</td>
{{/tool-tip}}
<td>
{{instance-action apps=apps xs=true stop=true instance=instance_action failure=failure instance-id=lambda-instance.id request=request message=message action="start_stop"}}
{{instance-action apps=apps xs=true stop=true check_apps=false started_app=lambda-instance.running_app instance=instance_action failure=failure instance-id=lambda-instance.id request=request message=message action="start_stop"}}
</td>
<td>
{{#link-to "deploy-app-2" lambda-instance.id}}
......
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