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

Merge pull request #276 from ioantsaf/delete-instance

[Bug 1] Delete lambda instance improvements
parents c7ee8769 d72d3842
......@@ -69,6 +69,7 @@ export default Ember.Controller.extend({
success: function(){
_this.set('success_delete', true);
_this.set('delete_success_message', 'Your request to delete the lambda instance was successfully sent to the server.');
_this.get('model.instance').set('deleting', true);
Ember.run.later((function () {
_this.set('success_delete', false);
_this.transitionToRoute('dashboard');
......
......@@ -8,10 +8,15 @@ export default Ember.ArrayController.extend({
session: Ember.inject.service('session'),
delete_success_message: '',
delete_error_message: '',
showFailed: false,
queryParams: ["page", "perPage"],
sortAscending: true,
sortProperties: ['name'],
instanceCount: Ember.computed('model.length', function() {
return this.get('model.length');
}),
page: 1,
perPage: 10,
firstOfCurrentPage: Ember.computed('page', 'perPage', function() {
......@@ -22,8 +27,8 @@ export default Ember.ArrayController.extend({
return (this.get('page')-1)*(this.get('perPage'))+1;
}
}),
lastOfCurrentPage: Ember.computed('page', 'perPage', 'content', function() {
return Math.min(this.get('content.length'), (this.get('page'))*(this.get('perPage')));
lastOfCurrentPage: Ember.computed('page', 'perPage', 'instanceCount', function() {
return Math.min(this.get('instanceCount'), (this.get('page'))*(this.get('perPage')));
}),
pagedContent: pagedArray('arrangedContent', {pageBinding: "page", perPageBinding: "perPage"}),
......@@ -65,6 +70,7 @@ export default Ember.ArrayController.extend({
success: function(){
_this.set('success_delete', true);
_this.set('delete_success_message', 'Your request to delete the lambda instance was successfully sent to the server.');
_this.get('model').findBy('id', instance_id).set('deleting', true);
Ember.run.later((function () {
_this.set('success_delete', false);
}), ENV.message_dismiss);
......
......@@ -22,7 +22,8 @@ var LambdaInstance = DS.Model.extend({
started_app: DS.attr('boolean'), // is specific app started?
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
kafka_output_topics: DS.attr(), // kafka output topics of lambda instance
deleting: DS.attr('boolean') // has a delete request been sent?
});
export default LambdaInstance;
......@@ -23,7 +23,20 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
if (this.store.peekAll('instance-action').get('length') === 0) {
hash.instance_action = this.store.createRecord('instance-action', {});
}
return Ember.RSVP.hash(hash);
var _this = this;
return Ember.RSVP.hash(hash).then(function (hash) {
if (!_this.controllerFor('lambda-instances.index').get('showFailed')) {
hash.instances.forEach(function (instance) {
let status_code = instance.get('status_code');
if (status_code >= 9 && status_code <=23 && (status_code % 2) === 1) {
instance.unloadRecord();
}
});
}
_this.controllerFor('lambda-instances.index').send('checkPage');
return hash;
});
},
......@@ -32,6 +45,7 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
controller.set('instance_action', model.instance_action);
controller.set('failure', false);
controller.set('failed_delete', false);
controller.set('showFailed', false);
controller.send('checkPage');
},
......
......@@ -57,22 +57,28 @@
actions you may take depending on the <i>status</i> of the lambda instance.
</div>
{{#if (logical-op 'and'
(compare (lambda-instance-state model.instance.status_message) "!==" "DESTROYING")
(compare (lambda-instance-state model.instance.status_message) "!==" "DESTROYED")
)}}
<button name="del-btn" id="del-btn" class="btn btn-danger btn-primary pull-right"
{{action "delete_instance" model.instance.id}}>
<i class="fa fa-times"></i> Delete
</button>
{{else}}
{{#if (logical-op 'or'
(compare (lambda-instance-state model.instance.status_message) "===" "DESTROYING")
model.instance.deleting)
}}
{{#tool-tip}}
<button name="del-btn" id="del-btn" class="btn btn-danger btn-primary pull-right disabled has-tooltip"
data-tooltip-content="<center>Cannot delete a lambda instance, while its
status is {{lower-case model.instance.status_message}}!</center>">
<i class="fa fa-times"></i> Delete
</button>
<button name="del-btn" id="del-btn" class="btn btn-danger btn-primary pull-right disabled has-tooltip"
data-tooltip-content="<center>The lambda instance is being destroyed!</center>">
<i class="fa fa-times"></i> Deleting <i class="fa fa-spinner fa-spin"></i>
</button>
{{/tool-tip}}
{{else if (compare (lambda-instance-state model.instance.status_message) "===" "DESTROYED")}}
{{#tool-tip}}
<button name="del-btn" id="del-btn" class="btn btn-danger btn-primary pull-right disabled has-tooltip"
data-tooltip-content="<center>The lambda instance is destroyed!</center>">
<i class="fa fa-times"></i> Delete
</button>
{{/tool-tip}}
{{else}}
<button name="del-btn" id="del-btn" class="btn btn-danger btn-primary pull-right"
{{action "delete_instance" model.instance.id}}>
<i class="fa fa-times"></i> Delete
</button>
{{/if}}
{{#if (compare model.instance.status_code '==' '0')}}
{{#link-to 'deploy-app-2' model.instance.id}}
......
......@@ -85,7 +85,10 @@
<i class="fa fa-laptop"></i> Create New Instance</a>
{{/link-to}}
</div><!--box-tools-->
<h5><label>{{input type="checkbox" name="showFailed" checked=showFailed}}
Show failed Lambda Instances</label></h5>
</div><!-- /.box-header -->
{{#if model.length}}
<div class="box-body">
<div class="row">
......@@ -196,19 +199,21 @@
</td>
{{/if}}
<td>
{{#if (compare (lambda-instance-state lambda-instance.status_message) "!==" "DESTROYING")}}
<button name="del-btn" id="del-btn" class="btn btn-danger btn-xs"
{{action "delete_instance" lambda-instance.id}}>
<i class="fa fa-times"></i> Delete
</button>
{{else}}
{{#tool-tip}}
{{#if (logical-op 'or'
(compare (lambda-instance-state lambda-instance.status_message) "===" "DESTROYING")
lambda-instance.deleting)
}}
{{#tool-tip}}
<button name="del-btn" id="del-btn" class="btn btn-danger btn-xs disabled has-tooltip"
data-tooltip-content="<center>Cannot delete a lambda instance, while its
status is {{lower-case lambda-instance.status_message}}!</center>">
<i class="fa fa-times"></i> Delete
data-tooltip-content="<center>The lambda instance is being destroyed!</center>">
<i class="fa fa-times"></i> Deleting <i class="fa fa-spinner fa-spin"></i>
</button>
{{/tool-tip}}
{{/tool-tip}}
{{else}}
<button name="del-btn" id="del-btn" class="btn btn-danger btn-xs"
{{action "delete_instance" lambda-instance.id}}>
<i class="fa fa-times"></i> Delete
</button>
{{/if}}
</td>
</td>
......
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