Schemas Multi Project
This commit is contained in:
1 parent
8dba5c1136
commit
272ef96415
11 files changed
+120
-51
No files matched your search
@@ -31,7 +31,7 @@ function newCryptoEcosystemFunctions() {
|
||||
}
|
||||
}
|
||||
|
||||
callServer(JSON.stringify(params), 'CCXT', onResponse)
|
||||
callWebServer(JSON.stringify(params), 'CCXT', onResponse)
|
||||
|
||||
function onResponse(err, data) {
|
||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
@@ -79,7 +79,7 @@ function newCryptoEcosystemFunctions() {
|
||||
exchangeId: exchangeId,
|
||||
method: 'fetchMarkets'
|
||||
}
|
||||
callServer(JSON.stringify(params), 'CCXT', onResponse)
|
||||
callWebServer(JSON.stringify(params), 'CCXT', onResponse)
|
||||
|
||||
function onResponse(err, data) {
|
||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
@@ -155,7 +155,7 @@ function newCryptoEcosystemFunctions() {
|
||||
exchangeId: exchangeId,
|
||||
method: 'fetchMarkets'
|
||||
}
|
||||
callServer(JSON.stringify(params), 'CCXT', onResponse)
|
||||
callWebServer(JSON.stringify(params), 'CCXT', onResponse)
|
||||
|
||||
function onResponse(err, data) {
|
||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
@@ -10,7 +10,7 @@ function newPluginsFunctions() {
|
||||
return thisObject
|
||||
|
||||
function getPluginFileNames(pluginType, callBack) {
|
||||
callServer(undefined, 'PluginFileNames/' + pluginType, onResponse)
|
||||
callWebServer(undefined, 'PluginFileNames/' + pluginType, onResponse)
|
||||
|
||||
function onResponse(err, data) {
|
||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
@@ -145,7 +145,7 @@ function newTaskFunctions() {
|
||||
let networkDefinition = functionLibraryProtocolNode.getProtocolNode(networkNode.payload.parentNode, false, true, true, false, false, networkLightingPath)
|
||||
|
||||
let event = {
|
||||
appSchema: JSON.stringify(APP_SCHEMA_ARRAY),
|
||||
appSchema: JSON.stringify(SCHEMAS_BY_PROJECT.get('Superalgos').array.appSchema),
|
||||
taskId: node.id,
|
||||
taskName: node.name,
|
||||
taskDefinition: JSON.stringify(taskDefinition),
|
||||
|
||||
@@ -9,7 +9,7 @@ function newWebhookFunctions() {
|
||||
let testMessage = loadPropertyFromNodeConfig(node.payload, 'testMessage')
|
||||
let letURL = loadPropertyFromNodeConfig(node.payload, 'webhookURL')
|
||||
|
||||
callServer(testMessage, letURL, onResponse)
|
||||
callWebServer(testMessage, letURL, onResponse)
|
||||
|
||||
function onResponse(err) {
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
@@ -215,7 +215,7 @@ function newWorkspace() {
|
||||
}
|
||||
|
||||
let url = 'SaveWorkspace/' + workspace.name
|
||||
callServer(textToSave, url, onResponse)
|
||||
callWebServer(textToSave, url, onResponse)
|
||||
return true
|
||||
|
||||
function onResponse(err) {
|
||||
|
||||
+2
-7
@@ -1,12 +1,7 @@
|
||||
/* Canvas is the root object that will contain all spaces and everything inside. */
|
||||
let canvas
|
||||
|
||||
let APP_SCHEMA_MAP = new Map()
|
||||
let APP_SCHEMA_ARRAY = []
|
||||
let DOC_SCHEMA_MAP = new Map()
|
||||
let DOC_SCHEMA_ARRAY = []
|
||||
let CONCEPT_SCHEMA_MAP = new Map()
|
||||
let CONCEPT_SCHEMA_ARRAY = []
|
||||
let PROJECTS
|
||||
let SCHEMAS_BY_PROJECT = new Map()
|
||||
|
||||
/* User Interface Colors */
|
||||
const UI_COLOR = {
|
||||
|
||||
+90
-20
@@ -15,33 +15,103 @@ function newPostLoader() {
|
||||
function start() {
|
||||
try {
|
||||
setBrowserEvents()
|
||||
setUpSchemas()
|
||||
setUpProjects(setUpSchemas)
|
||||
|
||||
function setUpProjects(callBack) {
|
||||
let url = 'ProjectNames'
|
||||
callWebServer(undefined, url, onResponse)
|
||||
|
||||
function onResponse(err, projects) {
|
||||
PROJECTS = JSON.parse(projects)
|
||||
callBack()
|
||||
}
|
||||
}
|
||||
|
||||
function setUpSchemas() {
|
||||
APP_SCHEMA_ARRAY = getAppSchema()
|
||||
for (let i = 0; i < APP_SCHEMA_ARRAY.length; i++) {
|
||||
let nodeDefinition = APP_SCHEMA_ARRAY[i]
|
||||
let key = nodeDefinition.type
|
||||
APP_SCHEMA_MAP.set(key, nodeDefinition)
|
||||
|
||||
let totalWebServerCalls = 0
|
||||
let webServerResponses = 0
|
||||
|
||||
for (let i = 0; i < PROJECTS.length; i++) {
|
||||
let project = PROJECTS[i]
|
||||
let schemas = {
|
||||
array: {
|
||||
appSchema: [],
|
||||
docSchema: [],
|
||||
conceptSchema: []
|
||||
},
|
||||
map: {
|
||||
appSchema: new Map(),
|
||||
docSchema: new Map(),
|
||||
conceptSchema: new Map()
|
||||
}
|
||||
}
|
||||
SCHEMAS_BY_PROJECT.set(project, schemas)
|
||||
|
||||
totalWebServerCalls++
|
||||
callWebServer(undefined, 'Schema/' + project + '/AppSchema', onResponseAppSchema)
|
||||
|
||||
function onResponseAppSchema(err, schema) {
|
||||
try {
|
||||
schemas.array.appSchema = JSON.parse(schema)
|
||||
|
||||
for (let j = 0; j < schemas.array.appSchema.length; j++) {
|
||||
let nodeDefinition = schemas.array.appSchema[j]
|
||||
let key = nodeDefinition.type
|
||||
schemas.map.appSchema.set(key, nodeDefinition)
|
||||
}
|
||||
} catch(err) {
|
||||
console.log(err.stack)
|
||||
}
|
||||
|
||||
webServerResponses++
|
||||
if (webServerResponses === totalWebServerCalls) {startCanvas()}
|
||||
}
|
||||
|
||||
totalWebServerCalls++
|
||||
callWebServer(undefined, 'Schema/' + project + '/DocSchema', onResponseDocSchema)
|
||||
|
||||
function onResponseDocSchema(err, schema) {
|
||||
try {
|
||||
schemas.array.docSchema = JSON.parse(schema)
|
||||
|
||||
for (let j = 0; j < schemas.array.docSchema.length; j++) {
|
||||
let nodeDefinition = schemas.array.docSchema[j]
|
||||
let key = nodeDefinition.type
|
||||
schemas.map.docSchema.set(key, nodeDefinition)
|
||||
}
|
||||
} catch(err) {
|
||||
console.log(err.stack)
|
||||
}
|
||||
|
||||
webServerResponses++
|
||||
if (webServerResponses === totalWebServerCalls) {startCanvas()}
|
||||
}
|
||||
|
||||
totalWebServerCalls++
|
||||
callWebServer(undefined, 'Schema/' + project + '/ConceptSchema', onResponseConceptSchema)
|
||||
|
||||
function onResponseConceptSchema(err, schema) {
|
||||
try {
|
||||
schemas.array.conceptSchema = JSON.parse(schema)
|
||||
|
||||
for (let j = 0; j < schemas.array.conceptSchema.length; j++) {
|
||||
let nodeDefinition = schemas.array.conceptSchema[j]
|
||||
let key = nodeDefinition.type
|
||||
schemas.map.conceptSchema.set(key, nodeDefinition)
|
||||
}
|
||||
} catch(err) {
|
||||
console.log(err.stack)
|
||||
}
|
||||
|
||||
webServerResponses++
|
||||
if (webServerResponses === totalWebServerCalls) {startCanvas()}
|
||||
}
|
||||
}
|
||||
DOC_SCHEMA_ARRAY = getDocSchema()
|
||||
for (let i = 0; i < DOC_SCHEMA_ARRAY.length; i++) {
|
||||
let nodeDefinition = DOC_SCHEMA_ARRAY[i]
|
||||
let key = nodeDefinition.type
|
||||
DOC_SCHEMA_MAP.set(key, nodeDefinition)
|
||||
}
|
||||
CONCEPT_SCHEMA_ARRAY = getConceptSchema()
|
||||
for (let i = 0; i < CONCEPT_SCHEMA_ARRAY.length; i++) {
|
||||
let nodeDefinition = CONCEPT_SCHEMA_ARRAY[i]
|
||||
let key = nodeDefinition.type
|
||||
CONCEPT_SCHEMA_MAP.set(key, nodeDefinition)
|
||||
}
|
||||
startCanvas()
|
||||
}
|
||||
|
||||
function startCanvas() {
|
||||
/* If this method is executed for a second time, it should finalize the current execution structure */
|
||||
|
||||
if (canvas !== undefined) { canvas.finalize() }
|
||||
|
||||
canvas = newCanvas()
|
||||
|
||||
@@ -90,7 +90,7 @@ function newListView() {
|
||||
function turnOn() {
|
||||
firstVisibleListItem = 1
|
||||
|
||||
callServer(undefined, 'ListWorkspaces', onResponse)
|
||||
callWebServer(undefined, 'ListWorkspaces', onResponse)
|
||||
|
||||
function onResponse(err, text) {
|
||||
if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
+17
-12
@@ -6,7 +6,7 @@ function newDesignSpace() {
|
||||
iconsByProjectAndName: undefined,
|
||||
iconsByProjectAndType: undefined,
|
||||
workspace: undefined,
|
||||
getIconByProjectAndName: getIconByProjectAndName,
|
||||
getIconByProjectAndName: getIconByProjectAndName,
|
||||
getIconByProjectAndType: getIconByProjectAndType,
|
||||
physics: physics,
|
||||
draw: draw,
|
||||
@@ -38,16 +38,21 @@ function newDesignSpace() {
|
||||
|
||||
function buildIconByProjectAndTypeMap() {
|
||||
/* Take types-icons relationships defined at the schema */
|
||||
for (let i = 0; i < APP_SCHEMA_ARRAY.length; i++) {
|
||||
let nodeDefinition = APP_SCHEMA_ARRAY[i]
|
||||
let iconName = nodeDefinition.icon
|
||||
if (iconName === undefined) {
|
||||
iconName = nodeDefinition.type.toLowerCase()
|
||||
iconName = iconName.split(" ").join("-")
|
||||
}
|
||||
let icon = thisObject.getIconByProjectAndName('Superalgos', iconName)
|
||||
if (icon !== undefined) {
|
||||
thisObject.iconsByProjectAndType.set('Superalgos' + '-' + nodeDefinition.type, icon)
|
||||
for (let i = 0; i < PROJECTS.length; i++) {
|
||||
let project = PROJECTS[i]
|
||||
let appSchema = SCHEMAS_BY_PROJECT.get(project).array.appSchema
|
||||
for (let j = 0; j < appSchema.length; j++) {
|
||||
let nodeDefinition = appSchema[j]
|
||||
let iconName = nodeDefinition.icon
|
||||
if (iconName === undefined) {
|
||||
iconName = nodeDefinition.type.toLowerCase()
|
||||
iconName = iconName.split(" ").join("-")
|
||||
}
|
||||
let icon = thisObject.getIconByProjectAndName(project, iconName)
|
||||
if (icon !== undefined) {
|
||||
let key = project + '-' + nodeDefinition.type
|
||||
thisObject.iconsByProjectAndType.set(key, icon)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,7 +60,7 @@ function newDesignSpace() {
|
||||
|
||||
function loadIconCollection(callBack) {
|
||||
|
||||
callServer(undefined, 'IconNames', onResponse)
|
||||
callWebServer(undefined, 'IconNames', onResponse)
|
||||
|
||||
function onResponse(err, data) {
|
||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
@@ -1187,9 +1187,9 @@ function newTutorialSpace() {
|
||||
if (nodeType === undefined) {
|
||||
return resultingText + firstPart
|
||||
}
|
||||
let definitionNode = DOC_SCHEMA_MAP.get(nodeType)
|
||||
let definitionNode = SCHEMAS_BY_PROJECT.get(currentNode.project).map.docSchema.get(nodeType)
|
||||
if (definitionNode === undefined) {
|
||||
definitionNode = CONCEPT_SCHEMA_MAP.get(nodeType)
|
||||
definitionNode = SCHEMAS_BY_PROJECT.get(currentNode.project).map.conceptSchema.get(nodeType)
|
||||
if (definitionNode === undefined) {
|
||||
currentNode.payload.uiObject.setErrorMessage(nodeType + ' not found at Doc Schema or Concept Schema.')
|
||||
return
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
function getNodeDefinition(node) {
|
||||
let key = node.type
|
||||
return APP_SCHEMA_MAP.get(key)
|
||||
return SCHEMAS_BY_PROJECT.get(node.project).map.appSchema.get(node.type)
|
||||
}
|
||||
|
||||
function dynamicDecimals(value, minDecimals) {
|
||||
|
||||
Reference in new issue
Block a user