Task remembering their running status

This commit is contained in:
Luis Fernando Molina committed 2020-02-04 16:43:24 +01:00
1 parent 511783c518
commit 9dde60975c
4 files changed
+47 -7

No files matched your search

+1 -1
View File
@@ -88,7 +88,7 @@ function newDashboard () {
function setBrowserEvents () {
window.onbeforeunload = onBrowserClosed
function onBrowserClosed () {
canvas.designerSpace.workspace.stopAllRunningTasks()
// canvas.designerSpace.workspace.stopAllRunningTasks()
}
}
}
@@ -9,11 +9,13 @@ function newUiObjectsFromNodes () {
let mapOfReferenceChildren = new Map()
let mapOfNodes
let tasksToRun
return thisObject
function recreateWorkspace (node) {
mapOfNodes = new Map()
tasksToRun = []
/* Create the workspace UI OBject and then continue with the root nodes. */
createUiObject(false, 'Workspace', node.name, node, undefined, undefined, 'Workspace')
@@ -25,6 +27,16 @@ function newUiObjectsFromNodes () {
}
tryToConnectChildrenWithReferenceParents()
setTimeout(runTasks, 70000) // We need to wait all tasks that were potentially running to stop
}
function runTasks () {
for (let i = 0; i < tasksToRun.length; i++) {
let node = tasksToRun[i]
node.payload.uiObject.menu.internalClick('Run Task')
}
tasksToRun = undefined
}
function tryToConnectChildrenWithReferenceParents () {
@@ -362,5 +374,11 @@ function newUiObjectsFromNodes () {
canvas.floatingSpace.uiObjectConstructor.createUiObject(userAddingNew, payload)
mapOfNodes.set(node.id, node)
if (userAddingNew === false && uiObjectType === 'Task' && node.savedPayload !== undefined) {
if (node.savedPayload.uiObject.isRunning === true) {
tasksToRun.push(node)
}
}
}
}
+4 -2
View File
@@ -23,13 +23,13 @@ function newCircularProgressBar () {
let opacityCounters = []
let eventSubscriptionHeartbeat
let eventSubscriptionIdHeartbeat
return thisObject
function finalize () {
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
systemEventHandler.stopListening(key, eventSubscriptionHeartbeat)
systemEventHandler.stopListening(key, eventSubscriptionIdHeartbeat)
thisObject.container = undefined
thisObject.payload = undefined
@@ -52,6 +52,8 @@ function newCircularProgressBar () {
}
function onHeartBeat (message) {
if (thisObject.payload === undefined) { return }
if (thisObject.payload.uiObject === undefined) { return }
opacityCounters[message.event.seconds] = 2000
thisObject.payload.uiObject.setValue(message.event.processingDate)
}
+24 -4
View File
@@ -94,9 +94,16 @@ function newUiObject () {
let currentValue = 0
let rightDragging = false
let eventSubscriptionIdHeartbeat
let eventSubscriptionIdOnStopped
return thisObject
function finalize () {
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
systemEventHandler.stopListening(key, eventSubscriptionIdHeartbeat, 'UiObject')
systemEventHandler.stopListening(key, eventSubscriptionIdOnStopped, 'UiObject')
thisObject.container.eventHandler.stopListening(selfFocusEventSubscriptionId)
thisObject.container.eventHandler.stopListening(selfNotFocuskEventSubscriptionId)
thisObject.container.eventHandler.stopListening(selfDisplaceEventSubscriptionId)
@@ -589,11 +596,19 @@ function newUiObject () {
thisObject.circularProgressBar.fitFunction = thisObject.fitFunction
thisObject.circularProgressBar.container = thisObject.container
/* We will wait to the event that the execution was terminated in order to call back the menu item */
/* We will wait to hear the first onHeartBeat in order to confirm the execution was really started */
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
systemEventHandler.listenToEvent(key, 'Running', undefined, key, undefined, onRunning)
systemEventHandler.listenToEvent(key, 'Heartbeat', undefined, 'UiObject', onResponse, onHeartBeat)
function onResponse (message) {
eventSubscriptionIdHeartbeat = message.eventSubscriptionId
}
function onHeartBeat () {
if (thisObject.payload === undefined) { return }
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
systemEventHandler.stopListening(key, eventSubscriptionIdHeartbeat, 'UiObject')
function onRunning () {
if (callBackFunction !== undefined) {
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
}
@@ -621,9 +636,14 @@ function newUiObject () {
function stop (callBackFunction, event) {
/* We will wait to the event that the execution was terminated in order to call back the menu item */
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
systemEventHandler.listenToEvent(key, 'Stopped', undefined, key, undefined, onStopped)
systemEventHandler.listenToEvent(key, 'Stopped', undefined, 'UiObject', onResponse, onStopped)
function onResponse (message) {
eventSubscriptionIdOnStopped = message.eventSubscriptionId
}
function onStopped () {
if (thisObject.payload === undefined) { return }
if (callBackFunction !== undefined) {
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, event)
}