diff options
| author | Alex Rudyy <orudyy@apache.org> | 2014-05-07 11:42:23 +0000 |
|---|---|---|
| committer | Alex Rudyy <orudyy@apache.org> | 2014-05-07 11:42:23 +0000 |
| commit | 7a0ef9873040923c2ca330c4b024dd5197af8156 (patch) | |
| tree | 077e380e32f567af8d2d024b5ac0969c83bc3be8 /qpid/java/bdbstore | |
| parent | 7dffa6c6bd8db286afa61108ef6c70bc4875251c (diff) | |
| download | qpid-python-7a0ef9873040923c2ca330c4b024dd5197af8156.tar.gz | |
QPID-5413: Add BDB HA Virtual host node editing UI
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1592976 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/bdbstore')
4 files changed, 348 insertions, 2 deletions
diff --git a/qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb_ha/edit.js b/qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb_ha/edit.js new file mode 100644 index 0000000000..269bb402c5 --- /dev/null +++ b/qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb_ha/edit.js @@ -0,0 +1,180 @@ +/* + * + * 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/array", + "dojo/_base/event", + "dojo/_base/lang", + "dojo/_base/window", + "dojo/dom", + "dojo/dom-construct", + "dijit/registry", + "dojo/parser", + 'dojo/json', + "dojo/query", + "dojo/store/Memory", + "dojo/data/ObjectStore", + "dojo/text!virtualhostnode/bdb_ha/edit.html", + "dijit/Dialog", + "dijit/form/CheckBox", + "dijit/form/FilteringSelect", + "dijit/form/ValidationTextBox", + "dijit/form/Button", + "dijit/form/Form", + "dojox/validate/us", + "dojox/validate/web", + "dojo/domReady!"], + function (xhr, array, event, lang, win, dom, domConstruct, registry, parser, json, query, Memory, ObjectStore, template) + { + var fields = [ "storePath", "name", "groupName", "address", "durability", + "coalescingSync", "designatedPrimary", "priority", "quorumOverride"]; + + var bdbHaNodeEditor = + { + init: function() + { + var that=this; + this.containerNode = domConstruct.create("div", {innerHTML: template}); + parser.parse(this.containerNode); + this.dialog = registry.byId("editBDBHANodeDialog") + this.saveButton = registry.byId("editBDBHANode.saveButton"); + this.cancelButton = registry.byId("editBDBHANode.cancelButton"); + this.cancelButton.on("click", function(e){that._cancel(e);}); + this.saveButton.on("click", function(e){that._save(e);}); + for(var i = 0; i < fields.length; i++) + { + var fieldName = fields[i]; + this[fieldName] = registry.byId("editBDBHANode." + fieldName); + } + this.form = registry.byId("editBDBHANodeForm"); + }, + show: function(nodeName) + { + var that=this; + this.nodeName = nodeName; + this.query = "api/latest/virtualhostnode/" + encodeURIComponent(nodeName); + xhr.get( + { + url: this.query, + sync: true, + handleAs: "json", + load: function(data) + { + that._show(data[0]); + } + } + ); + }, + destroy: function() + { + if (this.dialog) + { + this.dialog.destroyRecursive(); + this.dialog = null; + } + + if (this.containerNode) + { + domConstruct.destroy(this.containerNode); + this.containerNode = null; + } + }, + _cancel: function(e) + { + this.dialog.hide(); + }, + _save: function(e) + { + event.stop(e); + if(this.form.validate()) + { + var data = {}; + for(var i = 0; i < fields.length; i++) + { + var fieldName = fields[i]; + var widget = this[fieldName]; + if (!widget.get("disabled")) + { + data[fieldName] = widget.hasOwnProperty("checked")? widget.get("checked"):widget.get("value"); + } + } + var success = false,failureReason=null; + xhr.put({ + url: this.query, + sync: true, + handleAs: "json", + headers: { "Content-Type": "application/json"}, + putData: json.stringify(data), + load: function(x) {success = true; }, + error: function(error) {success = false; failureReason = error;} + }); + + if(success === true) + { + this.dialog.hide(); + } + else + { + alert("Error:" + failureReason); + } + } + else + { + alert('Form contains invalid data. Please correct first'); + } + }, + _show:function(node) + { + for(var i = 0; i < fields.length; i++) + { + var fieldName = fields[i]; + this[fieldName].set("value", node[fieldName]); + } + + var overrideData = [{id: '0', name: 'Majority', selected: '1'}]; + + if (node.remotereplicationnodes && node.remotereplicationnodes.length>1) + { + this["designatedPrimary"].set("disabled", true); + this["priority"].set("disabled", false); + this["quorumOverride"].set("disabled", false); + var overrideLimit = Math.floor((node.remotereplicationnodes.length + 1)/2); + for(var i = 1; i <= overrideLimit; i++) + { + overrideData.push({id: i, name: i + ""}); + } + } + else + { + this["designatedPrimary"].set("disabled", false); + this["priority"].set("disabled", true); + this["quorumOverride"].set("disabled", true); + } + var store = new Memory({data :overrideData, idProperty: "id" }); + this["quorumOverride"].set("store", new ObjectStore({objectStore: store})); + this.dialog.show(); + } + }; + + bdbHaNodeEditor.init(); + + return bdbHaNodeEditor; + } +);
\ No newline at end of file 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 index 1dfbf0bad5..49501990ca 100644 --- 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 @@ -30,8 +30,9 @@ define(["dojo/_base/xhr", "dojox/grid/EnhancedGrid", "qpid/common/UpdatableStore", "qpid/management/UserPreferences", + "qpid/management/virtualhostnode/bdb_ha/edit", "dojo/domReady!"], - function (xhr, lang, connect, parser, json, entities, query, json, registry, EnhancedGrid, UpdatableStore, UserPreferences) + function (xhr, lang, connect, parser, json, entities, query, json, registry, EnhancedGrid, UpdatableStore, UserPreferences, edit) { var nodeFields = ["storePath", "groupName", "role", "address", "coalescingSync", "designatedPrimary", "durability", "priority", "quorumOverride"]; @@ -173,6 +174,12 @@ define(["dojo/_base/xhr", this.stopNodeButton = registry.byNode(findNode("stopNodeButton", containerNode)); this.startNodeButton = registry.byNode(findNode("startNodeButton", containerNode)); this.editNodeButton = registry.byNode(findNode("editNodeButton", containerNode)); + this.editNodeButton.on("click", + function(e) + { + edit.show(that.data.name); + } + ); this.deleteNodeButton = registry.byNode(query(".deleteNodeButton", containerNode)[0]); this.deleteNodeButton.on("click", function(e) diff --git a/qpid/java/bdbstore/src/main/java/resources/virtualhostnode/bdb_ha/edit.html b/qpid/java/bdbstore/src/main/java/resources/virtualhostnode/bdb_ha/edit.html new file mode 100644 index 0000000000..79ab5155c3 --- /dev/null +++ b/qpid/java/bdbstore/src/main/java/resources/virtualhostnode/bdb_ha/edit.html @@ -0,0 +1,159 @@ +<!-- + ~ 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 class="dijitHidden"> + <div data-dojo-type="dijit/Dialog" data-dojo-props="title:'Edit BDB HA Virtual Host Node'" id="editBDBHANodeDialog"> + <form id="editBDBHANodeForm" method="post" data-dojo-type="dijit/form/Form"> + <table class="tableContainer-table tableContainer-table-horiz"> + <tr> + <td class="tableContainer-labelCell" style="width: 200px;"><strong>Path to store location*: </strong></td> + <td class="tableContainer-valueCell"> + <input type="text" id="editBDBHANode.storePath" + data-dojo-type="dijit/form/ValidationTextBox" + data-dojo-props=" + name: 'storePath', + placeHolder: '/path/to/message/store', + required: true, + disabled: true, + missingMessage: 'A store path must be supplied', + title: 'Enter path to the store folder'" /> + </td> + </tr> + <tr> + <td class="tableContainer-labelCell" style="width: 200px;"><strong>Node Name*: </strong></td> + <td class="tableContainer-valueCell"> + <input type="text" id="editBDBHANode.name" + data-dojo-type="dijit/form/ValidationTextBox" + data-dojo-props=" + name: 'name', + placeHolder: 'Node Name', + required: true, + disabled: true, + missingMessage: 'A node name must be supplied', + title: 'Enter node name', + pattern: '^[\x20-\x2e\x30-\x7F]{1,255}$'" /> + </td> + </tr> + <tr> + <td class="tableContainer-labelCell" style="width: 200px;"><strong>Replication Group*: </strong></td> + <td class="tableContainer-valueCell"> + <input type="text" id="editBDBHANode.groupName" + data-dojo-type="dijit/form/ValidationTextBox" + data-dojo-props=" + name: 'groupName', + placeHolder: 'Group Name', + required: true, + disabled: true, + missingMessage: 'A group name must be supplied', + title: 'Enter group name', + pattern: '^[\x20-\x2e\x30-\x7F]{1,255}$'" /> + </td> + </tr> + <tr> + <td class="tableContainer-labelCell" style="width: 200px;"><strong>Address*: </strong></td> + <td class="tableContainer-valueCell"> + <input type="text" id="editBDBHANode.address" + data-dojo-type="dijit/form/ValidationTextBox" + data-dojo-props=" + name: 'address', + placeHolder: 'host:port', + disabled: true, + required: true, + missingMessage: 'A Host and Port must be supplied', + invalidMessage: 'Must be of the form host:port', + title: 'Enter Host and Port name', + pattern: '^([0-9a-zA-Z.-_]|::)+:[0-9]{1,5}$'" /> + </td> + </tr> + <tr> + <td class="tableContainer-labelCell" style="width: 200px;"><strong>Durability: </strong></td> + <td class="tableContainer-valueCell"> + <input type="text" id="editBDBHANode.durability" + data-dojo-type="dijit/form/ValidationTextBox" + data-dojo-props=" + name: 'durability', + disabled: true, + required: false, + placeHolder: 'NO_SYNC,NO_SYNC,SIMPLE_MAJORITY', + title: 'Enter node durability settings', + pattern: '^(SYN|NO_SYNC|WRITE_NO_SYNC),(SYN|NO_SYNC|WRITE_NO_SYNC),(SIMPLE_MAJORITY|ALL|NONE)*$'" /> + </td> + </tr> + <tr> + <td class="tableContainer-labelCell" style="width: 200px;"><strong>Coalescing sync: </strong></td> + <td class="tableContainer-valueCell"> + <input type="checkbox" id="editBDBHANode.coalescingSync" checked="checked" + data-dojo-type="dijit/form/CheckBox" + data-dojo-props=" + name: 'coalescingSync', + required: false, + disabled: true, + title: 'Enable coalescing sync mode for a better performance: when many transactions are synced to disk at the same time'" /> + </td> + </tr> + <tr> + <td class="tableContainer-labelCell" style="width: 200px;"><strong>Allow this node to operate solo: </strong></td> + <td class="tableContainer-valueCell"> + <input type="checkbox" id="editBDBHANode.designatedPrimary" checked="checked" + data-dojo-type="dijit/form/CheckBox" + data-dojo-props=" + name: 'designatedPrimary', + required: false, + title: 'Designate node as primary. It is applicable only to 2-nodes cluster'" /> + </td> + </tr> + <tr> + <td class="tableContainer-labelCell" style="width: 200px;"><strong>Election priority of this node: </strong></td> + <td class="tableContainer-valueCell"> + <div data-dojo-type="dojo/store/Memory" data-dojo-id="nodePriorityStore" + data-dojo-props="data: [ + {id: '0', name: 'Never'}, + {id: '1', name: 'Default', selected: '1'}, + {id: '2', name: 'Normal'}, + {id: '3', name: 'High'} + ]"></div> + <input id="editBDBHANode.priority" data-dojo-type="dijit/form/FilteringSelect" value="1" + data-dojo-props=" + name: 'priority', + required: false, + title: 'Select node priority for election as a Master', + store: nodePriorityStore, + searchAttr: 'name'" /> + </td> + </tr> + <tr> + <td class="tableContainer-labelCell" style="width: 200px;"><strong>Required minimum number of nodes: </strong></td> + <td class="tableContainer-valueCell"> + <div data-dojo-type="dojo/store/Memory" data-dojo-id="nodeQuorumOverrideStore" + data-dojo-props="data: [{id: '0', name: 'Majority', selected: '1'}]"></div> + <input type="text" id="editBDBHANode.quorumOverride" + data-dojo-type="dijit/form/FilteringSelect" value="0" + data-dojo-props=" + name: 'quorumOverride', + required: false, + title: 'Enter quorum override. 0 signifies simple majority', + store: nodeQuorumOverrideStore, + searchAttr: 'name'" /> + </td> + </tr> + </table> + <div class="dijitDialogPaneActionBar"> + <button data-dojo-type="dijit/form/Button" id="editBDBHANode.saveButton" data-dojo-props="label: 'Save'" type="submit">Save</button> + <button data-dojo-type="dijit/form/Button" id="editBDBHANode.cancelButton" data-dojo-props="label: 'Cancel'" ></button> + </div> + </form> + </div> +</div> 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 index 5feb5db256..18da913948 100644 --- 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 @@ -72,7 +72,7 @@ <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="editNodeButton" type="button">Edit</button> <button data-dojo-type="dijit.form.Button" class="deleteNodeButton" data-dojo-props="iconClass: 'dijitIconDelete', disabled: true">Delete Node</button> </div> |
