Bläddra i källkod

HPCC-9305 Auto open DFU Workunits on file action

Fixes HPCC-9305

Signed-off-by: Gordon Smith <gordon.smith@lexisnexis.com>
Gordon Smith 12 år sedan
förälder
incheckning
c30386ae02

+ 9 - 28
esp/files/scripts/DFUWUDetailsWidget.js

@@ -14,6 +14,7 @@
 #   limitations under the License.
 ############################################################################## */
 define([
+    "exports",
     "dojo/_base/declare",
     "dojo/_base/array",
     "dojo/dom",
@@ -37,39 +38,21 @@ define([
     "hpcc/FileSpray",
     "hpcc/ESPDFUWorkunit",
     "hpcc/ECLSourceWidget",
-    "hpcc/TargetSelectWidget",
-    "hpcc/SampleSelectWidget",
-    "hpcc/GraphWidget",
-    "hpcc/ResultsWidget",
-    "hpcc/InfoGridWidget",
     "hpcc/LFDetailsWidget",
 
     "dojo/text!../templates/DFUWUDetailsWidget.html",
 
     "dojox/layout/TableContainer"
 
-], function (declare, arrayUtil, dom, domAttr, domClass, domStyle, query,
+], function (exports, declare, arrayUtil, dom, domAttr, domClass, domStyle, query,
                 _TemplatedMixin, _WidgetsInTemplateMixin, BorderContainer, TabContainer, ContentPane, Toolbar, Textarea, TitlePane, registry, ProgressBar,
-                _TabContainerWidget, FileSpray, ESPDFUWorkunit, EclSourceWidget, TargetSelectWidget, SampleSelectWidget, GraphWidget, ResultsWidget, InfoGridWidget, LFDetailsWidget,
+                _TabContainerWidget, FileSpray, ESPDFUWorkunit, ECLSourceWidget, LFDetailsWidget,
                 template) {
-    return declare("DFUWUDetailsWidget", [_TabContainerWidget, _TemplatedMixin, _WidgetsInTemplateMixin], {
+    exports.fixCircularDependency = declare("DFUWUDetailsWidget", [_TabContainerWidget, _TemplatedMixin, _WidgetsInTemplateMixin], {
         templateString: template,
         baseClass: "DFUWUDetailsWidget",
         summaryWidget: null,
-        resultsWidget: null,
-        resultsWidgetLoaded: false,
-        filesWidget: null,
-        filesWidgetLoaded: false,
-        timersWidget: null,
-        timersWidgetLoaded: false,
-        graphsWidget: null,
-        graphsWidgetLoaded: false,
-        sourceWidget: null,
-        sourceWidgetLoaded: false,
-        playgroundWidget: null,
-        playgroundWidgetLoaded: false,
         xmlWidget: null,
-        xmlWidgetLoaded: false,
 
         wu: null,
         loaded: false,
@@ -150,20 +133,18 @@ define([
             if (!this.wu) {
                 return
             }
+
             var currSel = this.getSelectedChild();
-            if (currSel.id == this.summaryWidget.id) {
-            } else if (currSel.id == this.xmlWidget.id) {
-                if (!this.xmlWidgetLoaded) {
+            if (!currSel.initalized) {
+                if (currSel.id == this.summaryWidget.id) {
+                } else if (currSel.id == this.xmlWidget.id) {
                     var context = this;
                     this.wu.fetchXML(function (response) {
-                        context.xmlWidgetLoaded = true;
                         context.xmlWidget.init({
                             ECL: response
                         });
                     });
-                }
-            } else {
-                if (!currSel.initalized) {
+                } else {
                     currSel.init(currSel._hpccParams);
                 }
             }

+ 1 - 3
esp/files/scripts/GetDFUWorkunitsWidget.js

@@ -229,9 +229,7 @@ define([
             if (currSel && !currSel.initalized) {
                 if (currSel.id == this.workunitsTab.id) {
                 } else {
-                    if (!currSel.initalized) {
-                        currSel.init(currSel.params);
-                    }
+                    currSel.init(currSel.params);
                 }
             }
         },

+ 85 - 56
esp/files/scripts/LFDetailsWidget.js

@@ -47,13 +47,14 @@ define([
     "hpcc/DFUWUDetailsWidget",
     "hpcc/TargetSelectWidget",
     "hpcc/ESPLogicalFile",
+    "hpcc/ESPDFUWorkunit",
 
     "dojo/text!../templates/LFDetailsWidget.html",
 
     "dijit/TooltipDialog"
 ], function (exports, declare, lang, arrayUtil, dom, domAttr, domClass, domForm, query,
                 _TemplatedMixin, _WidgetsInTemplateMixin, BorderContainer, TabContainer, ContentPane, Toolbar, TooltipDialog, Form, SimpleTextarea, TextBox, Button, DropDownButton, TitlePane, registry,
-                _TabContainerWidget, ResultWidget, EclSourceWidget, FilePartsWidget, WUDetailsWidget, DFUWUDetailsWidget, TargetSelectWidget, ESPLogicalFile,
+                _TabContainerWidget, ResultWidget, EclSourceWidget, FilePartsWidget, WUDetailsWidget, DFUWUDetailsWidget, TargetSelectWidget, ESPLogicalFile, ESPDFUWorkunit,
                 template) {
     exports.fixCircularDependency = declare("LFDetailsWidget", [_TabContainerWidget, _TemplatedMixin, _WidgetsInTemplateMixin], {
         templateString: template,
@@ -62,19 +63,12 @@ define([
         tabContainer: null,
         summaryWidget: null,
         contentWidget: null,
-        contentWidgetLoaded: false,
         sourceWidget: null,
-        sourceWidgetLoaded: false,
         defWidget: null,
-        defWidgetLoaded: false,
         xmlWidget: null,
-        xmlWidgetLoaded: false,
         filePartsWidget: null,
-        filePartsWidgetLoaded: false,
         workunitWidget: null,
-        workunitWidgetLoaded: false,
         dfuWorkunitWidget: null,
-        dfuWorkunitWidgetLoaded: false,
 
         logicalFile: null,
         prevState: "",
@@ -108,33 +102,55 @@ define([
                 }
             });
         },
+
+        _handleResponse: function (wuidQualifier, response) {
+            if (lang.exists(wuidQualifier, response)) {
+                var wu = ESPDFUWorkunit.Get(lang.getObject(wuidQualifier, false, response));
+                wu.startMonitor(true);
+                var tab = this.ensurePane(this.id + "_" + wu.ID, {
+                    Wuid: wu.ID
+                });
+                if (tab) {
+                    this.selectChild(tab);
+                }
+            }
+        },
         _onCopyOk: function (event) {
+            var context = this;
             this.logicalFile.copy({
                 request: domForm.toObject(this.id + "CopyDialog")
+            }).then(function (response) {
+                context._handleResponse("CopyResponse.result", response);
             });
             registry.byId(this.id + "CopyDropDown").closeDropDown();
         },
         _onCopyCancel: function (event) {
             registry.byId(this.id + "CopyDropDown").closeDropDown();
         },
-        _onDesprayOk: function (event) {
-            this.logicalFile.despray({
-                request: domForm.toObject(this.id + "DesprayDialog")
-            });
-            registry.byId(this.id + "DesprayDropDown").closeDropDown();
-        },
-        _onDesprayCancel: function (event) {
-            registry.byId(this.id + "DesprayDropDown").closeDropDown();
-        },
         _onRenameOk: function (event) {
+            var context = this;
             this.logicalFile.rename({
                 request: domForm.toObject(this.id + "RenameDialog")
+            }).then(function (response) {
+                context._handleResponse("RenameResponse.wuid", response);
             });
             registry.byId(this.id + "RenameDropDown").closeDropDown();
         },
         _onRenameCancel: function (event) {
             registry.byId(this.id + "RenameDropDown").closeDropDown();
         },
+        _onDesprayOk: function (event) {
+            var context = this;
+            this.logicalFile.despray({
+                request: domForm.toObject(this.id + "DesprayDialog")
+            }).then(function (response) {
+                context._handleResponse("DesprayResponse.wuid", response);
+            });
+            registry.byId(this.id + "DesprayDropDown").closeDropDown();
+        },
+        _onDesprayCancel: function (event) {
+            registry.byId(this.id + "DesprayDropDown").closeDropDown();
+        },
 
         //  Implementation  ---
         init: function (params) {
@@ -169,47 +185,45 @@ define([
 
         initTab: function() {
             var currSel = this.getSelectedChild();
-            if (currSel.id == this.contentWidget.id && !this.contentWidgetLoaded) {
-                this.contentWidgetLoaded = true;
-                this.contentWidget.init({
-                    result: this.logicalFile.result
-                });
-            } else if (currSel.id == this.sourceWidget.id && !this.sourceWidgetLoaded) {
-                this.sourceWidgetLoaded = true;
-                this.sourceWidget.init({
-                    ECL: this.logicalFile.Ecl
-                });
-            } else if (currSel.id == this.defWidget.id && !this.defWidgetLoaded) {
-                var context = this;
-                this.logicalFile.fetchDEF(function (response) {
-                    context.defWidgetLoaded = true;
-                    context.defWidget.init({
-                        ECL: response
+            if (currSel && !currSel.initalized) {
+                if (currSel.id == this.summaryWidget.id) {
+                } else if (currSel.id == this.contentWidget.id) {
+                    this.contentWidget.init({
+                        result: this.logicalFile.result
                     });
-                });
-            } else if (currSel.id == this.xmlWidget.id && !this.xmlWidgetLoaded) {
-                var context = this;
-                this.logicalFile.fetchXML(function (response) {
-                    context.xmlWidgetLoaded = true;
-                    context.xmlWidget.init({
-                        ECL: response
+                } else if (currSel.id == this.sourceWidget.id) {
+                    this.sourceWidget.init({
+                        ECL: this.logicalFile.Ecl
                     });
-                });
-            } else if (currSel.id == this.filePartsWidget.id && !this.filePartsWidgetLoaded) {
-                this.filePartsWidgetLoaded = true;
-                this.filePartsWidget.init({
-                    fileParts: lang.exists("logicalFile.DFUFileParts.DFUPart", this) ? this.logicalFile.DFUFileParts.DFUPart : []
-                });
-            } else if (this.workunitWidget && currSel.id == this.workunitWidget.id && !this.workunitWidgetLoaded) {
-                this.workunitWidgetLoaded = true;
-                this.workunitWidget.init({
-                    Wuid: this.logicalFile.Wuid
-                });
-            } else if (this.dfuWorkunitWidget && currSel.id == this.dfuWorkunitWidget.id && !this.workunitWidgetLoaded) {
-                this.dfuWorkunitWidgetLoaded = true;
-                this.dfuWorkunitWidget.init({
-                    Wuid: this.logicalFile.Wuid
-                });
+                } else if (currSel.id == this.defWidget.id) {
+                    var context = this;
+                    this.logicalFile.fetchDEF(function (response) {
+                        context.defWidget.init({
+                            ECL: response
+                        });
+                    });
+                } else if (currSel.id == this.xmlWidget.id) {
+                    var context = this;
+                    this.logicalFile.fetchXML(function (response) {
+                        context.xmlWidget.init({
+                            ECL: response
+                        });
+                    });
+                } else if (currSel.id == this.filePartsWidget.id) {
+                    this.filePartsWidget.init({
+                        fileParts: lang.exists("logicalFile.DFUFileParts.DFUPart", this) ? this.logicalFile.DFUFileParts.DFUPart : []
+                    });
+                } else if (this.workunitWidget && currSel.id == this.workunitWidget.id) {
+                    this.workunitWidget.init({
+                        Wuid: this.logicalFile.Wuid
+                    });
+                } else if (this.dfuWorkunitWidget && currSel.id == this.dfuWorkunitWidget.id) {
+                    this.dfuWorkunitWidget.init({
+                        Wuid: this.logicalFile.Wuid
+                    });
+                } else {
+                    currSel.init(currSel.params);
+                }
             }
         },
 
@@ -311,6 +325,21 @@ define([
             dom.byId(this.id + "Filesize").innerHTML = fileDetails.Filesize;
             dom.byId(this.id + "PathMask").innerHTML = fileDetails.PathMask;
             */
+        },
+
+        ensurePane: function (id, params) {
+            var retVal = registry.byId(id);
+            if (!retVal) {
+                var context = this;
+                retVal = new DFUWUDetailsWidget.fixCircularDependency({
+                    id: id,
+                    title: params.Wuid,
+                    closable: true,
+                    params: params
+                });
+                this.addChild(retVal);
+            }
+            return retVal;
         }
 
     });

+ 41 - 24
esp/files/scripts/LogsWidget.js

@@ -121,10 +121,8 @@ define([
                             params = "/WUFile/res.txt?Wuid=" + this.wu.Wuid + "&Type=" + selection[i].Orig.Type;
                             break;
                         case "ThorLog":
-                            params = "/WUFile/" + selection[i].Type + "?Wuid=" + this.wu.Wuid + "&Name=" + selection[i].Orig.Name + "&Type=" + selection[i].Orig.Type;
-                            break;
                         case "EclAgentLog":
-                            params = "/WUFile/" + selection[i].Type + "?Wuid=" + this.wu.Wuid + "&Process=" + selection[i].Orig.Description + "&Type=" + selection[i].Orig.Type;
+                            params = "/WUFile/" + selection[i].Type + "?Wuid=" + this.wu.Wuid + "&Name=" + selection[i].Orig.Name + "&Type=" + selection[i].Orig.Type;
                             break;
                         case "ThorSlaveLog":
                             params = "/WUFile?Wuid=" + this.wu.Wuid + "&Process=" + selection[i].Orig.ProcessName + "&ClusterGroup=" + selection[i].Orig.ProcessName + "&LogDate=" + selection[i].Orig.LogDate + "&SlaveNumber=" + selection[i].Orig.SlaveNumber + "&Type=" + selection[i].Type;
@@ -154,30 +152,49 @@ define([
                     return;
                 this.initalized = true;
 
-                this.wu = ESPWorkunit.Get(params.Wuid);
-
+                this.logData = [];
                 var context = this;
-                this.wu.monitor(function () {
-                    context.wu.getInfo({
-                        onAfterSend: function (response) {
-                            context.logData = [];
-                            if (response.HasArchiveQuery) {
-                                context.logData.push({
-                                    id: "A:0",
-                                    Type: "Archive Query"
-                                });
-                            }
-                            if (response.Helpers && response.Helpers.ECLHelpFile) {
-                                context.loadHelpers(response.Helpers.ECLHelpFile);
-                            }
-                            if (response.ThorLogList && response.ThorLogList.ThorLogInfo) {
-                                context.loadThorLogInfo(response.ThorLogList.ThorLogInfo);
+                if (params.wu) {
+                    this.wu = params.wu;
+                    this.wu.fetchLogs(function (logs) {
+                        context.loadLogs(logs);
+                        context.logsStore.setData(context.logData);
+                        context.logsGrid.refresh();
+                    });
+                } else {
+                    this.wu = ESPWorkunit.Get(params.Wuid);
+                    this.wu.monitor(function () {
+                        context.wu.getInfo({
+                            onAfterSend: function (response) {
+                                if (response.HasArchiveQuery) {
+                                    context.logData.push({
+                                        id: "A:0",
+                                        Type: "Archive Query"
+                                    });
+                                }
+                                if (response.Helpers && response.Helpers.ECLHelpFile) {
+                                    context.loadHelpers(response.Helpers.ECLHelpFile);
+                                }
+                                if (response.ThorLogList && response.ThorLogList.ThorLogInfo) {
+                                    context.loadThorLogInfo(response.ThorLogList.ThorLogInfo);
+                                }
+                                context.logsStore.setData(context.logData);
+                                context.logsGrid.refresh();
                             }
-                            context.logsStore.setData(context.logData);
-                            context.logsGrid.refresh();
-                        }
+                        });
                     });
-                });
+                }
+            },
+
+            loadLogs: function (logs) {
+                for (var i = 0; i < logs.length; ++i) {
+                    this.logData.push({
+                        id: "L:" + i,
+                        Type: "dfulog",
+                        Description: logs[i],
+                        Orig: logs[i]
+                    });
+                }
             },
 
             loadHelpers: function (helpers) {

+ 6 - 7
esp/files/templates/LFDetailsWidget.html

@@ -12,13 +12,12 @@
                         <span>Copy</span>
                         <div data-dojo-type="dijit.TooltipDialog">
                             <div id="${id}CopyDialog" data-dojo-type="dijit.form.Form" style="width: 460px;">
+                                <h2>Source</h2>
                                 <div data-dojo-props="cols:2" data-dojo-type="dojox.layout.TableContainer">
-                                    <h2>Source</h2>
-                                    <div id="${id}CopySourceName" style="width: 100%;" title="Logical&nbsp;File:" colspan="2">
-                                    </div>
+                                    <input id="${id}CopySourceName" title="Logical&nbsp;File:" style="width: 100%;" name="sourceLogicalName" colspan="2" data-dojo-props="trim: true, readonly: true" data-dojo-type="dijit.form.Textarea" />
                                 </div>
+                                <h2>Target</h2>
                                 <div data-dojo-props="cols:2" data-dojo-type="dojox.layout.TableContainer">
-                                    <h2>Target</h2>
                                     <input id="${id}CopyTargetSelect" title="Group:" name="destGroup" colspan="2" style="width:100%;" data-dojo-type="TargetSelectWidget" style="display: inline-block; vertical-align: middle" />
                                     <input id="${id}CopyTargetName"  title="Logical&nbsp;File:" name="destLogicalName" colspan="2" data-dojo-props="trim: true" data-dojo-type="dijit.form.Textarea" />
                                     <input id="${id}CopyTargetWrap" title="Wrap:" name="Wrap" data-dojo-type="dijit/form/CheckBox" />
@@ -38,7 +37,7 @@
                             <div id="${id}RenameDialog" style="width: 460px;" data-dojo-type="dijit.form.Form">
                                 <h2>Source</h2>
                                 <div data-dojo-props="cols:2" data-dojo-type="dojox.layout.TableContainer">
-                                    <input id="${id}RenameSourceName" title="Logical&nbsp;File:" style="width: 100%;" name="RenameSourceName" colspan="2" data-dojo-props="trim: true" data-dojo-type="dijit.form.Textarea" />
+                                    <input id="${id}RenameSourceName" title="Logical&nbsp;File:" style="width: 100%;" name="RenameSourceName" colspan="2" data-dojo-props="trim: true, readonly: true" data-dojo-type="dijit.form.Textarea" />
                                 </div>
                                 <h2>Target</h2>
                                 <div data-dojo-props="cols:2" data-dojo-type="dojox.layout.TableContainer">
@@ -53,10 +52,10 @@
                     <div id="${id}DesprayDropDown" data-dojo-type="dijit.form.DropDownButton">
                         <span>Despray</span>
                         <div data-dojo-type="dijit.TooltipDialog">
-                            <h2>Source</h2>
                             <div id="${id}DesprayDialog" style="width: 460px;" data-dojo-type="dijit.form.Form">
+                                <h2>Source</h2>
                                 <div data-dojo-props="cols:2" data-dojo-type="dojox.layout.TableContainer">
-                                    <input id="${id}DespraySourceName" title="Logical&nbsp;File:" style="width: 100%;" name="DespraySourceName" colspan="2" data-dojo-props="trim: true" data-dojo-type="dijit.form.Textarea" />
+                                    <input id="${id}DespraySourceName" title="Logical&nbsp;File:" style="width: 100%;" name="DespraySourceName" colspan="2" data-dojo-props="trim: true, readonly: true" data-dojo-type="dijit.form.Textarea" />
                                 </div>
                                 <h2>Target</h2>
                                 <div data-dojo-props="cols:2" data-dojo-type="dojox.layout.TableContainer">