Modified: 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js?rev=1754027&r1=1754026&r2=1754027&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js
 (original)
+++ 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js
 Mon Jul 25 15:13:24 2016
@@ -24,7 +24,7 @@ define(["dojo/_base/lang",
         "qpid/common/util",
         "qpid/management/controller",
         "dojo/ready",
-        "dojo/domReady!"], function (lang, query, Tree, util, controller, 
ready)
+        "dojo/domReady!"], function (lang, query, Tree, util, controller)
 {
 
     function TreeViewModel(management, node)
@@ -296,135 +296,7 @@ define(["dojo/_base/lang",
 
     TreeViewModel.prototype.relocate = function (theItem)
     {
-
-        function findItemDetails(theItem, details, type, object, parent)
-        {
-            if (theItem.id == object.id)
-            {
-                details.type = type;
-                details[type] = object.name;
-                details.parent = parent;
-            }
-            else
-            {
-                var parentObject = {
-                    type: type,
-                    name: object.name
-                };
-                if (parent)
-                {
-                    parentObject.parent = parent;
-                }
-                // iterate over children
-                for (var propName in object)
-                {
-                    if (object.hasOwnProperty(propName))
-                    {
-                        var prop = object[propName];
-                        if (util.isArray(prop))
-                        {
-                            for (var i = 0; i < prop.length; i++)
-                            {
-                                findItemDetails(theItem,
-                                    details,
-                                    propName.substring(0, propName.length - 1),
-                                    prop[i],
-                                    parentObject);
-
-                                if (details.type)
-                                {
-                                    break;
-                                }
-                            }
-                        }
-                        if (details.type)
-                        {
-                            break;
-                        }
-                    }
-                }
-
-                if (!details.type)
-                {
-                    details[type] = null;
-                }
-            }
-        }
-
-        var details = new Object();
-        findItemDetails(theItem, details, "broker", this.model, null);
-
-        if (details.type == "broker")
-        {
-            controller.show("broker", "", null, theItem.id);
-        }
-        else if (details.type == "virtualhost")
-        {
-            controller.show("virtualhost", details.virtualhost, 
details.parent, theItem.id);
-        }
-        else if (details.type == "exchange")
-        {
-            controller.show("exchange", details.exchange, details.parent, 
theItem.id);
-        }
-        else if (details.type == "queue")
-        {
-            controller.show("queue", details.queue, details.parent, 
theItem.id);
-        }
-        else if (details.type == "connection")
-        {
-            controller.show("connection", details.connection, details.parent, 
theItem.id);
-        }
-        else if (details.type == 'port')
-        {
-            controller.show("port", details.port, details.parent, theItem.id);
-        }
-        else if (details.type == 'authenticationprovider')
-        {
-            controller.show("authenticationprovider", 
details.authenticationprovider, details.parent, theItem.id);
-        }
-        else if (details.type == 'groupprovider')
-        {
-            controller.show("groupprovider", details.groupprovider, 
details.parent, theItem.id);
-        }
-        else if (details.type == 'group')
-        {
-            controller.show("group", details.group, details.parent, 
theItem.id);
-        }
-        else if (details.type == 'keystore')
-        {
-            controller.show("keystore", details.keystore, details.parent, 
theItem.id);
-        }
-        else if (details.type == 'truststore')
-        {
-            controller.show("truststore", details.truststore, details.parent, 
theItem.id);
-        }
-        else if (details.type == 'accesscontrolprovider')
-        {
-            controller.show("accesscontrolprovider", 
details.accesscontrolprovider, details.parent, theItem.id);
-        }
-        else if (details.type == 'plugin')
-        {
-            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);
-        }
-        else if (details.type == "brokerlogger")
-        {
-            controller.show("brokerlogger", details.brokerlogger, 
details.parent, theItem.id);
-        }
-        else if (details.type == "virtualhostlogger")
-        {
-            controller.show("virtualhostlogger", details.virtualhostlogger, 
details.parent, theItem.id);
-        }
+        controller.showById(theItem.id);
     };
 
     TreeViewModel.prototype.update = function (data)
@@ -452,42 +324,6 @@ define(["dojo/_base/lang",
 
         }), true);
         tree.startup();
-        try
-        {
-            controller.show("broker", "");
-
-            var tabs = management.userPreferences.tabs;
-            if (tabs)
-            {
-                for (var i in tabs)
-                {
-                    var tab = tabs[i], modelObject;
-                    if (tab.objectType != "broker")
-                    {
-                        if (tab.objectId)
-                        {
-                            modelObject = 
this.fetchItemByIdentity(tab.objectId);
-                            if (modelObject)
-                            {
-                                this.relocate(modelObject);
-                            }
-                            else
-                            {
-                                this.management.userPreferences.removeTab(tab);
-                            }
-                        }
-                        else
-                        {
-                            controller.show(tab.objectType, "");
-                        }
-                    }
-                }
-            }
-        }
-        catch (e)
-        {
-            console.error(e);
-        }
     };
 
     return TreeViewModel;

Added: 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/userpreference/UserPreferenceForm.js
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/userpreference/UserPreferenceForm.js?rev=1754027&view=auto
==============================================================================
--- 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/userpreference/UserPreferenceForm.js
 (added)
+++ 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/userpreference/UserPreferenceForm.js
 Mon Jul 25 15:13:24 2016
@@ -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/declare",
+        "dojo/_base/lang",
+        "dojo/text!userpreference/UserPreferenceForm.html",
+        "dojo/Evented",
+        "qpid/common/TimeZoneSelector",
+        "dijit/form/Form",
+        "dijit/form/Button",
+        "dijit/form/NumberSpinner",
+        "dijit/_WidgetBase",
+        "dijit/_TemplatedMixin",
+        "dijit/_WidgetsInTemplateMixin",
+        "dojox/validate/us",
+        "dojox/validate/web",
+        "dojo/domReady!"], function (declare, lang, template, Evented, 
TimeZoneSelector)
+{
+
+    return declare("qpid.management.userpreference.UserPreferenceForm",
+        [dijit._WidgetBase, dijit._TemplatedMixin, 
dijit._WidgetsInTemplateMixin, Evented],
+        {
+            /**
+             * dijit._TemplatedMixin enforced fields
+             */
+            //Strip out the apache comment header from the template html as 
comments unsupported.
+            templateString: template.replace(/<!--[\s\S]*?-->/g, ""),
+
+            /**
+             * template attach points
+             */
+            preferenceForm: null,
+            timeZoneSelector: null,
+            updatePeriod: null,
+            cancelButton: null,
+            saveButton: null,
+
+            /**
+             * inner fields
+             */
+            _changedPreferences: null,
+            _timeZone: null,
+            _updatePeriod: null,
+
+            postCreate: function ()
+            {
+                this.inherited(arguments);
+                this._postCreate();
+            },
+            _postCreate: function ()
+            {
+                this._changedPreferences = {};
+                this.cancelButton.on("click", lang.hitch(this, 
this._onCancel));
+                this.preferenceForm.on("submit", lang.hitch(this, 
this._onFormSubmit));
+                this.timeZoneSelector.on("change", lang.hitch(this, 
this._onTimeZoneChange));
+                this.updatePeriod.on("change", lang.hitch(this, 
this._onUpdatePeriodChange));
+                this.saveButton.set("disabled", true);
+            },
+            _onCancel: function ()
+            {
+                this.emit("cancel");
+            },
+            _setTimezonesAttr: function (timezones)
+            {
+                this.timeZoneSelector.set("timezones", timezones);
+            },
+            _setTimezoneAttr: function (timezone)
+            {
+                this.timeZoneSelector.set("value", timezone);
+                this._timeZone = timezone;
+            },
+            _setUpdatePeriodAttr: function (updatePeriod, priority)
+            {
+                this.updatePeriod.set("value", updatePeriod, priority);
+                this._updatePeriod = updatePeriod;
+            },
+            _onTimeZoneChange: function (value)
+            {
+                this._changedPreferences.timeZone = value;
+                this._onChange();
+            },
+            _onUpdatePeriodChange: function (value)
+            {
+                this._changedPreferences.updatePeriod = value;
+                this._onChange();
+            },
+            _onChange: function ()
+            {
+                this.saveButton.set("disabled",
+                    this._updatePeriod == this.updatePeriod.value && 
this._timeZone == this.timeZoneSelector.value);
+            },
+            _onFormSubmit: function ()
+            {
+                if (this.preferenceForm.validate())
+                {
+                    try
+                    {
+                        var preferences = lang.clone(this._changedPreferences);
+                        this.emit("save", {preferences: preferences});
+                        this._changedPreferences = {};
+                    }
+                    catch(e)
+                    {
+                        alert('Save failed:' + e);
+                    }
+                }
+                else
+                {
+                    alert('Form contains invalid data.  Please correct first');
+                }
+                return false;
+            }
+        });
+});

Added: 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/userpreference/UserPreferenceForm.html
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/userpreference/UserPreferenceForm.html?rev=1754027&view=auto
==============================================================================
--- 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/userpreference/UserPreferenceForm.html
 (added)
+++ 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/userpreference/UserPreferenceForm.html
 Mon Jul 25 15:13:24 2016
@@ -0,0 +1,65 @@
+<!--
+ -
+ - 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>
+
+    <form method="post"
+          data-dojo-type="dijit/form/Form"
+          data-dojo-attach-point="preferenceForm">
+        <div class="clear">
+            <label class="formLabel-labelCell tableContainer-labelCell" 
for="${id}_timeZone">Time zone:</label>
+            <div id="${id}_timeZone"
+                 class="formLabel-controlCell tableContainer-valueCell"
+                 data-dojo-attach-point="timeZoneSelector"
+                 data-dojo-type="qpid/common/TimeZoneSelector"
+                 data-dojo-props="name: 'timeZone'"></div>
+        </div>
+        <div class="clear">
+            <label class="formLabel-labelCell tableContainer-labelCell" 
for="${id}_updatePeriod">Update period:</label>
+            <input id="${id}_updatePeriod"
+                   class="formLabel-controlCell tableContainer-valueCell"
+                   data-dojo-attach-point="updatePeriod"
+                   data-dojo-type="dijit/form/NumberSpinner"
+                   data-dojo-props="
+                    name:'updatePeriod',
+                    invalidMessage: 'Invalid value',
+                    required: false,
+                    smallDelta: 1,
+                    value: 5,
+                    constraints: {min:1,max:65535,places:0, pattern: 
'#####'}"/>
+        </div>
+        <div class="clear"></div>
+
+        <div class="dijitDialogPaneActionBar">
+            <input id="${id}_cancelButton"
+                   data-dojo-attach-point="cancelButton"
+                   data-dojo-type="dijit/form/Button"
+                   type="button"
+                   label="Cancel"/>
+            <input id="${id}_saveButton"
+                   type="submit"
+                   data-dojo-type="dijit/form/Button"
+                   data-dojo-props="label: 'Save'"
+                   data-dojo-attach-point="saveButton"/>
+        </div>
+
+    </form>
+
+</div>



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to