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=1741993&r1=1741992&r2=1741993&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
 Mon May  2 15:57:52 2016
@@ -31,10 +31,10 @@ define(["dojo/dom",
         "dojo/text!addQueue.html",
         "qpid/common/ContextVariablesEditor",
         "dijit/form/NumberSpinner", // required by the form
-           /* dojox/ validate resources */
+    /* dojox/ validate resources */
         "dojox/validate/us",
         "dojox/validate/web",
-           /* basic dijit classes */
+    /* basic dijit classes */
         "dijit/Dialog",
         "dijit/form/CheckBox",
         "dijit/form/Textarea",
@@ -47,129 +47,126 @@ define(["dojo/dom",
         "dijit/form/RadioButton",
         "dijit/form/Form",
         "dijit/form/DateTextBox",
-           /* basic dojox classes */
+    /* 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 addQueue = {};
 
-           var node = construct.create("div", null, win.body(), "last");
+    var node = construct.create("div", null, win.body(), "last");
 
-           var requiredFields = {sorted: "sortKey"};
+    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);
-           };
+    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=1741993&r1=1741992&r2=1741993&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
 Mon May  2 15:57:52 2016
@@ -44,249 +44,248 @@ 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)
-                                       {
-                                           that.categoryTemplates[category] = 
template;
-                                           templateHandler(new 
String(template));
-                                       }
-                                   });
-                       }
-                   }
-               }
-           };
-
-           try
-           {
-               addStore.init();
-           }
-           catch (e)
-           {
-               console.warn(e);
-           }
-           return addStore;
-       });
+    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));
+                            }
+                        });
+                    }
+                }
+            }
+        };
+
+        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=1741993&r1=1741992&r2=1741993&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
 Mon May  2 15:57:52 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",
@@ -44,195 +44,196 @@ define(["dojo/_base/lang",
         "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;
-       });
+{
+    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;
+});

Modified: 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js?rev=1741993&r1=1741992&r2=1741993&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js
 (original)
+++ 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js
 Mon May  2 15:57:52 2016
@@ -46,363 +46,383 @@ define(["dojo/_base/event",
         "dojox/validate/us",
         "dojox/validate/web",
         "dojo/domReady!"],
-       function (event, lang, array, dom, domConstruct, json, parser, Memory, 
win, on, fobject, registry, Dialog, Button, FilteringSelect, properties, util, 
template)
-       {
+    function (event,
+              lang,
+              array,
+              dom,
+              domConstruct,
+              json,
+              parser,
+              Memory,
+              win,
+              on,
+              fobject,
+              registry,
+              Dialog,
+              Button,
+              FilteringSelect,
+              properties,
+              util,
+              template)
+    {
+
+        var addVirtualHostNodeAndVirtualHost = {
+            init: function ()
+            {
+                var that = this;
+                this.containerNode = domConstruct.create("div", {innerHTML: 
template});
+                parser.parse(this.containerNode)
+                    .then(function (instances)
+                    {
+                        that._postParse();
+                    });
+            },
+            _postParse: function ()
+            {
+                var that = this;
+                var virtualHostNodeName = 
registry.byId("addVirtualHostNode.nodeName");
+                virtualHostNodeName.set("regExpGen", 
util.nameOrContextVarRegexp);
+
+                // Readers are HTML5
+                this.reader = window.FileReader ? new FileReader() : undefined;
+
+                this.dialog = 
registry.byId("addVirtualHostNodeAndVirtualHost");
+                this.addButton = 
registry.byId("addVirtualHostNodeAndVirtualHost.addButton");
+                this.cancelButton = 
registry.byId("addVirtualHostNodeAndVirtualHost.cancelButton");
+                this.cancelButton.on("click", function (e)
+                {
+                    that._cancel(e);
+                });
+                this.addButton.on("click", function (e)
+                {
+                    that._add(e);
+                });
+
+                this.virtualHostNodeTypeFieldsContainer = 
dom.byId("addVirtualHostNode.typeFields");
+                this.virtualHostNodeSelectedFileContainer = 
dom.byId("addVirtualHostNode.selectedFile");
+                this.virtualHostNodeSelectedFileStatusContainer = 
dom.byId("addVirtualHostNode.selectedFileStatus");
+                this.virtualHostNodeUploadFields = 
dom.byId("addVirtualHostNode.uploadFields");
+                this.virtualHostNodeFileFields = 
dom.byId("addVirtualHostNode.fileFields");
+
+                this.virtualHostNodeForm = 
registry.byId("addVirtualHostNode.form");
+                this.virtualHostNodeType = 
registry.byId("addVirtualHostNode.type");
+                this.virtualHostNodeFileCheck = 
registry.byId("addVirtualHostNode.upload");
+                this.virtualHostNodeFile = 
registry.byId("addVirtualHostNode.file");
+
+                this.virtualHostNodeType.set("disabled", true);
+
+                this.virtualHostTypeFieldsContainer = 
dom.byId("addVirtualHost.typeFields");
+                this.virtualHostForm = registry.byId("addVirtualHost.form");
+                this.virtualHostType = registry.byId("addVirtualHost.type");
+
+                this.virtualHostType.set("disabled", true);
+
+                this.virtualHostNodeType.set("disabled", false);
+                this.virtualHostNodeType.on("change", function (type)
+                {
+                    that._vhnTypeChanged(type,
+                        that.virtualHostNodeTypeFieldsContainer,
+                        "qpid/management/virtualhostnode/");
+                });
+
+                this.virtualHostType.set("disabled", true);
+                this.virtualHostType.on("change", function (type)
+                {
+                    that._vhTypeChanged(type, 
that.virtualHostTypeFieldsContainer, "qpid/management/virtualhost/");
+                });
+
+                if (this.reader)
+                {
+                    this.reader.onload = function (evt)
+                    {
+                        that._vhnUploadFileComplete(evt);
+                    };
+                    this.reader.onerror = function (ex)
+                    {
+                        console.error("Failed to load JSON file", ex);
+                    };
+                    this.virtualHostNodeFile.on("change", function (selected)
+                    {
+                        that._vhnFileChanged(selected)
+                    });
+                    this.virtualHostNodeFileCheck.on("change", function 
(selected)
+                    {
+                        that._vhnFileFlagChanged(selected)
+                    });
+                }
+                else
+                {
+                    // Fall back for IE8/9 which do not support FileReader
+                    this.virtualHostNodeFileCheck.set("disabled", "disabled");
+                    this.virtualHostNodeFileCheck.set("title", "Requires a 
more recent browser with HTML5 support");
+                }
+
+                this.virtualHostNodeUploadFields.style.display = "none";
+                this.virtualHostNodeFileFields.style.display = "none";
+            },
+            show: function (management)
+            {
+                this.management = management;
+                this.virtualHostNodeForm.reset();
+                this.virtualHostNodeType.set("value", null);
+
+                this.virtualHostForm.reset();
+                this.virtualHostType.set("value", null);
+
+                var supportedVirtualHostNodeTypes = 
management.metadata.getTypesForCategory("VirtualHostNode");
+                supportedVirtualHostNodeTypes.sort();
+
+                var virtualHostNodeTypeStore = 
util.makeTypeStore(supportedVirtualHostNodeTypes);
+                this.virtualHostNodeType.set("store", 
virtualHostNodeTypeStore);
+
+                if (!this.virtualHostNodeContext)
+                {
+                    this.virtualHostNodeContext = new 
qpid.common.ContextVariablesEditor({
+                        name: 'context',
+                        title: 'Context variables'
+                    });
+                    
this.virtualHostNodeContext.placeAt(dom.byId("addVirtualHostNode.context"));
+                    var that = this;
+                    this.virtualHostNodeContext.on("change", function (value)
+                    {
+                        var inherited = 
that.virtualHostContext.inheritedActualValues;
+                        var effective = 
that.virtualHostContext.effectiveValues;
+                        var actuals = that.virtualHostContext.value;
+                        for (var key in value)
+                        {
+                            var val = value[key];
+                            if (!(key in actuals))
+                            {
+                                inherited[key] = val;
+                                if (!(key in effective))
+                                {
+                                    effective[key] = val.indexOf("${") == -1 ? 
val : "";
+                                }
+                            }
+                        }
+                        
that.virtualHostContext.setData(that.virtualHostContext.value, effective, 
inherited);
+                    });
+                }
+                if (!this.virtualHostContext)
+                {
+                    this.virtualHostContext = new 
qpid.common.ContextVariablesEditor({
+                        name: 'context',
+                        title: 'Context variables'
+                    });
+                    
this.virtualHostContext.placeAt(dom.byId("addVirtualHost.context"));
+
+                }
+
+                var that = this;
+                management.load({type: "broker"})
+                    .then(function (effectiveData)
+                    {
+                        util.setContextData(that.virtualHostNodeContext,
+                            management,
+                            {type: "broker"},
+                            {},
+                            effectiveData[0],
+                            function ()
+                            {
+                                that.virtualHostContext.setData({},
+                                    
that.virtualHostNodeContext.effectiveValues,
+                                    
that.virtualHostNodeContext.inheritedActualValues);
+                            });
+                    }, util.xhrErrorHandler);
+
+                this.dialog.show();
+                if (!this.resizeEventRegistered)
+                {
+                    this.resizeEventRegistered = true;
+                    
util.resizeContentAreaAndRepositionDialog(dom.byId("addVirtualHostNodeAndVirtualHost.contentPane"),
+                        this.dialog);
+                }
+            },
+            destroy: function ()
+            {
+                if (this.dialog)
+                {
+                    this.dialog.destroyRecursive();
+                    this.dialog = null;
+                }
+
+                if (this.containerNode)
+                {
+                    domConstruct.destroy(this.containerNode);
+                    this.containerNode = null;
+                }
+            },
+            _vhnTypeChanged: function (type, typeFieldsContainer, urlStem)
+            {
+                var validChildTypes = this.management ? 
this.management.metadata.validChildTypes("VirtualHostNode",
+                    type,
+                    "VirtualHost") : [];
+                validChildTypes.sort();
+
+                var virtualHostTypeStore = util.makeTypeStore(validChildTypes);
+
+                this.virtualHostType.set("store", virtualHostTypeStore);
+                this.virtualHostType.set("disabled", validChildTypes.length <= 
1);
+                if (validChildTypes.length == 1)
+                {
+                    this.virtualHostType.set("value", validChildTypes[0]);
+                }
+                else
+                {
+                    this.virtualHostType.reset();
+                }
+
+                var vhnTypeSelected = !(type == '');
+                this.virtualHostNodeUploadFields.style.display = 
vhnTypeSelected ? "block" : "none";
+
+                if (!vhnTypeSelected)
+                {
+                    this._vhnFileFlagChanged(false);
+                }
+
+                this._typeChanged(type, typeFieldsContainer, urlStem, 
"VirtualHostNode");
+            },
+            _vhTypeChanged: function (type, typeFieldsContainer, urlStem)
+            {
+                this._typeChanged(type, typeFieldsContainer, urlStem, 
"VirtualHost");
+            },
+            _typeChanged: function (type, typeFieldsContainer, urlStem, 
category)
+            {
+                var widgets = registry.findWidgets(typeFieldsContainer);
+                array.forEach(widgets, function (item)
+                {
+                    item.destroyRecursive();
+                });
+                domConstruct.empty(typeFieldsContainer);
+                if (category)
+                {
+                    var context = this["v" + category.substring(1) + 
"Context"];
+                    if (context)
+                    {
+                        context.removeDynamicallyAddedInheritedContext();
+                    }
+                }
+                if (type)
+                {
+                    var that = this;
+                    require([urlStem + type.toLowerCase() + "/add"], function 
(typeUI)
+                    {
+                        try
+                        {
+                            var metadata = that.management.metadata;
+                            typeUI.show({
+                                containerNode: typeFieldsContainer,
+                                parent: that,
+                                metadata: metadata
+                            });
+                            util.applyMetadataToWidgets(typeFieldsContainer, 
category, type, metadata);
+                        }
+                        catch (e)
+                        {
+                            console.warn(e);
+                        }
+                    });
+                }
+            },
+            _vhnFileFlagChanged: function (selected)
+            {
+                this.virtualHostForm.domNode.style.display = selected ? "none" 
: "block";
+                this.virtualHostNodeFileFields.style.display = selected ? 
"block" : "none";
+                this.virtualHostType.set("required", !selected);
+                this.virtualHostNodeFile.reset();
+                this.virtualHostInitialConfiguration = undefined;
+                this.virtualHostNodeSelectedFileContainer.innerHTML = "";
+                this.virtualHostNodeSelectedFileStatusContainer.className = "";
+            },
+            _vhnFileChanged: function (evt)
+            {
+                // We only ever expect a single file
+                var file = 
this.virtualHostNodeFile.domNode.children[0].files[0];
+
+                this.addButton.set("disabled", true);
+                this.virtualHostNodeSelectedFileContainer.innerHTML = 
file.name;
+                this.virtualHostNodeSelectedFileStatusContainer.className = 
"loadingIcon";
+
+                console.log("Beginning to read file " + file.name);
+                this.reader.readAsDataURL(file);
+            },
+            _vhnUploadFileComplete: function (evt)
+            {
+                var reader = evt.target;
+                var result = reader.result;
+                console.log("File read complete, contents " + result);
+                this.virtualHostInitialConfiguration = result;
+                this.addButton.set("disabled", false);
+                this.virtualHostNodeSelectedFileStatusContainer.className = 
"loadedIcon";
+            },
+            _cancel: function (e)
+            {
+                util.abortReaderSafely(this.reader);
+                this.dialog.hide();
+            },
+            _add: function (e)
+            {
+                event.stop(e);
+                this._submit();
+            },
+            _submit: function ()
+            {
+
+                var uploadVHConfig = 
this.virtualHostNodeFileCheck.get("checked");
+                var virtualHostNodeData = undefined;
+
+                if (uploadVHConfig && 
this.virtualHostNodeFile.getFileList().length > 0
+                    && this.virtualHostNodeForm.validate())
+                {
+                    // VH config is being uploaded
+                    virtualHostNodeData = 
util.getFormWidgetValues(this.virtualHostNodeForm);
+                    var virtualHostNodeContext = 
this.virtualHostNodeContext.get("value");
+                    if (virtualHostNodeContext)
+                    {
+                        virtualHostNodeData["context"] = 
virtualHostNodeContext;
+                    }
+
+                    // Add the loaded virtualhost configuration
+                    virtualHostNodeData["virtualHostInitialConfiguration"] = 
this.virtualHostInitialConfiguration;
+                }
+                else if (!uploadVHConfig && 
this.virtualHostNodeForm.validate() && this.virtualHostForm.validate())
+                {
+                    virtualHostNodeData = 
util.getFormWidgetValues(this.virtualHostNodeForm);
+                    var virtualHostNodeContext = 
this.virtualHostNodeContext.get("value");
+                    if (virtualHostNodeContext)
+                    {
+                        virtualHostNodeData["context"] = 
virtualHostNodeContext;
+                    }
+
+                    var virtualHostData = 
util.getFormWidgetValues(this.virtualHostForm);
+                    var virtualHostContext = 
this.virtualHostContext.get("value");
+                    if (virtualHostContext)
+                    {
+                        virtualHostData["context"] = virtualHostContext;
+                    }
+
+                    //Default the VH name to be the same as the VHN name.
+                    virtualHostData["name"] = virtualHostNodeData["name"];
+
+                    virtualHostNodeData["virtualHostInitialConfiguration"] = 
json.stringify(virtualHostData)
+
+                }
+                else
+                {
+                    alert('Form contains invalid data. Please correct first');
+                    return;
+                }
+
+                var that = this;
+                that.management.create("virtualhostnode", {type: "broker"}, 
virtualHostNodeData)
+                    .then(function (x)
+                    {
+                        that.dialog.hide();
+                    });
+            }
+        };
 
-           var addVirtualHostNodeAndVirtualHost = {
-               init: function ()
-               {
-                   var that = this;
-                   this.containerNode = domConstruct.create("div", {innerHTML: 
template});
-                   parser.parse(this.containerNode).then(function (instances)
-                                                         {
-                                                             that._postParse();
-                                                         });
-               },
-               _postParse: function ()
-               {
-                   var that = this;
-                   var virtualHostNodeName = 
registry.byId("addVirtualHostNode.nodeName");
-                   virtualHostNodeName.set("regExpGen", 
util.nameOrContextVarRegexp);
-
-                   // Readers are HTML5
-                   this.reader = window.FileReader ? new FileReader() : 
undefined;
-
-                   this.dialog = 
registry.byId("addVirtualHostNodeAndVirtualHost");
-                   this.addButton = 
registry.byId("addVirtualHostNodeAndVirtualHost.addButton");
-                   this.cancelButton = 
registry.byId("addVirtualHostNodeAndVirtualHost.cancelButton");
-                   this.cancelButton.on("click", function (e)
-                   {
-                       that._cancel(e);
-                   });
-                   this.addButton.on("click", function (e)
-                   {
-                       that._add(e);
-                   });
-
-                   this.virtualHostNodeTypeFieldsContainer = 
dom.byId("addVirtualHostNode.typeFields");
-                   this.virtualHostNodeSelectedFileContainer = 
dom.byId("addVirtualHostNode.selectedFile");
-                   this.virtualHostNodeSelectedFileStatusContainer = 
dom.byId("addVirtualHostNode.selectedFileStatus");
-                   this.virtualHostNodeUploadFields = 
dom.byId("addVirtualHostNode.uploadFields");
-                   this.virtualHostNodeFileFields = 
dom.byId("addVirtualHostNode.fileFields");
-
-                   this.virtualHostNodeForm = 
registry.byId("addVirtualHostNode.form");
-                   this.virtualHostNodeType = 
registry.byId("addVirtualHostNode.type");
-                   this.virtualHostNodeFileCheck = 
registry.byId("addVirtualHostNode.upload");
-                   this.virtualHostNodeFile = 
registry.byId("addVirtualHostNode.file");
-
-                   this.virtualHostNodeType.set("disabled", true);
-
-                   this.virtualHostTypeFieldsContainer = 
dom.byId("addVirtualHost.typeFields");
-                   this.virtualHostForm = registry.byId("addVirtualHost.form");
-                   this.virtualHostType = registry.byId("addVirtualHost.type");
-
-                   this.virtualHostType.set("disabled", true);
-
-                   this.virtualHostNodeType.set("disabled", false);
-                   this.virtualHostNodeType.on("change", function (type)
-                   {
-                       that._vhnTypeChanged(type,
-                                            
that.virtualHostNodeTypeFieldsContainer,
-                                            
"qpid/management/virtualhostnode/");
-                   });
-
-                   this.virtualHostType.set("disabled", true);
-                   this.virtualHostType.on("change", function (type)
-                   {
-                       that._vhTypeChanged(type, 
that.virtualHostTypeFieldsContainer, "qpid/management/virtualhost/");
-                   });
-
-                   if (this.reader)
-                   {
-                       this.reader.onload = function (evt)
-                       {
-                           that._vhnUploadFileComplete(evt);
-                       };
-                       this.reader.onerror = function (ex)
-                       {
-                           console.error("Failed to load JSON file", ex);
-                       };
-                       this.virtualHostNodeFile.on("change", function 
(selected)
-                       {
-                           that._vhnFileChanged(selected)
-                       });
-                       this.virtualHostNodeFileCheck.on("change", function 
(selected)
-                       {
-                           that._vhnFileFlagChanged(selected)
-                       });
-                   }
-                   else
-                   {
-                       // Fall back for IE8/9 which do not support FileReader
-                       this.virtualHostNodeFileCheck.set("disabled", 
"disabled");
-                       this.virtualHostNodeFileCheck.set("title", "Requires a 
more recent browser with HTML5 support");
-                   }
-
-                   this.virtualHostNodeUploadFields.style.display = "none";
-                   this.virtualHostNodeFileFields.style.display = "none";
-               },
-               show: function (management)
-               {
-                   this.management = management;
-                   this.virtualHostNodeForm.reset();
-                   this.virtualHostNodeType.set("value", null);
-
-                   this.virtualHostForm.reset();
-                   this.virtualHostType.set("value", null);
-
-                   var supportedVirtualHostNodeTypes = 
management.metadata.getTypesForCategory("VirtualHostNode");
-                   supportedVirtualHostNodeTypes.sort();
-
-                   var virtualHostNodeTypeStore = 
util.makeTypeStore(supportedVirtualHostNodeTypes);
-                   this.virtualHostNodeType.set("store", 
virtualHostNodeTypeStore);
-
-                   if (!this.virtualHostNodeContext)
-                   {
-                       this.virtualHostNodeContext = new 
qpid.common.ContextVariablesEditor({
-                           name: 'context',
-                           title: 'Context variables'
-                       });
-                       
this.virtualHostNodeContext.placeAt(dom.byId("addVirtualHostNode.context"));
-                       var that = this;
-                       this.virtualHostNodeContext.on("change", function 
(value)
-                       {
-                           var inherited = 
that.virtualHostContext.inheritedActualValues;
-                           var effective = 
that.virtualHostContext.effectiveValues;
-                           var actuals = that.virtualHostContext.value;
-                           for (var key in value)
-                           {
-                               var val = value[key];
-                               if (!(key in actuals))
-                               {
-                                   inherited[key] = val;
-                                   if (!(key in effective))
-                                   {
-                                       effective[key] = val.indexOf("${") == 
-1 ? val : "";
-                                   }
-                               }
-                           }
-                           
that.virtualHostContext.setData(that.virtualHostContext.value, effective, 
inherited);
-                       });
-                   }
-                   if (!this.virtualHostContext)
-                   {
-                       this.virtualHostContext = new 
qpid.common.ContextVariablesEditor({
-                           name: 'context',
-                           title: 'Context variables'
-                       });
-                       
this.virtualHostContext.placeAt(dom.byId("addVirtualHost.context"));
-
-                   }
-
-                   var that = this;
-                   management.load({type: "broker"}).then(function 
(effectiveData)
-                                                          {
-                                                              
util.setContextData(that.virtualHostNodeContext,
-                                                                               
   management,
-                                                                               
   {type: "broker"},
-                                                                               
   {},
-                                                                               
   effectiveData[0],
-                                                                               
   function ()
-                                                                               
   {
-                                                                               
       that.virtualHostContext.setData({},
-                                                                               
                                       
that.virtualHostNodeContext.effectiveValues,
-                                                                               
                                       
that.virtualHostNodeContext.inheritedActualValues);
-                                                                               
   });
-                                                          }, 
util.xhrErrorHandler);
-
-                   this.dialog.show();
-                   if (!this.resizeEventRegistered)
-                   {
-                       this.resizeEventRegistered = true;
-                       
util.resizeContentAreaAndRepositionDialog(dom.byId("addVirtualHostNodeAndVirtualHost.contentPane"),
-                                                                 this.dialog);
-                   }
-               },
-               destroy: function ()
-               {
-                   if (this.dialog)
-                   {
-                       this.dialog.destroyRecursive();
-                       this.dialog = null;
-                   }
-
-                   if (this.containerNode)
-                   {
-                       domConstruct.destroy(this.containerNode);
-                       this.containerNode = null;
-                   }
-               },
-               _vhnTypeChanged: function (type, typeFieldsContainer, urlStem)
-               {
-                   var validChildTypes = this.management ? 
this.management.metadata.validChildTypes("VirtualHostNode",
-                                                                               
                     type,
-                                                                               
                     "VirtualHost") : [];
-                   validChildTypes.sort();
-
-                   var virtualHostTypeStore = 
util.makeTypeStore(validChildTypes);
-
-                   this.virtualHostType.set("store", virtualHostTypeStore);
-                   this.virtualHostType.set("disabled", validChildTypes.length 
<= 1);
-                   if (validChildTypes.length == 1)
-                   {
-                       this.virtualHostType.set("value", validChildTypes[0]);
-                   }
-                   else
-                   {
-                       this.virtualHostType.reset();
-                   }
-
-                   var vhnTypeSelected = !(type == '');
-                   this.virtualHostNodeUploadFields.style.display = 
vhnTypeSelected ? "block" : "none";
-
-                   if (!vhnTypeSelected)
-                   {
-                       this._vhnFileFlagChanged(false);
-                   }
-
-                   this._typeChanged(type, typeFieldsContainer, urlStem, 
"VirtualHostNode");
-               },
-               _vhTypeChanged: function (type, typeFieldsContainer, urlStem)
-               {
-                   this._typeChanged(type, typeFieldsContainer, urlStem, 
"VirtualHost");
-               },
-               _typeChanged: function (type, typeFieldsContainer, urlStem, 
category)
-               {
-                   var widgets = registry.findWidgets(typeFieldsContainer);
-                   array.forEach(widgets, function (item)
-                   {
-                       item.destroyRecursive();
-                   });
-                   domConstruct.empty(typeFieldsContainer);
-                   if (category)
-                   {
-                       var context = this["v" + category.substring(1) + 
"Context"];
-                       if (context)
-                       {
-                           context.removeDynamicallyAddedInheritedContext();
-                       }
-                   }
-                   if (type)
-                   {
-                       var that = this;
-                       require([urlStem + type.toLowerCase() + "/add"], 
function (typeUI)
-                       {
-                           try
-                           {
-                               var metadata = that.management.metadata;
-                               typeUI.show({
-                                               containerNode: 
typeFieldsContainer,
-                                               parent: that,
-                                               metadata: metadata
-                                           });
-                               
util.applyMetadataToWidgets(typeFieldsContainer, category, type, metadata);
-                           }
-                           catch (e)
-                           {
-                               console.warn(e);
-                           }
-                       });
-                   }
-               },
-               _vhnFileFlagChanged: function (selected)
-               {
-                   this.virtualHostForm.domNode.style.display = selected ? 
"none" : "block";
-                   this.virtualHostNodeFileFields.style.display = selected ? 
"block" : "none";
-                   this.virtualHostType.set("required", !selected);
-                   this.virtualHostNodeFile.reset();
-                   this.virtualHostInitialConfiguration = undefined;
-                   this.virtualHostNodeSelectedFileContainer.innerHTML = "";
-                   this.virtualHostNodeSelectedFileStatusContainer.className = 
"";
-               },
-               _vhnFileChanged: function (evt)
-               {
-                   // We only ever expect a single file
-                   var file = 
this.virtualHostNodeFile.domNode.children[0].files[0];
-
-                   this.addButton.set("disabled", true);
-                   this.virtualHostNodeSelectedFileContainer.innerHTML = 
file.name;
-                   this.virtualHostNodeSelectedFileStatusContainer.className = 
"loadingIcon";
-
-                   console.log("Beginning to read file " + file.name);
-                   this.reader.readAsDataURL(file);
-               },
-               _vhnUploadFileComplete: function (evt)
-               {
-                   var reader = evt.target;
-                   var result = reader.result;
-                   console.log("File read complete, contents " + result);
-                   this.virtualHostInitialConfiguration = result;
-                   this.addButton.set("disabled", false);
-                   this.virtualHostNodeSelectedFileStatusContainer.className = 
"loadedIcon";
-               },
-               _cancel: function (e)
-               {
-                   util.abortReaderSafely(this.reader);
-                   this.dialog.hide();
-               },
-               _add: function (e)
-               {
-                   event.stop(e);
-                   this._submit();
-               },
-               _submit: function ()
-               {
-
-                   var uploadVHConfig = 
this.virtualHostNodeFileCheck.get("checked");
-                   var virtualHostNodeData = undefined;
-
-                   if (uploadVHConfig && 
this.virtualHostNodeFile.getFileList().length > 0
-                       && this.virtualHostNodeForm.validate())
-                   {
-                       // VH config is being uploaded
-                       virtualHostNodeData = 
util.getFormWidgetValues(this.virtualHostNodeForm);
-                       var virtualHostNodeContext = 
this.virtualHostNodeContext.get("value");
-                       if (virtualHostNodeContext)
-                       {
-                           virtualHostNodeData["context"] = 
virtualHostNodeContext;
-                       }
-
-                       // Add the loaded virtualhost configuration
-                       virtualHostNodeData["virtualHostInitialConfiguration"] 
= this.virtualHostInitialConfiguration;
-                   }
-                   else if (!uploadVHConfig && 
this.virtualHostNodeForm.validate() && this.virtualHostForm.validate())
-                   {
-                       virtualHostNodeData = 
util.getFormWidgetValues(this.virtualHostNodeForm);
-                       var virtualHostNodeContext = 
this.virtualHostNodeContext.get("value");
-                       if (virtualHostNodeContext)
-                       {
-                           virtualHostNodeData["context"] = 
virtualHostNodeContext;
-                       }
-
-                       var virtualHostData = 
util.getFormWidgetValues(this.virtualHostForm);
-                       var virtualHostContext = 
this.virtualHostContext.get("value");
-                       if (virtualHostContext)
-                       {
-                           virtualHostData["context"] = virtualHostContext;
-                       }
-
-                       //Default the VH name to be the same as the VHN name.
-                       virtualHostData["name"] = virtualHostNodeData["name"];
-
-                       virtualHostNodeData["virtualHostInitialConfiguration"] 
= json.stringify(virtualHostData)
-
-                   }
-                   else
-                   {
-                       alert('Form contains invalid data. Please correct 
first');
-                       return;
-                   }
-
-                   var that = this;
-                   that.management.create("virtualhostnode", {type: "broker"}, 
virtualHostNodeData).then(function (x)
-                                                                               
                          {
-                                                                               
                              that.dialog.hide();
-                                                                               
                          });
-               }
-           };
+        addVirtualHostNodeAndVirtualHost.init();
 
-           addVirtualHostNodeAndVirtualHost.init();
-
-           return addVirtualHostNodeAndVirtualHost;
-       });
+        return addVirtualHostNodeAndVirtualHost;
+    });



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

Reply via email to