Running and Stopping all tasks

This commit is contained in:
Luis Fernando Molina committed 2019-09-20 15:48:56 +02:00
1 parent 065efd6017
commit a9e3941e12
3 files changed
+46 -20

No files matched your search

+29 -17
View File
@@ -5,6 +5,7 @@ function newCircularMenu () {
let thisObject = {
container: undefined,
isDeployed: undefined,
internalClick: internalClick,
physics: physics,
drawBackground: drawBackground,
drawForeground: drawForeground,
@@ -96,54 +97,65 @@ function newCircularMenu () {
if (thisObject.isDeployed === true) {
for (let i = 0; i < menuItems.length; i++) {
let menutItem = menuItems[i]
if (menutItem.visible === true) {
container = menutItem.getContainer(point)
let menuItem = menuItems[i]
if (menuItem.visible === true) {
container = menuItem.getContainer(point)
}
if (container !== undefined) { return container }
}
}
}
function internalClick (action) {
for (let i = 0; i < menuItems.length; i++) {
let menuItem = menuItems[i]
if (menuItem.visible === true) {
if (menuItem.nextAction === action) {
menuItem.internalClick()
}
}
}
}
function physics () {
for (let i = 0; i < menuItems.length; i++) {
let menutItem = menuItems[i]
menutItem.physics()
let menuItem = menuItems[i]
menuItem.physics()
}
}
function onFocus () {
for (let i = 0; i < menuItems.length; i++) {
let menutItem = menuItems[i]
menutItem.targetRadius = menutItem.rawRadius * 1.5
menutItem.isDeployed = true
let menuItem = menuItems[i]
menuItem.targetRadius = menuItem.rawRadius * 1.5
menuItem.isDeployed = true
}
thisObject.isDeployed = true
}
function onNotFocus () {
for (let i = 0; i < menuItems.length; i++) {
let menutItem = menuItems[i]
menutItem.targetRadius = menutItem.rawRadius * 0 - i * 4
menutItem.isDeployed = false
let menuItem = menuItems[i]
menuItem.targetRadius = menuItem.rawRadius * 0 - i * 4
menuItem.isDeployed = false
}
thisObject.isDeployed = false
}
function drawBackground (pFloatingObject) {
for (let i = 0; i < menuItems.length; i++) {
let menutItem = menuItems[i]
if (menutItem.visible === true) {
menutItem.drawBackground()
let menuItem = menuItems[i]
if (menuItem.visible === true) {
menuItem.drawBackground()
}
}
}
function drawForeground (pFloatingObject) {
for (let i = 0; i < menuItems.length; i++) {
let menutItem = menuItems[i]
if (menutItem.visible === true) {
menutItem.drawForeground()
let menuItem = menuItems[i]
if (menuItem.visible === true) {
menuItem.drawForeground()
}
}
}
+11 -1
View File
@@ -23,6 +23,7 @@ function newCircularMenuItem () {
secondaryWorkDoneLabel: undefined,
secondaryWorkFailedLabel: undefined,
secondaryIcon: undefined,
nextAction: undefined,
visible: false,
iconPathOn: undefined,
iconPathOff: undefined,
@@ -34,6 +35,7 @@ function newCircularMenuItem () {
payload: undefined,
relatedStrategyPart: undefined,
dontShowAtFullscreen: undefined,
internalClick: internalClick,
physics: physics,
drawBackground: drawBackground,
drawForeground: drawForeground,
@@ -102,6 +104,8 @@ function newCircularMenuItem () {
} else {
thisObject.container.frame.width = 50
}
thisObject.nextAction = thisObject.action
}
function getContainer (point) {
@@ -142,6 +146,7 @@ function newCircularMenuItem () {
if (temporaryStatus === STATUS_DEFAULT) {
labelToPrint = thisObject.label
backgroundColorToUse = defaultBackgroudColor
thisObject.nextAction = thisObject.action
}
iconPhysics()
@@ -188,7 +193,11 @@ function newCircularMenuItem () {
isMouseOver = false
}
async function onMouseClick (event) {
function internalClick () {
onMouseClick()
}
function onMouseClick () {
if (thisObject.askConfirmation !== true) { /* No confirmation is needed */
if (temporaryStatus === STATUS_DEFAULT || temporaryStatus === STATUS_PRIMARY_WORK_DONE) {
executeAction()
@@ -242,6 +251,7 @@ function newCircularMenuItem () {
} else {
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
if (thisObject.workDoneLabel !== undefined) {
thisObject.nextAction = thisObject.secondaryAction
setTemporaryStatus(thisObject.secondaryLabel, defaultBackgroudColor, STATUS_PRIMARY_WORK_DONE)
}
} else {
@@ -49,14 +49,18 @@ function newTaskFunctions () {
function runAllTasks (taskManager, functionLibraryProtocolNode) {
for (let i = 0; i < taskManager.tasks.length; i++) {
let node = taskManager.tasks[i]
runTask(node, functionLibraryProtocolNode)
let menu = node.payload.uiObject.menu
menu.internalClick('Run Task')
}
}
function stopAllTasks (taskManager, functionLibraryProtocolNode) {
for (let i = 0; i < taskManager.tasks.length; i++) {
let node = taskManager.tasks[i]
stopTask(node, functionLibraryProtocolNode)
let menu = node.payload.uiObject.menu
menu.internalClick('Stop Task')
}
}
}