You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2016/08/22 15:20:59 UTC

svn commit: r1757207 - in /qpid/java/trunk/broker-plugins/management-http/src/main/java/resources: dashboard/ js/qpid/management/dashboard/ js/qpid/management/dashboard/widget/

Author: orudyy
Date: Mon Aug 22 15:20:59 2016
New Revision: 1757207

URL: http://svn.apache.org/viewvc?rev=1757207&view=rev
Log:
QPID-7118: [Java Broker, WMC] Display placeholder for unavailable widgets on dashboard

Added:
    qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/dashboard/widget/unavailable.js
Modified:
    qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/dashboard/QueryWidgetSettings.html
    qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/dashboard/DashboardWidget.js
    qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/dashboard/widget/query.js

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/dashboard/QueryWidgetSettings.html
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/dashboard/QueryWidgetSettings.html?rev=1757207&r1=1757206&r2=1757207&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/dashboard/QueryWidgetSettings.html (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/dashboard/QueryWidgetSettings.html Mon Aug 22 15:20:59 2016
@@ -56,11 +56,11 @@
                    data-dojo-type="dijit/form/Button"
                    type="button"
                    label="Cancel"/>
-            <input id="${id}_saveButton"
-                   data-dojo-attach-point="saveButton"
+            <input id="${id}_applyButton"
+                   data-dojo-attach-point="applyButton"
                    data-dojo-type="dijit/form/Button"
                    type="submit"
-                   label="Save"/>
+                   label="Apply"/>
         </div>
     </form>
-</div>
\ No newline at end of file
+</div>

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/dashboard/DashboardWidget.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/dashboard/DashboardWidget.js?rev=1757207&r1=1757206&r2=1757207&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/dashboard/DashboardWidget.js (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/dashboard/DashboardWidget.js Mon Aug 22 15:20:59 2016
@@ -175,7 +175,7 @@ define(["dojo/_base/declare",
                         lang.hitch(this._saveDashboardDialog, this._saveDashboardDialog.hide));
                     this._saveDashboardDialogContent.on("save", lang.hitch(this, this._onPreferenceSave));
 
-                    this.widgetContainer.subscribe("/dojox/mdnd/drop", lang.hitch(this,"_widgetDropped"));
+                    this.widgetContainer.subscribe("/dojox/mdnd/drop", lang.hitch(this, "_widgetDropped"));
 
                     this.widgetContainer.enableDnd();
 
@@ -190,7 +190,11 @@ define(["dojo/_base/declare",
                 },
                 _onCloneButton: function ()
                 {
-                    var preference = {id : generateRandomUuid(), type: this.preference.type, value: this.preference.value};
+                    var preference = {
+                        id: generateRandomUuid(),
+                        type: this.preference.type,
+                        value: this.preference.value
+                    };
                     this.emit("clone", {preference: preference, parentObject: this.parentObject});
                 },
                 _onDeleteButton: function ()
@@ -235,8 +239,9 @@ define(["dojo/_base/declare",
                 {
                     this._addWidgetDialog.hide();
                     var promise = this._createWidget(event.widget);
-                    promise.then(lang.hitch(this, function(widget)
+                    promise.then(lang.hitch(this, function (widget)
                     {
+                        this._placePortlet(widget.portlet);
                         this._widgetChanged(widget);
                     }));
                 },
@@ -277,33 +282,31 @@ define(["dojo/_base/declare",
                             widget.id = kwargs.id;
                             var portletPromise = widget.createPortlet();
                             portletPromise.then(lang.hitch(this, function (portlet)
-                            {
-                                // Required so we can update the layout in sympathy with drag and drop events.
-                                portlet.widgetId = widget.id;
-                                this.widgetContainer.addChild(portlet);
-                                portlet.startup();
-                                widget.on("close", lang.hitch(this, function ()
                                 {
-                                    this.widgetContainer.removeChild(portlet);
-                                    delete this.preference.value.widgets[widget.id];
-                                    var position = this.preference.value.layout.column.indexOf(widget.id);
-                                    this.preference.value.layout.column.splice(position, 1);
-                                    widget.destroy();
-                                    this._dashboardChanged();
-                                }));
-
-                                widget.on("change", lang.hitch(this, function ()
+                                    // Required so we can update the layout in sympathy with drag and drop events.
+                                    portlet.widgetId = widget.id;
+                                    widget.on("close", lang.hitch(this, function ()
+                                    {
+                                        this.widgetContainer.removeChild(portlet);
+                                        delete this.preference.value.widgets[widget.id];
+                                        var position = this.preference.value.layout.column.indexOf(widget.id);
+                                        this.preference.value.layout.column.splice(position, 1);
+                                        widget.destroy();
+                                        this._dashboardChanged();
+                                    }));
+
+                                    widget.on("change", lang.hitch(this, function ()
+                                    {
+                                        this._widgetChanged(widget);
+                                    }));
+
+                                    deferred.resolve(widget);
+                                }),
+                                lang.hitch(this, function (error)
                                 {
-                                    this._widgetChanged(widget);
+                                    deferred.cancel(error);
+                                    this.management.errorHandler(error);
                                 }));
-
-                                deferred.resolve(widget);
-                            }),
-                            lang.hitch(this, function(error)
-                            {
-                                deferred.cancel(error);
-                                this.management.errorHandler(error);
-                            }));
                         }));
                     return deferred.promise;
                 },
@@ -313,7 +316,7 @@ define(["dojo/_base/declare",
                 },
                 _verifyLayout: function ()
                 {
-                    if (!this.preference.value )
+                    if (!this.preference.value)
                     {
                         this.preference.value = {widgets: {}, layout: {type: "singleColumn", column: []}};
                     }
@@ -330,7 +333,7 @@ define(["dojo/_base/declare",
                         }
                     }
                 },
-                _loadPreferencesAndRestoreWidgets: function()
+                _loadPreferencesAndRestoreWidgets: function ()
                 {
                     if (this.preference.value && this.preference.value.widgets)
                     {
@@ -383,37 +386,56 @@ define(["dojo/_base/declare",
                 },
                 _restoreWidgets: function (preferences)
                 {
-                    for(var i = 0; i < this.preference.value.layout.column.length; i++)
+                    var widgetPromises = [];
+                    for (var i = 0; i < this.preference.value.layout.column.length; i++)
                     {
                         var id = this.preference.value.layout.column[i];
                         var widgetSetting = this.preference.value.widgets[id];
                         if (widgetSetting && widgetSetting.preference && widgetSetting.preference.id)
                         {
+                            var widgetArgs = null;
                             var preference = preferences[widgetSetting.preference.id];
                             if (preference)
                             {
                                 var parentObject = this.structure.findById(preference.associatedObject);
                                 if (parentObject)
                                 {
-                                    this._createWidget({
+                                    widgetArgs = {
                                         preference: preference,
                                         parentObject: parentObject,
                                         settings: widgetSetting,
                                         type: widgetSetting.type,
                                         id: id
-                                    });
-                                }
-                                else
-                                {
-                                    // display special widget
+                                    };
                                 }
                             }
-                            else
+
+                            if (!widgetArgs)
                             {
-                                delete this.preference.value.widgets[id];
+                                widgetArgs = {
+                                    settings: widgetSetting,
+                                    type: "unavailable",
+                                    id: id
+                                };
                             }
+
+                            widgetPromises.push(this._createWidget(widgetArgs));
                         }
                     }
+                    all(widgetPromises)
+                        .then(lang.hitch(this,
+                            function (widgets)
+                            {
+                                for (var i = 0; i < widgets.length; i++)
+                                {
+                                    this._placePortlet(widgets[i].portlet);
+                                }
+                            }), this.management.errorHandler);
+                },
+                _placePortlet: function (portlet)
+                {
+                    this.widgetContainer.addChild(portlet);
+                    portlet.startup();
                 },
                 _widgetChanged: function (widget)
                 {

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/dashboard/widget/query.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/dashboard/widget/query.js?rev=1757207&r1=1757206&r2=1757207&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/dashboard/widget/query.js (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/dashboard/widget/query.js Mon Aug 22 15:20:59 2016
@@ -56,7 +56,7 @@ define(["dojo/_base/declare",
 
                 // template fields
                 cancelButton: null,
-                saveButton: null,
+                applyButton: null,
                 refreshPeriod: null,
                 limit: null,
                 settingsForm: null,
@@ -89,7 +89,7 @@ define(["dojo/_base/declare",
                 },
                 _onChange: function ()
                 {
-                    this.saveButton.set("disabled", !this.settingsForm.validate());
+                    this.applyButton.set("disabled", !this.settingsForm.validate());
                 },
                 _setLimitAttr: function (value)
                 {

Added: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/dashboard/widget/unavailable.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/dashboard/widget/unavailable.js?rev=1757207&view=auto
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/dashboard/widget/unavailable.js (added)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/dashboard/widget/unavailable.js Mon Aug 22 15:20:59 2016
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+define(["dojo/_base/declare",
+        "dojo/_base/lang",
+        "dojo/json",
+        "dojo/Deferred",
+        "dojo/Evented",
+        "dojox/widget/Portlet"],
+    function (declare,
+              lang,
+              json,
+              Deferred,
+              Evented,
+              Portlet)
+    {
+
+        return declare(Evented, {
+            portlet : null,
+
+            constructor: function (kwargs)
+            {
+                this.widgetSettings = kwargs.widgetSettings || {};
+            },
+            createPortlet: function ()
+            {
+                var portlet = new Portlet({
+                    title: "Unvailable",
+                    content: "This widget is currently not available",
+                    open: !this.widgetSettings.hidden,
+                    onClose: lang.hitch(this, function ()
+                    {
+                        if (confirm("Are you sure you want to remove the widget?\nIt might become available at a later point."))
+                        {
+                            this.emit("close");
+                        }
+                    })
+                });
+
+                if (portlet.closeIcon)
+                {
+                    portlet.closeIcon.title = "Remove this query from the dashboard.";
+                }
+
+                if (portlet.arrowNode)
+                {
+                    portlet.arrowNode.title = "Maximise/minimise this widget.";
+                }
+
+                portlet.on("hide", lang.hitch(this, function(){
+                    this.widgetSettings.hidden = true;
+                    this.emit("change");
+                }));
+                portlet.on("show", lang.hitch(this, function(){
+                    this.widgetSettings.hidden = false;
+                    this.emit("change");
+                }));
+
+                this.portlet = portlet;
+                var deferred = new Deferred();
+                deferred.resolve(portlet);
+
+                return deferred.promise;
+            },
+            destroy : function ()
+            {
+                if (this.portlet)
+                {
+                    this.portlet.destroyRecursive();
+                }
+            },
+            getSettings: function ()
+            {
+                return this.widgetSettings;
+            }
+        });
+
+    });



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