Session Running and Stopping from menu and at task server
This commit is contained in:
1 parent
a876a15e42
commit
ca576af89d
4 files changed
+37
-10
No files matched your search
@@ -259,7 +259,16 @@ function newCircularMenuItem () {
|
||||
return
|
||||
}
|
||||
|
||||
function onPrimaryCallBack (err) {
|
||||
function onPrimaryCallBack (err, event) {
|
||||
/* While the primary action is being executed some event might have happen. Following we process the ones we can */
|
||||
|
||||
if (event !== undefined) {
|
||||
if (event.type === 'Secondary Action Already Executed') {
|
||||
setStatus(thisObject.secondaryWorkDoneLabel, UI_COLOR.PATINATED_TURQUOISE, 250, STATUS_SECONDARY_WORK_DONE)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
/* If there is a secondary action we will act different that if there is not */
|
||||
if (thisObject.secondaryAction === undefined) { // This means there are no more possible actions.
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
@@ -595,23 +595,39 @@ function newStrategyPart () {
|
||||
|
||||
/* 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, 'Running', undefined, key, undefined, onExecutionTerminated)
|
||||
systemEventHandler.listenToEvent(key, 'Running', undefined, key, undefined, onRunning)
|
||||
|
||||
function onExecutionTerminated () {
|
||||
function onRunning () {
|
||||
if (callBackFunction !== undefined) {
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
While it is running, it can happen that it naturally stops or is stopped not from the UI but from other means.
|
||||
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.
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
let event = {
|
||||
type: 'Secondary Action Already Executed'
|
||||
}
|
||||
stop(callBackFunction, event)
|
||||
}
|
||||
|
||||
function stop (callBackFunction) {
|
||||
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
|
||||
let eventSubscriptionId = systemEventHandler.listenToEvent(key, 'Stopped', undefined, key, undefined, onExecutionTerminated)
|
||||
systemEventHandler.listenToEvent(key, 'Stopped', undefined, key, undefined, onStopped)
|
||||
|
||||
function onExecutionTerminated () {
|
||||
function onStopped () {
|
||||
if (callBackFunction !== undefined) {
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, event)
|
||||
}
|
||||
|
||||
if (thisObject.circularProgressBar !== undefined) {
|
||||
|
||||
@@ -890,7 +890,7 @@ function newStrategyPartConstructor () {
|
||||
action: 'Run Session',
|
||||
actionFunction: payload.onMenuItemClick,
|
||||
label: 'Run',
|
||||
workingLabel: 'Stop',
|
||||
workingLabel: 'Runing...',
|
||||
workDoneLabel: 'Session Running',
|
||||
workFailedLabel: 'Session Cannot be Run',
|
||||
secondaryAction: 'Stop Session',
|
||||
|
||||
@@ -9,12 +9,14 @@ function newSessionFunctions () {
|
||||
function runSession (node, functionLibraryProtocolNode, callBackFunction) {
|
||||
node.payload.uiObject.run(callBackFunction)
|
||||
|
||||
let key = node.name + '-' + node.type + '-' + node.id
|
||||
|
||||
/* Raise event to run the session */
|
||||
let event = {
|
||||
session: JSON.stringify(functionLibraryProtocolNode.getProtocolNode(node, false, false, true)),
|
||||
definition: getDefinition()
|
||||
}
|
||||
|
||||
let key = 'Session' + '-' + node.id + '-' + 'Events'
|
||||
systemEventHandler.raiseEvent(key, 'Run Session', event)
|
||||
|
||||
function getDefinition () {
|
||||
@@ -25,7 +27,7 @@ function newSessionFunctions () {
|
||||
}
|
||||
|
||||
function stopSession (node, functionLibraryProtocolNode, callBackFunction) {
|
||||
let key = 'Session' + '-' + node.id + '-' + 'Events'
|
||||
let key = node.name + '-' + node.type + '-' + node.id
|
||||
systemEventHandler.raiseEvent(key, 'Stop Session')
|
||||
|
||||
node.payload.uiObject.stop(callBackFunction)
|
||||
|
||||
Reference in new issue
Block a user