From 9d523abb97c112d37381ccfb6f9750997bf1532b Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Fri, 11 Nov 2011 11:31:15 -0800 Subject: [PATCH] cloudStack 3.0 new UI - network offering page - add "enable", "disable" action. --- ui/scripts/configuration.js | 89 ++++++++++++++++++++++++++++++++++--- 1 file changed, 84 insertions(+), 5 deletions(-) diff --git a/ui/scripts/configuration.js b/ui/scripts/configuration.js index 48d91ef6020..7dbf1e287ae 100644 --- a/ui/scripts/configuration.js +++ b/ui/scripts/configuration.js @@ -845,7 +845,7 @@ success: function(json) { var items = json.listnetworkofferingsresponse.networkoffering; args.response.success({ - actionFilter: networkOfferingsActionfilter, + actionFilter: networkOfferingActionfilter, data:items }); } @@ -869,7 +869,81 @@ } }); } - } + }, + //??? +enable: { + label: 'Enable network offering', + messages: { + confirm: function(args) { + return 'Are you sure you want to enable this network offering?'; + }, + success: function(args) { + return 'This network offering is being enabled.'; + }, + notification: function(args) { + return 'Enabling network offering'; + }, + complete: function(args) { + return 'Network offering has been enabled.'; + } + }, + action: function(args) { + $.ajax({ + url: createURL("updateNetworkOffering&id=" + args.context.networkOfferings[0].id + "&state=Enabled"), + dataType: "json", + async: true, + success: function(json) { + var item = json.updatenetworkofferingresponse.networkoffering; + args.response.success({ + actionFilter: networkOfferingActionfilter, + data:item + }); + } + }); + }, + notification: { + poll: function(args) { + args.complete(); + } + } + }, + + disable: { + label: 'Disable network offering', + messages: { + confirm: function(args) { + return 'Are you sure you want to disable this network offering?'; + }, + success: function(args) { + return 'This network offering is being disabled.'; + }, + notification: function(args) { + return 'Disabling network offering'; + }, + complete: function(args) { + return 'Network offering has been disabled.'; + } + }, + action: function(args) { + $.ajax({ + url: createURL("updateNetworkOffering&id=" + args.context.networkOfferings[0].id + "&state=Disabled"), + dataType: "json", + async: true, + success: function(json) { + var item = json.updatenetworkofferingresponse.networkoffering; + args.response.success({ + actionFilter: networkOfferingActionfilter, + data:item + }); + } + }); + }, + notification: { + poll: function(args) { + args.complete(); + } + } + } }, tabs: { details: { @@ -887,6 +961,7 @@ label: 'Description', isEditable: true }, + state: { label: 'State' }, availability: { label: 'Availability', isEditable: true, @@ -928,7 +1003,7 @@ dataProvider: function(args) { args.response.success( { - actionFilter: networkOfferingsActionfilter, + actionFilter: networkOfferingActionfilter, data:args.context.networkOfferings[0] } ); @@ -965,10 +1040,14 @@ return allowedActions; } - var networkOfferingsActionfilter = function(args) { + var networkOfferingActionfilter = function(args) { var jsonObj = args.context.item; var allowedActions = []; - allowedActions.push("edit"); + allowedActions.push("edit"); + if(jsonObj.state == "Enabled") + allowedActions.push("disable"); + else if(jsonObj.state == "Disabled") + allowedActions.push("enable"); return allowedActions; }