Author: kwall
Date: Thu Jul 14 17:51:56 2016
New Revision: 1752717

URL: http://svn.apache.org/viewvc?rev=1752717&view=rev
Log:
QPID-7238: [Java Broker] Web Management Console - share structure data with 
tree view

Modified:
    
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ConsoleHelper.js
    
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/controller.js
    
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js

Modified: 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ConsoleHelper.js
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ConsoleHelper.js?rev=1752717&r1=1752716&r2=1752717&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ConsoleHelper.js
 (original)
+++ 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ConsoleHelper.js
 Thu Jul 14 17:51:56 2016
@@ -148,7 +148,7 @@ define(["dojo/query",
         {
             this.controller.show("queryBrowser", "QueueBrowser");
         },
-        init: function (controller, treeView)
+        init: function (controller, TreeView)
         {
             this.controller = controller;
             this.management = new Management("", util.xhrErrorHandler);
@@ -173,10 +173,8 @@ define(["dojo/query",
                     management.init(function ()
                     {
                         
updater.registerUpdateIntervalListener(management.userPreferences);
-                        controller.init(management, structure);
-                        treeView.create(getContextPath() + 'service/structure',
-                            management,
-                            query('div[qpid-type="treeView"]')[0]);
+                        var treeView = new TreeView(management, 
query('div[qpid-type="treeView"]')[0]);
+                        controller.init(management, structure, treeView);
                         dijit.Tooltip.defaultPosition =
                             ["after-centered",
                              "below-centered"];

Modified: 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/controller.js
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/controller.js?rev=1752717&r1=1752716&r2=1752717&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/controller.js
 (original)
+++ 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/controller.js
 Thu Jul 14 17:51:56 2016
@@ -198,19 +198,26 @@ define(["dojo/dom",
 
         };
 
-        controller.init = function (management, structure)
+        controller.init = function (management, structure, treeView)
         {
             controller.management = management;
             controller.structure = structure;
 
-            updater.add({update : function()
+            var structureUpdate = function()
             {
-                var promise = management.get({url: "service/structure"});
-                promise.then(lang.hitch(this, function (data)
-                {
-                    structure.update(data);
-                }));
-            }});
+              var promise = management.get({url: "service/structure"});
+              return promise.then(lang.hitch(this, function (data)
+              {
+                  structure.update(data);
+                  treeView.update(data);
+              }));
+            };
+
+            var initialUpdate = structureUpdate();
+            initialUpdate.then(lang.hitch(this, function ()
+            {
+                updater.add({update : structureUpdate});
+            }));
         };
 
         controller.update = function(tabObject, name, parent, objectId)

Modified: 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js
URL: 
http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js?rev=1752717&r1=1752716&r2=1752717&view=diff
==============================================================================
--- 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js
 (original)
+++ 
qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/treeView.js
 Thu Jul 14 17:51:56 2016
@@ -18,20 +18,19 @@
  * under the License.
  *
  */
-define(["dojo/query",
-        "dojo/io-query",
+define(["dojo/_base/lang",
+        "dojo/query",
         "dijit/Tree",
         "qpid/common/util",
-        "qpid/common/updater",
         "qpid/management/controller",
         "dojo/ready",
-        "dojo/domReady!"], function (query, ioQuery, Tree, util, updater, 
controller, ready)
+        "dojo/domReady!"], function (lang, query, Tree, util, controller, 
ready)
 {
 
-    function TreeViewModel(queryString, management)
+    function TreeViewModel(management, node)
     {
-        this.query = queryString;
         this.management = management;
+        this.node = node;
 
         this.onChildrenChange = function (parent, children)
         {
@@ -428,64 +427,32 @@ define(["dojo/query",
         }
     };
 
-    TreeViewModel.prototype.update = function (callback)
+    TreeViewModel.prototype.update = function (data)
     {
-        var thisObj = this;
-
-        this.management.get({url: this.query})
-            .then(function (data)
-            {
-                try
-                {
-                    if (thisObj.model)
-                    {
-                        thisObj.updateModel(data);
-                    }
-                    else
-                    {
-                        thisObj.buildModel(data);
-                    }
-
-                    if (callback)
-                    {
-                        callback();
-                    }
-                }
-                catch (e)
-                {
-                    console.error(e);
-                }
-            }, util.xhrErrorHandler);
-
+        if (this.model)
+        {
+            this.updateModel(data);
+        }
+        else
+        {
+            this.buildModel(data);
+            this.startUp();
+        }
     };
 
-    TreeViewModel.create = function (structureUrl, management, node)
+    TreeViewModel.prototype.startUp = function ()
     {
-        var treeModel = new TreeViewModel(structureUrl, management);
-        treeModel.update(function ()
+        var tree = new Tree({model: this}, this.node);
+        tree.on("dblclick", lang.hitch(this, function (object)
         {
-            var tree = new Tree({model: treeModel}, node);
-            tree.on("dblclick", function (object)
-            {
-                if (object && !object._dummyChild)
-                {
-                    treeModel.relocate(object);
-                }
-
-            }, true);
-            tree.startup();
-            updater.add(treeModel);
-            try
-            {
-                onReady();
-            }
-            catch (e)
+            if (object && !object._dummyChild)
             {
-                console.error(e);
+                this.relocate(object);
             }
-        });
 
-        var onReady = function ()
+        }), true);
+        tree.startup();
+        try
         {
             controller.show("broker", "");
 
@@ -499,14 +466,14 @@ define(["dojo/query",
                     {
                         if (tab.objectId)
                         {
-                            modelObject = 
treeModel.fetchItemByIdentity(tab.objectId);
+                            modelObject = 
this.fetchItemByIdentity(tab.objectId);
                             if (modelObject)
                             {
-                                treeModel.relocate(modelObject);
+                                this.relocate(modelObject);
                             }
                             else
                             {
-                                management.userPreferences.removeTab(tab);
+                                this.management.userPreferences.removeTab(tab);
                             }
                         }
                         else
@@ -516,7 +483,11 @@ define(["dojo/query",
                     }
                 }
             }
-        };
+        }
+        catch (e)
+        {
+            console.error(e);
+        }
     };
 
     return TreeViewModel;



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

Reply via email to