diff --git a/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js b/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js index a7913454e..615c8dd2a 100644 --- a/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js @@ -1,6 +1,6 @@ function newTaskFunctions() { thisObject = { - getReady: getReady, + syncronizeTaskWithBackEnd: syncronizeTaskWithBackEnd, runTask: runTask, stopTask: stopTask, @@ -35,7 +35,7 @@ function newTaskFunctions() { return thisObject - function getReady(node) { + function syncronizeTaskWithBackEnd(node) { let networkNode = validations(node) if (networkNode === undefined) { /* Nodes that do not belong to a network can not get ready. */ @@ -56,7 +56,7 @@ function newTaskFunctions() { function onStatus(message) { eventsServerClient.stopListening(key, eventSubscriptionIdOnStatus, node.id) if (message.event.status === 'Task Process Running' ) { - node.payload.uiObject.run() + node.payload.uiObject.menu.internalClick('Run Task') } } diff --git a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index c3f52c5a9..093bcef29 100644 --- a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -1,6 +1,6 @@ function newUiObjectsFromNodes() { thisObject = { - runTasks: runTasks, + syncronizeTasksFoundAtWorkspaceWithBackEnd: syncronizeTasksFoundAtWorkspaceWithBackEnd, runSessions: runSessions, playTutorials: playTutorials, recreateWorkspace: recreateWorkspace, @@ -13,7 +13,7 @@ function newUiObjectsFromNodes() { let mapOfReferenceChildren = new Map() let mapOfNodes - let tasksToRun + let tasksFoundAtWorkspace let sessionsToRun let tutorialsToPlay @@ -25,7 +25,7 @@ function newUiObjectsFromNodes() { function recreateWorkspace(node, callBackFunction) { mapOfNodes = new Map() - tasksToRun = [] + tasksFoundAtWorkspace = [] sessionsToRun = [] tutorialsToPlay = [] @@ -150,12 +150,12 @@ function newUiObjectsFromNodes() { } } - function runTasks() { - for (let i = 0; i < tasksToRun.length; i++) { - let node = tasksToRun[i] - node.payload.uiObject.menu.internalClick('Run Task') + function syncronizeTasksFoundAtWorkspaceWithBackEnd(functionLibraryTaskFunctions) { + for (let i = 0; i < tasksFoundAtWorkspace.length; i++) { + let node = tasksFoundAtWorkspace[i] + functionLibraryTaskFunctions.syncronizeTaskWithBackEnd(node) } - tasksToRun = undefined + tasksFoundAtWorkspace = undefined } function runSessions() { @@ -625,14 +625,10 @@ function newUiObjectsFromNodes() { /* This is the point where we build a map with all nodes present at the workspace */ mapOfNodes.set(node.id, node) - /* Check if there are tasks to run */ + /* We will collect all tasks at the workspace in order to later syncronize them with the backend */ if (userAddingNew === false && uiObjectType === 'Task' && node.savedPayload !== undefined) { - if (node.savedPayload.uiObject.isRunning === true) { - if (node.payload.parentNode !== undefined) { - if (tasksToRun !== undefined) { // it might be undefined when you are spawning a task that was running while backed up - tasksToRun.push(node) - } - } + if (tasksFoundAtWorkspace !== undefined) { // it might be undefined when you are spawning a task that was backed up + tasksFoundAtWorkspace.push(node) } } diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index 747baf496..92f5aec44 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -137,13 +137,13 @@ function newWorkspace() { function runTasksAndSessions(replacingCurrentWorkspace) { if (replacingCurrentWorkspace === true) { // We need to wait all tasks that were potentially running to stop - setTimeout(functionLibraryUiObjectsFromNodes.runTasks, 70000) + setTimeout(functionLibraryUiObjectsFromNodes.syncronizeTasksFoundAtWorkspaceWithBackEnd, 70000) // We give a few seconds for the tasks to start setTimeout(functionLibraryUiObjectsFromNodes.runSessions, 80000) // We give a few seconds setTimeout(functionLibraryUiObjectsFromNodes.playTutorials, 3000) } else { - functionLibraryUiObjectsFromNodes.runTasks() + functionLibraryUiObjectsFromNodes.syncronizeTasksFoundAtWorkspaceWithBackEnd(functionLibraryTaskFunctions) // We give a few seconds for the tasks to start setTimeout(functionLibraryUiObjectsFromNodes.runSessions, 10000) // We give a few seconds