|
@@ -17,6 +17,7 @@
|
|
|
import apiHelper from 'api/apiHelper';
|
|
import apiHelper from 'api/apiHelper';
|
|
|
import { ExecutionResult } from 'apps/notebook2/execution/executionResult';
|
|
import { ExecutionResult } from 'apps/notebook2/execution/executionResult';
|
|
|
import hueAnalytics from 'utils/hueAnalytics';
|
|
import hueAnalytics from 'utils/hueAnalytics';
|
|
|
|
|
+import huePubSub from 'utils/huePubSub';
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @type { { canceling: string, canceled: string, fail: string, ready: string, executing: string, done: string } }
|
|
* @type { { canceling: string, canceled: string, fail: string, ready: string, executing: string, done: string } }
|
|
@@ -34,6 +35,10 @@ const EXECUTION_STATUS = {
|
|
|
closed: 'closed'
|
|
closed: 'closed'
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+const notifyUpdates = executable => {
|
|
|
|
|
+ huePubSub.publish('hue.executable.updated', executable);
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
class ExecutableStatement {
|
|
class ExecutableStatement {
|
|
|
/**
|
|
/**
|
|
|
* @param options
|
|
* @param options
|
|
@@ -98,6 +103,7 @@ class ExecutableStatement {
|
|
|
case 'running':
|
|
case 'running':
|
|
|
case 'starting':
|
|
case 'starting':
|
|
|
case 'waiting':
|
|
case 'waiting':
|
|
|
|
|
+ notifyUpdates(this);
|
|
|
checkStatusTimeout = window.setTimeout(
|
|
checkStatusTimeout = window.setTimeout(
|
|
|
() => {
|
|
() => {
|
|
|
checkStatus()
|
|
checkStatus()
|
|
@@ -117,11 +123,15 @@ class ExecutableStatement {
|
|
|
this.lastCancellable.onCancel(() => {
|
|
this.lastCancellable.onCancel(() => {
|
|
|
window.clearTimeout(checkStatusTimeout);
|
|
window.clearTimeout(checkStatusTimeout);
|
|
|
});
|
|
});
|
|
|
|
|
+ }).finally(() => {
|
|
|
|
|
+ notifyUpdates(this);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
hueAnalytics.log('notebook', 'execute/' + this.sourceType);
|
|
hueAnalytics.log('notebook', 'execute/' + this.sourceType);
|
|
|
this.status = EXECUTION_STATUS.running;
|
|
this.status = EXECUTION_STATUS.running;
|
|
|
|
|
+ this.progress = 0;
|
|
|
|
|
|
|
|
|
|
+ notifyUpdates(this);
|
|
|
this.lastCancellable = apiHelper
|
|
this.lastCancellable = apiHelper
|
|
|
.executeStatement({
|
|
.executeStatement({
|
|
|
executable: this
|
|
executable: this
|
|
@@ -149,8 +159,10 @@ class ExecutableStatement {
|
|
|
if (this.lastCancellable && this.status === EXECUTION_STATUS.running) {
|
|
if (this.lastCancellable && this.status === EXECUTION_STATUS.running) {
|
|
|
hueAnalytics.log('notebook', 'cancel/' + this.sourceType);
|
|
hueAnalytics.log('notebook', 'cancel/' + this.sourceType);
|
|
|
this.status = EXECUTION_STATUS.canceling;
|
|
this.status = EXECUTION_STATUS.canceling;
|
|
|
|
|
+ notifyUpdates(this);
|
|
|
this.lastCancellable.cancel().always(() => {
|
|
this.lastCancellable.cancel().always(() => {
|
|
|
this.status = EXECUTION_STATUS.canceled;
|
|
this.status = EXECUTION_STATUS.canceled;
|
|
|
|
|
+ notifyUpdates(this);
|
|
|
resolve();
|
|
resolve();
|
|
|
});
|
|
});
|
|
|
this.lastCancellable = undefined;
|
|
this.lastCancellable = undefined;
|
|
@@ -169,6 +181,7 @@ class ExecutableStatement {
|
|
|
}
|
|
}
|
|
|
}).finally(() => {
|
|
}).finally(() => {
|
|
|
this.status = EXECUTION_STATUS.closed;
|
|
this.status = EXECUTION_STATUS.closed;
|
|
|
|
|
+ notifyUpdates(this);
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|