Task Syncronization with Backend

This commit is contained in:
Luis Fernando Molina committed 2020-09-25 14:15:55 +02:00
1 parent 89c4ad8780
commit 584b721a86
3 files changed
+16 -20

No files matched your search

@@ -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')
}
}
@@ -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)
}
}
+2 -2
View File
@@ -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