diff options
| author | Alex Rudyy <orudyy@apache.org> | 2014-05-07 09:27:02 +0000 |
|---|---|---|
| committer | Alex Rudyy <orudyy@apache.org> | 2014-05-07 09:27:02 +0000 |
| commit | 7dffa6c6bd8db286afa61108ef6c70bc4875251c (patch) | |
| tree | f02ec234a95ecdc912b2de3119c55f35db33b872 /qpid/java/bdbstore/src | |
| parent | 304b0dbebc28597538b79472e97af47d4b13a7f4 (diff) | |
| download | qpid-python-7dffa6c6bd8db286afa61108ef6c70bc4875251c.tar.gz | |
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
Diffstat (limited to 'qpid/java/bdbstore/src')
4 files changed, 459 insertions, 0 deletions
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<nodeFields.length;i++) + { + var fieldName = nodeFields[i]; + this[fieldName]= findNode(fieldName, containerNode); + } + + this.designatedPrimaryContainer = findNode("designatedPrimaryContainer", containerNode); + this.priorityContainer = findNode("priorityContainer", containerNode); + this.quorumOverrideContainer = findNode("quorumOverrideContainer", containerNode); + 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 ); + this.replicatedEnvironmentConfigurationPanel = registry.byNode(query(".replicatedEnvironmentConfigurationPanel", containerNode)[0]); + this.replicatedEnvironmentConfigurationGrid = new UpdatableStore([], + query(".replicatedEnvironmentConfiguration", containerNode)[0], + [ {name: 'Name', field: 'id', width: '50%'}, {name: 'Value', field: 'value', width: '50%'} ], + null, + null, + null, true ); + + this.membersGridPanel = registry.byNode(query(".membersGridPanel", containerNode)[0]); + this.membersGrid = new UpdatableStore([], + findNode("groupMembers", containerNode), + [ + { name: 'Name', field: 'name', width: '10%' }, + { name: 'Role', field: 'role', width: '10%' }, + { name: 'Address', field: 'address', width: '35%' }, + { name: 'Join Time', field: 'joinTime', width: '25%', formatter: function(value){ return value ? UserPreferences.formatDateTime(value) : "";} }, + { name: 'Replication Transaction ID', field: 'lastKnownReplicationTransactionId', width: '20%' } + ], + null, + { + selectionMode: "single", + keepSelection: true, + plugins: { + indirectSelection: true + } + }, + EnhancedGrid, true ); + + this.removeNodeButton = registry.byNode(query(".removeNodeButton", containerNode)[0]); + this.transferMasterButton = registry.byNode(query(".transferMasterButton", containerNode)[0]); + this.transferMasterButton.set("disabled", true); + this.removeNodeButton.set("disabled", true); + + var nodeControlsToggler = function(rowIndex) + { + var data = that.membersGrid.grid.selection.getSelected(); + that.transferMasterButton.set("disabled", data.length != 1|| data[0].role != "REPLICA"); + that.removeNodeButton.set("disabled", data.length != 1 || data[0].role == "MASTER" || data[0].name == that.data.name); + }; + connect.connect(this.membersGrid.grid.selection, 'onSelected', nodeControlsToggler); + connect.connect(this.membersGrid.grid.selection, 'onDeselected', nodeControlsToggler); + + this.transferMasterButton.on("click", + function(e) + { + var data = that.membersGrid.grid.selection.getSelected(); + if (data.length == 1 && confirm("Are you sure you would like to transfer mastership to node '" + data[0].name + "'?")) + { + sendRequest(that.data.name, data[0].name, "POST", {role: "MASTER"}); + that.membersGrid.grid.selection.clear(); + } + } + ); + + this.removeNodeButton.on("click", + function(e){ + var data = that.membersGrid.grid.selection.getSelected(); + if (data.length == 1 && confirm("Are you sure you would like to delete node '" + data[0].name + "'?")) + { + sendRequest(that.data.name, data[0].name, "DELETE"); + that.membersGrid.grid.selection.clear(); + } + } + ); + + this.stopNodeButton = registry.byNode(findNode("stopNodeButton", containerNode)); + this.startNodeButton = registry.byNode(findNode("startNodeButton", containerNode)); + this.editNodeButton = registry.byNode(findNode("editNodeButton", containerNode)); + 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?")) + { + sendRequest(that.data.name, that.data.name, "DELETE"); + // TODO: close tab + } + } + ); + + } + + BDBHA.prototype.update=function(data) + { + this.data = data; + for(var i = 0; i < nodeFields.length; i++) + { + var name = nodeFields[i]; + this[name].innerHTML = entities.encode(String(data[name])); + } + + this._updateGrid(this._convertConfig(data.environmentConfiguration), this.environmentConfigurationPanel, this.environmentConfigurationGrid ); + this._updateGrid(this._convertConfig(data.replicatedEnvironmentConfiguration), this.replicatedEnvironmentConfigurationPanel, this.replicatedEnvironmentConfigurationGrid ); + + var members = data.remotereplicationnodes; + if (members) + { + members.push({ + id: data.id, + name: data.name, + groupName: data.groupName, + address: data.address, + role: data.role, + joinTime: data.joinTime, + lastKnownReplicationTransactionId: data.lastKnownReplicationTransactionId + }); + } + this._updateGrid(members, this.membersGridPanel, this.membersGrid); + + if (!members || members.length < 3) + { + this.designatedPrimaryContainer.style.display="block"; + this.priorityContainer.style.display="none"; + this.quorumOverrideContainer.style.display="none"; + } + else + { + this.designatedPrimaryContainer.style.display="none"; + this.priorityContainer.style.display="block"; + this.quorumOverrideContainer.style.display="block"; + } + this.deleteNodeButton.set("disabled", data.role=="MASTER"); + }; + + BDBHA.prototype._updateGrid=function(conf, panel, updatableGrid) + { + if (conf && conf.length > 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 @@ +<!-- + ~ 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. + --> +<div> + <div style="clear:both"> + <div class="formLabel-labelCell" style="float:left; width: 200px;">Store Path:</div> + <div class="storePath" style="float:left;"></div> + </div> + <div style="clear:both"></div> + <div data-dojo-type="dijit.TitlePane" data-dojo-props="title: 'Environment Configuration', open: true" class="environmentConfigurationPanel"> + <div class="environmentConfiguration"></div> + </div> +</div>
\ 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 @@ +<!-- + - + - 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. + - + --> +<div> + <div style="clear:both"> + <div class="formLabel-labelCell" style="float:left; width: 200px;">Group Name:</div> + <div class="groupName" style="float:left;"></div> + </div> + <div style="clear:both"> + <div class="formLabel-labelCell" style="float:left; width: 200px">Store Path:</div> + <div class="storePath" style="float:left;"></div> + </div> + <div style="clear:both"> + <div class="formLabel-labelCell" style="float:left; width: 200px;">Role:</div> + <div class="role" style="float:left;">N/A</div> + </div> + <div style="clear:both"> + <div class="formLabel-labelCell" style="float:left; width: 200px;">Address:</div> + <div class="address" style="float:left;">N/A</div> + </div> + <div style="clear:both"> + <div class="formLabel-labelCell" style="float:left; width: 200px;">Coalescing Sync:</div> + <div class="coalescingSync" style="float:left;">N/A</div> + </div> + <div style="clear:both"> + <div class="formLabel-labelCell" style="float:left; width: 200px;">Durability:</div> + <div class="durability" style="float:left;">N/A</div> + </div> + <div style="clear:both" class="designatedPrimaryContainer"> + <div class="formLabel-labelCell" style="float:left; width: 200px;">Allow this node to operate solo:</div> + <div class="designatedPrimary" style="float:left;">N/A</div> + </div> + <div style="clear:both" class="priorityContainer"> + <div class="formLabel-labelCell" style="float:left; width: 200px;">Election priority:</div> + <div class="priority" style="float:left;">Never</div> + </div> + <div style="clear:both" class="quorumOverrideContainer"> + <div class="formLabel-labelCell" style="float:left; width: 200px;">Required minimum number of nodes:</div> + <div style="float:left;"> + <span class="quorumOverride" >N/A</span> + <span style="margin-left: 20px;">[ 0 signifies simple majority ]</span> + </div> + </div> + <div style="clear:both"></div> + <br/> + <div style="clear:both" data-dojo-type="dijit.TitlePane" data-dojo-props="title: 'Environment Configuration'" class="environmentConfigurationPanel"> + <div class="environmentConfiguration"></div> + </div> + <div style="clear:both"></div> + <br/> + <div style="clear:both" data-dojo-type="dijit.TitlePane" data-dojo-props="title: 'Replicated Environment Configuration'" class="replicatedEnvironmentConfigurationPanel"> + <div class="replicatedEnvironmentConfiguration"></div> + </div> + <div style="clear:both"></div> + <div class="dijitDialogPaneActionBar"> + <button data-dojo-type="dijit.form.Button" class="startNodeButton" type="button" data-dojo-props="disabled: true">Start</button> + <button data-dojo-type="dijit.form.Button" class="stopNodeButton" type="button" data-dojo-props="disabled: true">Stop</button> + <button data-dojo-type="dijit.form.Button" class="editNodeButton" type="button" data-dojo-props="disabled: true">Edit</button> + <button data-dojo-type="dijit.form.Button" class="deleteNodeButton" data-dojo-props="iconClass: 'dijitIconDelete', disabled: true">Delete Node</button> + </div> + + <br/> + <div data-dojo-type="dijit.TitlePane" data-dojo-props="title: 'Group nodes'" class="membersGridPanel"> + <div class="groupMembers"></div> + <div class="groupMembersToolbar dijitDialogPaneActionBar"> + <button data-dojo-type="dijit.form.Button" class="removeNodeButton" data-dojo-props="iconClass: 'dijitIconDelete'">Remove Node</button> + <button data-dojo-type="dijit.form.Button" class="transferMasterButton" data-dojo-props="iconClass: 'dijitIconConfigure'">Make Node Master</button> + </div> + </div> +</div> |
