فهرست منبع

HPCC-10055 Add Error/Warning Log for Toaster Messages

Fixes HPCC-10055

Signed-off-by: Gordon Smith <gordon.smith@lexisnexis.com>
Gordon Smith 11 سال پیش
والد
کامیت
3678e6da53

+ 8 - 21
esp/files/scripts/ESPRequest.js

@@ -117,24 +117,11 @@ define([
                 if (!params.suppressExceptionToaster && handleAs == "json") {
                     var deletedWorkunit = false; //  Deleted WU
                     if (lang.exists("Exceptions.Source", response)) {
-                        var message = "<h3>" + response.Exceptions.Source + "</h3>";
-                        if (lang.exists("Exceptions.Exception", response)) {
-                            exceptions = response.Exceptions.Exception;
-                            for (var i = 0; i < response.Exceptions.Exception.length; ++i) {
-                                if ((service === "WsWorkunits" && action === "WUInfo" && response.Exceptions.Exception[i].Code === 20080) ||
-                                    (service === "WsWorkunits" && action === "WUQuery" && response.Exceptions.Exception[i].Code === 20081)) {
-                                    deletedWorkunit = true;
-                                }
-                                message += "<p>" + response.Exceptions.Exception[i].Message + "</p>";
-                            }
-                        }
-                        if (!deletedWorkunit) {
-                            dojo.publish("hpcc/brToaster", {
-                                message: message,
-                                type: "error",
-                                duration: -1
-                            });
-                        }
+                        dojo.publish("hpcc/brToaster", {
+                            Severity: "Error",
+                            Source: service + "." + action,
+                            Exceptions: response.Exceptions
+                        });
                     }
                 }
                 dojo.publish("hpcc/standbyBackgroundHide");
@@ -150,9 +137,9 @@ define([
                 }
 
                 dojo.publish("hpcc/brToaster", {
-                    message: message,
-                    type: "error",
-                    duration: -1
+                    Severity: "Error",
+                    Source: service + "." + action,
+                    Exceptions: [{ Message: message }]
                 });
                 dojo.publish("hpcc/standbyBackgroundHide");
                 return error;

+ 6 - 5
esp/files/scripts/FileSpray.js

@@ -322,14 +322,15 @@ define([
                     var resultMessage = response.DFUWorkunitsActionResponse.DFUActionResults.DFUActionResult[0].Result;
                     if (resultMessage.indexOf("Success") === 0) {
                         dojo.publish("hpcc/brToaster", {
-                            message: "<h4>Delete " + resultID + "</h4>" + "<p>" + resultMessage + "</p>",
-                            type: "message"
+                            Severity: "Message",
+                            Source: "FileSpray.DeleteDropZoneFiles",
+                            Exceptions: [{ Source: "Delete " + resultID, Message: resultMessage }]
                         });
                     } else {
                         dojo.publish("hpcc/brToaster", {
-                            message: "<h4>Delete " + resultID + "</h4>" + "<p>" + resultMessage + "</p>",
-                            type: "error",
-                            duration: -1
+                            Severity: "Error",
+                            Source: "FileSpray.DeleteDropZoneFiles",
+                            Exceptions: [{ Source: "Delete " + resultID, Message: resultMessage }]
                         });
                     }
                 }

+ 10 - 1
esp/files/scripts/HPCCPlatformWidget.js

@@ -17,6 +17,7 @@ define([
     "dojo/_base/declare",
     "dojo/_base/lang",
     "dojo/dom",
+    "dojo/dom-style",
 
     "dijit/registry",
     "dijit/Tooltip",
@@ -48,7 +49,7 @@ define([
     "hpcc/HPCCPlatformRoxieWidget",
     "hpcc/HPCCPlatformOpsWidget"
 
-], function (declare, lang, dom,
+], function (declare, lang, dom, domStyle,
                 registry, Tooltip,
                 _TabContainerWidget, ESPRequest, WsAccount, WsSMC, GraphWidget,
                 template) {
@@ -64,12 +65,16 @@ define([
             this.searchPage = registry.byId(this.id + "_Main" + "_Search");
             this.stackContainer = registry.byId(this.id + "TabContainer");
             this.mainPage = registry.byId(this.id + "_Main");
+            this.errWarnPage = registry.byId(this.id + "_ErrWarn");
             this.mainStackContainer = registry.byId(this.mainPage.id + "TabContainer");
             this.searchPage = registry.byId(this.id + "_Main" + "_Search");
         },
 
         startup: function (args) {
             this.inherited(arguments);
+            domStyle.set(dom.byId(this.id + "StackController_stub_ErrWarn").parentNode.parentNode, {
+                visibility: "hidden"
+            });
         },
 
         //  Implementation  ---
@@ -132,6 +137,10 @@ define([
             win.focus();
         },
 
+        _onOpenErrWarn: function (evt) {
+            this.stackContainer.selectChild(this.errWarnPage);
+        },
+
         _onAboutLoaded: false,
         _onAbout: function (evt) {
             if (!this._onAboutLoaded) {

+ 66 - 12
esp/files/scripts/InfoGridWidget.js

@@ -18,13 +18,18 @@ define([
     "dojo/_base/declare",
     "dojo/_base/lang",
     "dojo/_base/array",
+    "dojo/dom",
+    "dojo/dom-construct",
     "dojo/dom-class",
     "dojo/store/Memory",
     "dojo/store/Observable",
+    "dojo/topic",
 
     "dijit/registry",
 
     "dojox/data/AndOrReadStore",
+    "dojox/gfx",
+    "dojox/html/entities",
 
     "dgrid/OnDemandGrid",
     "dgrid/Keyboard",
@@ -42,9 +47,9 @@ define([
     "dijit/layout/ContentPane",
     "dijit/form/CheckBox"
 ],
-    function (declare, lang, arrayUtil, domClass, Memory, Observable,
+    function (declare, lang, arrayUtil, dom, domConstruct, domClass, Memory, Observable, topic,
             registry, 
-            AndOrReadStore,
+            AndOrReadStore, gfx, entities,
             OnDemandGrid, Keyboard, Selection, ColumnResizer, DijitRegistry,
             _Widget, ESPUtil, ESPWorkunit,
             template) {
@@ -71,6 +76,7 @@ define([
                 this.errorsCheck = registry.byId(this.id + "Errors");
                 this.warningsCheck = registry.byId(this.id + "Warnings");
                 this.infoCheck = registry.byId(this.id + "Info");
+                this.errWarnMenuItem = registry.byId("stubErrWarn");
             },
 
             startup: function (args) {
@@ -100,7 +106,7 @@ define([
                                 node.innerText = value;
                             }
                         }, 
-                        Source: { label: "Source", field: "", width: 72, sortable: false },
+                        Source: { label: "Source", field: "", width: 144, sortable: false },
                         Code: { label: "Code", field: "", width: 45, sortable: false },
                         Message: { label: "Message", field: "", sortable: false },
                         Column: { label: "Col", field: "", width: 36, sortable: false },
@@ -117,6 +123,31 @@ define([
                     context.onErrorClick(line, col);
                 });
                 this.infoGrid.startup();
+
+                if (this.errWarn) {
+                    this.infoData = [];
+                    topic.subscribe("hpcc/brToaster", function (topic) {
+                        context.loadTopic(topic);
+                    });
+
+                    var target = dom.byId("stubMore");
+                    if (target) {
+                        var newTarget = domConstruct.create("div", {
+                            style: {
+                                position: "relative",
+                                top: "16px",
+                                left: "12px"
+                            }
+                        }, target.firstChild);
+                        var surface = gfx.createSurface(newTarget, 16, 16);
+                        this.errWarnCount = surface.createText({ x: 8, y: 12, align: "middle", text: "" })
+                                    .setFill([255, 255, 255, 1])
+                        ;
+                        this.errWarnCount.setFont({
+                            size: "12px"
+                        });
+                    }
+                }
             },
 
             resize: function (args) {
@@ -165,17 +196,19 @@ define([
                 if (params.onErrorClick) {
                     this.onErrorClick = params.onErrorClick;
                 }
-                
-                this.wu = ESPWorkunit.Get(params.Wuid);
 
-                var context = this;
-                this.wu.monitor(function () {
-                    context.wu.getInfo({
-                        onGetWUExceptions: function (exceptions) {
-                            context.loadExceptions(exceptions);
-                        }
+                if (params.Wuid) {
+                    this.wu = ESPWorkunit.Get(params.Wuid);
+
+                    var context = this;
+                    this.wu.monitor(function () {
+                        context.wu.getInfo({
+                            onGetWUExceptions: function (exceptions) {
+                                context.loadExceptions(exceptions);
+                            }
+                        });
                     });
-                });
+                }
             },
 
             refreshFilter: function (graphName) {
@@ -199,6 +232,7 @@ define([
                                 data.push(item);
                             }
                             break;
+                        case "Message":
                         case "Info":
                             if (infoChecked) {
                                 data.push(item);
@@ -238,6 +272,26 @@ define([
                 });
                 this.infoData = exceptions;
                 this.refreshFilter();
+            },
+
+            loadTopic: function (topic) {
+                if (lang.exists("Exceptions", topic)) {
+                    var context = this;
+                    arrayUtil.forEach(topic.Exceptions, function (item, idx) {
+                        context.infoData.unshift(lang.mixin({
+                            Severity: topic.Severity,
+                            Source: topic.Source
+                        }, item));
+                    });
+                }
+
+                this.refreshFilter();
+                if (this.errWarnCount) {
+                    this.errWarnCount.rawNode.textContent = this.infoData.length;
+                    if (this.errWarnMenuItem) {
+                        this.errWarnMenuItem.set("label", "Error/Warnings (" + this.infoData.length + ")");
+                    }
+                }
             }
         });
     });

+ 4 - 13
esp/files/scripts/PackageMapDetailsWidget.js

@@ -129,23 +129,14 @@ define([
             domAttr.set(this.id + "StateIdImage", "title", this.active? "Active":"Not active");
         },
 
-        showErrorMessage: function (message) {
+        showErrors: function (errMsg, errStack) {
             dojo.publish("hpcc/brToaster", {
-                message: message,
-                type: "error",
-                duration: -1
+                Severity: "Error",
+                Source: errMsg,
+                Exceptions: [{ Message: errStack }]
             });
         },
 
-        showErrors: function (errMsg, errStack) {
-            var message = "Unknown Error";
-            if (errMsg != '')
-                message = "<h3>" + errMsg + "</h3>";
-            if (errStack != '')
-                message += "<p>" + errStack + "</p>";
-            this.showErrorMessage(message);
-        },
-
         _onActivate: function (event) {
             var context = this;
             var packageMaps = [];

+ 4 - 13
esp/files/scripts/PackageMapQueryWidget.js

@@ -300,23 +300,14 @@ define([
             });
         },
 
-        showErrorMessage: function (message) {
+        showErrors: function (errMsg, errStack) {
             dojo.publish("hpcc/brToaster", {
-                message: message,
-                type: "error",
-                duration: -1
+                Severity: "Error",
+                Source: errMsg,
+                Exceptions: [{ Message: errStack }]
             });
         },
 
-        showErrors: function (errMsg, errStack) {
-            var message = "Unknown Error";
-            if (errMsg != '')
-                message = "<h3>" + errMsg + "</h3>";
-            if (errStack != '')
-                message += "<p>" + errStack + "</p>";
-            this.showErrorMessage(message);
-        },
-
         getSelections: function () {
             this.targets = new Array();
             ///this.processes = new Array();

+ 4 - 13
esp/files/scripts/PackageMapValidateWidget.js

@@ -188,21 +188,12 @@ define([
             });
         },
 
-        showErrorMessage: function (message) {
+        showErrors: function (errMsg, errStack) {
             dojo.publish("hpcc/brToaster", {
-                message: message,
-                type: "error",
-                duration: -1
+                Severity: "Error",
+                Source: errMsg,
+                Exceptions: [{ Message: errStack }]
             });
-        },
-
-        showErrors: function (errMsg, errStack) {
-            var message = "Unknown Error";
-            if (errMsg != '')
-                message = "<h3>" + errMsg + "</h3>";
-            if (errStack != '')
-                message += "<p>" + errStack + "</p>";
-            this.showErrorMessage(message);
         }
     });
 });

+ 4 - 13
esp/files/scripts/PackageSourceWidget.js

@@ -108,23 +108,14 @@ define([
                 }
             },
 
-            showErrorMessage: function (message) {
+            showErrors: function (errMsg, errStack) {
                 dojo.publish("hpcc/brToaster", {
-                    message: message,
-                    type: "error",
-                    duration: -1
+                    Severity: "Error",
+                    Source: errMsg,
+                    Exceptions: [{ Message: errStack }]
                 });
             },
 
-            showErrors: function (errMsg, errStack) {
-                var message = "Unknown Error";
-                if (errMsg != '')
-                    message = "<h3>" + errMsg + "</h3>";
-                if (errStack != '')
-                    message += "<p>" + errStack + "</p>";
-                this.showErrorMessage(message);
-            },
-
             addArrayToText: function (arrayTitle, arrayItems, text) {
                 if ((arrayItems.Item != undefined) && (arrayItems.Item.length > 0)) {
                     text += arrayTitle + ":\n";

+ 9 - 9
esp/files/scripts/WsDfu.js

@@ -45,9 +45,9 @@ define([
                 load: function (response) {
                     if (lang.exists("DFUArrayActionResponse.DFUArrayActionResult", response)) {
                         dojo.publish("hpcc/brToaster", {
-                            message: response.DFUArrayActionResponse.DFUArrayActionResult,
-                            type: "error",
-                            duration: -1
+                            Severity: "Error",
+                            Source: "WsDfu.DFUArrayAction",
+                            Exceptions: [{ Message: response.DFUArrayActionResponse.DFUArrayActionResult }]
                         });
                     }
 
@@ -77,9 +77,9 @@ define([
                 load: function (response) {
                     if (lang.exists("SuperfileActionResponse", response)) {
                         dojo.publish("hpcc/brToaster", {
-                            message: response.AddtoSuperfileResponse.Subfiles,
-                            type: "error",
-                            duration: -1
+                            Severity: "Error",
+                            Source: "WsDfu.SuperfileAction",
+                            Exceptions: [{ Message: response.AddtoSuperfileResponse.Subfiles }]
                         });
                     }
 
@@ -108,9 +108,9 @@ define([
                 load: function (response) {
                     if (lang.exists("AddtoSuperfileResponse.Subfiles", response)) {
                         dojo.publish("hpcc/brToaster", {
-                            message: response.AddtoSuperfileResponse.Subfiles,
-                            type: "error",
-                            duration: -1
+                            Severity: "Error",
+                            Source: "WsDfu.AddtoSuperfile",
+                            Exceptions: [{ Message: response.AddtoSuperfileResponse.Subfiles }]
                         });
                     }
 

+ 18 - 12
esp/files/scripts/WsWorkunits.js

@@ -63,18 +63,24 @@ define([
                 if (lang.exists("WUPublishWorkunitResponse", response)) {
                     if (response.WUPublishWorkunitResponse.ErrorMesssage) {
                         dojo.publish("hpcc/brToaster", {
-                            message: "<h4>Publish " + response.WUPublishWorkunitResponse.Wuid + "</h4>" + "<p>" + response.WUPublishWorkunitResponse.ErrorMesssage + "</p>",
-                            type: "error",
-                            duration: -1
+                            Severity: "Error",
+                            Source: service + "." + action,
+                            Exceptions: response.Exceptions
                         });
                     } else {
                         dojo.publish("hpcc/brToaster", {
-                            message: "<h4>Publish " + response.WUPublishWorkunitResponse.Wuid + "</h4>" + "<p><ul>" +
-                                "<li>Query ID:  " + response.WUPublishWorkunitResponse.QueryId + "</li>" +
-                                "<li>Query Name:  " + response.WUPublishWorkunitResponse.QueryName + "</li>" +
-                                "<li>Query Set:  " + response.WUPublishWorkunitResponse.QuerySet + "</li>" +
-                                "</ul></p>",
-                            type: "message"
+                            Severity: "Error",
+                            Source: "WsWorkunits.WUPublishWorkunit",
+                            Exceptions: [{
+                                Source: "Query ID",
+                                Message: response.WUPublishWorkunitResponse.QueryId
+                            }, {
+                                Source: "Query Name",
+                                Message: response.WUPublishWorkunitResponse.QueryName
+                            }, {
+                                Source: "Query Set",
+                                Message: response.WUPublishWorkunitResponse.QuerySet
+                            }]
                         });
                     }
                 }
@@ -157,9 +163,9 @@ define([
                         arrayUtil.forEach(response.WUActionResponse.ActionResults.WUActionResult, function (item, index) {
                             if (item.Result.indexOf("Failed:") === 0) {
                                 dojo.publish("hpcc/brToaster", {
-                                    message: "<h4>" + item.Action + " " + item.Wuid + "</h4>" + "<p>" + item.Result + "</p>",
-                                    type: "error",
-                                    duration: -1
+                                    Severity: "Error",
+                                    Source: "WsWorkunits.WUAction",
+                                    Exceptions: [{Source: item.Action + " " + item.Wuid, Message: item.Result}]
                                 });
                             }
                         });

+ 24 - 4
esp/files/stub.js

@@ -15,6 +15,7 @@
 ############################################################################## */
 define([
     "dojo/_base/lang",
+    "dojo/_base/array",
     "dojo/_base/fx",
     "dojo/_base/window",
     "dojo/dom",
@@ -24,10 +25,11 @@ define([
     "dojo/topic",
     "dojo/ready",
 
+    "dojox/html/entities",
     "dojox/widget/Toaster",
     "dojox/widget/Standby"
-], function (lang, fx, baseWindow, dom, domStyle, domGeometry, ioQuery, topic, ready,
-        Toaster, Standby) {
+], function (lang, arrayUtil, fx, baseWindow, dom, domStyle, domGeometry, ioQuery, topic, ready,
+        entities, Toaster, Standby) {
 
     var initUi = function () {
         var params = ioQuery.queryToObject(dojo.doc.location.search.substr((dojo.doc.location.search.substr(0, 1) == "?" ? 1 : 0)));
@@ -95,8 +97,26 @@ define([
                 });
                 var myToaster = new Toaster({
                     id: 'hpcc_toaster',
-                    positionDirection: 'br-left',
-                    messageTopic: 'hpcc/brToaster'
+                    positionDirection: 'br-left'
+                });
+                topic.subscribe("hpcc/brToaster", function (topic) {
+                    if (lang.exists("Exceptions", topic)) {
+                        var context = this;
+                        arrayUtil.forEach(topic.Exceptions, function (_item, idx) {
+                            var item = lang.mixin({
+                                Severity: topic.Severity,
+                                Source: topic.Source
+                            }, _item);
+
+                            if ((item.Source === "WsWorkunits.WUInfo" && item.Code === 20080) ||
+                                (item.Source === "WsWorkunits.WUQuery" && item.Code === 20081)) {
+                            } else {
+                                var message = "<h4>" + entities.encode(item.Source) + "</h4><p>" + entities.encode(item.Message) + "</p>";
+                                myToaster.setContent(message, item.Severity, item.Severity === "Error" ? -1 : null);
+                                myToaster.show();
+                            }
+                        });
+                    }
                 });
 
                 if (widget) {

+ 8 - 3
esp/files/templates/HPCCPlatformWidget.html

@@ -21,6 +21,7 @@
                         <span data-dojo-type="dijit.MenuSeparator"></span>
                         <div id="${id}About" data-dojo-attach-event="onClick:_onAbout" data-dojo-type="dijit.MenuItem">About</div>
                         <div id="${id}ReleaseNotes" data-dojo-attach-event="onClick:_onOpenReleaseNotes" data-dojo-type="dijit.MenuItem">Release Notes</div>
+                        <div id="${id}ErrWarn" data-dojo-attach-event="onClick:_onOpenErrWarn" data-dojo-type="dijit.MenuItem">Error/Warnings</div>
                     </div>
                 </div>
             </div>
@@ -30,11 +31,15 @@
             </div>
             <div id="${id}_ECL" data-dojo-props="iconClass: 'iconWu', showLabel: false" data-dojo-type="HPCCPlatformECLWidget">
             </div>
-            <div id="${id}_Files" data-dojo-props="iconClass: 'iconLandingZone'" data-dojo-type="HPCCPlatformFilesWidget">
+            <div id="${id}_Files" data-dojo-props="iconClass: 'iconLandingZone', showLabel: false" data-dojo-type="HPCCPlatformFilesWidget">
             </div>
-            <div id="${id}_Queries" data-dojo-props="iconClass: 'iconTargets'" data-dojo-type="HPCCPlatformRoxieWidget">
+            <div id="${id}_Queries" data-dojo-props="iconClass: 'iconTargets', showLabel: false" data-dojo-type="HPCCPlatformRoxieWidget">
             </div>
-            <div id="${id}_OPS" data-dojo-props="iconClass: 'iconOperations'" data-dojo-type="HPCCPlatformOpsWidget">
+            <div id="${id}_OPS" data-dojo-props="iconClass: 'iconOperations', showLabel: false" data-dojo-type="HPCCPlatformOpsWidget">
+            </div>
+            <div id="${id}_ErrWarn" data-dojo-props="showLabel: false" data-dojo-type="dijit.layout.TabContainer">
+                <div id="${id}ErrWarnGrid" data-dojo-props="title: 'Error/Warning(s)', errWarn: true" data-dojo-type="InfoGridWidget">
+                </div>
             </div>
         </div>
     </div>