Commit bdd3a463 authored by Kostas Papadimitriou's avatar Kostas Papadimitriou
Browse files

Network view actions fixes

- Reset network status after a failed destroy action
- Fix multiple network actions (Refs #2298)
- Reset button visibility after nic disconnect
parent 2ffebae7
......@@ -115,8 +115,8 @@
parse: function(resp, xhr) {
},
remove: function() {
this.api_call(this.api_path(), "delete");
remove: function(complete, error, success) {
this.api_call(this.api_path(), "delete", undefined, complete, error, success);
},
changedKeys: function() {
......@@ -570,18 +570,27 @@
call: function(action, params, success, error) {
if (action == "destroy") {
var previous_state = this.get('state');
var previous_status = this.get('status');
this.set({state:"DESTROY"});
this.get("actions").remove("destroy", params);
this.remove(_.bind(function(){
success();
}, this), error);
var _success = _.bind(function() {
if (success) { success() };
}, this);
var _error = _.bind(function() {
this.set({state: previous_state, status: previous_status})
if (error) { error() };
}, this);
this.remove(undefined, _error, _success);
}
if (action == "disconnect") {
if (this.get("state") == "DESTROY") {
return;
}
_.each(params, _.bind(function(nic_id) {
var nic = snf.storage.nics.get(nic_id);
this.get("actions").remove("disconnect", nic_id);
......@@ -660,10 +669,12 @@
},
do_all_pending_actions: function(success, error) {
var destroy = this.get("actions").has_action("destroy");
_.each(this.get("actions").actions, _.bind(function(params, action) {
_.each(params, _.bind(function(with_params) {
this.call(action, with_params, success, error);
var params, actions, action_params;
actions = _.clone(this.get("actions").actions);
_.each(actions, _.bind(function(params, action) {
action_params = _.map(actions[action], function(a){ return _.clone(a)});
_.each(action_params, _.bind(function(params) {
this.call(action, params, success, error);
}, this));
}, this));
this.get("actions").reset();
......
......@@ -395,6 +395,7 @@
this.confirm = this.$("button.yes");
this.details = this.$(".action-details");
this.vm_connect = this.$(".machine-connect");
this.actions = this.$(".net-vm-actions");
this.init_handlers();
this.connect_overlay = new views.VMConnectView();
......@@ -434,6 +435,7 @@
this.disconnect_nic();
this.confirm_el.hide();
this.disconnect.removeClass("selected");
this.actions.find("a").removeClass("visible");
}, this));
snf.ui.main.bind("view:change", _.bind(function(v) {
......@@ -1090,6 +1092,10 @@
this.$(".spinner").show();
this.$(".state").addClass("destroying-state");
this.$(".actions").hide();
} else {
this.$(".state").removeClass("destroying-state");
this.$(".actions").show();
this.$(".actions a").removeClass("visible");
}
},
......
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