From 535c8669b64a19e4ce9100e2e3e14f6c5224a685 Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Tue, 29 Nov 2011 16:05:52 -0800 Subject: [PATCH] cloudStack 3.0 new UI - zone chart - virtual router provider - implement enable/disable action. --- ui/scripts/system.js | 103 +++++++++++++++++++++++++++++++------------ 1 file changed, 75 insertions(+), 28 deletions(-) diff --git a/ui/scripts/system.js b/ui/scripts/system.js index 96433ace747..1207bce55e8 100644 --- a/ui/scripts/system.js +++ b/ui/scripts/system.js @@ -1054,38 +1054,85 @@ }, types: { - // Virtual router list view + // Virtual router provider virtualRouter: { id: 'virtualRouterProviders', - label: 'Virtual Router', - fields: { - name: { label: 'Name' }, - ipaddress: { label: 'IP Address' }, - state: { label: 'Status' } + label: 'Virtual Router', + providerActionFilter: function(args) { + var allowedActions = []; + var jsonObj = nspMap["virtualRouter"]; + if(jsonObj.state == "Enabled") + allowedActions.push("disable"); + else if(jsonObj.state == "Disabled") + allowedActions.push("enable"); + return allowedActions; }, - dataProvider: function(args) { - setTimeout(function() { - args.response.success({ - data: [ - { - name: 'Router0001S', - ipaddress: '192.168.1.1', - state: 'Enabled' - }, - { - name: 'Router0001B', - ipaddress: '192.168.1.155', - state: 'Enabled' - }, - { - name: 'Router0002', - ipaddress: '192.168.1.13', - state: 'Enabled' + providerActions: { + enable: { + label: 'Enable', + action: function(args) { + $.ajax({ + url: createURL("updateNetworkServiceProvider&id=" + nspMap["virtualRouter"].id + "&state=Enabled"), + dataType: "json", + success: function(json) { + var jid = json.updatenetworkserviceproviderresponse.jobid; + args.response.success( + {_custom: + { + jobId: jid, + getUpdatedItem: function(json) { + var item = json.queryasyncjobresultresponse.jobresult.networkserviceprovider; + nspMap["virtualRouter"] = item; + return item; + } + } + } + ); } - ] - }); - }, 500); - } + }); + }, + messages: { + notification: function() { return 'Enabled Netscaler provider'; } + }, + notification: { poll: pollAsyncJobResult } + }, + disable: { + label: 'Disable', + action: function(args) { + $.ajax({ + url: createURL("updateNetworkServiceProvider&id=" + nspMap["virtualRouter"].id + "&state=Disabled"), + dataType: "json", + success: function(json) { + var jid = json.updatenetworkserviceproviderresponse.jobid; + args.response.success( + {_custom: + { + jobId: jid, + getUpdatedItem: function(json) { + var item = json.queryasyncjobresultresponse.jobresult.networkserviceprovider; + nspMap["virtualRouter"] = item; + return item; + } + } + } + ); + } + }); + }, + messages: { + notification: function() { return 'Disabled Netscaler provider'; } + }, + notification: { poll: pollAsyncJobResult } + } + }, + fields: { + id: { label: 'ID' }, + name: { label: 'Name' }//, + //state: { label: 'Status' } //comment it for now, since dataProvider below doesn't get called by widget code after action is done + }, + dataProvider: function(args) { + args.response.success({data: nspMap["virtualRouter"]}); + } }, // NetScaler list view