qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kw...@apache.org
Subject svn commit: r1752823 - in /qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid: common/ConsoleHelper.js management/Management.js management/query/QueryBrowserWidget.js management/query/QueryWidget.js
Date Fri, 15 Jul 2016 11:40:38 GMT
Author: kwall
Date: Fri Jul 15 11:40:37 2016
New Revision: 1752823

URL: http://svn.apache.org/viewvc?rev=1752823&view=rev
Log:
QPID-7248: [Java Broker] Query UI - wire up visibilityList to the authenticated user's groups

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/Management.js
    qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/QueryBrowserWidget.js
    qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/QueryWidget.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=1752823&r1=1752822&r2=1752823&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
Fri Jul 15 11:40:37 2016
@@ -162,13 +162,7 @@ define(["dojo/query",
             {
                 if (data.user)
                 {
-                    var userName = entities.encode(String(data.user));
                     var controlButton = registry.byId("authenticatedUserControls");
-                    if (controlButton)
-                    {
-                        controlButton.set("label", userName);
-                        controlButton.domNode.style.display = '';
-                    }
                     registry.byId("login").domNode.style.display = "inline";
                     management.init(function ()
                     {
@@ -178,8 +172,12 @@ define(["dojo/query",
                         dijit.Tooltip.defaultPosition =
                             ["after-centered",
                              "below-centered"];
+                        if (controlButton)
+                        {
+                            controlButton.set("label", management.getAuthenticatedUser().name);
+                            controlButton.domNode.style.display = '';
+                        }
                     });
-                    management.userName = userName; // TODO Temporary - will be repolaced
by whoami
                 }
                 else
                 {

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Management.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Management.js?rev=1752823&r1=1752822&r2=1752823&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Management.js
(original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Management.js
Fri Jul 15 11:40:37 2016
@@ -19,6 +19,7 @@
  *
  */
 define(["dojo/_base/lang",
+        "dojo/promise/all",
         "dojo/_base/array",
         "dojo/request/xhr",
         "dojo/io-query",
@@ -29,7 +30,7 @@ define(["dojo/_base/lang",
         "qpid/common/metadata",
         "qpid/common/timezone",
         "qpid/management/UserPreferences"],
-    function (lang, array, xhr, ioQuery, json, Promise, Deferred, sasl, Metadata, Timezone,
UserPreferences)
+    function (lang, all, array, xhr, ioQuery, json, Promise, Deferred, sasl, Metadata, Timezone,
UserPreferences)
     {
 
         function shallowCopy(source, target, excludes)
@@ -482,15 +483,43 @@ define(["dojo/_base/lang",
         Management.prototype.init = function (callback)
         {
             var that = this;
-            this.loadMetadata(function ()
+            this.getAuthenticatedUserAndGroups(function()
             {
-                that.loadTimezones(function ()
+                that.loadMetadata(function ()
                 {
-                    that.loadUserPreferences(callback);
+                    that.loadTimezones(function ()
+                    {
+                        that.loadUserPreferences(callback);
+                    });
                 });
             });
         };
 
+        Management.prototype.getAuthenticatedUserAndGroups = function (callback)
+        {
+            var baseUrl = this.objectToURL({type : "broker"});
+
+            var userPromise = this.get({url: baseUrl + "/getUser"});
+            var groupsPromise = this.get({url: baseUrl + "/getGroups"});
+
+            var complete = function(result)
+            {
+                if (result)
+                {
+                    this.user = result.user;
+                    this.groups = result.groups;
+                }
+            };
+
+            all({
+                user: userPromise,
+                groups: groupsPromise
+            })
+                .then(lang.hitch(this, complete), lang.hitch(this, this.errorHandler))
+                .then(lang.hitch(callback));
+
+        };
+
         // summary:
         //  Loads meta data and store it under 'metadata' field as object of type qpid.common.metadata
object.
         //  When meta data are loaded successfully a callback function is executed, otherwise
default error handler is invoked
@@ -666,5 +695,15 @@ define(["dojo/_base/lang",
                    + (name ? "/" + encodeURIComponent(encodeURIComponent(name)) : "" );
         };
 
+        Management.prototype.getGroups = function ()
+        {
+            return lang.clone(this.groups);
+        };
+
+        Management.prototype.getAuthenticatedUser = function ()
+        {
+            return this.user;
+        };
+
         return Management;
     });

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/QueryBrowserWidget.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/QueryBrowserWidget.js?rev=1752823&r1=1752822&r2=1752823&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/QueryBrowserWidget.js
(original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/QueryBrowserWidget.js
Fri Jul 15 11:40:37 2016
@@ -292,14 +292,15 @@ define(["dojo/_base/declare",
                 {
                     if (this.filter != "all")
                     {
+                        var authenticatedUser = this.management.getAuthenticatedUser().name;
                         for (var i = preferenceList.length - 1; i >= 0; i--)
                         {
                             var item = preferenceList[i];
-                            if (this.filter == "myQueries" && item.owner != this.management.userName)
+                            if (this.filter == "myQueries" && item.owner != authenticatedUser)
                             {
                                 preferenceList.splice(i, 1);
                             }
-                            else if (this.filter == "sharedWithMe" && item.owner
== this.management.userName)
+                            else if (this.filter == "sharedWithMe" && item.owner
== authenticatedUser)
                             {
                                 preferenceList.splice(i, 1);
                             }

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/QueryWidget.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/QueryWidget.js?rev=1752823&r1=1752822&r2=1752823&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/QueryWidget.js
(original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/query/QueryWidget.js
Fri Jul 15 11:40:37 2016
@@ -93,14 +93,14 @@ define(["dojo/_base/declare",
                     this.queryName.set("value", this.preference.name);
                     this.queryDescription.set("value", this.preference.description);
 
-                    var userGroups = [];  // TODO retrieve groups from server
+                    var userGroups = this.management.getGroups();
                     var selected = this.preference.visibilityList || [];
-                    for (var i = 0; i < selected.length; i++)
+                    for (var i = selected.length - 1; i >= 0; i--)
                     {
                         var present = false;
                         for (var j = 0; j < userGroups.length; j++)
                         {
-                            if (selected[i] === userGroups[j])
+                            if (selected[i] === userGroups[j].name)
                             {
                                 present = true;
                                 break;
@@ -108,13 +108,13 @@ define(["dojo/_base/declare",
                         }
                         if (!present)
                         {
-                            userGroups.push(selected[i]);
+                            selected.splice(i, 1);
                         }
                     }
                     var items = [];
                     for (var j = 0; j < userGroups.length; j++)
                     {
-                        items[j] = {id: userGroups[j], name: userGroups[j]};
+                        items[j] = {id: userGroups[j].name, name: userGroups[j].name};
                     }
                     this.groupChooser.set("data", {items: items, selected: selected});
                     this._onChange();



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


Mime
View raw message