Jelajahi Sumber

Merge pull request #6917 from GordonSmith/HPCC-12951

HPCC-12951 Refresh WU Lists on Tab Selection

Reviewed-By: Miguel Vazquez <miguel.vazquez@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 10 tahun lalu
induk
melakukan
3e19413414

+ 5 - 0
esp/src/eclwatch/ActivityWidget.js

@@ -193,6 +193,11 @@ define([
             });
 
             this._refreshActionState();
+            ESPUtil.MonitorVisibility(this.gridTab, function (visibility) {
+                if (visibility) {
+                    context.refreshGrid();
+                }
+            });
         },
 
         createGrid: function (domID) {

+ 50 - 1
esp/src/eclwatch/ESPUtil.js

@@ -19,9 +19,11 @@ define([
     "dojo/i18n",
     "dojo/i18n!./nls/hpcc",
     "dojo/_base/array",
+    "dojo/dom-class",
     "dojo/Stateful",
     "dojo/query",
     "dojo/json",
+    "dojo/aspect",
 
     "dijit/registry",
     "dijit/Tooltip",
@@ -35,7 +37,7 @@ define([
     "dgrid/extensions/ColumnReorder",
     "dgrid/extensions/DijitRegistry",
     "dgrid/extensions/Pagination"
-], function (declare, lang, i18n, nlsHPCC, arrayUtil, Stateful, query, json,
+], function (declare, lang, i18n, nlsHPCC, arrayUtil, domClass, Stateful, query, json, aspect,
     registry, Tooltip,
     Grid, OnDemandGrid, Keyboard, Selection, ColumnResizer, ColumnHider, ColumnReorder, DijitRegistry, Pagination) {
 
@@ -281,6 +283,53 @@ define([
             }
             baseClass.push(GridHelper);
             return declare(baseClass, params);
+        },
+
+        MonitorVisibility: function (widget, callback) {
+            //  There are many places that may cause the widget to be hidden, the possible places are calculated by walking the DOM hierarchy upwards. 
+            var watchList = {};
+            var domNode = widget.domNode;
+            while (domNode) {
+                if (domNode.id) {
+                    watchList[domNode.id] = false;
+                }
+                domNode = domNode.parentElement;
+            }
+
+            function isHidden() {
+                for (key in watchList) {
+                    if (watchList[key] === true) {
+                        return true;
+                    }
+                }
+                return false;
+            }
+
+            //  Hijack the dojo style class replacement call and monitor for elements in our watchList. 
+            aspect.around(domClass, "replace", function (origFunc) {
+                return function (node, addStyle, removeStyle) {
+                    if (node.firstChild && (node.firstChild.id in watchList)) {
+                        if (addStyle === "dijitHidden" || addStyle === "hpccHidden") {
+                            if (!isHidden()) {
+                                if (callback(false, node)) {
+                                    addStyle = "hpccHidden";
+                                    removeStyle = "hpccVisible";
+                                }
+                            }
+                            watchList[node.firstChild.id] = true;
+                        } else if ((addStyle === "dijitVisible" || addStyle === "hpccVisible") && watchList[node.firstChild.id] === true) {
+                            watchList[node.firstChild.id] = false;
+                            if (!isHidden()) {
+                                if (callback(true, node)) {
+                                    addStyle = "hpccVisible";
+                                    removeStyle = "hpccHidden";
+                                }
+                            }
+                        }
+                    }
+                    return origFunc(node, addStyle, removeStyle);
+                }
+            });
         }
     };
 });

+ 5 - 0
esp/src/eclwatch/GetDFUWorkunitsWidget.js

@@ -206,6 +206,11 @@ define([
             topic.subscribe("hpcc/dfu_wu_created", function (topic) {
                 context.refreshGrid();
             });
+            ESPUtil.MonitorVisibility(this.workunitsTab, function (visibility) {
+                if (visibility) {
+                    context.refreshGrid();
+                }
+            });
         },
 
         initTab: function () {

+ 16 - 37
esp/src/eclwatch/GraphWidget.js

@@ -20,7 +20,6 @@ define([
     "dojo/i18n!./nls/hpcc",
     "dojo/_base/array",
     "dojo/_base/Deferred",
-    "dojo/aspect",
     "dojo/has",
     "dojo/dom",
     "dojo/dom-construct",
@@ -36,6 +35,7 @@ define([
     "dijit/layout/ContentPane",
 
     "hpcc/_Widget",
+    "hpcc/ESPUtil",
 
     "dojo/text!../templates/GraphWidget.html",
 
@@ -44,9 +44,9 @@ define([
     "dijit/form/Button",
     "dijit/form/NumberSpinner"
     
-], function (declare, lang, i18n, nlsHPCC, arrayUtil, Deferred, aspect, has, dom, domConstruct, domClass, domStyle, Memory, Observable, QueryResults, Evented,
+], function (declare, lang, i18n, nlsHPCC, arrayUtil, Deferred, has, dom, domConstruct, domClass, domStyle, Memory, Observable, QueryResults, Evented,
             registry, BorderContainer, ContentPane,
-            _Widget,
+            _Widget, ESPUtil,
             template) {
 
     var GraphStore = declare("GraphStore", [Memory], {
@@ -1033,40 +1033,19 @@ define([
             },
 
             watchStyleChange: function () {
-                //  Prevent control from being "hidden" as it gets destroyed on Chrome/FF/(Maybe IE11?)
-                var watchList = [];
-                var context = this;
-                var domNode = this.domNode;
-
-                //  There are many places that may cause the plugin to be hidden, the possible places are calculated by walking the hierarchy upwards. 
-                while (domNode) {
-                    if (domNode.id) {
-                        watchList[domNode.id] = false;
-                    }
-                    domNode = domNode.parentElement;
-                }
-
-                //  Hijack the dojo style class replacement call and monitor for elements in our watchList. 
-                aspect.around(domClass, "replace", function (origFunc) {
-                    return function (node, addStyle, removeStyle) {
-                        if (node.firstChild && (node.firstChild.id in watchList)) {
-                            if (addStyle == "dijitHidden") {
-                                watchList[node.firstChild.id] = true;
-                                dojo.style(node, "width", "1px");
-                                dojo.style(node, "height", "1px");
-                                dojo.style(node.firstChild, "width", "1px");
-                                dojo.style(node.firstChild, "height", "1px");
-                                return;
-                            } else if (addStyle == "dijitVisible" && watchList[node.firstChild.id] == true) {
-                                watchList[node.firstChild.id] = false;
-                                dojo.style(node, "width", "100%");
-                                dojo.style(node, "height", "100%");
-                                dojo.style(node.firstChild, "width", "100%");
-                                dojo.style(node.firstChild, "height", "100%");
-                                return;
-                            }
-                        }
-                        return origFunc(node, addStyle, removeStyle);
+                ESPUtil.MonitorVisibility(this, function (visibility, node) {
+                    if (visibility) {
+                        dojo.style(node, "width", "100%");
+                        dojo.style(node, "height", "100%");
+                        dojo.style(node.firstChild, "width", "100%");
+                        dojo.style(node.firstChild, "height", "100%");
+                        return true;
+                    } else {
+                        dojo.style(node, "width", "1px");
+                        dojo.style(node, "height", "1px");
+                        dojo.style(node.firstChild, "width", "1px");
+                        dojo.style(node.firstChild, "height", "1px");
+                        return true;
                     }
                 });
             },

+ 7 - 2
esp/src/eclwatch/WUQueryWidget.js

@@ -20,7 +20,6 @@ define([
     "dojo/i18n!./nls/hpcc",
     "dojo/_base/array",
     "dojo/dom",
-    "dojo/dom-class",
     "dojo/dom-form",
     "dojo/date",
     "dojo/on",
@@ -57,7 +56,7 @@ define([
     "dijit/ToolbarSeparator",
     "dijit/TooltipDialog"
 
-], function (declare, lang, i18n, nlsHPCC, arrayUtil, dom, domClass, domForm, date, on, topic,
+], function (declare, lang, i18n, nlsHPCC, arrayUtil, dom, domForm, date, on, topic,
                 registry, Menu, MenuItem, MenuSeparator, PopupMenuItem,
                 selector,
                 _TabContainerWidget, WsWorkunits, ESPUtil, ESPWorkunit, DelayLoadWidget, TargetSelectWidget, FilterDropDownWidget,
@@ -257,6 +256,12 @@ define([
             topic.subscribe("hpcc/ecl_wu_created", function (topic) {
                 context.refreshGrid();
             });
+
+            ESPUtil.MonitorVisibility(this.workunitsTab, function (visibility) {
+                if (visibility) {
+                    context.refreshGrid();
+                }
+            });
         },
 
         initTab: function () {