UI Improvement when stopping nodes

This commit is contained in:
Luis Fernando Molina committed 2020-11-07 08:58:12 +01:00
1 parent 7d91c60005
commit 04d311533a
4 files changed
+28 -8

No files matched your search

@@ -158,7 +158,7 @@ function newLearningSessionFunctions() {
let key = node.name + '-' + node.type + '-' + node.id
eventsServerClient.raiseEvent(key, 'Stop Learning Session')
node.payload.uiObject.stop(callBackFunction)
node.payload.uiObject.stop(callBackFunction, undefined, true)
}
function validations(node) {
@@ -192,7 +192,7 @@ function newTaskFunctions() {
taskName: node.name
}
node.payload.uiObject.stop(callBackFunction)
node.payload.uiObject.stop(callBackFunction, undefined, true)
eventsServerClient.raiseEvent('Task Manager', 'Stop Task', event)
if (node.bot === undefined) { return }
@@ -200,7 +200,7 @@ function newTaskFunctions() {
for (let i = 0; i < node.bot.processes.length; i++) {
let process = node.bot.processes[i]
process.payload.uiObject.stop()
process.payload.uiObject.stop(undefined, undefined, true)
if (process.session !== undefined) {
process.session.payload.uiObject.reset()
}
@@ -158,7 +158,7 @@ function newTradingSessionFunctions() {
let key = node.name + '-' + node.type + '-' + node.id
eventsServerClient.raiseEvent(key, 'Stop Trading Session')
node.payload.uiObject.stop(callBackFunction)
node.payload.uiObject.stop(callBackFunction, undefined, true)
}
function validations(node) {
@@ -1034,7 +1034,7 @@ function newUiObject() {
In those cases, the stop function would never be called (from the UI). So what we will do is to call it from
here with and event, and passing our own callBackFunction. In case there is an external source stopping this,
this will produce an execution of the callback with our event, which will produce that the menu item is restored
to its default stage.
to its default value.
If on the other side, it is executed from the UI, then we will be processing the Stopped event twice, which in
both cases will reset the menu item to its default state.
@@ -1110,8 +1110,9 @@ function newUiObject() {
return uiObject
}
function stop(callBackFunction, event) {
/* We will wait to the event that the execution was terminated in order to call back the menu item */
function stop(callBackFunction, event, requestFromUI) {
let wasStopped = false
/* We will wait for 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
eventsServerClient.listenToEvent(key, 'Stopped', undefined, 'UiObject', onResponse, onStopped)
@@ -1121,6 +1122,25 @@ function newUiObject() {
function onStopped() {
completeStop(callBackFunction, event)
wasStopped = true
}
/*
When the request comes from the UI, we need to consider the possibility that the backend is down or it
was restarted while this node was running.
*/
if (requestFromUI === true) {
/*
It can happen that the backend is down, the task is down, session is down of for whatever reason there is no
answer to the command to stop. In those cases, we will stop execute the onStopped funcion anyways so as to
return the UI to its default state.
*/
setTimeout(returnToDefualtState, 90000)
function returnToDefualtState() {
if (wasStopped === false) {
completeStop(callBackFunction, event)
}
}
}
}
@@ -1587,7 +1607,7 @@ function newUiObject() {
let phrase = phrases[i]
labelPoint = {
x: position.x - phrase.length / 2 * fontSize * FONT_ASPECT_RATIO - 5,
y: position.y + thisObject.payload.floatingObject.currentImageSize / 2 + lineSeparator * ( 1 + i)
y: position.y + thisObject.payload.floatingObject.currentImageSize / 2 + lineSeparator * (1 + i)
}
if (UI.projects.superalgos.spaces.floatingSpace.inMapMode === false) {
printMessage(phrase)