You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by lq...@apache.org on 2016/04/29 13:04:44 UTC

svn commit: r1741609 [18/31] - in /qpid/java/trunk: bdbstore/src/main/java/resources/js/qpid/management/virtualhost/bdb/ bdbstore/src/main/java/resources/js/qpid/management/virtualhost/bdb_ha/ bdbstore/src/main/java/resources/js/qpid/management/virtual...

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addPreferencesProvider.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addPreferencesProvider.js?rev=1741609&r1=1741608&r2=1741609&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addPreferencesProvider.js (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addPreferencesProvider.js Fri Apr 29 11:04:40 2016
@@ -18,8 +18,7 @@
  * under the License.
  *
  */
-define([
-        "dojo/_base/event",
+define(["dojo/_base/event",
         "dojo/dom-construct",
         "dojo/parser",
         "dijit/registry",
@@ -32,80 +31,98 @@ define([
         "dijit/Dialog",
         "dijit/form/Button",
         "dojo/domReady!"],
-    function ( event, construct, parser, registry, PreferencesProviderForm, util, template, entities) {
+       function (event, construct, parser, registry, PreferencesProviderForm, util, template, entities)
+       {
 
-        var addPreferencesProvider =
-        {
-            init: function()
-            {
-                var that=this;
-                this.containerNode = construct.create("div", {innerHTML: template});
-                parser.parse(this.containerNode).then(function(instances) { that._postParse(); });
-            },
-            _postParse: function()
-            {
-                var that=this;
-                this.preferencesProviderForm = registry.byId("addPreferencesProvider.preferencesProvider");
-                this.dialog = registry.byId("addPreferencesProvider");
+           var addPreferencesProvider = {
+               init: function ()
+               {
+                   var that = this;
+                   this.containerNode = construct.create("div", {innerHTML: template});
+                   parser.parse(this.containerNode).then(function (instances)
+                                                         {
+                                                             that._postParse();
+                                                         });
+               },
+               _postParse: function ()
+               {
+                   var that = this;
+                   this.preferencesProviderForm = registry.byId("addPreferencesProvider.preferencesProvider");
+                   this.dialog = registry.byId("addPreferencesProvider");
 
-                var cancelButton = registry.byId("addPreferencesProvider.cancelButton");
-                cancelButton.on("click", function() { that.dialog.hide(); });
+                   var cancelButton = registry.byId("addPreferencesProvider.cancelButton");
+                   cancelButton.on("click", function ()
+                   {
+                       that.dialog.hide();
+                   });
 
-                var saveButton = registry.byId("addPreferencesProvider.saveButton");
-                saveButton.on("click", function()
-                {
-                    var result = that.preferencesProviderForm.submit(
-                                            function(preferencesProviderData){
-                                                if (that.preferencesProviderForm.data)
-                                                {
-                                                    // update request
-                                                    that.management.update(that.modelObj, preferencesProviderData).then(function(){that.dialog.hide();});
-                                                }
-                                                else
-                                                {
-                                                    that.management.create("preferencesprovider",that.modelObj, preferencesProviderData).then(function(){that.dialog.hide();});
-                                                }
-                                            });
-                });
-            },
-            show: function(management, modelObj)
-            {
-                this.management = management;
-                this.modelObj = modelObj;
-                this.preferencesProviderForm.setMetadata(management.metadata)
-                this.authenticationProviderName = modelObj.type == "authenticationprovider" ? modelObj.name : modelObj.parent.name;
-                this.dialog.set("title", modelObj.type == "preferencesprovider" ?
-                                        "Edit preferences provider '" + entities.encode(String(modelObj.name))
-                                            + "' for '" + entities.encode(String(modelObj.parent.name)) + "'":
-                                        "Add preferences provider " + " for '" + entities.encode(String(modelObj.name)) );
-                if (modelObj.type == "preferencesprovider")
-                {
-                    var that = this;
-                    management.load(modelObj, {actuals: true}).then(
-                        function(data)
-                        {
-                            that.preferencesProviderForm.setData(data[0]);
-                            that.dialog.show();
-                        },
-                        util.xhrErrorHandler
-                    );
-                }
-                else
-                {
-                    this.preferencesProviderForm.reset();
-                    this.dialog.show();
-                }
-            }
-        };
+                   var saveButton = registry.byId("addPreferencesProvider.saveButton");
+                   saveButton.on("click", function ()
+                   {
+                       var result = that.preferencesProviderForm.submit(function (preferencesProviderData)
+                                                                        {
+                                                                            if (that.preferencesProviderForm.data)
+                                                                            {
+                                                                                // update request
+                                                                                that.management.update(that.modelObj,
+                                                                                                       preferencesProviderData)
+                                                                                    .then(function ()
+                                                                                          {
+                                                                                              that.dialog.hide();
+                                                                                          });
+                                                                            }
+                                                                            else
+                                                                            {
+                                                                                that.management.create(
+                                                                                    "preferencesprovider",
+                                                                                    that.modelObj,
+                                                                                    preferencesProviderData)
+                                                                                    .then(function ()
+                                                                                          {
+                                                                                              that.dialog.hide();
+                                                                                          });
+                                                                            }
+                                                                        });
+                   });
+               },
+               show: function (management, modelObj)
+               {
+                   this.management = management;
+                   this.modelObj = modelObj;
+                   this.preferencesProviderForm.setMetadata(management.metadata)
+                   this.authenticationProviderName =
+                       modelObj.type == "authenticationprovider" ? modelObj.name : modelObj.parent.name;
+                   this.dialog.set("title",
+                                   modelObj.type == "preferencesprovider" ? "Edit preferences provider '"
+                                                                            + entities.encode(String(modelObj.name))
+                                                                            + "' for '" + entities.encode(String(
+                                       modelObj.parent.name)) + "'" : "Add preferences provider " + " for '"
+                                                                      + entities.encode(String(modelObj.name)));
+                   if (modelObj.type == "preferencesprovider")
+                   {
+                       var that = this;
+                       management.load(modelObj, {actuals: true}).then(function (data)
+                                                                       {
+                                                                           that.preferencesProviderForm.setData(data[0]);
+                                                                           that.dialog.show();
+                                                                       }, util.xhrErrorHandler);
+                   }
+                   else
+                   {
+                       this.preferencesProviderForm.reset();
+                       this.dialog.show();
+                   }
+               }
+           };
 
-        try
-        {
-            addPreferencesProvider.init();
-        }
-        catch(e)
-        {
-            console.warn("Initialisation of add preferences dialog failed", e);
-        }
+           try
+           {
+               addPreferencesProvider.init();
+           }
+           catch (e)
+           {
+               console.warn("Initialisation of add preferences dialog failed", e);
+           }
 
-        return addPreferencesProvider;
-    });
+           return addPreferencesProvider;
+       });

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addQueue.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addQueue.js?rev=1741609&r1=1741608&r2=1741609&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addQueue.js (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addQueue.js Fri Apr 29 11:04:40 2016
@@ -31,123 +31,145 @@ define(["dojo/dom",
         "dojo/text!addQueue.html",
         "qpid/common/ContextVariablesEditor",
         "dijit/form/NumberSpinner", // required by the form
-        /* dojox/ validate resources */
-        "dojox/validate/us", "dojox/validate/web",
-        /* basic dijit classes */
+           /* dojox/ validate resources */
+        "dojox/validate/us",
+        "dojox/validate/web",
+           /* basic dijit classes */
         "dijit/Dialog",
-        "dijit/form/CheckBox", "dijit/form/Textarea",
-        "dijit/form/FilteringSelect", "dijit/form/TextBox",
-        "dijit/form/ValidationTextBox", "dijit/form/DateTextBox",
-        "dijit/form/TimeTextBox", "dijit/form/Button",
-        "dijit/form/RadioButton", "dijit/form/Form",
+        "dijit/form/CheckBox",
+        "dijit/form/Textarea",
+        "dijit/form/FilteringSelect",
+        "dijit/form/TextBox",
+        "dijit/form/ValidationTextBox",
         "dijit/form/DateTextBox",
-        /* basic dojox classes */
-        "dojox/form/BusyButton", "dojox/form/CheckedMultiSelect",
-        "dojo/domReady!"],
-    function (dom, construct, win, registry, parser, array, event, json, query, util, template) {
-
-        var addQueue = {};
-
-        var node = construct.create("div", null, win.body(), "last");
-
-        var requiredFields = { sorted: "sortKey"};
-
-        var numericFieldNames = ["maximumMessageTtl",
-        "minimumMessageTtl",
-        "queueFlowControlSizeBytes",
-        "queueFlowResumeSizeBytes",
-        "alertThresholdQueueDepthMessages",
-        "alertThresholdQueueDepthBytes",
-        "alertThresholdMessageAge",
-        "alertThresholdMessageSize",
-        "alertRepeatGap",
-        "maximumDeliveryAttempts"];
-
-        var theForm;
-        node.innerHTML = template;
-        addQueue.dialogNode = dom.byId("addQueue");
-        parser.instantiate([addQueue.dialogNode]);
-
-        // for children which have name type, add a function to make all the associated atrributes
-        // visible / invisible as the select is changed
-        theForm = registry.byId("formAddQueue");
-        var typeSelector = registry.byId("formAddQueue.type");
-        typeSelector.on("change", function(value)
-        {
-            query(".typeSpecificDiv").forEach(function(node, index, arr)
-            {
-                if (node.id === "formAddQueueType:" + value)
-                {
-                    node.style.display = "block";
-                    if (addQueue.management)
-                    {
-                        util.applyMetadataToWidgets(node, "Queue", value, addQueue.management.metadata);
-                    }
-                }
-                else
-                {
-                    node.style.display = "none";
-                }
-            });
-            for(var requiredField in requiredFields)
-            {
-                dijit.byId('formAddQueue.' + requiredFields[requiredField]).required = (requiredField == value);
-            }
-        });
-
-        theForm.on("submit", function(e) {
-
-            event.stop(e);
-            if(theForm.validate())
-            {
-
-                var newQueue = util.getFormWidgetValues(theForm);
-                var context = addQueue.context.get("value");
-                if (context)
-                {
-                  newQueue["context"] = context;
-                }
-
-                addQueue.management.create("queue", addQueue.modelObj,
-                          newQueue).then(function(x){registry.byId("addQueue").hide();});
-                return false;
-
-
-            }else{
-                alert('Form contains invalid data.  Please correct first');
-                return false;
-            }
-
-        });
-
-        addQueue.show = function(management, modelObj) {
-                            addQueue.management = management;
-                            addQueue.modelObj = modelObj;
-
-                            var form = registry.byId("formAddQueue");
-                            form.reset();
-                            registry.byId("addQueue").show();
-                            util.applyMetadataToWidgets(form.domNode, "Queue", "standard", addQueue.management.metadata);
-
-                            // Add regexp to the numeric fields
-                            for(var i = 0; i < numericFieldNames.length; i++)
-                            {
-                              registry.byId("formAddQueue." + numericFieldNames[i]).set("regExpGen", util.numericOrContextVarRegexp);
-                            }
-
-                            if (!this.context)
-                            {
-                             this.context = new qpid.common.ContextVariablesEditor({name: 'context', title: 'Context variables'});
-                             this.context.placeAt(dom.byId("formAddQueue.context"));
-                            }
-
-                            management.load(modelObj).then(
-                                          function(effectiveData)
-                                          {
-                                            util.setContextData(addQueue.context, management, modelObj, {}, effectiveData[0]);
-                                          },
-                                          util.xhrErrorHandler);
-        };
+        "dijit/form/TimeTextBox",
+        "dijit/form/Button",
+        "dijit/form/RadioButton",
+        "dijit/form/Form",
+        "dijit/form/DateTextBox",
+           /* basic dojox classes */
+        "dojox/form/BusyButton",
+        "dojox/form/CheckedMultiSelect",
+        "dojo/domReady!"], function (dom, construct, win, registry, parser, array, event, json, query, util, template)
+       {
+
+           var addQueue = {};
+
+           var node = construct.create("div", null, win.body(), "last");
+
+           var requiredFields = {sorted: "sortKey"};
+
+           var numericFieldNames = ["maximumMessageTtl",
+                                    "minimumMessageTtl",
+                                    "queueFlowControlSizeBytes",
+                                    "queueFlowResumeSizeBytes",
+                                    "alertThresholdQueueDepthMessages",
+                                    "alertThresholdQueueDepthBytes",
+                                    "alertThresholdMessageAge",
+                                    "alertThresholdMessageSize",
+                                    "alertRepeatGap",
+                                    "maximumDeliveryAttempts"];
+
+           var theForm;
+           node.innerHTML = template;
+           addQueue.dialogNode = dom.byId("addQueue");
+           parser.instantiate([addQueue.dialogNode]);
+
+           // for children which have name type, add a function to make all the associated atrributes
+           // visible / invisible as the select is changed
+           theForm = registry.byId("formAddQueue");
+           var typeSelector = registry.byId("formAddQueue.type");
+           typeSelector.on("change", function (value)
+           {
+               query(".typeSpecificDiv").forEach(function (node, index, arr)
+                                                 {
+                                                     if (node.id === "formAddQueueType:" + value)
+                                                     {
+                                                         node.style.display = "block";
+                                                         if (addQueue.management)
+                                                         {
+                                                             util.applyMetadataToWidgets(node,
+                                                                                         "Queue",
+                                                                                         value,
+                                                                                         addQueue.management.metadata);
+                                                         }
+                                                     }
+                                                     else
+                                                     {
+                                                         node.style.display = "none";
+                                                     }
+                                                 });
+               for (var requiredField in requiredFields)
+               {
+                   dijit.byId('formAddQueue.' + requiredFields[requiredField]).required = (requiredField == value);
+               }
+           });
+
+           theForm.on("submit", function (e)
+           {
+
+               event.stop(e);
+               if (theForm.validate())
+               {
+
+                   var newQueue = util.getFormWidgetValues(theForm);
+                   var context = addQueue.context.get("value");
+                   if (context)
+                   {
+                       newQueue["context"] = context;
+                   }
+
+                   addQueue.management.create("queue", addQueue.modelObj, newQueue).then(function (x)
+                                                                                         {
+                                                                                             registry.byId("addQueue")
+                                                                                                     .hide();
+                                                                                         });
+                   return false;
+
+               }
+               else
+               {
+                   alert('Form contains invalid data.  Please correct first');
+                   return false;
+               }
+
+           });
+
+           addQueue.show = function (management, modelObj)
+           {
+               addQueue.management = management;
+               addQueue.modelObj = modelObj;
+
+               var form = registry.byId("formAddQueue");
+               form.reset();
+               registry.byId("addQueue").show();
+               util.applyMetadataToWidgets(form.domNode, "Queue", "standard", addQueue.management.metadata);
+
+               // Add regexp to the numeric fields
+               for (var i = 0; i < numericFieldNames.length; i++)
+               {
+                   registry.byId("formAddQueue." + numericFieldNames[i])
+                           .set("regExpGen", util.numericOrContextVarRegexp);
+               }
+
+               if (!this.context)
+               {
+                   this.context = new qpid.common.ContextVariablesEditor({
+                       name: 'context',
+                       title: 'Context variables'
+                   });
+                   this.context.placeAt(dom.byId("formAddQueue.context"));
+               }
+
+               management.load(modelObj).then(function (effectiveData)
+                                              {
+                                                  util.setContextData(addQueue.context,
+                                                                      management,
+                                                                      modelObj,
+                                                                      {},
+                                                                      effectiveData[0]);
+                                              }, util.xhrErrorHandler);
+           };
 
-        return addQueue;
-    });
+           return addQueue;
+       });

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addStore.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addStore.js?rev=1741609&r1=1741608&r2=1741609&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addStore.js (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addStore.js Fri Apr 29 11:04:40 2016
@@ -44,206 +44,249 @@ define(["dojo/_base/lang",
         "dijit/layout/ContentPane",
         "dojox/layout/TableContainer",
         "dojo/domReady!"],
-    function (lang, dom, construct, registry, parser, memory, array, event, json, util, template, xhr)
-    {
-        var addStore =
-        {
-            categoryTemplates: {},
-            init: function()
-            {
-                var that=this;
-                this.containerNode = construct.create("div", {innerHTML: template});
-                parser.parse(this.containerNode).then(function(instances) { that._postParse(); });
-            },
-            _postParse: function()
-            {
-                var that=this;
-                this.storeName = registry.byId("addStore.name");
-                this.storeName.set("regExpGen", util.nameOrContextVarRegexp);
-
-                this.dialog = registry.byId("addStore");
-                this.addButton = registry.byId("addStore.addButton");
-                this.cancelButton = registry.byId("addStore.cancelButton");
-                this.cancelButton.on("click", function(e){that._cancel(e);});
-                this.addButton.on("click", function(e){that._add(e);});
-
-                this.storeTypeFieldsContainer = dom.byId("addStore.typeFields");
-                this.storeCategoryFieldsContainer = dom.byId("addStore.categoryFields");
-                this.storeForm = registry.byId("addStore.form");
-
-                this.storeType = registry.byId("addStore.type");
-                this.storeType.on("change", function(type){that._storeTypeChanged(type);});
-            },
-            setupTypeStore: function(management, category, modelObj)
-            {
-                this.management = management;
-                this.modelObj = modelObj;
-                var metadata = management.metadata;
-                this.category = category;
-                var storeTypeSupportedTypes = metadata.getTypesForCategory(category);
-                storeTypeSupportedTypes.sort();
-                var storeTypeStore = util.makeTypeStore(storeTypeSupportedTypes);
-                this.storeType.set("store", storeTypeStore);
-            },
-            show: function(effectiveData)
-            {
-                this.effectiveData = effectiveData;
-                this._destroyTypeFields(this.storeTypeFieldsContainer);
-                this._destroyTypeFields(this.storeCategoryFieldsContainer);
-                this._loadCategoryUI = true;
-                this.storeForm.reset();
-
-                if (effectiveData)
-                {
-                    this._initFields(effectiveData);
-                }
-                this.storeName.set("disabled", effectiveData == null ? false : true);
-                this.storeType.set("disabled", effectiveData == null ? false : true);
-                if (effectiveData == null)
-                {
-                    this.dialog.set("title", "Add " + this.category);
-                }
-                else
-                {
-                    this.dialog.set("title", "Edit " + this.category + " - " + effectiveData.name);
-                }
-                this.dialog.show();
-            },
-            _initFields:function(data)
-            {
-                var type = data["type"];
-                var metadata = this.management.metadata;
-                var attributes = metadata.getMetaData(this.category, type).attributes;
-                for(var name in attributes)
-                {
-                    var widget = registry.byId("addStore."+name);
-                    if (widget)
-                    {
-                        widget.set("value", data[name]);
-                    }
-                }
-            },
-            _cancel: function(e)
-            {
-                event.stop(e);
-                this._destroyTypeFields(this.storeTypeFieldsContainer);
-                this._destroyTypeFields(this.storeCategoryFieldsContainer);
-                this.dialog.hide();
-            },
-            _add: function(e)
-            {
-                event.stop(e);
-                this._submit();
-            },
-            _submit: function()
-            {
-                if (this.storeForm.validate())
-                {
-                    var that = this;
-
-                    function disableButtons(disabled) {
-                        that.addButton.set("disabled", disabled);
-                        that.cancelButton.set("disabled", disabled);
-                    }
-
-                    disableButtons(true);
-
-                    var storeData = util.getFormWidgetValues(this.storeForm, this.initialData);
-
-                    if (this.effectiveData)
-                    {
-                        // update request
-                        this.management.update(this.modelObj, storeData).then(function(x){ disableButtons(false); that.dialog.hide();}, function(err) { disableButtons(false); that.management.errorHandler(err); });
-                    }
-                    else
-                    {
-                        this.management.create(this.category, this.modelObj, storeData).then(function(x){ disableButtons(false); that.dialog.hide();}, function(err) { disableButtons(false); that.management.errorHandler(err); });
-                    }
-                }
-                else
-                {
-                    alert('Form contains invalid data. Please correct first');
-                }
-            },
-            _storeTypeChanged: function(type)
-            {
-                this._typeChanged(type, this.storeTypeFieldsContainer, "qpid/management/store/", this.category );
-            },
-            _destroyTypeFields: function(typeFieldsContainer)
-            {
-                var widgets = registry.findWidgets(typeFieldsContainer);
-                array.forEach(widgets, function(item) { item.destroyRecursive();});
-                construct.empty(typeFieldsContainer);
-            },
-            _typeChanged: function(type, typeFieldsContainer, baseUrl, category )
-            {
-                 this._destroyTypeFields(typeFieldsContainer);
-                 if (type)
-                 {
-                     this._addCategoryMarkupIfRequired(category, type, this.effectiveData);
-                     var that = this;
-                     require([ baseUrl + type.toLowerCase() + "/add"], function(typeUI)
-                     {
-                         try
-                         {
-                             var metadata = that.management.metadata;
-                             typeUI.show({containerNode:typeFieldsContainer, parent: that, data: that.initialData, effectiveData: that.effectiveData, metadata: metadata});
-                             util.applyMetadataToWidgets(typeFieldsContainer, category, type, metadata);
-                         }
-                         catch(e)
-                         {
-                             console.warn(e);
-                         }
-                     });
-                 }
-            },
-            _addCategoryMarkupIfRequired: function(category, type, data)
-            {
-                if (this._loadCategoryUI)
-                {
-                    this._loadCategoryUI = false;
-                    var containerNode = this.storeCategoryFieldsContainer;
-                    var metadata = this.management.metadata;
-                    this._destroyTypeFields(this.storeCategoryFieldsContainer);
-
-                    var templateHandler = function(template)
-                                          {
-                                            containerNode.innerHTML = template;
-                                            parser.parse(containerNode).then(function(instances)
-                                            {
-                                              if (type)
-                                              {
-                                                util.applyToWidgets(containerNode, category, type, data, metadata);
-                                              }
-                                            });
-                                          };
-
-                    if (this.categoryTemplates[category])
-                    {
-                        templateHandler(new String(this.categoryTemplates[category]));
-                    }
-                    else
-                    {
-                        var that = this;
-                        xhr.get({url: "store/" + category.toLowerCase() + ".html",
-                                 load: function(template)
+       function (lang, dom, construct, registry, parser, memory, array, event, json, util, template, xhr)
+       {
+           var addStore = {
+               categoryTemplates: {},
+               init: function ()
+               {
+                   var that = this;
+                   this.containerNode = construct.create("div", {innerHTML: template});
+                   parser.parse(this.containerNode).then(function (instances)
+                                                         {
+                                                             that._postParse();
+                                                         });
+               },
+               _postParse: function ()
+               {
+                   var that = this;
+                   this.storeName = registry.byId("addStore.name");
+                   this.storeName.set("regExpGen", util.nameOrContextVarRegexp);
+
+                   this.dialog = registry.byId("addStore");
+                   this.addButton = registry.byId("addStore.addButton");
+                   this.cancelButton = registry.byId("addStore.cancelButton");
+                   this.cancelButton.on("click", function (e)
+                   {
+                       that._cancel(e);
+                   });
+                   this.addButton.on("click", function (e)
+                   {
+                       that._add(e);
+                   });
+
+                   this.storeTypeFieldsContainer = dom.byId("addStore.typeFields");
+                   this.storeCategoryFieldsContainer = dom.byId("addStore.categoryFields");
+                   this.storeForm = registry.byId("addStore.form");
+
+                   this.storeType = registry.byId("addStore.type");
+                   this.storeType.on("change", function (type)
+                   {
+                       that._storeTypeChanged(type);
+                   });
+               },
+               setupTypeStore: function (management, category, modelObj)
+               {
+                   this.management = management;
+                   this.modelObj = modelObj;
+                   var metadata = management.metadata;
+                   this.category = category;
+                   var storeTypeSupportedTypes = metadata.getTypesForCategory(category);
+                   storeTypeSupportedTypes.sort();
+                   var storeTypeStore = util.makeTypeStore(storeTypeSupportedTypes);
+                   this.storeType.set("store", storeTypeStore);
+               },
+               show: function (effectiveData)
+               {
+                   this.effectiveData = effectiveData;
+                   this._destroyTypeFields(this.storeTypeFieldsContainer);
+                   this._destroyTypeFields(this.storeCategoryFieldsContainer);
+                   this._loadCategoryUI = true;
+                   this.storeForm.reset();
+
+                   if (effectiveData)
+                   {
+                       this._initFields(effectiveData);
+                   }
+                   this.storeName.set("disabled", effectiveData == null ? false : true);
+                   this.storeType.set("disabled", effectiveData == null ? false : true);
+                   if (effectiveData == null)
+                   {
+                       this.dialog.set("title", "Add " + this.category);
+                   }
+                   else
+                   {
+                       this.dialog.set("title", "Edit " + this.category + " - " + effectiveData.name);
+                   }
+                   this.dialog.show();
+               },
+               _initFields: function (data)
+               {
+                   var type = data["type"];
+                   var metadata = this.management.metadata;
+                   var attributes = metadata.getMetaData(this.category, type).attributes;
+                   for (var name in attributes)
+                   {
+                       var widget = registry.byId("addStore." + name);
+                       if (widget)
+                       {
+                           widget.set("value", data[name]);
+                       }
+                   }
+               },
+               _cancel: function (e)
+               {
+                   event.stop(e);
+                   this._destroyTypeFields(this.storeTypeFieldsContainer);
+                   this._destroyTypeFields(this.storeCategoryFieldsContainer);
+                   this.dialog.hide();
+               },
+               _add: function (e)
+               {
+                   event.stop(e);
+                   this._submit();
+               },
+               _submit: function ()
+               {
+                   if (this.storeForm.validate())
+                   {
+                       var that = this;
+
+                       function disableButtons(disabled)
+                       {
+                           that.addButton.set("disabled", disabled);
+                           that.cancelButton.set("disabled", disabled);
+                       }
+
+                       disableButtons(true);
+
+                       var storeData = util.getFormWidgetValues(this.storeForm, this.initialData);
+
+                       if (this.effectiveData)
+                       {
+                           // update request
+                           this.management.update(this.modelObj, storeData).then(function (x)
+                                                                                 {
+                                                                                     disableButtons(false);
+                                                                                     that.dialog.hide();
+                                                                                 }, function (err)
+                                                                                 {
+                                                                                     disableButtons(false);
+                                                                                     that.management.errorHandler(err);
+                                                                                 });
+                       }
+                       else
+                       {
+                           this.management.create(this.category, this.modelObj, storeData).then(function (x)
+                                                                                                {
+                                                                                                    disableButtons(false);
+                                                                                                    that.dialog.hide();
+                                                                                                }, function (err)
+                                                                                                {
+                                                                                                    disableButtons(false);
+                                                                                                    that.management.errorHandler(
+                                                                                                        err);
+                                                                                                });
+                       }
+                   }
+                   else
+                   {
+                       alert('Form contains invalid data. Please correct first');
+                   }
+               },
+               _storeTypeChanged: function (type)
+               {
+                   this._typeChanged(type, this.storeTypeFieldsContainer, "qpid/management/store/", this.category);
+               },
+               _destroyTypeFields: function (typeFieldsContainer)
+               {
+                   var widgets = registry.findWidgets(typeFieldsContainer);
+                   array.forEach(widgets, function (item)
+                   {
+                       item.destroyRecursive();
+                   });
+                   construct.empty(typeFieldsContainer);
+               },
+               _typeChanged: function (type, typeFieldsContainer, baseUrl, category)
+               {
+                   this._destroyTypeFields(typeFieldsContainer);
+                   if (type)
+                   {
+                       this._addCategoryMarkupIfRequired(category, type, this.effectiveData);
+                       var that = this;
+                       require([baseUrl + type.toLowerCase() + "/add"], function (typeUI)
+                       {
+                           try
+                           {
+                               var metadata = that.management.metadata;
+                               typeUI.show({
+                                               containerNode: typeFieldsContainer,
+                                               parent: that,
+                                               data: that.initialData,
+                                               effectiveData: that.effectiveData,
+                                               metadata: metadata
+                                           });
+                               util.applyMetadataToWidgets(typeFieldsContainer, category, type, metadata);
+                           }
+                           catch (e)
+                           {
+                               console.warn(e);
+                           }
+                       });
+                   }
+               },
+               _addCategoryMarkupIfRequired: function (category, type, data)
+               {
+                   if (this._loadCategoryUI)
+                   {
+                       this._loadCategoryUI = false;
+                       var containerNode = this.storeCategoryFieldsContainer;
+                       var metadata = this.management.metadata;
+                       this._destroyTypeFields(this.storeCategoryFieldsContainer);
+
+                       var templateHandler = function (template)
+                       {
+                           containerNode.innerHTML = template;
+                           parser.parse(containerNode).then(function (instances)
+                                                            {
+                                                                if (type)
+                                                                {
+                                                                    util.applyToWidgets(containerNode,
+                                                                                        category,
+                                                                                        type,
+                                                                                        data,
+                                                                                        metadata);
+                                                                }
+                                                            });
+                       };
+
+                       if (this.categoryTemplates[category])
+                       {
+                           templateHandler(new String(this.categoryTemplates[category]));
+                       }
+                       else
+                       {
+                           var that = this;
+                           xhr.get({
+                                       url: "store/" + category.toLowerCase() + ".html",
+                                       load: function (template)
                                        {
-                                         that.categoryTemplates[category]= template;
-                                         templateHandler(new String(template));
+                                           that.categoryTemplates[category] = template;
+                                           templateHandler(new String(template));
                                        }
-                                });
-                    }
-                }
-            }
-        };
-
-        try
-        {
-            addStore.init();
-        }
-        catch(e)
-        {
-            console.warn(e);
-        }
-        return addStore;
-    });
+                                   });
+                       }
+                   }
+               }
+           };
+
+           try
+           {
+               addStore.init();
+           }
+           catch (e)
+           {
+               console.warn(e);
+           }
+           return addStore;
+       });

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostAlias.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostAlias.js?rev=1741609&r1=1741608&r2=1741609&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostAlias.js (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostAlias.js Fri Apr 29 11:04:40 2016
@@ -27,11 +27,11 @@ define(["dojo/_base/lang",
         "dojo/_base/event",
         'dojo/json',
         "dojo/text!addVirtualHostAlias.html",
-/*
-        "dojox/validate/us",
-        "dojox/validate/web",
-        "dojox/layout/TableContainer",
- */
+           /*
+            "dojox/validate/us",
+            "dojox/validate/web",
+            "dojox/layout/TableContainer",
+            */
         "qpid/common/util",
         "dijit/registry",
         "dijit/Dialog",
@@ -43,158 +43,196 @@ define(["dojo/_base/lang",
         "dijit/form/Button",
         "dijit/form/Form",
         "dijit/layout/ContentPane",
-        "dojo/domReady!"],
-    function (lang, dom, construct, parser, memory, array, event, json, template, util, registry)
-    {
-        var addVirtualHostAlias =
-        {
-            init: function()
-            {
-                var that=this;
-                this.category = "VirtualHostAlias";
-                this.containerNode = construct.create("div", {innerHTML: template});
-                parser.parse(this.containerNode).then(function(instances) { that._postParse(); });
-            },
-            _postParse: function()
-            {
-                var that=this;
-                this.name = registry.byId("addVirtualHostAlias.name");
-                this.name.set("regExpGen", util.nameOrContextVarRegexp);
-
-                this.dialog = registry.byId("addVirtualHostAlias");
-                this.addButton = registry.byId("addVirtualHostAlias.addButton");
-                this.cancelButton = registry.byId("addVirtualHostAlias.cancelButton");
-                this.cancelButton.on("click", function(e){that._cancel(e);});
-                this.addButton.on("click", function(e){that._add(e);});
-
-                this.typeFieldsContainer = dom.byId("addVirtualHostAlias.typeFields");
-                this.form = registry.byId("addVirtualHostAlias.form");
-                this.form.on("submit", function(){return false;});
-
-                this.virtualHostAliasType = registry.byId("addVirtualHostAlias.type");
-                this.virtualHostAliasType.on("change", function(type){that._typeChanged(type);});
-
-                this.durable = registry.byId("addVirtualHostAlias.durable");
-                this.priority = registry.byId("addVirtualHostAlias.priority");
-                this.priority.set("regExpGen", util.numericOrContextVarRegexp);
-
-                this.allFieldsContainer = dom.byId("addVirtualHostAlias.contentPane");
-            },
-            show: function(management, modelObj, actualData)
-            {
-                this.management = management;
-                this.modelObj = modelObj;
-                var metadata = management.metadata;
-                this.configured = false;
-                this._destroyTypeFields(this.typeFieldsContainer);
-                this.virtualHostAliasType.set("store", util.makeTypeStoreFromMetadataByCategory(management.metadata, this.category));
-                this.form.reset();
-
-                this.initialData = actualData;
-                this.isNew = !actualData;
-
-                this.name.set("disabled", !this.isNew);
-                this.virtualHostAliasType.set("disabled", !this.isNew);
-                this.durable.set("disabled", !this.isNew);
-                this.dialog.set("title", this.isNew ? "Add Virtual Host Alias" : "Edit Virtual Host Alias - " + actualData.name);
-
-                if (actualData)
-                {
-                    this._configure(actualData.type);
-                }
-
-                this.dialog.show();
-            },
-            _cancel: function(e)
-            {
-                event.stop(e);
-                this._destroyTypeFields(this.typeFieldsContainer);
-                this.dialog.hide();
-            },
-            _add: function(e)
-            {
-                event.stop(e);
-                this._submit();
-            },
-            _submit: function()
-            {
-                if (this.form.validate())
-                {
-                    var that = this;
-                    var formData = util.getFormWidgetValues(this.form, this.initialData);
-
-                    if (this.isNew)
-                    {
-                        this.management.create(this.category, this.modelObj, formData).then(function(x){that.dialog.hide();});
-                    }
-                    else
-                    {
-                        this.management.update(this.modelObj, formData).then(function(x){that.dialog.hide();});
-                    }
-                }
-                else
-                {
-                    alert('Form contains invalid data. Please correct first');
-                }
-            },
-            _destroyTypeFields: function(typeFieldsContainer)
-            {
-                var widgets = registry.findWidgets(typeFieldsContainer);
-                array.forEach(widgets, function(item) { item.destroyRecursive();});
-                construct.empty(typeFieldsContainer);
-            },
-            _typeChanged: function(type)
-            {
-                this._destroyTypeFields(this.typeFieldsContainer);
-
-                if (type)
-                {
-                    this._configure(type);
-                    var that = this;
-                    require(["qpid/management/virtualhostalias/" + type.toLowerCase() + "/add"], function(typeUI)
-                    {
-                        try
-                        {
-                            var metadata = that.management.metadata;
-                            var promise = typeUI.show({containerNode:that.typeFieldsContainer, data: that.initialData, metadata: metadata, category: that.category, type: type});
-                            if (promise)
-                            {
-                                promise.then(
-                                    function(instances)
-                                    {
-                                        util.applyToWidgets(that.typeFieldsContainer, that.category, type, that.initialData, metadata);
-                                        if (!that.isNew)
-                                        {
-                                            util.disableWidgetsForImmutableFields(that.allFieldsContainer, that.category, type, metadata);
-                                        }
-                                    });
-                            }
-                        }
-                        catch(e)
-                        {
-                            console.warn(e);
-                        }
-                    });
-                }
-            },
-            _configure: function(type)
-            {
-                if (!this.configured)
-                {
-                    var metadata = this.management.metadata;
-                    util.applyToWidgets(this.allFieldsContainer, this.category, type, this.initialData, metadata);
-                    this.configured = true;
-                }
-            }
-        };
-
-        try
-        {
-            addVirtualHostAlias.init();
-        }
-        catch(e)
-        {
-            console.warn(e);
-        }
-        return addVirtualHostAlias;
-    });
+        "dojo/domReady!"], function (lang, dom, construct, parser, memory, array, event, json, template, util, registry)
+       {
+           var addVirtualHostAlias = {
+               init: function ()
+               {
+                   var that = this;
+                   this.category = "VirtualHostAlias";
+                   this.containerNode = construct.create("div", {innerHTML: template});
+                   parser.parse(this.containerNode).then(function (instances)
+                                                         {
+                                                             that._postParse();
+                                                         });
+               },
+               _postParse: function ()
+               {
+                   var that = this;
+                   this.name = registry.byId("addVirtualHostAlias.name");
+                   this.name.set("regExpGen", util.nameOrContextVarRegexp);
+
+                   this.dialog = registry.byId("addVirtualHostAlias");
+                   this.addButton = registry.byId("addVirtualHostAlias.addButton");
+                   this.cancelButton = registry.byId("addVirtualHostAlias.cancelButton");
+                   this.cancelButton.on("click", function (e)
+                   {
+                       that._cancel(e);
+                   });
+                   this.addButton.on("click", function (e)
+                   {
+                       that._add(e);
+                   });
+
+                   this.typeFieldsContainer = dom.byId("addVirtualHostAlias.typeFields");
+                   this.form = registry.byId("addVirtualHostAlias.form");
+                   this.form.on("submit", function ()
+                   {
+                       return false;
+                   });
+
+                   this.virtualHostAliasType = registry.byId("addVirtualHostAlias.type");
+                   this.virtualHostAliasType.on("change", function (type)
+                   {
+                       that._typeChanged(type);
+                   });
+
+                   this.durable = registry.byId("addVirtualHostAlias.durable");
+                   this.priority = registry.byId("addVirtualHostAlias.priority");
+                   this.priority.set("regExpGen", util.numericOrContextVarRegexp);
+
+                   this.allFieldsContainer = dom.byId("addVirtualHostAlias.contentPane");
+               },
+               show: function (management, modelObj, actualData)
+               {
+                   this.management = management;
+                   this.modelObj = modelObj;
+                   var metadata = management.metadata;
+                   this.configured = false;
+                   this._destroyTypeFields(this.typeFieldsContainer);
+                   this.virtualHostAliasType.set("store",
+                                                 util.makeTypeStoreFromMetadataByCategory(management.metadata,
+                                                                                          this.category));
+                   this.form.reset();
+
+                   this.initialData = actualData;
+                   this.isNew = !actualData;
+
+                   this.name.set("disabled", !this.isNew);
+                   this.virtualHostAliasType.set("disabled", !this.isNew);
+                   this.durable.set("disabled", !this.isNew);
+                   this.dialog.set("title",
+                                   this.isNew ? "Add Virtual Host Alias" : "Edit Virtual Host Alias - "
+                                                                           + actualData.name);
+
+                   if (actualData)
+                   {
+                       this._configure(actualData.type);
+                   }
+
+                   this.dialog.show();
+               },
+               _cancel: function (e)
+               {
+                   event.stop(e);
+                   this._destroyTypeFields(this.typeFieldsContainer);
+                   this.dialog.hide();
+               },
+               _add: function (e)
+               {
+                   event.stop(e);
+                   this._submit();
+               },
+               _submit: function ()
+               {
+                   if (this.form.validate())
+                   {
+                       var that = this;
+                       var formData = util.getFormWidgetValues(this.form, this.initialData);
+
+                       if (this.isNew)
+                       {
+                           this.management.create(this.category, this.modelObj, formData).then(function (x)
+                                                                                               {
+                                                                                                   that.dialog.hide();
+                                                                                               });
+                       }
+                       else
+                       {
+                           this.management.update(this.modelObj, formData).then(function (x)
+                                                                                {
+                                                                                    that.dialog.hide();
+                                                                                });
+                       }
+                   }
+                   else
+                   {
+                       alert('Form contains invalid data. Please correct first');
+                   }
+               },
+               _destroyTypeFields: function (typeFieldsContainer)
+               {
+                   var widgets = registry.findWidgets(typeFieldsContainer);
+                   array.forEach(widgets, function (item)
+                   {
+                       item.destroyRecursive();
+                   });
+                   construct.empty(typeFieldsContainer);
+               },
+               _typeChanged: function (type)
+               {
+                   this._destroyTypeFields(this.typeFieldsContainer);
+
+                   if (type)
+                   {
+                       this._configure(type);
+                       var that = this;
+                       require(["qpid/management/virtualhostalias/" + type.toLowerCase() + "/add"], function (typeUI)
+                       {
+                           try
+                           {
+                               var metadata = that.management.metadata;
+                               var promise = typeUI.show({
+                                                             containerNode: that.typeFieldsContainer,
+                                                             data: that.initialData,
+                                                             metadata: metadata,
+                                                             category: that.category,
+                                                             type: type
+                                                         });
+                               if (promise)
+                               {
+                                   promise.then(function (instances)
+                                                {
+                                                    util.applyToWidgets(that.typeFieldsContainer,
+                                                                        that.category,
+                                                                        type,
+                                                                        that.initialData,
+                                                                        metadata);
+                                                    if (!that.isNew)
+                                                    {
+                                                        util.disableWidgetsForImmutableFields(that.allFieldsContainer,
+                                                                                              that.category,
+                                                                                              type,
+                                                                                              metadata);
+                                                    }
+                                                });
+                               }
+                           }
+                           catch (e)
+                           {
+                               console.warn(e);
+                           }
+                       });
+                   }
+               },
+               _configure: function (type)
+               {
+                   if (!this.configured)
+                   {
+                       var metadata = this.management.metadata;
+                       util.applyToWidgets(this.allFieldsContainer, this.category, type, this.initialData, metadata);
+                       this.configured = true;
+                   }
+               }
+           };
+
+           try
+           {
+               addVirtualHostAlias.init();
+           }
+           catch (e)
+           {
+               console.warn(e);
+           }
+           return addVirtualHostAlias;
+       });



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