mirror of https://github.com/apache/cloudstack.git
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.
This commit is contained in:
parent
0a14f09fd7
commit
196ef1c1e0
|
|
@ -7,7 +7,7 @@
|
|||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
// limitations under the License.
|
||||
(function($, cloudStack) {
|
||||
var elems = {
|
||||
router: function() {
|
||||
|
|
@ -106,11 +106,13 @@
|
|||
if ($action.hasClass('disabled')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
tierAction({
|
||||
action: action,
|
||||
actionPreFilter: actionPreFilter,
|
||||
context: context,
|
||||
$tier: $tier
|
||||
$tier: $tier,
|
||||
$actions: $actions
|
||||
});
|
||||
|
||||
return true;
|
||||
|
|
@ -152,7 +154,7 @@
|
|||
if ($(this).find('.loading-overlay').size()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
addTierDialog({
|
||||
$tiers: $tiers,
|
||||
context: context,
|
||||
|
|
@ -204,7 +206,7 @@
|
|||
|
||||
disabledActions = actionPreFilter ? actionPreFilter({
|
||||
context: context
|
||||
}) : [];
|
||||
}) : [];
|
||||
|
||||
// Visual appearance for disabled actions
|
||||
$actions.find('.action').map(function(index, action) {
|
||||
|
|
@ -223,12 +225,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;
|
||||
|
|
@ -244,6 +248,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 {
|
||||
|
|
@ -258,6 +269,12 @@
|
|||
|
||||
$total.html(newTotal);
|
||||
}
|
||||
|
||||
filterActions({
|
||||
$actions: $actions,
|
||||
actionPreFilter: actionPreFilter,
|
||||
context: newContext
|
||||
});
|
||||
},
|
||||
|
||||
{},
|
||||
|
|
@ -361,7 +378,7 @@
|
|||
response: {
|
||||
success: function(args) {
|
||||
var tier = args.data;
|
||||
|
||||
|
||||
cloudStack.ui.notifications.add(
|
||||
// Notification
|
||||
{
|
||||
|
|
|
|||
|
|
@ -370,7 +370,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
|
||||
|
|
@ -407,7 +410,7 @@
|
|||
args.response.success();
|
||||
},
|
||||
notification: {
|
||||
poll: function(args) { args.complete(); }
|
||||
poll: function(args) { args.complete({ data: { state: 'Running' } }); }
|
||||
}
|
||||
},
|
||||
stop: {
|
||||
|
|
@ -417,7 +420,7 @@
|
|||
args.response.success();
|
||||
},
|
||||
notification: {
|
||||
poll: function(args) { args.complete(); }
|
||||
poll: function(args) { args.complete({ data: { state: 'Stopped' } }); }
|
||||
}
|
||||
},
|
||||
addVM: {
|
||||
|
|
@ -453,6 +456,7 @@
|
|||
id: 1,
|
||||
name: 'web',
|
||||
cidr: '192.168.0.0/24',
|
||||
state: 'Running',
|
||||
virtualMachines: [
|
||||
{ name: 'i-2-VM' },
|
||||
{ name: 'i-3-VM' }
|
||||
|
|
@ -461,6 +465,7 @@
|
|||
{
|
||||
id: 2,
|
||||
name: 'app',
|
||||
state: 'Stopped',
|
||||
cidr: '10.0.0.0/24',
|
||||
virtualMachines: []
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue