qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oru...@apache.org
Subject svn commit: r1776316 - in /qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management: Exchange.js Queue.js addBinding.js
Date Wed, 28 Dec 2016 18:27:13 GMT
Author: orudyy
Date: Wed Dec 28 18:27:12 2016
New Revision: 1776316

URL: http://svn.apache.org/viewvc?rev=1776316&view=rev
Log:
QPID-6028: Fix binding creation/deletion/listing UI in Web Management Console

Modified:
    qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Exchange.js
    qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Queue.js
    qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addBinding.js

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Exchange.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Exchange.js?rev=1776316&r1=1776315&r2=1776316&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Exchange.js
(original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Exchange.js
Wed Dec 28 18:27:12 2016
@@ -22,6 +22,9 @@ define(["dojo/_base/xhr",
         "dojo/parser",
         "dojo/query",
         "dojo/_base/connect",
+        "dojo/json",
+        "dojo/_base/lang",
+        "dojo/promise/all",
         "dijit/registry",
         "qpid/common/properties",
         "qpid/common/updater",
@@ -37,6 +40,9 @@ define(["dojo/_base/xhr",
               parser,
               query,
               connect,
+              json,
+              lang,
+              all,
               registry,
               properties,
               updater,
@@ -129,15 +135,38 @@ define(["dojo/_base/xhr",
 
         Exchange.prototype.deleteBindings = function ()
         {
-            util.deleteSelectedObjects(this.exchangeUpdater.bindingsGrid.grid,
+            var deletePromises = [];
+            var deleteSelectedBindings = lang.hitch(this, function (data)
+            {
+                for (var i = 0; i < data.length; i++)
+                {
+                    var selectedItem = data[i];
+                    var promise = this.management.update({
+                            type: "exchange",
+                            name: "unbind",
+                            parent: this.modelObj
+                        },
+                        {
+                            destination: selectedItem.destination,
+                            bindingKey: selectedItem.bindingKey
+                        });
+                    promise.then(lang.hitch(this, function ()
+                    {
+                        this.exchangeUpdater.bindingsGrid.grid.selection.setSelected(selectedItem,
false);
+                    }));
+                    deletePromises.push(promise);
+                }
+            });
+            util.confirmAndDeleteGridSelection(
+                this.exchangeUpdater.bindingsGrid.grid,
                 "Are you sure you want to delete binding",
-                this.management,
+                deleteSelectedBindings);
+            all(deletePromises)
+                .then(lang.hitch(this, function ()
                 {
-                    type: "binding",
-                    parent: this.modelObj
-                },
-                this.exchangeUpdater);
-        }
+                    this.exchangeUpdater.update();
+                }));
+        };
 
         function ExchangeUpdater(exchangeTab)
         {
@@ -186,16 +215,20 @@ define(["dojo/_base/xhr",
 
             that.bindingsGrid = new UpdatableStore([], findNode("bindings"), [{
                 name: "Queue",
-                field: "queue",
+                field: "destination",
                 width: "40%"
             }, {
                 name: "Binding Key",
-                field: "name",
+                field: "bindingKey",
                 width: "30%"
             }, {
                 name: "Arguments",
-                field: "argumentString",
-                width: "30%"
+                field: "arguments",
+                width: "30%",
+                formatter: function (arguments)
+                {
+                    return arguments ? json.stringify(arguments) : ""
+                }
             }], null, {
                 keepSelection: true,
                 plugins: {
@@ -246,21 +279,11 @@ define(["dojo/_base/xhr",
 
                     util.flattenStatistics(thisObj.exchangeData);
 
-                    var bindings = thisObj.exchangeData["bindings"];
-
-                    if (bindings)
+                    var bindings = thisObj.exchangeData.bindings || [];
+                    for (var i = 0; i < bindings.length; i++)
                     {
-                        for (var i = 0; i < bindings.length; i++)
-                        {
-                            if (bindings[i].arguments)
-                            {
-                                bindings[i].argumentString = dojo.toJson(bindings[i].arguments);
-                            }
-                            else
-                            {
-                                bindings[i].argumentString = "";
-                            }
-                        }
+                        bindings[i].name = bindings[i].bindingKey + "\" for \"" + bindings[i].destination;
+                        bindings[i].id = bindings[i].destination + "/" + bindings[i].bindingKey;
                     }
 
                     var sampleTime = new Date();
@@ -300,7 +323,10 @@ define(["dojo/_base/xhr",
                     thisObj.bytesDrop = bytesDrop;
 
                     // update bindings
-                    thisObj.bindingsGrid.update(thisObj.exchangeData.bindings)
+                    if (thisObj.bindingsGrid.update(bindings))
+                    {
+                        thisObj.bindingsGrid.grid._refresh();
+                    }
 
                 }, function (error)
                 {
@@ -327,7 +353,7 @@ define(["dojo/_base/xhr",
                         that.contentPane.destroyRecursive();
                     }, util.xhrErrorHandler);
             }
-        }
+        };
 
         return Exchange;
     });

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Queue.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Queue.js?rev=1776316&r1=1776315&r2=1776316&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Queue.js
(original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Queue.js
Wed Dec 28 18:27:12 2016
@@ -26,6 +26,7 @@ define(["dojo/_base/declare",
         "dojo/_base/connect",
         "dojo/_base/event",
         "dojo/json",
+        "dojo/promise/all",
         "qpid/common/properties",
         "qpid/common/updater",
         "qpid/common/util",
@@ -51,6 +52,7 @@ define(["dojo/_base/declare",
               connect,
               event,
               json,
+              all,
               properties,
               updater,
               util,
@@ -419,17 +421,17 @@ define(["dojo/_base/declare",
 
             that.queueData = {};
             that.bindingsGrid = new UpdatableStore([], findNode("bindings"), [{
-                name: "Exchange",
-                field: "exchange",
-                width: "40%"
-            }, {
                 name: "Binding Key",
-                field: "name",
-                width: "30%"
+                field: "bindingKey",
+                width: "60%"
             }, {
                 name: "Arguments",
-                field: "argumentString",
-                width: "30%"
+                field: "arguments",
+                width: "40%",
+                formatter: function (arguments)
+                {
+                    return arguments ? json.stringify(arguments) : ""
+                }
             }]);
 
             that.consumersGrid = new UpdatableStore([], findNode("consumers"), [{
@@ -523,14 +525,14 @@ define(["dojo/_base/declare",
 
             var thisObj = this;
 
-            this.management.load(this.modelObj, {
-                    excludeInheritedContext: true,
-                    depth: 1
-                })
+            var queuePromise = this.management.load(this.modelObj, {excludeInheritedContext:
true, depth: 1 });
+            var publishingLinkPromise = this.management.load({type: "queue", name: "getPublishingLinks",
parent: this.modelObj});
+
+            all({queue: queuePromise, publishingLinks: publishingLinkPromise})
                 .then(function (data)
                 {
                     var i, j;
-                    thisObj.queueData = data[0];
+                    thisObj.queueData = data.queue[0];
                     util.flattenStatistics(thisObj.queueData);
                     if (callback)
                     {
@@ -539,12 +541,10 @@ define(["dojo/_base/declare",
                     var bindings = thisObj.queueData["bindings"];
                     var consumers = thisObj.queueData["consumers"];
 
-                    if (bindings)
+                    var bindings = data.publishingLinks || [];
+                    for (i = 0; i < bindings.length; i++)
                     {
-                        for (i = 0; i < bindings.length; i++)
-                        {
-                            bindings[i].argumentString = json.stringify(bindings[i].arguments);
-                        }
+                        bindings[i].id = i;
                     }
                     thisObj.updateHeader();
 
@@ -630,7 +630,7 @@ define(["dojo/_base/declare",
                     thisObj.consumers = consumers;
 
                     // update bindings
-                    thisObj.bindingsGrid.update(thisObj.queueData.bindings);
+                    thisObj.bindingsGrid.update(bindings);
 
                     // update consumers
                     thisObj.consumersGrid.update(thisObj.queueData.consumers)

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addBinding.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addBinding.js?rev=1776316&r1=1776315&r2=1776316&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addBinding.js
(original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addBinding.js
Wed Dec 28 18:27:12 2016
@@ -150,71 +150,11 @@ define(["dojo/_base/connect",
 
         var node = construct.create("div", null, win.body(), "last");
 
-        var convertToBinding = function convertToBinding(formValues)
-        {
-            var newBinding = {};
-
-            newBinding.name = formValues.name;
-            for (var propName in formValues)
-            {
-                if (formValues.hasOwnProperty(propName))
-                {
-                    if (propName === "durable")
-                    {
-                        if (formValues.durable[0] && formValues.durable[0] == "durable")
-                        {
-                            newBinding.durable = true;
-                        }
-                    }
-                    else
-                    {
-                        if (formValues[propName] !== "")
-                        {
-                            newBinding[propName] = formValues[propName];
-                        }
-                    }
-
-                }
-            }
-            if (addBinding.queue)
-            {
-                newBinding.queue = addBinding.queue;
-            }
-            if (addBinding.exchange)
-            {
-                newBinding.exchange = addBinding.exchange;
-            }
-
-            addBinding.bindingArgumentsGrid.store.fetch({
-                onComplete: function (items, request)
-                {
-                    if (items.length)
-                    {
-                        array.forEach(items, function (item)
-                        {
-                            if (item && item.name && item.value)
-                            {
-                                var bindingArguments = newBinding.arguments;
-                                if (!bindingArguments)
-                                {
-                                    bindingArguments = {};
-                                    newBinding.arguments = bindingArguments;
-                                }
-                                bindingArguments[item.name] = item.value;
-                            }
-                        });
-                    }
-                }
-            });
-            return newBinding;
-        };
-
-        var theForm;
         node.innerHTML = template;
         addBinding.dialogNode = dom.byId("addBinding");
         parser.instantiate([addBinding.dialogNode]);
 
-        theForm = registry.byId("formAddBinding");
+        var theForm = registry.byId("formAddBinding");
         array.forEach(theForm.getDescendants(), function (widget)
         {
             if (widget.name === "type")
@@ -360,35 +300,55 @@ define(["dojo/_base/connect",
             event.stop(e);
             if (theForm.validate())
             {
+                var formValues = util.getFormWidgetValues(registry.byId("formAddBinding"));
+                var parameters = {
+                    destination: formValues.queue,
+                    bindingKey: formValues.name,
+                    replaceExistingArguments: false
+                };
+                addBinding.bindingArgumentsGrid.store.fetch({
+                    onComplete: function (items, request)
+                    {
+                        if (items.length)
+                        {
+                            array.forEach(items, function (item)
+                            {
+                                if (item && item.name && item.value)
+                                {
+                                    parameters.arguments = parameters.arguments || {};
+                                    parameters.arguments[item.name] = item.value;
+                                }
+                            });
+                        }
+                    }
+                });
 
-                var newBinding = convertToBinding(util.getFormWidgetValues(registry.byId("formAddBinding")));
-                var that = this;
-                var model = null;
-                if (addBinding.modelObj.type == "exchange")
-                {
-                    model = {
-                        name: newBinding.queue,
-                        type: "queue",
-                        parent: addBinding.modelObj
-                    };
-                }
-                else
+                var exchangeModelObj = addBinding.modelObj;
+                if (exchangeModelObj.type !== "exchange")
                 {
-                    model = {
-                        name: newBinding.queue,
-                        type: "queue",
-                        parent: {
-                            name: newBinding.exchange,
-                            type: "exchange",
-                            parent: addBinding.modelObj.parent
-                        }
+                    exchangeModelObj = {
+                        name: formValues.exchange,
+                        type: "exchange",
+                        parent: exchangeModelObj.parent
                     };
                 }
-                addBinding.management.create("binding", model, newBinding)
+                var operationModelObj = {
+                    name: "bind",
+                    type: "exchange",
+                    parent: exchangeModelObj
+                };
+                addBinding.management.update(operationModelObj, parameters)
                     .then(function (x)
                     {
-                        registry.byId("addBinding")
-                            .hide();
+                        if (x !== 'true' && x !== true)
+                        {
+                            alert("Binding was not created.");
+                        }
+                        else
+                        {
+                            registry.byId("addBinding")
+                                .hide();
+                        }
                     });
                 return false;
             }



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


Mime
View raw message