You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2014/05/07 13:42:23 UTC

svn commit: r1592976 - in /qpid/trunk/qpid/java/bdbstore/src/main/java/resources: js/qpid/management/virtualhostnode/bdb_ha/edit.js js/qpid/management/virtualhostnode/bdb_ha/show.js virtualhostnode/bdb_ha/edit.html virtualhostnode/bdb_ha/show.html

Author: orudyy
Date: Wed May  7 11:42:23 2014
New Revision: 1592976

URL: http://svn.apache.org/r1592976
Log:
QPID-5413: Add BDB HA Virtual host node editing UI

Added:
    qpid/trunk/qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb_ha/edit.js
    qpid/trunk/qpid/java/bdbstore/src/main/java/resources/virtualhostnode/bdb_ha/edit.html
Modified:
    qpid/trunk/qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb_ha/show.js
    qpid/trunk/qpid/java/bdbstore/src/main/java/resources/virtualhostnode/bdb_ha/show.html

Added: qpid/trunk/qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb_ha/edit.js
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb_ha/edit.js?rev=1592976&view=auto
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb_ha/edit.js (added)
+++ qpid/trunk/qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb_ha/edit.js Wed May  7 11:42:23 2014
@@ -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

Modified: qpid/trunk/qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb_ha/show.js
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb_ha/show.js?rev=1592976&r1=1592975&r2=1592976&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb_ha/show.js (original)
+++ qpid/trunk/qpid/java/bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb_ha/show.js Wed May  7 11:42:23 2014
@@ -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)

Added: qpid/trunk/qpid/java/bdbstore/src/main/java/resources/virtualhostnode/bdb_ha/edit.html
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/resources/virtualhostnode/bdb_ha/edit.html?rev=1592976&view=auto
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/main/java/resources/virtualhostnode/bdb_ha/edit.html (added)
+++ qpid/trunk/qpid/java/bdbstore/src/main/java/resources/virtualhostnode/bdb_ha/edit.html Wed May  7 11:42:23 2014
@@ -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>

Modified: qpid/trunk/qpid/java/bdbstore/src/main/java/resources/virtualhostnode/bdb_ha/show.html
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/resources/virtualhostnode/bdb_ha/show.html?rev=1592976&r1=1592975&r2=1592976&view=diff
==============================================================================
--- qpid/trunk/qpid/java/bdbstore/src/main/java/resources/virtualhostnode/bdb_ha/show.html (original)
+++ qpid/trunk/qpid/java/bdbstore/src/main/java/resources/virtualhostnode/bdb_ha/show.html Wed May  7 11:42:23 2014
@@ -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>
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org