mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
VPC tier UI: Update state after performing actions
After performing an action that changes state, namely starting and stopping a tier, run through the action pre-filter again, to make sure that the allowable actions are properly refreshed. Conflicts: ui/scripts/ui-custom/vpc.js
This commit is contained in:
parent
28e49e8880
commit
b1a5ec13cd
@ -112,11 +112,13 @@
|
||||
if ($action.hasClass('disabled')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
tierAction({
|
||||
action: action,
|
||||
actionPreFilter: actionPreFilter,
|
||||
context: context,
|
||||
$tier: $tier
|
||||
$tier: $tier,
|
||||
$actions: $actions
|
||||
});
|
||||
|
||||
return true;
|
||||
@ -158,7 +160,7 @@
|
||||
if ($(this).find('.loading-overlay').size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
addTierDialog({
|
||||
$tiers: $tiers,
|
||||
context: context,
|
||||
@ -210,7 +212,7 @@
|
||||
|
||||
disabledActions = actionPreFilter ? actionPreFilter({
|
||||
context: context
|
||||
}) : [];
|
||||
}) : [];
|
||||
|
||||
// Visual appearance for disabled actions
|
||||
$actions.find('.action').map(function(index, action) {
|
||||
@ -229,12 +231,14 @@
|
||||
var tierAction = function(args) {
|
||||
var $tier = args.$tier;
|
||||
var $loading = $('<div>').addClass('loading-overlay');
|
||||
var $actions = args.$actions;
|
||||
var actionArgs = args.action.action;
|
||||
var action = actionArgs.action;
|
||||
var actionID = args.action.id;
|
||||
var notification = actionArgs.notification;
|
||||
var label = actionArgs.label;
|
||||
var context = args.context;
|
||||
var actionPreFilter = args.actionPreFilter;
|
||||
|
||||
var success = function(args) {
|
||||
var remove = args ? args.remove : false;
|
||||
@ -250,6 +254,13 @@
|
||||
|
||||
// Success
|
||||
function(args) {
|
||||
var newData = args.data ? args.data : {};
|
||||
var newTier = $.extend(true, {}, context.tiers[0], newData);
|
||||
var newContext = $.extend(true, {}, context);
|
||||
|
||||
// Update data
|
||||
newContext.tiers = [newTier];
|
||||
|
||||
if (remove) {
|
||||
$tier.remove();
|
||||
} else {
|
||||
@ -264,6 +275,12 @@
|
||||
|
||||
$total.html(newTotal);
|
||||
}
|
||||
|
||||
filterActions({
|
||||
$actions: $actions,
|
||||
actionPreFilter: actionPreFilter,
|
||||
context: newContext
|
||||
});
|
||||
},
|
||||
|
||||
{},
|
||||
@ -367,7 +384,7 @@
|
||||
response: {
|
||||
success: function(args) {
|
||||
var tier = args.data;
|
||||
|
||||
|
||||
cloudStack.ui.notifications.add(
|
||||
// Notification
|
||||
{
|
||||
|
||||
@ -376,7 +376,10 @@
|
||||
},
|
||||
tiers: {
|
||||
actionPreFilter: function(args) {
|
||||
return ['start'];
|
||||
var tier = args.context.tiers[0];
|
||||
var state = tier.state;
|
||||
|
||||
return state == 'Running' ? ['start'] : ['stop'];
|
||||
},
|
||||
actions: {
|
||||
// Add new tier
|
||||
@ -413,7 +416,7 @@
|
||||
args.response.success();
|
||||
},
|
||||
notification: {
|
||||
poll: function(args) { args.complete(); }
|
||||
poll: function(args) { args.complete({ data: { state: 'Running' } }); }
|
||||
}
|
||||
},
|
||||
stop: {
|
||||
@ -423,7 +426,7 @@
|
||||
args.response.success();
|
||||
},
|
||||
notification: {
|
||||
poll: function(args) { args.complete(); }
|
||||
poll: function(args) { args.complete({ data: { state: 'Stopped' } }); }
|
||||
}
|
||||
},
|
||||
addVM: {
|
||||
@ -459,6 +462,7 @@
|
||||
id: 1,
|
||||
name: 'web',
|
||||
cidr: '192.168.0.0/24',
|
||||
state: 'Running',
|
||||
virtualMachines: [
|
||||
{ name: 'i-2-VM' },
|
||||
{ name: 'i-3-VM' }
|
||||
@ -467,6 +471,7 @@
|
||||
{
|
||||
id: 2,
|
||||
name: 'app',
|
||||
state: 'Stopped',
|
||||
cidr: '10.0.0.0/24',
|
||||
virtualMachines: []
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user