Browse Source

HPCC-8891 ECLPlayground broken

General regression broke ECL Playground (and possibly other widgets).

Signed-off-by: Gordon Smith <gordon.smith@lexisnexis.com>
Gordon Smith 12 years ago
parent
commit
8c6a615302

+ 5 - 10
esp/files/scripts/ECLPlaygroundWidget.js

@@ -171,6 +171,7 @@ define([
             this.watching = this.wu.watch(function (name, oldValue, newValue) {
                 context.updateInput(name, oldValue, newValue);
             });
+            this.wu.monitor();
         },
 
         updateInput: function (name, oldValue, newValue) {
@@ -222,15 +223,9 @@ define([
         displayGraphs: function (graphs) {
             for (var i = 0; i < graphs.length; ++i) {
                 var context = this;
-                if (i == 0) {
-                    this.wu.fetchGraphXgmml(i, function (xgmml) {
-                        context.graphControl.loadXGMML(xgmml);
-                    });
-                } else {
-                    this.wu.fetchGraphXgmml(i, function (xgmml) {
-                        context.graphControl.loadXGMML(xgmml, true);
-                    });
-                }
+                this.wu.fetchGraphXgmml(i, function (xgmml) {
+                    context.graphControl.loadXGMML(xgmml, i > 0);
+                });
             }
         },
 
@@ -249,6 +244,7 @@ define([
                     context.wu.update({
                         QueryText: context.editorControl.getText()
                     });
+                    context.watchWU();
                 },
                 onUpdate: function () {
                     context.wu.submit(context.targetSelectWidget.getValue());
@@ -256,7 +252,6 @@ define([
                 onSubmit: function () {
                 }
             });
-            this.watchWU();
         }
     });
 });

+ 31 - 11
esp/files/scripts/ESPWorkunit.js

@@ -109,6 +109,9 @@ define([
     });
 
     var WorkunitData = declare([Stateful], {
+        Wuid: "",
+        changedCount: 0,
+
         _StateIDSetter: function (StateID) {
             if (this.StateID !== StateID) {
                 this.StateID = StateID;
@@ -185,6 +188,12 @@ define([
 
         timers: [],
 
+        _assertHasWuid: function () {
+            if (!this.Wuid) {
+                throw new Error("Wuid cannot be empty.");
+            }
+        },
+
         onCreate: function () {
         },
         onUpdate: function () {
@@ -193,8 +202,8 @@ define([
         },
         constructor: function (args) {
             this.inherited(arguments);
+            declare.safeMixin(this, args);
             this.wu = this;
-            this.setTimer(1000);
         },
         isComplete: function () {
             return this.hasCompleted;
@@ -215,7 +224,7 @@ define([
                 this.killTimer();
                 return;
             } else {
-                if (this._timerTickCount < 5 && this._timerTickCount % 5 === 0) {
+                if (this._timerTickCount < 5 && this._timerTickCount % 1 === 0) {
                     this.refresh();
                 } else if (this._timerTickCount < 30 && this._timerTickCount % 5 === 0) {
                     this.refresh();
@@ -238,19 +247,21 @@ define([
             }
         },
         monitor: function (callback) {
-            if (callback) {
-                if (this.hasCompleted) {
+            if (this.hasCompleted) {
+                if (callback) {
                     callback(this);
-                } else {
-                    var context = this;
-                    this.watch("hasCompleted", function (name, oldValue, newValue) {
-                        if (oldValue !== newValue && newValue) {
+                }
+            } else {
+                this.setTimer(1000);
+                var context = this;
+                this.watch("changedCount", function (name, oldValue, newValue) {
+                    if (oldValue !== newValue && newValue) {
+                        if (callback) {
                             callback(context);
                         }
-                    });
-                }
+                    }
+                });
             }
-            return;
         },
         create: function (ecl) {
             var context = this;
@@ -263,6 +274,7 @@ define([
             });
         },
         update: function (request, appData) {
+            this._assertHasWuid();
             lang.mixin(request, {
                 Wuid: this.Wuid
             });
@@ -286,6 +298,7 @@ define([
             });
         },
         submit: function (target) {
+            this._assertHasWuid();
             var context = this;
             WsWorkunits.WUSubmit({
                 request: {
@@ -298,6 +311,7 @@ define([
             });
         },
         _resubmit: function (clone, resetWorkflow) {
+            this._assertHasWuid();
             var context = this;
             WsWorkunits.WUResubmit({
                 request: {
@@ -320,6 +334,7 @@ define([
             this._resubmit(false, true);
         },
         _action: function (action) {
+            this._assertHasWuid();
             var context = this;
             WsWorkunits.WUAction([{ Wuid: this.Wuid }], action, {
                 load: function (response) {
@@ -337,6 +352,7 @@ define([
             this._action("Delete");
         },
         publish: function (jobName) {
+            this._assertHasWuid();
             var context = this;
             WsWorkunits.WUPublishWorkunit({
                 request: {
@@ -376,6 +392,7 @@ define([
             }
         },
         getQuery: function () {
+            this._assertHasWuid();
             var context = this;
             WsWorkunits.WUQuery({
                 request: {
@@ -391,6 +408,7 @@ define([
             });
         },
         getInfo: function (args) {
+            this._assertHasWuid();
             var context = this;
             WsWorkunits.WUInfo({
                 request: {
@@ -575,6 +593,7 @@ define([
                 return;
             }
 
+            this._assertHasWuid();
             var context = this;
             WsWorkunits.WUFile({
                 request: {
@@ -624,6 +643,7 @@ define([
             }
         },
         fetchGraphXgmml: function (idx, onFetchGraphXgmml) {
+            this._assertHasWuid();
             var context = this;
             WsWorkunits.WUGetGraph({
                 request: {

+ 3 - 0
esp/files/scripts/GraphWidget.js

@@ -92,6 +92,9 @@ require([
             //  Plugin wrapper  ---
             clear: function () {
                 if (this._plugin) {
+                    this.xgmml = "";
+                    this.svg = "";
+                    this.dot = "";
                     this._plugin.clear();
                 }
             },

+ 1 - 0
esp/files/scripts/ResultsWidget.js

@@ -143,6 +143,7 @@ define([
             this.removeAllChildren();
             this.tabMap = [];
             this.selectedTab = null;
+            this.initalized = false;
         },
 
         refresh: function (wu) {