Commit 30a72e69 authored by Ioannis Tsafaras's avatar Ioannis Tsafaras
Browse files

Rework deployed app detection method

parent 68e3484c
......@@ -5,12 +5,13 @@ export default Ember.Controller.extend({
sortedInstances: Ember.computed.sort('instances', 'instanceSorting'),
instanceSorting: ['name'],
actions: {
deploy(application_id) {
deploy(application_id, instance_id) {
if (!this.get("failure")) {
var _this = this;
Ember.run.later((function () {
_this.set("request", false);
_this.controllerFor('lambda-app').set('deployWait', true);
_this.controllerFor('lambda-app').set('deployID', instance_id);
_this.transitionToRoute('lambda-app', application_id);
}), ENV.redirect_delay);
}
......
......@@ -11,6 +11,7 @@ export default Ember.Controller.extend({
Ember.run.later((function () {
_this.set("request", false);
_this.controllerFor('lambda-instance').set('deployWait', true);
_this.controllerFor('lambda-instance').set('deployID', application_id);
_this.transitionToRoute('lambda-instance', instance_id);
}), ENV.redirect_delay);
}
......
......@@ -11,7 +11,7 @@ export default Ember.Controller.extend({
delete_success_message: '',
delete_error_message: '',
deployWait: false,
numInstances: -1,
deployID: -1,
actions: {
withdraw: function(application_id, instance_id)
{
......
......@@ -10,7 +10,7 @@ export default Ember.Controller.extend({
delete_success_message: '',
delete_error_message: '',
deployWait: false,
numApps: -1,
deployID: -1,
actions: {
close_alert: function()
{
......
......@@ -8,7 +8,6 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
this._super(transition);
this.store.unloadAll('lambda-instance');
this.store.unloadAll('app-action');
this.controllerFor('lambda-app').set('numInstances', -1);
},
model: function (params) {
......@@ -26,12 +25,13 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
}
if (this.controllerFor('lambda-app').get('deployWait')) {
var numInstances = hash.instances.get('length');
var prevNumInstances = this.controllerFor('lambda-app').get('numInstances');
if ((prevNumInstances >= 0) && (prevNumInstances !== numInstances)) {
this.controllerFor('lambda-app').set('deployWait', false);
}
this.controllerFor('lambda-app').set('numInstances', numInstances);
var deployID = this.controllerFor('lambda-app').get('deployID');
var _this = this;
hash.instances.forEach(function(instance) {
if (instance.id === deployID) {
_this.controllerFor('lambda-app').set('deployWait', false);
}
});
}
return Ember.RSVP.hash(hash);
......@@ -47,6 +47,7 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
deactivate: function () {
Ember.run.cancel(this.poll);
this.controllerFor('lambda-app').set('deployWait', false);
this.controllerFor('lambda-app').set('deployID', -1);
},
actions: {
......
......@@ -9,7 +9,6 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
this.store.unloadAll('lambda-app');
this.store.unloadAll('app-action');
this.store.unloadAll('instance-action');
this.controllerFor('lambda-instance').set('numApps', -1);
},
model: function (params) {
......@@ -30,12 +29,13 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
}
if (this.controllerFor('lambda-instance').get('deployWait')) {
var numApps = hash.apps.get('length');
var prevNumApps = this.controllerFor('lambda-instance').get('numApps');
if ((prevNumApps >= 0) && (prevNumApps !== numApps)) {
this.controllerFor('lambda-instance').set('deployWait', false);
}
this.controllerFor('lambda-instance').set('numApps', numApps);
var deployID = this.controllerFor('lambda-instance').get('deployID');
var _this = this;
hash.apps.forEach(function(app) {
if (app.id === deployID) {
_this.controllerFor('lambda-instance').set('deployWait', false);
}
});
}
return Ember.RSVP.hash(hash);
......@@ -51,6 +51,7 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
deactivate: function () {
Ember.run.cancel(this.poll);
this.controllerFor('lambda-instance').set('deployWait', false);
this.controllerFor('lambda-instance').set('deployID', -1);
},
actions: {
......
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