qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lqu...@apache.org
Subject svn commit: r1741993 [12/29] - 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...
Date Mon, 02 May 2016 15:57:54 GMT
Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Preferences.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Preferences.js?rev=1741993&r1=1741992&r2=1741993&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Preferences.js (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Preferences.js Mon May  2 15:57:52 2016
@@ -48,279 +48,289 @@ define(["dojo/_base/declare",
         "dojox/validate/us",
         "dojox/validate/web",
         "dojo/domReady!"],
-       function (declare, event, connect, dom, domConstruct, parser, json, Memory, ObjectStore, entities, registry, TimeZoneSelector, markup, util)
-       {
+    function (declare,
+              event,
+              connect,
+              dom,
+              domConstruct,
+              parser,
+              json,
+              Memory,
+              ObjectStore,
+              entities,
+              registry,
+              TimeZoneSelector,
+              markup,
+              util)
+    {
+
+        var preferenceNames = ["timeZone", "updatePeriod"];
+
+        return declare("qpid.management.Preferences", null, {
+
+            preferencesDialog: null,
+
+            constructor: function (management)
+            {
+                var that = this;
+                this.management = management;
+                this.userPreferences = {};
+                this.domNode = domConstruct.create("div", {innerHTML: markup});
+                parser.parse(this.domNode)
+                    .then(function (instances)
+                    {
+                        that._postParse();
+                    });
+            },
+            _postParse: function ()
+            {
+                var that = this;
+                this.preferencesDialog = registry.byId("preferences.preferencesDialog");
+                for (var i = 0; i < preferenceNames.length; i++)
+                {
+                    var name = preferenceNames[i];
+                    this[name] = registry.byId("preferences." + name);
+                    this[name].on("change", function (val)
+                    {
+                        that._toggleSetButtons();
+                    });
+                }
+
+                this.timeZoneSelector = registry.byId("preferences.timeZone");
+                this.timeZoneSelector.set("timezones", this.management.timezone.getAllTimeZones());
+                this.setButton = registry.byId("preferences.setButton");
+                this.setAndCloseButton = registry.byId("preferences.setAndCloseButton");
+                this.setButton.on("click", function (e)
+                {
+                    that._savePreferences(e, false);
+                });
+                this.setAndCloseButton.on("click", function (e)
+                {
+                    that._savePreferences(e, true);
+                });
+                this.theForm = registry.byId("preferences.preferencesForm");
+                this.usersGrid = registry.byId("preferences.users");
+                this.usersGrid.set("structure", [{
+                    name: "User",
+                    field: "name",
+                    width: "50%"
+                }, {
+                    name: "Authentication Provider",
+                    field: "authenticationProvider",
+                    width: "50%"
+                }]);
+                this.deleteButton = registry.byId("preferences.deleteButton");
+                this.deleteAndCloseButton = registry.byId("preferences.deleteAndCloseButton");
+                this.deleteButton.on("click", function (e)
+                {
+                    that._deletePreferences(false);
+                });
+                this.deleteAndCloseButton.on("click", function (e)
+                {
+                    that._deletePreferences(true);
+                });
+
+                var deletePreferencesButtonToggler = function (rowIndex)
+                {
+                    var data = that.usersGrid.selection.getSelected();
+                    that.deleteButton.set("disabled", !data.length);
+                    that.deleteAndCloseButton.set("disabled", !data.length);
+                };
+                connect.connect(this.usersGrid.selection, 'onSelected', deletePreferencesButtonToggler);
+                connect.connect(this.usersGrid.selection, 'onDeselected', deletePreferencesButtonToggler);
+                this.theForm.on("submit", function (e)
+                {
+                    event.stop(e);
+                    return false;
+                });
+
+                this._setValues();
+
+                deletePreferencesButtonToggler();
+                this.preferencesDialog.startup();
+            },
+
+            showDialog: function ()
+            {
+                this._setValues();
+                var that = this;
+                this._loadUserPreferences(function ()
+                {
+                    that.preferencesDialog.show();
+                });
+            },
+
+            destroy: function ()
+            {
+                if (this.preferencesDialog)
+                {
+                    this.preferencesDialog.destroyRecursevly();
+                    this.preferencesDialog = null;
+                }
+            },
+
+            _savePreferences: function (e, hideDialog)
+            {
+                var that = this;
+                event.stop(e);
+                if (this.theForm.validate())
+                {
+                    var preferences = {};
+                    for (var i = 0; i < preferenceNames.length; i++)
+                    {
+                        var name = preferenceNames[i];
+                        var preferenceWidget = this[name];
+                        if (preferenceWidget)
+                        {
+                            preferences[name] = preferenceWidget.hasOwnProperty("checked")
+                                ? preferenceWidget.checked
+                                : preferenceWidget.get("value");
+                        }
+                    }
+
+                    this.management.userPreferences.save(preferences, function (preferences)
+                    {
+                        success = true;
+                        if (hideDialog)
+                        {
+                            that.preferencesDialog.hide();
+                        }
+                        else
+                        {
+                            var reloadUsers = true;
+                            if (that.users)
+                            {
+                                var authenticatedUser = dom.byId("authenticatedUser").innerHTML;
+                                for (var i = 0; i < that.users.length; i++)
+                                {
+                                    if (that.users[i].name == authenticatedUser)
+                                    {
+                                        reloadUsers = false;
+                                        break;
+                                    }
+                                }
+                            }
+                            if (reloadUsers)
+                            {
+                                that._loadUserPreferences();
+                            }
+                        }
+                        that._toggleSetButtons();
+                    });
+                }
+            },
+
+            _deletePreferences: function (hideDialog)
+            {
+                var that = this;
+                var postDelete = function (data)
+                {
+                    that._loadUserPreferences();
+                    var authenticatedUser = dom.byId("authenticatedUser").innerHTML;
+                    for (i = 0; i < data.length; i++)
+                    {
+                        if (data[i].name == authenticatedUser)
+                        {
+                            that.management.userPreferences.resetPreferences();
+                            that._setValues();
+                            break;
+                        }
+                    }
+                    if (hideDialog)
+                    {
+                        that.preferencesDialog.hide();
+                    }
+                };
+
+                util.deleteSelectedRows(this.usersGrid,
+                    "Are you sure you want to delete preferences for user",
+                    this.management,
+                    "service/userpreferences",
+                    null,
+                    "user",
+                    postDelete);
+            },
+
+            _setValues: function ()
+            {
+                for (var i = 0; i < preferenceNames.length; i++)
+                {
+                    var name = preferenceNames[i];
+                    var preferenceWidget = this[name];
+                    if (preferenceWidget)
+                    {
+                        var value = this.management.userPreferences[name]
+                        if (typeof value == "string")
+                        {
+                            value = entities.encode(String(value))
+                        }
+                        if (!value && name == "updatePeriod")
+                        {
+                            // set to default
+                            value = 5;
+                        }
+                        preferenceWidget.set("value", value);
+                        if (preferenceWidget.hasOwnProperty("checked"))
+                        {
+                            preferenceWidget.set("checked", this.management.userPreferences[name] ? true : false);
+                        }
+                    }
+                }
+                this._toggleSetButtons();
+            },
+
+            _loadUserPreferences: function (callback)
+            {
+                var that = this;
+                this.management.get({url: "service/userpreferences"})
+                    .then(function (users)
+                    {
+                        for (var i = 0; i < users.length; i++)
+                        {
+                            users[i].id = encodeURIComponent(users[i].authenticationProvider) + "/"
+                                          + encodeURIComponent(users[i].name);
+                        }
+                        that.users = users;
+                        var usersStore = new Memory({
+                            data: users,
+                            idProperty: "id"
+                        });
+                        var usersDataStore = new ObjectStore({objectStore: usersStore});
+                        if (that.usersGrid.store)
+                        {
+                            that.usersGrid.store.close();
+                        }
+                        that.usersGrid.set("store", usersDataStore);
+                        if (callback)
+                        {
+                            callback();
+                        }
+                        that.usersGrid._refresh();
+                    });
+            },
+
+            _toggleSetButtons: function ()
+            {
+                var changed = false;
+                for (var i = 0; i < preferenceNames.length; i++)
+                {
+                    var name = preferenceNames[i];
+                    var preferenceWidget = this[name];
+                    if (preferenceWidget)
+                    {
+                        var value = preferenceWidget.hasOwnProperty("checked")
+                            ? preferenceWidget.checked
+                            : preferenceWidget.get("value");
+                        if (value != this.management.userPreferences[name])
+                        {
+                            changed = true;
+                            break;
+                        }
+                    }
+                }
+                this.setButton.set("disabled", !changed);
+                this.setAndCloseButton.set("disabled", !changed);
+            }
 
-           var preferenceNames = ["timeZone", "updatePeriod"];
-
-           return declare("qpid.management.Preferences", null, {
-
-               preferencesDialog: null,
-
-               constructor: function (management)
-               {
-                   var that = this;
-                   this.management = management;
-                   this.userPreferences = {};
-                   this.domNode = domConstruct.create("div", {innerHTML: markup});
-                   parser.parse(this.domNode).then(function (instances)
-                                                   {
-                                                       that._postParse();
-                                                   });
-               },
-               _postParse: function ()
-               {
-                   var that = this;
-                   this.preferencesDialog = registry.byId("preferences.preferencesDialog");
-                   for (var i = 0; i < preferenceNames.length; i++)
-                   {
-                       var name = preferenceNames[i];
-                       this[name] = registry.byId("preferences." + name);
-                       this[name].on("change", function (val)
-                       {
-                           that._toggleSetButtons();
-                       });
-                   }
-
-                   this.timeZoneSelector = registry.byId("preferences.timeZone");
-                   this.timeZoneSelector.set("timezones", this.management.timezone.getAllTimeZones());
-                   this.setButton = registry.byId("preferences.setButton");
-                   this.setAndCloseButton = registry.byId("preferences.setAndCloseButton");
-                   this.setButton.on("click", function (e)
-                   {
-                       that._savePreferences(e, false);
-                   });
-                   this.setAndCloseButton.on("click", function (e)
-                   {
-                       that._savePreferences(e, true);
-                   });
-                   this.theForm = registry.byId("preferences.preferencesForm");
-                   this.usersGrid = registry.byId("preferences.users");
-                   this.usersGrid.set("structure",
-                                      [{
-                                          name: "User",
-                                          field: "name",
-                                          width: "50%"
-                                      },
-                                          {
-                                              name: "Authentication Provider",
-                                              field: "authenticationProvider",
-                                              width: "50%"
-                                          }]);
-                   this.deleteButton = registry.byId("preferences.deleteButton");
-                   this.deleteAndCloseButton = registry.byId("preferences.deleteAndCloseButton");
-                   this.deleteButton.on("click", function (e)
-                   {
-                       that._deletePreferences(false);
-                   });
-                   this.deleteAndCloseButton.on("click", function (e)
-                   {
-                       that._deletePreferences(true);
-                   });
-
-                   var deletePreferencesButtonToggler = function (rowIndex)
-                   {
-                       var data = that.usersGrid.selection.getSelected();
-                       that.deleteButton.set("disabled", !data.length);
-                       that.deleteAndCloseButton.set("disabled", !data.length);
-                   };
-                   connect.connect(this.usersGrid.selection, 'onSelected', deletePreferencesButtonToggler);
-                   connect.connect(this.usersGrid.selection, 'onDeselected', deletePreferencesButtonToggler);
-                   this.theForm.on("submit", function (e)
-                   {
-                       event.stop(e);
-                       return false;
-                   });
-
-                   this._setValues();
-
-                   deletePreferencesButtonToggler();
-                   this.preferencesDialog.startup();
-               },
-
-               showDialog: function ()
-               {
-                   this._setValues();
-                   var that = this;
-                   this._loadUserPreferences(function ()
-                                             {
-                                                 that.preferencesDialog.show();
-                                             });
-               },
-
-               destroy: function ()
-               {
-                   if (this.preferencesDialog)
-                   {
-                       this.preferencesDialog.destroyRecursevly();
-                       this.preferencesDialog = null;
-                   }
-               },
-
-               _savePreferences: function (e, hideDialog)
-               {
-                   var that = this;
-                   event.stop(e);
-                   if (this.theForm.validate())
-                   {
-                       var preferences = {};
-                       for (var i = 0; i < preferenceNames.length; i++)
-                       {
-                           var name = preferenceNames[i];
-                           var preferenceWidget = this[name];
-                           if (preferenceWidget)
-                           {
-                               preferences[name] = preferenceWidget.hasOwnProperty("checked")
-                                   ? preferenceWidget.checked
-                                   : preferenceWidget.get("value");
-                           }
-                       }
-
-                       this.management.userPreferences.save(preferences, function (preferences)
-                       {
-                           success = true;
-                           if (hideDialog)
-                           {
-                               that.preferencesDialog.hide();
-                           }
-                           else
-                           {
-                               var reloadUsers = true;
-                               if (that.users)
-                               {
-                                   var authenticatedUser = dom.byId("authenticatedUser").innerHTML;
-                                   for (var i = 0; i < that.users.length; i++)
-                                   {
-                                       if (that.users[i].name == authenticatedUser)
-                                       {
-                                           reloadUsers = false;
-                                           break;
-                                       }
-                                   }
-                               }
-                               if (reloadUsers)
-                               {
-                                   that._loadUserPreferences();
-                               }
-                           }
-                           that._toggleSetButtons();
-                       });
-                   }
-               },
-
-               _deletePreferences: function (hideDialog)
-               {
-                   var that = this;
-                   var postDelete = function (data)
-                   {
-                       that._loadUserPreferences();
-                       var authenticatedUser = dom.byId("authenticatedUser").innerHTML;
-                       for (i = 0; i < data.length; i++)
-                       {
-                           if (data[i].name == authenticatedUser)
-                           {
-                               that.management.userPreferences.resetPreferences();
-                               that._setValues();
-                               break;
-                           }
-                       }
-                       if (hideDialog)
-                       {
-                           that.preferencesDialog.hide();
-                       }
-                   };
-
-                   util.deleteSelectedRows(this.usersGrid,
-                                           "Are you sure you want to delete preferences for user",
-                                           this.management,
-                                           "service/userpreferences",
-                                           null,
-                                           "user",
-                                           postDelete);
-               },
-
-               _setValues: function ()
-               {
-                   for (var i = 0; i < preferenceNames.length; i++)
-                   {
-                       var name = preferenceNames[i];
-                       var preferenceWidget = this[name];
-                       if (preferenceWidget)
-                       {
-                           var value = this.management.userPreferences[name]
-                           if (typeof value == "string")
-                           {
-                               value = entities.encode(String(value))
-                           }
-                           if (!value && name == "updatePeriod")
-                           {
-                               // set to default
-                               value = 5;
-                           }
-                           preferenceWidget.set("value", value);
-                           if (preferenceWidget.hasOwnProperty("checked"))
-                           {
-                               preferenceWidget.set("checked", this.management.userPreferences[name] ? true : false);
-                           }
-                       }
-                   }
-                   this._toggleSetButtons();
-               },
-
-               _loadUserPreferences: function (callback)
-               {
-                   var that = this;
-                   this.management.get({url: "service/userpreferences"}).then(function (users)
-                                                                              {
-                                                                                  for (var i = 0; i < users.length; i++)
-                                                                                  {
-                                                                                      users[i].id =
-                                                                                          encodeURIComponent(users[i].authenticationProvider)
-                                                                                          + "/" + encodeURIComponent(
-                                                                                              users[i].name);
-                                                                                  }
-                                                                                  that.users = users;
-                                                                                  var usersStore = new Memory({
-                                                                                      data: users,
-                                                                                      idProperty: "id"
-                                                                                  });
-                                                                                  var usersDataStore = new ObjectStore({objectStore: usersStore});
-                                                                                  if (that.usersGrid.store)
-                                                                                  {
-                                                                                      that.usersGrid.store.close();
-                                                                                  }
-                                                                                  that.usersGrid.set("store",
-                                                                                                     usersDataStore);
-                                                                                  if (callback)
-                                                                                  {
-                                                                                      callback();
-                                                                                  }
-                                                                                  that.usersGrid._refresh();
-                                                                              });
-               },
-
-               _toggleSetButtons: function ()
-               {
-                   var changed = false;
-                   for (var i = 0; i < preferenceNames.length; i++)
-                   {
-                       var name = preferenceNames[i];
-                       var preferenceWidget = this[name];
-                       if (preferenceWidget)
-                       {
-                           var value = preferenceWidget.hasOwnProperty("checked")
-                               ? preferenceWidget.checked
-                               : preferenceWidget.get("value");
-                           if (value != this.management.userPreferences[name])
-                           {
-                               changed = true;
-                               break;
-                           }
-                       }
-                   }
-                   this.setButton.set("disabled", !changed);
-                   this.setAndCloseButton.set("disabled", !changed);
-               }
-
-           });
-       });
+        });
+    });

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProvider.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProvider.js?rev=1741993&r1=1741992&r2=1741993&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProvider.js (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProvider.js Mon May  2 15:57:52 2016
@@ -32,188 +32,199 @@ define(["dojo/parser",
         "qpid/management/addPreferencesProvider",
         "dojo/text!showPreferencesProvider.html",
         "dojo/domReady!"],
-       function (parser, query, construct, array, properties, updater, util, event, registry, domStyle, entities, addPreferencesProvider, template)
-       {
+    function (parser,
+              query,
+              construct,
+              array,
+              properties,
+              updater,
+              util,
+              event,
+              registry,
+              domStyle,
+              entities,
+              addPreferencesProvider,
+              template)
+    {
+
+        function PreferencesProvider(name, parent, controller)
+        {
+            this.name = name;
+            this.controller = controller;
+            this.management = management;
+            this.modelObj = {
+                type: "preferencesprovider",
+                name: name,
+                parent: parent
+            };
+            this.authenticationProviderName = parent.name;
+        }
+
+        PreferencesProvider.prototype.getTitle = function ()
+        {
+            return "PreferencesProvider:" + this.authenticationProviderName + "/" + this.name;
+        };
+
+        PreferencesProvider.prototype.init = function (node, parentObject)
+        {
+            var that = this;
+            node.innerHTML = template;
+            parser.parse(node)
+                .then(function (instances)
+                {
+                    that.containerNode = node;
+                    that.parentObject = parentObject;
+                    that.preferencesProviderType = query(".preferencesProviderType", node)[0];
+                    that.preferencesProviderState = query(".preferencesProviderState", node)[0];
+                    that.editPreferencesProviderButton = query(".editPreferencesProviderButton", node)[0];
+                    that.deletePreferencesProviderButton = query(".deletePreferencesProviderButton", node)[0];
+                    that.preferencesProviderAttributes = query(".preferencesProviderAttributes", node)[0];
+                    that.preferencesDetailsDiv = query(".preferencesDetails", node)[0];
+                    var editPreferencesProviderWidget = registry.byNode(that.editPreferencesProviderButton);
+                    editPreferencesProviderWidget.on("click", function (evt)
+                    {
+                        event.stop(evt);
+                        that.editPreferencesProvider();
+                    });
+                    var deletePreferencesProviderWidget = registry.byNode(that.deletePreferencesProviderButton);
+                    deletePreferencesProviderWidget.on("click", function (evt)
+                    {
+                        event.stop(evt);
+                        that.deletePreferencesProvider();
+                    });
+                });
+        };
+
+        PreferencesProvider.prototype.open = function (contentPane)
+        {
+            this.contentPane = contentPane;
+            this.init(contentPane.containerNode);
+            this.reload();
+            this.updater = new PreferencesProviderUpdater(this);
+            updater.add(this.updater);
+        };
+
+        PreferencesProvider.prototype.close = function ()
+        {
+            if (this.updater)
+            {
+                updater.remove(this.updater);
+            }
+        };
+
+        PreferencesProvider.prototype.deletePreferencesProvider = function ()
+        {
+            if (this.preferencesProviderData)
+            {
+                var preferencesProviderData = this.preferencesProviderData;
+                if (confirm("Are you sure you want to delete preferences provider '" + preferencesProviderData.name
+                            + "'?"))
+                {
+                    var that = this;
+                    this.management.remove(this.modelObj)
+                        .then(function (data)
+                        {
+                            that.update(null);
+
+                            // if opened in tab
+                            if (that.contentPane)
+                            {
+                                that.close();
+                                that.contentPane.onClose()
+                                that.controller.tabContainer.removeChild(that.contentPane);
+                                that.contentPane.destroyRecursive();
+                            }
+                            else
+                            {
+                                var widgets = registry.findWidgets(that.containerNode);
+                                array.forEach(widgets, function (item)
+                                {
+                                    item.destroyRecursive();
+                                });
+                                construct.empty(that.containerNode);
+                                if (that.parentObject)
+                                {
+                                    that.parentObject.onPreferencesProviderDeleted();
+                                }
+                            }
+                        }, util.xhrErrorHandler);
+                }
+            }
+        };
+
+        PreferencesProvider.prototype.editPreferencesProvider = function ()
+        {
+            if (this.preferencesProviderData)
+            {
+                addPreferencesProvider.show(this.management, this.modelObj);
+            }
+        };
+
+        PreferencesProvider.prototype.update = function (data)
+        {
+            this.preferencesProviderData = data;
+            if (data)
+            {
+                this.name = data.name;
+                this.preferencesProviderAttributes.style.display = 'block';
+                this.editPreferencesProviderButton.style.display = 'inline';
+                this.deletePreferencesProviderButton.style.display = 'inline';
+                this.preferencesProviderType.innerHTML = entities.encode(String(data.type));
+                this.preferencesProviderState.innerHTML = entities.encode(String(data.state));
+                if (!this.details)
+                {
+                    var that = this;
+                    require(["qpid/management/preferencesprovider/" + data.type.toLowerCase() + "/show"],
+                        function (PreferencesProviderDetails)
+                        {
+                            that.details = new PreferencesProviderDetails(that.preferencesDetailsDiv);
+                            that.details.update(data);
+                        });
+                }
+                else
+                {
+                    this.details.update(data);
+                }
+            }
+            else
+            {
+                this.editPreferencesProviderButton.style.display = 'none';
+                this.deletePreferencesProviderButton.style.display = 'none';
+                this.preferencesProviderAttributes.style.display = 'none';
+                this.details = null;
+            }
+        };
+
+        PreferencesProvider.prototype.reload = function ()
+        {
+            var that = this;
+            that.management.load(that.modelObj)
+                .then(function (data)
+                {
+                    var preferencesProviderData = data[0];
+                    util.flattenStatistics(preferencesProviderData);
+                    that.update(preferencesProviderData);
+                }, function (error)
+                {
+                    util.tabErrorHandler(error, {
+                        updater: that.updater,
+                        contentPane: that.contentPane,
+                        tabContainer: that.controller.tabContainer,
+                        name: that.modelObj.name,
+                        category: "Preferences Provider"
+                    });
+                });
+        };
+
+        function PreferencesProviderUpdater(preferencesProvider)
+        {
+            this.preferencesProvider = preferencesProvider;
+        };
+
+        PreferencesProviderUpdater.prototype.update = function ()
+        {
+            this.preferencesProvider.reload();
+        };
 
-           function PreferencesProvider(name, parent, controller)
-           {
-               this.name = name;
-               this.controller = controller;
-               this.management = management;
-               this.modelObj = {
-                   type: "preferencesprovider",
-                   name: name,
-                   parent: parent
-               };
-               this.authenticationProviderName = parent.name;
-           }
-
-           PreferencesProvider.prototype.getTitle = function ()
-           {
-               return "PreferencesProvider:" + this.authenticationProviderName + "/" + this.name;
-           };
-
-           PreferencesProvider.prototype.init = function (node, parentObject)
-           {
-               var that = this;
-               node.innerHTML = template;
-               parser.parse(node).then(function (instances)
-                                       {
-                                           that.containerNode = node;
-                                           that.parentObject = parentObject;
-                                           that.preferencesProviderType = query(".preferencesProviderType", node)[0];
-                                           that.preferencesProviderState = query(".preferencesProviderState", node)[0];
-                                           that.editPreferencesProviderButton =
-                                               query(".editPreferencesProviderButton", node)[0];
-                                           that.deletePreferencesProviderButton =
-                                               query(".deletePreferencesProviderButton", node)[0];
-                                           that.preferencesProviderAttributes =
-                                               query(".preferencesProviderAttributes", node)[0];
-                                           that.preferencesDetailsDiv = query(".preferencesDetails", node)[0];
-                                           var editPreferencesProviderWidget = registry.byNode(that.editPreferencesProviderButton);
-                                           editPreferencesProviderWidget.on("click", function (evt)
-                                           {
-                                               event.stop(evt);
-                                               that.editPreferencesProvider();
-                                           });
-                                           var deletePreferencesProviderWidget = registry.byNode(that.deletePreferencesProviderButton);
-                                           deletePreferencesProviderWidget.on("click", function (evt)
-                                           {
-                                               event.stop(evt);
-                                               that.deletePreferencesProvider();
-                                           });
-                                       });
-           };
-
-           PreferencesProvider.prototype.open = function (contentPane)
-           {
-               this.contentPane = contentPane;
-               this.init(contentPane.containerNode);
-               this.reload();
-               this.updater = new PreferencesProviderUpdater(this);
-               updater.add(this.updater);
-           };
-
-           PreferencesProvider.prototype.close = function ()
-           {
-               if (this.updater)
-               {
-                   updater.remove(this.updater);
-               }
-           };
-
-           PreferencesProvider.prototype.deletePreferencesProvider = function ()
-           {
-               if (this.preferencesProviderData)
-               {
-                   var preferencesProviderData = this.preferencesProviderData;
-                   if (confirm("Are you sure you want to delete preferences provider '" + preferencesProviderData.name
-                               + "'?"))
-                   {
-                       var that = this;
-                       this.management.remove(this.modelObj).then(function (data)
-                                                                  {
-                                                                      that.update(null);
-
-                                                                      // if opened in tab
-                                                                      if (that.contentPane)
-                                                                      {
-                                                                          that.close();
-                                                                          that.contentPane.onClose()
-                                                                          that.controller.tabContainer.removeChild(that.contentPane);
-                                                                          that.contentPane.destroyRecursive();
-                                                                      }
-                                                                      else
-                                                                      {
-                                                                          var widgets = registry.findWidgets(that.containerNode);
-                                                                          array.forEach(widgets, function (item)
-                                                                          {
-                                                                              item.destroyRecursive();
-                                                                          });
-                                                                          construct.empty(that.containerNode);
-                                                                          if (that.parentObject)
-                                                                          {
-                                                                              that.parentObject.onPreferencesProviderDeleted();
-                                                                          }
-                                                                      }
-                                                                  }, util.xhrErrorHandler);
-                   }
-               }
-           };
-
-           PreferencesProvider.prototype.editPreferencesProvider = function ()
-           {
-               if (this.preferencesProviderData)
-               {
-                   addPreferencesProvider.show(this.management, this.modelObj);
-               }
-           };
-
-           PreferencesProvider.prototype.update = function (data)
-           {
-               this.preferencesProviderData = data;
-               if (data)
-               {
-                   this.name = data.name;
-                   this.preferencesProviderAttributes.style.display = 'block';
-                   this.editPreferencesProviderButton.style.display = 'inline';
-                   this.deletePreferencesProviderButton.style.display = 'inline';
-                   this.preferencesProviderType.innerHTML = entities.encode(String(data.type));
-                   this.preferencesProviderState.innerHTML = entities.encode(String(data.state));
-                   if (!this.details)
-                   {
-                       var that = this;
-                       require(["qpid/management/preferencesprovider/" + data.type.toLowerCase() + "/show"],
-                               function (PreferencesProviderDetails)
-                               {
-                                   that.details = new PreferencesProviderDetails(that.preferencesDetailsDiv);
-                                   that.details.update(data);
-                               });
-                   }
-                   else
-                   {
-                       this.details.update(data);
-                   }
-               }
-               else
-               {
-                   this.editPreferencesProviderButton.style.display = 'none';
-                   this.deletePreferencesProviderButton.style.display = 'none';
-                   this.preferencesProviderAttributes.style.display = 'none';
-                   this.details = null;
-               }
-           };
-
-           PreferencesProvider.prototype.reload = function ()
-           {
-               var that = this;
-               that.management.load(that.modelObj)
-                   .then(function (data)
-                         {
-                             var preferencesProviderData = data[0];
-                             util.flattenStatistics(preferencesProviderData);
-                             that.update(preferencesProviderData);
-                         }, function (error)
-                         {
-                             util.tabErrorHandler(error, {
-                                 updater: that.updater,
-                                 contentPane: that.contentPane,
-                                 tabContainer: that.controller.tabContainer,
-                                 name: that.modelObj.name,
-                                 category: "Preferences Provider"
-                             });
-                         });
-           };
-
-           function PreferencesProviderUpdater(preferencesProvider)
-           {
-               this.preferencesProvider = preferencesProvider;
-           };
-
-           PreferencesProviderUpdater.prototype.update = function ()
-           {
-               this.preferencesProvider.reload();
-           };
-
-           return PreferencesProvider;
-       });
+        return PreferencesProvider;
+    });

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/QueryTab.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/QueryTab.js?rev=1741993&r1=1741992&r2=1741993&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/QueryTab.js (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/QueryTab.js Mon May  2 15:57:52 2016
@@ -29,60 +29,59 @@ define(["dojo/parser",
         "qpid/management/query/QueryBuilder",
         "dojo/dom-construct",
         "dojo/domReady!"],
-       function (parser, query, registry, entities, properties, util, formatter, template, QueryBuilder, domConstruct)
-       {
+    function (parser, query, registry, entities, properties, util, formatter, template, QueryBuilder, domConstruct)
+    {
 
-           function QueryTab(name, parent, controller)
-           {
-               this.name = name;
-               this.controller = controller;
-               this.management = controller.management;
-               this.parent = parent;
-           }
-
-           QueryTab.prototype.getTitle = function ()
-           {
-               return "Query";
-           };
-
-           QueryTab.prototype.open = function (contentPane)
-           {
-               var that = this;
-               this.contentPane = contentPane;
-               contentPane.containerNode.innerHTML = template;
-               parser.parse(contentPane.containerNode).then(function (instances)
-                                                            {
-                                                                that.onOpen(contentPane.containerNode)
-                                                            }, function (e)
-                                                            {
-                                                                console.error(
-                                                                    "Unexpected error on parsing query tab template",
-                                                                    e);
-                                                            });
-           };
-
-           QueryTab.prototype.onOpen = function (containerNode)
-           {
-               this.queryEditorNode = query(".queryEditorNode", containerNode)[0];
-               this.queryBuilder = new QueryBuilder({
-                   management: this.management,
-                   parentModelObj: this.parent,
-                   controller: this.controller
-               }, this.queryEditorNode);
-           };
-
-           QueryTab.prototype.close = function ()
-           {
-
-           };
-
-           QueryTab.prototype.destroy = function ()
-           {
-               this.close();
-               this.contentPane.onClose();
-               this.controller.tabContainer.removeChild(this.contentPane);
-               this.contentPane.destroyRecursive();
-           };
+        function QueryTab(name, parent, controller)
+        {
+            this.name = name;
+            this.controller = controller;
+            this.management = controller.management;
+            this.parent = parent;
+        }
+
+        QueryTab.prototype.getTitle = function ()
+        {
+            return "Query";
+        };
+
+        QueryTab.prototype.open = function (contentPane)
+        {
+            var that = this;
+            this.contentPane = contentPane;
+            contentPane.containerNode.innerHTML = template;
+            parser.parse(contentPane.containerNode)
+                .then(function (instances)
+                {
+                    that.onOpen(contentPane.containerNode)
+                }, function (e)
+                {
+                    console.error("Unexpected error on parsing query tab template", e);
+                });
+        };
+
+        QueryTab.prototype.onOpen = function (containerNode)
+        {
+            this.queryEditorNode = query(".queryEditorNode", containerNode)[0];
+            this.queryBuilder = new QueryBuilder({
+                management: this.management,
+                parentModelObj: this.parent,
+                controller: this.controller
+            }, this.queryEditorNode);
+        };
+
+        QueryTab.prototype.close = function ()
+        {
+
+        };
+
+        QueryTab.prototype.destroy = function ()
+        {
+            this.close();
+            this.contentPane.onClose();
+            this.controller.tabContainer.removeChild(this.contentPane);
+            this.contentPane.destroyRecursive();
+        };
 
-           return QueryTab;
-       });
+        return QueryTab;
+    });



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


Mime
View raw message