From 7dffa6c6bd8db286afa61108ef6c70bc4875251c Mon Sep 17 00:00:00 2001 From: Alex Rudyy Date: Wed, 7 May 2014 09:27:02 +0000 Subject: QPID-5413: Add virtual host node UI to view the details about existing virtual host nodes git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1592951 13f79535-47bb-0310-9956-ffa450edef68 --- .../js/qpid/management/virtualhostnode/bdb/show.js | 81 +++++++ .../qpid/management/virtualhostnode/bdb_ha/show.js | 265 +++++++++++++++++++++ .../java/resources/virtualhostnode/bdb/show.html | 26 ++ .../resources/virtualhostnode/bdb_ha/show.html | 87 +++++++ .../virtualhostnode/AbstractVirtualHostNode.java | 9 +- .../qpid/management/virtualhostnode/derby/show.js | 50 ++++ .../java/resources/virtualhostnode/derby/show.html | 21 ++ .../qpid/server/store/jdbc/JDBCMessageStore.java | 2 +- .../virtualhostnode/jdbc/JDBCVirtualHostNode.java | 4 +- .../jdbc/JDBCVirtualHostNodeImpl.java | 2 +- .../qpid/management/virtualhost/store/jdbc/add.js | 2 +- .../qpid/management/virtualhostnode/jdbc/show.js | 61 +++++ .../java/resources/virtualhost/store/jdbc/add.html | 2 +- .../java/resources/virtualhostnode/jdbc/show.html | 44 ++++ .../resources/js/qpid/common/UpdatableStore.js | 7 +- .../java/resources/js/qpid/management/Broker.js | 88 +++++-- .../js/qpid/management/VirtualHostNode.js | 132 ++++++++++ .../resources/js/qpid/management/controller.js | 6 +- .../java/resources/js/qpid/management/treeView.js | 2 + .../qpid/management/virtualhostnode/json/show.js | 50 ++++ .../src/main/java/resources/showBroker.html | 22 +- .../main/java/resources/showVirtualHostNode.html | 48 ++++ .../java/resources/virtualhostnode/json/show.html | 21 ++ 23 files changed, 998 insertions(+), 34 deletions(-) create mode 100644 qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb/show.js create mode 100644 qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb_ha/show.js create mode 100644 qpid/java/bdbstore/src/main/java/resources/virtualhostnode/bdb/show.html create mode 100644 qpid/java/bdbstore/src/main/java/resources/virtualhostnode/bdb_ha/show.html create mode 100644 qpid/java/broker-plugins/derby-store/src/main/java/resources/js/qpid/management/virtualhostnode/derby/show.js create mode 100644 qpid/java/broker-plugins/derby-store/src/main/java/resources/virtualhostnode/derby/show.html create mode 100644 qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/show.js create mode 100644 qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhostnode/jdbc/show.html create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/VirtualHostNode.js create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/virtualhostnode/json/show.js create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/showVirtualHostNode.html create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/resources/virtualhostnode/json/show.html diff --git a/qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb/show.js b/qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb/show.js new file mode 100644 index 0000000000..704f7a197c --- /dev/null +++ b/qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb/show.js @@ -0,0 +1,81 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software 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. + * + */ +define(["dojo/_base/xhr", + "dojo/_base/lang", + "dojo/_base/connect", + "dojo/parser", + "dojo/string", + "dojox/html/entities", + "dojo/query", + "dojo/json", + "dijit/registry", + "qpid/common/UpdatableStore", + "dojo/domReady!"], + function (xhr, lang, connect, parser, json, entities, query, json, registry, UpdatableStore) + { + function BdbNode(containerNode) + { + var that = this; + xhr.get({url: "virtualhostnode/bdb/show.html", + sync: true, + load: function(template) { + containerNode.innerHTML = template; + parser.parse(containerNode); + }}); + this.storePath = query(".storePath", containerNode)[0]; + this.environmentConfigurationPanel = registry.byNode(query(".environmentConfigurationPanel", containerNode)[0]); + this.environmentConfigurationGrid = new UpdatableStore([], + query(".environmentConfiguration", containerNode)[0], + [ {name: 'Name', field: 'id', width: '50%'}, {name: 'Value', field: 'value', width: '50%'} ], + null, + null, + null, true ); + } + + BdbNode.prototype.update=function(data) + { + this.storePath.innerHTML = entities.encode(String(data.storePath)); + if (data.environmentConfiguration) + { + this.environmentConfigurationPanel.domNode.style.display="block"; + var conf = data.environmentConfiguration; + var settings = []; + for(var propName in conf) + { + if(conf.hasOwnProperty(propName)) + { + settings.push({"id": propName, "value": conf[propName]}); + } + } + var changed = this.environmentConfigurationGrid.update(settings); + if (changed) + { + this.environmentConfigurationGrid.grid._refresh(); + } + } + else + { + this.environmentConfigurationPanel.domNode.style.display="none"; + } + }; + + return BdbNode; +}); diff --git a/qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb_ha/show.js b/qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb_ha/show.js new file mode 100644 index 0000000000..1dfbf0bad5 --- /dev/null +++ b/qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb_ha/show.js @@ -0,0 +1,265 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software 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. + * + */ +define(["dojo/_base/xhr", + "dojo/_base/lang", + "dojo/_base/connect", + "dojo/parser", + "dojo/string", + "dojox/html/entities", + "dojo/query", + "dojo/json", + "dijit/registry", + "dojox/grid/EnhancedGrid", + "qpid/common/UpdatableStore", + "qpid/management/UserPreferences", + "dojo/domReady!"], + function (xhr, lang, connect, parser, json, entities, query, json, registry, EnhancedGrid, UpdatableStore, UserPreferences) + { + var nodeFields = ["storePath", "groupName", "role", "address", "coalescingSync", "designatedPrimary", "durability", "priority", "quorumOverride"]; + + function findNode(nodeClass, containerNode) + { + return query("." + nodeClass, containerNode)[0]; + } + + function sendRequest(nodeName, remoteNodeName, method, attributes) + { + var success = false; + var failureReason = ""; + var url = null; + if (nodeName == remoteNodeName) + { + url = "api/latest/virtualhostnode/" + encodeURIComponent(nodeName); + } + else + { + url = "api/latest/replicationnode/" + encodeURIComponent(nodeName) + "/" + encodeURIComponent(remoteNodeName); + } + + if (method == "POST") + { + xhr.put({ + url: url, + sync: true, + handleAs: "json", + headers: { "Content-Type": "application/json"}, + putData: json.stringify(attributes), + load: function(x) {success = true; }, + error: function(error) {success = false; failureReason = error;} + }); + } + else if (method == "DELETE") + { + xhr.del({url: url, sync: true, handleAs: "json"}).then( + function(data) { success = true; }, + function(error) {success = false; failureReason = error;} + ); + } + + if (!success) + { + alert("Error:" + failureReason); + } + } + + function BDBHA(containerNode) { + var that = this; + xhr.get({url: "virtualhostnode/bdb_ha/show.html", + sync: true, + load: function(template) { + containerNode.innerHTML = template; + parser.parse(containerNode); + }}); + + for(var i=0; i 0) + { + panel.domNode.style.display="block"; + var changed = updatableGrid.update(conf); + if (changed) + { + updatableGrid.grid._refresh(); + } + } + else + { + panel.domNode.style.display="none"; + } + } + + BDBHA.prototype._convertConfig=function(conf) + { + var settings = []; + if (conf) + { + for(var propName in conf) + { + if(conf.hasOwnProperty(propName)) + { + settings.push({"id": propName, "value": conf[propName]}); + } + } + } + return settings; + } + return BDBHA; +}); diff --git a/qpid/java/bdbstore/src/main/java/resources/virtualhostnode/bdb/show.html b/qpid/java/bdbstore/src/main/java/resources/virtualhostnode/bdb/show.html new file mode 100644 index 0000000000..cdf96c3fb8 --- /dev/null +++ b/qpid/java/bdbstore/src/main/java/resources/virtualhostnode/bdb/show.html @@ -0,0 +1,26 @@ + +
+
+
Store Path:
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/qpid/java/bdbstore/src/main/java/resources/virtualhostnode/bdb_ha/show.html b/qpid/java/bdbstore/src/main/java/resources/virtualhostnode/bdb_ha/show.html new file mode 100644 index 0000000000..5feb5db256 --- /dev/null +++ b/qpid/java/bdbstore/src/main/java/resources/virtualhostnode/bdb_ha/show.html @@ -0,0 +1,87 @@ + +
+
+
Group Name:
+
+
+
+
Store Path:
+
+
+
+
Role:
+
N/A
+
+
+
Address:
+
N/A
+
+
+
Coalescing Sync:
+
N/A
+
+
+
Durability:
+
N/A
+
+
+
Allow this node to operate solo:
+
N/A
+
+
+
Election priority:
+
Never
+
+
+
Required minimum number of nodes:
+
+ N/A + [ 0 signifies simple majority ] +
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + +
+ +
+
+
+
+ + +
+
+
diff --git a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java index 6655ec1e4b..c3c85d5ed5 100644 --- a/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java +++ b/qpid/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractVirtualHostNode.java @@ -256,9 +256,12 @@ public abstract class AbstractVirtualHostNode + +
+
Store Path:
+
+
\ No newline at end of file diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java index 037b9ee037..d70f2a3d78 100644 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java +++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java @@ -50,7 +50,7 @@ public class JDBCMessageStore extends AbstractJDBCMessageStore implements Messag private static final Logger _logger = Logger.getLogger(JDBCMessageStore.class); public static final String TYPE = "JDBC"; - public static final String CONNECTION_URL = "connectionURL"; + public static final String CONNECTION_URL = "connectionUrl"; public static final String CONNECTION_POOL_TYPE = "connectionPoolType"; public static final String JDBC_BIG_INT_TYPE = "bigIntType"; public static final String JDBC_BYTES_FOR_BLOB = "bytesForBlob"; diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNode.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNode.java index f66cb74529..302ec9c59f 100644 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNode.java +++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNode.java @@ -21,10 +21,10 @@ package org.apache.qpid.server.virtualhostnode.jdbc; import org.apache.qpid.server.model.ManagedAttribute; +import org.apache.qpid.server.model.VirtualHostNode; import org.apache.qpid.server.store.jdbc.DefaultConnectionProviderFactory; - -public interface JDBCVirtualHostNode +public interface JDBCVirtualHostNode> extends VirtualHostNode { //TODO: Split this attribute into connectionUrl, username and password. Make the password attribute secure. @ManagedAttribute(mandatory=true) diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java index 8d7c79b656..cb3077bc65 100644 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java +++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java @@ -31,7 +31,7 @@ import org.apache.qpid.server.store.jdbc.JDBCMessageStoreFactory; import org.apache.qpid.server.virtualhostnode.AbstractStandardVirtualHostNode; @ManagedObject( category = false, type = "JDBC" ) -public class JDBCVirtualHostNodeImpl extends AbstractStandardVirtualHostNode implements JDBCVirtualHostNode +public class JDBCVirtualHostNodeImpl extends AbstractStandardVirtualHostNode implements JDBCVirtualHostNode { @ManagedAttributeField private String _connectionUrl; diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/store/jdbc/add.js b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/store/jdbc/add.js index d1f4787202..21c0c17de9 100644 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/store/jdbc/add.js +++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/store/jdbc/add.js @@ -81,7 +81,7 @@ define(["dojo/_base/xhr", var poolTypesDiv = dom.byId("addVirtualHost.specific.selectPoolType"); var input = construct.create("input", {id: "addPoolType", required: false}, poolTypesDiv); that.poolTypeChooser = new FilteringSelect({ id: "addVirtualHost.specific.store.poolType", - name: "connectionPool", + name: "connectionPoolType", store: poolTypesStore, searchAttr: "name", required: false, onChange: selectPoolType }, input); diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/show.js b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/show.js new file mode 100644 index 0000000000..20637da6c2 --- /dev/null +++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/show.js @@ -0,0 +1,61 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software 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. + * + */ +define(["dojo/_base/xhr", + "dojo/_base/lang", + "dojo/_base/connect", + "dojo/parser", + "dojo/string", + "dojox/html/entities", + "dojo/query", + "dojo/json", + "dojo/domReady!"], + function (xhr, lang, connect, parser, json, entities, query, json) + { + var fieldNames = ["connectionUrl", "bigIntType", "varBinaryType", "blobType", "bytesForBlob", "connectionPoolType"]; + + function JdbcNode(containerNode) + { + var that = this; + xhr.get({url: "virtualhostnode/jdbc/show.html", + sync: true, + load: function(template) { + containerNode.innerHTML = template; + parser.parse(containerNode); + }}); + for(var i=0; iJDBC Url*: + name="connectionUrl" placeholder="jdbc:provider:info" /> Connection Pool: diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhostnode/jdbc/show.html b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhostnode/jdbc/show.html new file mode 100644 index 0000000000..63fec28012 --- /dev/null +++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/virtualhostnode/jdbc/show.html @@ -0,0 +1,44 @@ + +
+
+
Connection URL:
+
+
+
+
Big Integer Type:
+
+
+
+
Var Binary Type:
+
+
+
+
Blob Type:
+
+
+
+
Bytes For Blob:
+
+
+
+
Connection Pool Type:
+
+
+
+
+ diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/UpdatableStore.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/UpdatableStore.js index ea3ba78372..97b1e32798 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/UpdatableStore.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/UpdatableStore.js @@ -97,8 +97,11 @@ define(["dojo/store/Memory", } } if(modified) { - // ... check attributes for updates - store.notify(theItem, data[i].id); + store.put(data[i], {overwrite: true}); + if (store instanceof Observable) + { + store.notify(theItem, data[i].id); + } changed = true; } } else { diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js index a0414b07d2..9696280b2c 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js @@ -44,6 +44,9 @@ define(["dojo/_base/xhr", "dijit/form/ValidationTextBox", "dijit/form/CheckBox", "dojo/store/Memory", + "dijit/form/DropDownButton", + "dijit/Menu", + "dijit/MenuItem", "dojo/domReady!"], function (xhr, parser, query, connect, properties, updater, util, UpdatableStore, EnhancedGrid, registry, entities, addAuthenticationProvider, addVirtualHost, addPort, addKeystore, addGroupProvider, addAccessControlProvider) { @@ -197,17 +200,6 @@ define(["dojo/_base/xhr", var addHostButton = query(".addVirtualHost", contentPane.containerNode)[0]; connect.connect(registry.byNode(addHostButton), "onClick", function(evt){ addVirtualHost.show(); }); - var deleteHostButton = query(".deleteVirtualHost", contentPane.containerNode)[0]; - connect.connect(registry.byNode(deleteHostButton), "onClick", - function(evt){ - util.deleteGridSelections( - that.brokerUpdater, - that.brokerUpdater.vhostsGrid.grid, - "api/latest/virtualhostnodes", - "Deletion of virtual host will delete the message store data.\n\n Are you sure you want to delete virtual host"); - } - ); - var addPortButton = query(".addPort", contentPane.containerNode)[0]; connect.connect(registry.byNode(addPortButton), "onClick", function(evt){ addPort.show(null, that.brokerUpdater.brokerData.authenticationproviders, @@ -335,6 +327,7 @@ define(["dojo/_base/xhr", var gridProperties = { height: 400, + selectionMode: "single", plugins: { pagination: { pageSizes: ["10", "25", "50", "100"], @@ -350,27 +343,30 @@ define(["dojo/_base/xhr", that.vhostsGrid = new UpdatableStore(that.brokerData.virtualhostnodes, query(".broker-virtualhosts")[0], - [ { name: "Virtual Host", field: "_item", width: "120px", + [ + { name: "Node Name", field: "name", width: "20%"}, + { name: "Node State", field: "state", width: "15%"}, + { name: "Virtual Host Path", field: "_item", width: "20%", formatter: function(item){ return item && item.virtualhosts? item.virtualhosts[0].name: (item?item.name: "N/A"); } }, - { name: "State", field: "_item", width: "70px", + { name: "Virtual Host State", field: "_item", width: "15%", formatter: function(item){ return item && item.virtualhosts? item.virtualhosts[0].state: (item?item.state: "N/A"); } }, - { name: "Connections", field: "_item", width: "80px", + { name: "Connections", field: "_item", width: "10%", formatter: function(item){ return item && item.virtualhosts? item.virtualhosts[0].statistics.connectionCount: 0; } }, - { name: "Queues", field: "_item", width: "80px", + { name: "Queues", field: "_item", width: "10%", formatter: function(item){ return item && item.virtualhosts? item.virtualhosts[0].statistics.queueCount: 0; } }, - { name: "Exchanges", field: "_item", width: "100%", + { name: "Exchanges", field: "_item", width: "10%", formatter: function(item){ return item && item.virtualhosts? item.virtualhosts[0].statistics.exchangeCount: 0; } @@ -380,13 +376,57 @@ define(["dojo/_base/xhr", function(evt){ var idx = evt.rowIndex, theItem = this.getItem(idx); - var nodeName = obj.dataStore.getValue(theItem,"name"); - var host = theItem && theItem.virtualhosts? theItem.virtualhosts[0]: null; - var nodeObject = { type: "virtualhostnode", name: nodeName, parent: brokerObj}; - that.controller.show("virtualhost", host?host.name:nodeName, nodeObject, host?host.id:null); + that.showVirtualHost(theItem, brokerObj); }); }, gridProperties, EnhancedGrid); + var virtualHostNodeMenuButton = registry.byNode(query(".virtualHostNodeMenuButton", node)[0]); + var virtualHostMenuButton = registry.byNode(query(".virtualHostMenuButton", node)[0]); + + var toggleVirtualHostNodeNodeMenus = function(rowIndex){ + var data = that.vhostsGrid.grid.selection.getSelected(); + virtualHostNodeMenuButton.set("disabled",data.length!=1); + virtualHostMenuButton.set("disabled",data.length!=1 ); + }; + + connect.connect(that.vhostsGrid.grid.selection, 'onSelected', toggleVirtualHostNodeNodeMenus); + connect.connect(that.vhostsGrid.grid.selection, 'onDeselected', toggleVirtualHostNodeNodeMenus); + + var hostMenuItems = virtualHostMenuButton.dropDown.getChildren(); + var viewVirtualHostItem = hostMenuItems[0]; + viewVirtualHostItem.on("click", function(){ + var data = that.vhostsGrid.grid.selection.getSelected(); + if (data.length == 1) + { + that.showVirtualHost(data[0], brokerObj); + } + }); + + var nodeMenuItems = virtualHostNodeMenuButton.dropDown.getChildren(); + var viewNodeButton = nodeMenuItems[0]; + viewNodeButton.on("click", + function(evt){ + var data = that.vhostsGrid.grid.selection.getSelected(); + if (data.length == 1) + { + var item = data[0]; + that.controller.show("virtualhostnode", item.name, brokerObj, item.id); + } + } + ); + var deleteNodeButton = nodeMenuItems[1]; + deleteNodeButton.on("click", + function(evt){ + util.deleteGridSelections( + that, + that.vhostsGrid.grid, + "api/latest/virtualhostnode", + "Deletion of virtual host node will delete both configuration and message data.\n\n Are you sure you want to delete virtual host node"); + } + ); + + gridProperties.selectionMode="extended"; + that.portsGrid = new UpdatableStore(that.brokerData.ports, query(".broker-ports")[0], [ { name: "Name", field: "name", width: "150px"}, @@ -502,6 +542,14 @@ define(["dojo/_base/xhr", }); } + BrokerUpdater.prototype.showVirtualHost=function(item, brokerObj) + { + var nodeName = item.name; + var host = item.virtualhosts? item.virtualhosts[0]: null; + var nodeObject = { type: "virtualhostnode", name: nodeName, parent: brokerObj}; + this.controller.show("virtualhost", host?host.name:nodeName, nodeObject, host?host.id:null); + } + BrokerUpdater.prototype.updateHeader = function() { this.showReadOnlyAttributes(); 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 new file mode 100644 index 0000000000..e2cd763fba --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/VirtualHostNode.js @@ -0,0 +1,132 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software 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. + * + */ +define(["dojo/_base/xhr", + "dojo/parser", + "dojo/query", + "dojo/_base/connect", + "dijit/registry", + "dojox/html/entities", + "qpid/common/properties", + "qpid/common/updater", + "qpid/common/util", + "qpid/common/formatter", + "qpid/common/UpdatableStore", + "qpid/management/addQueue", + "qpid/management/addExchange", + "dojox/grid/EnhancedGrid", + "dojo/domReady!"], + function (xhr, parser, query, connect, registry, entities, properties, updater, util, formatter, UpdatableStore, addQueue, addExchange, EnhancedGrid) { + + function VirtualHostNode(name, parent, controller) + { + this.name = name; + this.controller = controller; + this.modelObj = { type: "virtualhostnode", name: name, parent: parent}; + } + + VirtualHostNode.prototype.getTitle = function() + { + return "VirtualHostNode: " + this.name; + }; + + VirtualHostNode.prototype.open = function(contentPane) + { + var that = this; + this.contentPane = contentPane; + xhr.get({url: "showVirtualHostNode.html", + sync: true, + load: function(data) { + contentPane.containerNode.innerHTML = data; + parser.parse(contentPane.containerNode); + + that.vhostNodeUpdater = new Updater(contentPane.containerNode, that.modelObj, that.controller); + that.vhostNodeUpdater.update(); + + updater.add( that.vhostNodeUpdater ); + }}); + + }; + + VirtualHostNode.prototype.close = function() + { + updater.remove( this.vhostNodeUpdater ); + }; + + function Updater(node, vhost, controller) + { + var that = this; + + function findNode(name) + { + return query("." + name, node)[0]; + } + + function storeNodes(names) + { + for(var i = 0; i < names.length; i++) + { + that[names[i]] = findNode(names[i]); + } + } + + storeNodes(["name", "state", "type", "messageStoreProviderYes","messageStoreProviderNo"]); + this.detailsDiv = findNode("virtualhostnodedetails"); + + this.query = "api/latest/virtualhostnode/" + encodeURIComponent(vhost.name); + } + + Updater.prototype.update = function() + { + var that = this; + xhr.get({url: this.query, sync: properties.useSyncGet, handleAs: "json"}).then( + function(data) + { + that.updateUI(data[0]); + } + ); + }; + + Updater.prototype.updateUI = function(data) + { + this.name.innerHTML = entities.encode(String(data[ "name" ])); + this.state.innerHTML = entities.encode(String(data[ "state" ])); + this.type.innerHTML = entities.encode(String(data[ "type" ])); + this.messageStoreProviderYes.style.display = data.messageStoreProvider? "block" : "none"; + this.messageStoreProviderNo.style.display = data.messageStoreProvider? "none" : "block"; + if (!this.details) + { + var that = this; + require(["qpid/management/virtualhostnode/" + data.type.toLowerCase() + "/show"], + function(VirtualHostNodeDetails) + { + that.details = new VirtualHostNodeDetails(that.detailsDiv); + that.details.update(data); + } + ); + } + else + { + this.details.update(data); + } + } + + return VirtualHostNode; + }); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/controller.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/controller.js index edf534176d..4b8e9db4b0 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/controller.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/controller.js @@ -39,10 +39,11 @@ define(["dojo/dom", "qpid/management/Plugin", "qpid/management/logs/LogViewer", "qpid/management/PreferencesProvider", + "qpid/management/VirtualHostNode", "dojo/ready", "dojo/domReady!"], function (dom, registry, ContentPane, CheckBox, UserPreferences, entities, Broker, VirtualHost, Exchange, Queue, Connection, AuthProvider, - GroupProvider, Group, KeyStore, TrustStore, AccessControlProvider, Port, Plugin, LogViewer, PreferencesProvider, ready) { + GroupProvider, Group, KeyStore, TrustStore, AccessControlProvider, Port, Plugin, LogViewer, PreferencesProvider, VirtualHostNode, ready) { var controller = {}; var constructors = { broker: Broker, virtualhost: VirtualHost, exchange: Exchange, @@ -50,7 +51,8 @@ define(["dojo/dom", authenticationprovider: AuthProvider, groupprovider: GroupProvider, group: Group, keystore: KeyStore, truststore: TrustStore, accesscontrolprovider: AccessControlProvider, port: Port, - plugin: Plugin, logViewer: LogViewer, preferencesprovider: PreferencesProvider}; + plugin: Plugin, logViewer: LogViewer, preferencesprovider: PreferencesProvider, + virtualhostnode: VirtualHostNode}; var tabDiv = dom.byId("managedViews"); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js index 0a05cca75d..3b65ffaacf 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js @@ -296,6 +296,8 @@ define(["dojo/_base/xhr", controller.show("plugin", details.plugin, {type:"broker", name:""}, theItem.id); } else if (details.type == "preferencesprovider") { controller.show("preferencesprovider", details.preferencesprovider, details.parent, theItem.id); + } else if (details.type == "virtualhostnode") { + controller.show("virtualhostnode", details.virtualhostnode, details.parent, theItem.id); } }; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/virtualhostnode/json/show.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/virtualhostnode/json/show.js new file mode 100644 index 0000000000..e912cf2fb0 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/virtualhostnode/json/show.js @@ -0,0 +1,50 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software 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. + * + */ +define(["dojo/_base/xhr", + "dojo/_base/lang", + "dojo/_base/connect", + "dojo/parser", + "dojo/string", + "dojox/html/entities", + "dojo/query", + "dojo/json", + "dojo/domReady!"], + function (xhr, lang, connect, parser, json, entities, query, json) + { + function JsonNode(containerNode) + { + var that = this; + xhr.get({url: "virtualhostnode/json/show.html", + sync: true, + load: function(template) { + containerNode.innerHTML = template; + parser.parse(containerNode); + }}); + this.storePath = query(".storePath", containerNode)[0]; + } + + JsonNode.prototype.update=function(data) + { + this.storePath.innerHTML = entities.encode(String(data.storePath)); + }; + + return JsonNode; +}); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/showBroker.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/showBroker.html index 0fab44fe84..d036fd9e22 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/showBroker.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/showBroker.html @@ -74,7 +74,27 @@
- +
+ Virtual Host Node +
+
View
+
Delete
+
Start
+
Stop
+
+
+
+ Virtual Host +
+
View
+
Start
+
Quiesce
+
+

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 new file mode 100644 index 0000000000..2559dd98f9 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/showVirtualHostNode.html @@ -0,0 +1,48 @@ + + + +
+
+
+
Name:
+
+
+
+
State:
+
+
+
+
Type:
+
+
+
+
Message Store Provider:
+ + +
+
+
+
+
+
+
+ diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/virtualhostnode/json/show.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/virtualhostnode/json/show.html new file mode 100644 index 0000000000..9cf5dadae8 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/virtualhostnode/json/show.html @@ -0,0 +1,21 @@ + + +
+
Store Path:
+
+
\ No newline at end of file -- cgit v1.2.1