From 2b4466cdd87b162f13ab98bbb0f3293452755209 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 8 Dec 2020 14:27:02 +0100 Subject: [PATCH] Tooltips multi project --- Projects/Ethereum/Schemas/DocSchema.json | 4 + Projects/Superalgos/Schemas/DocSchema.json | 2 +- .../UI/Spaces/Docs-Space/DocsSpace.js | 96 +++++++++++-------- 3 files changed, 62 insertions(+), 40 deletions(-) diff --git a/Projects/Ethereum/Schemas/DocSchema.json b/Projects/Ethereum/Schemas/DocSchema.json index 32960f8ce..8d8c61318 100644 --- a/Projects/Ethereum/Schemas/DocSchema.json +++ b/Projects/Ethereum/Schemas/DocSchema.json @@ -1,2 +1,6 @@ [ + { + "type": "Ethereum Project", + "definition": "This is the definition for the Ethereum Project." + } ] \ No newline at end of file diff --git a/Projects/Superalgos/Schemas/DocSchema.json b/Projects/Superalgos/Schemas/DocSchema.json index 5ad82aea2..fdfc040f4 100644 --- a/Projects/Superalgos/Schemas/DocSchema.json +++ b/Projects/Superalgos/Schemas/DocSchema.json @@ -754,7 +754,7 @@ }, { "type": "Network Node", - "definition": "A network node represents a machine running Superalgos within a Shapes, on which processes run and data is stored. Do not confuse this with a Template Structure which is similar to a Task Manager but it is not one.", + "definition": "A network node represents a Ethereum Project running Superalgos within a Shapes, on which processes run and data is stored. Do not confuse this with a Template Structure which is similar to a Task Manager but it is not one.", "content": [ "By default, processes are set up to run locally in a network node representing your local machine. However, the system is prepared to run distributed on a network of nodes, or what we call a trading farm.", "You may create unlimited network nodes and map them with different machines on a network. Each machine in the network runs an instance of the Superalgos backend, and you may control the whole network operation from a single machine, or—in general—from any machine in the network running the Superalgos frontend. To learn more about distributed setups, check the trading farms pages.", diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js index 7f9a4b5de..ef3dde925 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js @@ -105,7 +105,7 @@ function newSuperalgosDocSpace() { function addToolTips(node, text) { const TOOL_TIP_HTML = '
NODE_TYPENODE_DEFINITION
' let resultingText = '' - text = tagNodeTypes(text, node.project, node.type) + text = tagNodeTypes(text, node.type) let splittedText = text.split('->') for (let i = 0; i < splittedText.length; i = i + 2) { @@ -114,36 +114,42 @@ function newSuperalgosDocSpace() { if (nodeType === undefined) { return resultingText + firstPart } - let splittedNodeType = nodeType.split('/') - let project - let type - if (splittedNodeType.length > 1) { - project = splittedNodeType[0] - type = splittedNodeType[1] - } else { - project = 'Superalgos' - type = splittedNodeType[0] - } - let definitionNode = SCHEMAS_BY_PROJECT.get(project).map.docSchema.get(type) - if (definitionNode === undefined) { - definitionNode = SCHEMAS_BY_PROJECT.get(project).map.conceptSchema.get(type) - if (definitionNode === undefined) { - node.payload.uiObject.setErrorMessage(type + ' not found at Doc Schema or Concept Schema.') - return + /* + We will search across all DOC and CONCEPT SCHEMAS + */ + let found = false + let definitionNode + + for (let j = 0; j < PROJECTS_ARRAY.length; j++) { + let project = PROJECTS_ARRAY[j] + definitionNode = SCHEMAS_BY_PROJECT.get(project).map.docSchema.get(nodeType) + if (definitionNode !== undefined) { + found = true + break + } + definitionNode = SCHEMAS_BY_PROJECT.get(project).map.conceptSchema.get(nodeType) + if (definitionNode !== undefined) { + found = true + break } } + if (found === false) { + node.payload.uiObject.setErrorMessage(nodeType + ' not found at Doc Schema or Concept Schema of any Project.') + return + } + let definition = definitionNode.definition if (definition === undefined || definition === "") { - resultingText = resultingText + firstPart + type + resultingText = resultingText + firstPart + nodeType } else { - let tooltip = TOOL_TIP_HTML.replace('NODE_TYPE', type).replace('NODE_DEFINITION', definition) + let tooltip = TOOL_TIP_HTML.replace('NODE_TYPE', nodeType).replace('NODE_DEFINITION', definition) resultingText = resultingText + firstPart + tooltip } } return resultingText } - function tagNodeTypes(text, project, excludeNodeType) { + function tagNodeTypes(text, excludeNodeType) { let words = text.split(' ') let taggedText = '' for (let i = 0; i < words.length; i++) { @@ -157,27 +163,39 @@ function newSuperalgosDocSpace() { let cleanPhrase3 = cleanPhrase(phrase3) let cleanPhrase4 = cleanPhrase(phrase4) - if (SCHEMAS_BY_PROJECT.get(project).map.docSchema.get(cleanPhrase4) !== undefined && cleanPhrase4 !== excludeNodeType) { - taggedText = taggedText + phrase4.replace(cleanPhrase4, '->' + cleanPhrase4 + '->') + ' ' - i = i + 3 - continue - } - if (SCHEMAS_BY_PROJECT.get(project).map.docSchema.get(cleanPhrase3) !== undefined && cleanPhrase3 !== excludeNodeType) { - taggedText = taggedText + phrase3.replace(cleanPhrase3, '->' + cleanPhrase3 + '->') + ' ' - i = i + 2 - continue - } - if (SCHEMAS_BY_PROJECT.get(project).map.docSchema.get(cleanPhrase2) !== undefined && cleanPhrase2 !== excludeNodeType) { - taggedText = taggedText + phrase2.replace(cleanPhrase2, '->' + cleanPhrase2 + '->') + ' ' - i = i + 1 - continue - } - if (SCHEMAS_BY_PROJECT.get(project).map.docSchema.get(cleanPhrase1) !== undefined && cleanPhrase1 !== excludeNodeType) { - taggedText = taggedText + phrase1.replace(cleanPhrase1, '->' + cleanPhrase1 + '->') + ' ' - continue + let found = false + + for (let j = 0; j < PROJECTS_ARRAY.length; j++) { + let project = PROJECTS_ARRAY[j] + + if (SCHEMAS_BY_PROJECT.get(project).map.docSchema.get(cleanPhrase4) !== undefined && cleanPhrase4 !== excludeNodeType) { + taggedText = taggedText + phrase4.replace(cleanPhrase4, '->' + cleanPhrase4 + '->') + ' ' + i = i + 3 + found = true + break + } + if (SCHEMAS_BY_PROJECT.get(project).map.docSchema.get(cleanPhrase3) !== undefined && cleanPhrase3 !== excludeNodeType) { + taggedText = taggedText + phrase3.replace(cleanPhrase3, '->' + cleanPhrase3 + '->') + ' ' + i = i + 2 + found = true + break + } + if (SCHEMAS_BY_PROJECT.get(project).map.docSchema.get(cleanPhrase2) !== undefined && cleanPhrase2 !== excludeNodeType) { + taggedText = taggedText + phrase2.replace(cleanPhrase2, '->' + cleanPhrase2 + '->') + ' ' + i = i + 1 + found = true + break + } + if (SCHEMAS_BY_PROJECT.get(project).map.docSchema.get(cleanPhrase1) !== undefined && cleanPhrase1 !== excludeNodeType) { + taggedText = taggedText + phrase1.replace(cleanPhrase1, '->' + cleanPhrase1 + '->') + ' ' + found = true + break + } } - taggedText = taggedText + phrase1 + ' ' + if (found === false) { + taggedText = taggedText + phrase1 + ' ' + } function cleanPhrase(phrase) { return phrase.replace(',', '').replace(';', '').replace('(', '').replace(')', '').replace('-', '').replace('_', '')