diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties
index f51a5f2a6b7..94bb0057ab3 100644
--- a/client/WEB-INF/classes/resources/messages.properties
+++ b/client/WEB-INF/classes/resources/messages.properties
@@ -1,4 +1,8 @@
#new labels (begin) **********************************************************************************************
+label.action.enable.physical.network=Enable physical network
+label.action.disable.physical.network=Disable physical network
+message.action.enable.physical.network=Please confirm that you want to enable this physical network.
+message.action.disable.physical.network=Please confirm that you want to disable this physical network.
label.ipaddress=IP Address
label.vcdcname=vCenter DC name
label.vcipaddress=vCenter IP Address
diff --git a/ui/index.jsp b/ui/index.jsp
index ab1ce02bd1b..43281bb66ee 100644
--- a/ui/index.jsp
+++ b/ui/index.jsp
@@ -1659,6 +1659,10 @@ dictionary = {
'message.edit.traffic.type': '',
'label.label': '',
'message.configure.all.traffic.types': '',
+'label.action.enable.physical.network': '',
+'label.action.disable.physical.network': '',
+'message.action.enable.physical.network': '',
+'message.action.disable.physical.network': '',
'label.ipaddress': '',
'label.vcdcname': '',
'label.vcipaddress': '',
diff --git a/ui/scripts/system.js b/ui/scripts/system.js
index 730341985a2..a60cb29c10f 100644
--- a/ui/scripts/system.js
+++ b/ui/scripts/system.js
@@ -1827,7 +1827,81 @@
notification: {
poll: pollAsyncJobResult
}
- }
+ },
+ enable: {
+ label: 'label.action.enable.physical.network',
+ messages: {
+ confirm: function(args) {
+ return 'message.action.enable.physical.network';
+ },
+ notification: function(args) {
+ return 'label.action.enable.physical.network';
+ }
+ },
+ action: function(args) {
+ $.ajax({
+ url: createURL('updatePhysicalNetwork'),
+ data: {
+ id: args.context.physicalNetworks[0].id,
+ state: 'Enabled'
+ },
+ success: function(json) {
+ args.response.success({
+ _custom: {
+ jobId: json.updatephysicalnetworkresponse.jobid,
+ getUpdatedItem: function(json) {
+ return {
+ state: 'Enabled'
+ };
+ },
+ getActionFilter: function() {
+ return cloudStack.actionFilter.physicalNetwork;
+ }
+ }
+ });
+ },
+ error: function(json) { args.response.error(parseXMLHttpResponse(json)); }
+ });
+ },
+ notification: { poll: pollAsyncJobResult }
+ },
+ disable: {
+ label: 'label.action.disable.physical.network',
+ messages: {
+ confirm: function(args) {
+ return 'message.action.disable.physical.network';
+ },
+ notification: function(args) {
+ return 'label.action.disable.physical.network';
+ }
+ },
+ action: function(args) {
+ $.ajax({
+ url: createURL('updatePhysicalNetwork'),
+ data: {
+ id: args.context.physicalNetworks[0].id,
+ state: 'Disabled'
+ },
+ success: function(json) {
+ args.response.success({
+ _custom: {
+ jobId: json.updatephysicalnetworkresponse.jobid,
+ getUpdatedItem: function(json) {
+ return {
+ state: 'Disabled'
+ };
+ },
+ getActionFilter: function() {
+ return cloudStack.actionFilter.physicalNetwork;
+ }
+ }
+ });
+ },
+ error: function(json) { args.response.error(parseXMLHttpResponse(json)); }
+ });
+ },
+ notification: { poll: pollAsyncJobResult }
+ }
}
},
dataProvider: function(args) {
@@ -1839,6 +1913,7 @@
success: function(json) {
physicalNetworkObjs = json.listphysicalnetworksresponse.physicalnetwork;
args.response.success({
+ actionFilter: cloudStack.actionFilter.physicalNetwork,
data: json.listphysicalnetworksresponse.physicalnetwork
});
}
@@ -9235,7 +9310,17 @@
}
);
}
- }
-
-
+ };
+
+ cloudStack.actionFilter.physicalNetwork = function(args) {
+ var state = args.context.item.state;
+
+ if (state == 'Enabled') {
+ return ['disable', 'remove'];
+ } else if (state == 'Disabled') {
+ return ['enable', 'remove'];
+ }
+
+ return [];
+ };
})($, cloudStack);
diff --git a/ui/scripts/ui-custom/zoneChart.js b/ui/scripts/ui-custom/zoneChart.js
index 7c4951a2ad2..dfe26e91f3c 100644
--- a/ui/scripts/ui-custom/zoneChart.js
+++ b/ui/scripts/ui-custom/zoneChart.js
@@ -295,11 +295,12 @@
response: {
success: function(args) {
var data = args.data;
+ var actionFilter = args.actionFilter;
$chart.listView({
listView: $.extend(true, {}, cloudStack.sections.system.naas.networks.listView, {
dataProvider: function(args) {
- args.response.success({ data: data });
+ args.response.success({ actionFilter: actionFilter, data: data });
},
detailView: {
tabs: {