diff --git a/AppSchema.json b/AppSchema.json index 411b00154..5da0a476e 100644 --- a/AppSchema.json +++ b/AppSchema.json @@ -713,6 +713,13 @@ "actionFunction": "payload.onMenuItemClick", "ring": 1 }, + { + "action": "Configure Workspace", + "actionFunction": "uiObject.configEditor.activate", + "label": "Configure Workspace", + "iconPathOn": "html", + "iconPathOff": "html" + }, { "action": "Add UI Object", "label": "Add Trading System", @@ -731,18 +738,6 @@ "relatedUiObject": "Data Mine", "actionFunction": "payload.onMenuItemClick" }, - { - "action": "Add UI Object", - "label": "Add Crypto Ecosystem", - "relatedUiObject": "Crypto Ecosystem", - "actionFunction": "payload.onMenuItemClick" - }, - { - "action": "Add UI Object", - "label": "Add Charting Space", - "relatedUiObject": "Charting Space", - "actionFunction": "payload.onMenuItemClick" - }, { "action": "Add UI Object", "label": "Add Super Scripts", @@ -761,7 +756,13 @@ "addLeftIcons": false, "isPinned": true, "positionLocked": true, - "icon": "design-tool" + "icon": "design-tool", + "editors": { + "config": true + }, + "initialValues": { + "code": "{ \n\"includeDataMines\": [\"Masters\", \"Sparta\", \"TradingEngines\"]\n}" + } }, { "type": "Situation", @@ -4524,15 +4525,6 @@ "label": "Add Super Actions", "relatedUiObject": "Super Actions", "actionFunction": "payload.onMenuItemClick" - }, - { - "action": "Delete UI Object", - "askConfirmation": true, - "confirmationLabel": "Confirm to Delete", - "label": "Delete Crypto Ecosystem", - "iconPathOn": "delete", - "iconPathOff": "delete", - "actionFunction": "payload.onMenuItemClick" } ], "isHierarchyHead": true, @@ -5300,15 +5292,6 @@ "label": "Add Dashboard", "relatedUiObject": "Dashboard", "actionFunction": "payload.onMenuItemClick" - }, - { - "action": "Delete UI Object", - "askConfirmation": true, - "confirmationLabel": "Confirm to Delete", - "label": "Delete Charting Space", - "iconPathOn": "delete", - "iconPathOff": "delete", - "actionFunction": "payload.onMenuItemClick" } ], "isHierarchyHead": true, @@ -5469,15 +5452,6 @@ "iconPathOff": "html", "dontShowAtFullscreen": true, "actionFunction": "uiObject.configEditor.activate" - }, - { - "action": "Delete UI Object", - "askConfirmation": true, - "confirmationLabel": "Confirm to Delete", - "label": "Delete Viewport", - "iconPathOn": "delete", - "iconPathOff": "delete", - "actionFunction": "payload.onMenuItemClick" } ], "initialValues": { diff --git a/CanvasApp/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/CanvasApp/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index 772681f5c..df7391fee 100644 --- a/CanvasApp/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/CanvasApp/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -19,26 +19,69 @@ function newUiObjectsFromNodes () { tasksToRun = [] sessionsToRun = [] - /* Create the workspace UI OBject and then continue with the root nodes. */ - createUiObject(false, 'Workspace', node.name, node, undefined, undefined, 'Workspace') - if (node.rootNodes !== undefined) { - for (let i = 0; i < node.rootNodes.length; i++) { - let rootNode = node.rootNodes[i] - createUiObjectFromNode(rootNode, undefined, undefined) + addIncludedNodes() + + function addIncludedNodes () { + blobService = newFileStorage() + + if (node.code === undefined) { + node.code = '{ \n"includeDataMines": ["Masters", "Sparta", "TradingEngines"]\n}' + } + + let code = JSON.parse(node.code) + let includeDataMines = code.includeDataMines + + let totalIncluded = 0 + + for (let i = 0; i < includeDataMines.length; i++) { + let dataMine = includeDataMines[i] + blobService.getBlobToText('DataMines' + '/' + dataMine, undefined, onFileReceived, true) + function onFileReceived (err, text, response) { + if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) { + console.log('Cannot load included Data Mine ' + dataMine + '. The workspace can not be loaded.') + return + } + let includedDataMine = JSON.parse(text) + for (let i = 0; i < node.rootNodes.length; i++) { + let rootNode = node.rootNodes[i] + if (rootNode.type === 'Data Mine') { + let code = JSON.parse(rootNode.code) + if (code.name === dataMine) { + rootNodes.splice(i, 1) + } + } + } + node.rootNodes.push(includedDataMine) + totalIncluded++ + if (totalIncluded === includeDataMines.length) { + addUserDefinedNodes() + } + } } } - tryToConnectChildrenWithReferenceParents() + function addUserDefinedNodes () { + /* Create the workspace UI OBject and then continue with the root nodes. */ + createUiObject(false, 'Workspace', node.name, node, undefined, undefined, 'Workspace') + if (node.rootNodes !== undefined) { + for (let i = 0; i < node.rootNodes.length; i++) { + let rootNode = node.rootNodes[i] + createUiObjectFromNode(rootNode, undefined, undefined) + } + } - if (replacingCurrentWorkspace === true) { - // We need to wait all tasks that were potentially running to stop - setTimeout(runTasks, 70000) - // We give a few seconds for the tasks to start - setTimeout(runSessions, 80000) - } else { - runTasks() - // We give a few seconds for the tasks to start - setTimeout(runSessions, 10000) + tryToConnectChildrenWithReferenceParents() + + if (replacingCurrentWorkspace === true) { + // We need to wait all tasks that were potentially running to stop + setTimeout(runTasks, 70000) + // We give a few seconds for the tasks to start + setTimeout(runSessions, 80000) + } else { + runTasks() + // We give a few seconds for the tasks to start + setTimeout(runSessions, 10000) + } } } diff --git a/CanvasApp/DesignSpace/Workspace/Workspace.js b/CanvasApp/DesignSpace/Workspace/Workspace.js index 45fbf03d7..debbc7ed2 100644 --- a/CanvasApp/DesignSpace/Workspace/Workspace.js +++ b/CanvasApp/DesignSpace/Workspace/Workspace.js @@ -169,12 +169,26 @@ function newWorkspace () { } function stringifyWorkspace (removePersonalData) { + let code + if (thisObject.workspaceNode.code === undefined) { + thisObject.workspaceNode.code = '{ \n"includeDataMines": ["Masters", "Sparta", "TradingEngines"]\n}' + } + code = JSON.parse(thisObject.workspaceNode.code) + let includeDataMines = code.includeDataMines + let stringifyReadyNodes = [] for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) { let rootNode = thisObject.workspaceNode.rootNodes[i] let node = functionLibraryProtocolNode.getProtocolNode(rootNode, removePersonalData, false, true, true, true) if (node) { - stringifyReadyNodes.push(node) + if (node.type !== 'Data Mine') { + stringifyReadyNodes.push(node) + } else { + code = JSON.parse(node.code) + if (includeDataMines.includes(code.codeName) === false) { + stringifyReadyNodes.push(node) + } + } } } let workspace = { diff --git a/CanvasApp/Spaces/ChartingSpace.js b/CanvasApp/Spaces/ChartingSpace.js index dba998962..b120852e0 100644 --- a/CanvasApp/Spaces/ChartingSpace.js +++ b/CanvasApp/Spaces/ChartingSpace.js @@ -41,6 +41,9 @@ function newChartingSpace () { const PERCENTAGE_OF_SCREEN_FOR_DISPLACEMENT = 25 initialSetup() + + let isInitialized = false + return thisObject function reset () { @@ -87,6 +90,8 @@ function newChartingSpace () { } function initialize () { + if (isInitialized === true) { return } + let rootNodes = canvas.designSpace.workspace.workspaceNode.rootNodes for (let i = 0; i < rootNodes.length; i++) { let rootNode = rootNodes[i] @@ -96,7 +101,7 @@ function newChartingSpace () { } if (thisObject.payload === undefined) { - if (ERROR_LOG === true) { logger.write('[WARN] initialize -> There must exist a Charting Space at the Design Space in order to enable Charts. PLease create one and refreash your browser. ') } + // if (ERROR_LOG === true) { logger.write('[WARN] initialize -> There must exist a Charting Space at the Design Space in order to enable Charts. PLease create one and refreash your browser. ') } return } @@ -111,6 +116,8 @@ function newChartingSpace () { thisObject.viewport.initialize() canvasBrowserResizedEventSubscriptionId = canvas.eventHandler.listenToEvent('Browser Resized', resize) + + isInitialized = true } function getContainer (point, purpose) { @@ -263,6 +270,7 @@ function newChartingSpace () { } function physics () { + initialize() thisObjectPhysics() if (thisObject.visible !== true) { return } if (thisObject.viewport !== undefined) { diff --git a/Files-Component/src/FileStorage.js b/Files-Component/src/FileStorage.js index 9a9abd787..bdd833546 100644 --- a/Files-Component/src/FileStorage.js +++ b/Files-Component/src/FileStorage.js @@ -29,11 +29,15 @@ function newFileStorage () { return thisObject - async function getBlobToText (filePath, host, callBackFunction) { + async function getBlobToText (filePath, host, callBackFunction, pathComplete) { try { if (INFO_LOG === true) { logger.write('[INFO] getBlobToText -> Entering function.') } - callServer(undefined, 'Storage/' + filePath, (response, fileContent) => { + let folder = '' + if (pathComplete === false || pathComplete === undefined) { + folder = 'Storage/' + } + callServer(undefined, folder + filePath, (response, fileContent) => { if (response.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, fileContent) } else { diff --git a/WebServer/.env b/WebServer/.env index f7a8d4bc0..cda53b79b 100644 --- a/WebServer/.env +++ b/WebServer/.env @@ -17,6 +17,7 @@ GATEWAY_ENDPOINT=https://demo-api-dev.superalgos.org/graphql INTER_PROCESS_FILES_PATH=../Inter-Process-Files STORAGE_PATH=../Data-Storage PLOTTERS_PATH=../Legacy-Code +DATA_MINES_PATH=../Data-Mines PATH_TO_WEB_SERVER =./ APP_SCHEMA_PATH=../ WORKSPACE_PATH=../ diff --git a/WebServer/server.js b/WebServer/server.js index 6f6e974f0..7a79b70d5 100644 --- a/WebServer/server.js +++ b/WebServer/server.js @@ -464,6 +464,12 @@ function onBrowserRequest (request, response) { } break + case 'DataMines': + { + respondWithFile(process.env.DATA_MINES_PATH + '/' + requestParameters[2] + '.json', response) + } + break + case 'Storage': { respondWithFile(process.env.STORAGE_PATH + '/' + request.url.substring(9), response)