From 7c06267d61b45d9028d634130442ef910135b3f0 Mon Sep 17 00:00:00 2001 From: Alex Rudyy Date: Thu, 29 May 2014 11:36:59 +0000 Subject: QPID-5413: [Java Broker-Web Management] Allow stopping and starting of virtual host node from the virtual host node tab git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1598257 13f79535-47bb-0310-9956-ffa450edef68 --- .../js/qpid/management/VirtualHostNode.js | 55 ++++++++++++++++++++-- .../main/java/resources/showVirtualHostNode.html | 8 +++- 2 files changed, 57 insertions(+), 6 deletions(-) (limited to 'qpid/java/broker-plugins/management-http') diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/VirtualHostNode.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/VirtualHostNode.js index b608663512..f34b2df8a8 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/VirtualHostNode.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/VirtualHostNode.js @@ -56,15 +56,57 @@ define(["dojo/_base/xhr", load: function(data) { contentPane.containerNode.innerHTML = data; parser.parse(contentPane.containerNode); - - that.vhostNodeUpdater = new Updater(contentPane.containerNode, that.modelObj, that); - that.vhostNodeUpdater.update(); - - updater.add( that.vhostNodeUpdater ); + that.onOpen(contentPane.containerNode) }}); }; + VirtualHostNode.prototype.onOpen = function(containerNode) + { + var that = this; + this.stopNodeButton = registry.byNode(query(".stopNodeButton", containerNode)[0]); + this.startNodeButton = registry.byNode(query(".startNodeButton", containerNode)[0]); + this.editNodeButton = registry.byNode(query(".editNodeButton", containerNode)[0]); + this.deleteNodeButton = registry.byNode(query(".deleteNodeButton", containerNode)[0]); + this.deleteNodeButton.on("click", + function(e) + { + if (confirm("Deletion of virtual host node will delete both configuration and message data.\n\n" + + "Are you sure you want to delete virtual host node '" + entities.encode(String(that.name)) + "'?")) + { + if (util.sendRequest("api/latest/virtualhostnode/" + encodeURIComponent( that.name) , "DELETE")) + { + that.destroy(); + } + } + } + ); + this.startNodeButton.on("click", + function(event) + { + that.startNodeButton.set("disabled", true); + util.sendRequest("api/latest/virtualhostnode/" + encodeURIComponent(that.name), + "PUT", {desiredState: "ACTIVE"}); + }); + + this.stopNodeButton.on("click", + function(event) + { + if (confirm("Stopping the node will also shutdown the virtual host. " + + "Are you sure you want to stop virtual host node '" + + entities.encode(String(that.name)) +"'?")) + { + that.stopNodeButton.set("disabled", true); + util.sendRequest("api/latest/virtualhostnode/" + encodeURIComponent(that.name), + "PUT", {desiredState: "STOPPED"}); + } + }); + this.vhostNodeUpdater = new Updater(containerNode, this.modelObj, this); + this.vhostNodeUpdater.update(); + + updater.add( this.vhostNodeUpdater ); + } + VirtualHostNode.prototype.close = function() { updater.remove( this.vhostNodeUpdater ); @@ -115,6 +157,9 @@ define(["dojo/_base/xhr", Updater.prototype.updateUI = function(data) { + this.virtualHostNode.startNodeButton.set("disabled", data.state != "STOPPED"); + this.virtualHostNode.stopNodeButton.set("disabled", data.state != "ACTIVE"); + this.name.innerHTML = entities.encode(String(data[ "name" ])); this.state.innerHTML = entities.encode(String(data[ "state" ])); this.type.innerHTML = entities.encode(String(data[ "type" ])); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/showVirtualHostNode.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/showVirtualHostNode.html index 2559dd98f9..f5643eebfd 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/showVirtualHostNode.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/showVirtualHostNode.html @@ -42,7 +42,13 @@
- + +
+ + + + +

-- cgit v1.2.1