diff --git a/Projects/Foundations/UI/Function-Libraries/PluginsFunctions.js b/Projects/Foundations/UI/Function-Libraries/PluginsFunctions.js index e59549499..dabbe14b7 100644 --- a/Projects/Foundations/UI/Function-Libraries/PluginsFunctions.js +++ b/Projects/Foundations/UI/Function-Libraries/PluginsFunctions.js @@ -61,12 +61,8 @@ function newFoundationsFunctionLibraryPluginsFunctions() { for (let i = 0; i < projectDefinition.plugins.length; i++) { let pluginType = "Plugin" + " " + projectDefinition.plugins[i] - if (UI.projects.foundations.utilities.children.isMissingChildrenByName(node, pluginType) === true) { - let child = UI.projects.foundations.functionLibraries.uiObjectsFromNodes.addUIObject(node, 'Plugin Project') - child.name = project - let config = JSON.parse(child.config) - config.codeName = project - child.config = JSON.stringify(config) + if (UI.projects.foundations.utilities.children.isMissingChildrenByType(node, pluginType) === true) { + UI.projects.foundations.functionLibraries.uiObjectsFromNodes.addUIObject(node, pluginType) } } } diff --git a/Projects/Governance/Schemas/App-Schema/plugin-user-profiles.json b/Projects/Governance/Schemas/App-Schema/plugin-user-profiles.json new file mode 100644 index 000000000..8599d57c8 --- /dev/null +++ b/Projects/Governance/Schemas/App-Schema/plugin-user-profiles.json @@ -0,0 +1,37 @@ +{ + "type": "Plugin Data Mines", + "menuItems": [ + { + "action": "Add Missing Plugin Data Mines", + "label": "Add Missing Data Mines", + "askConfirmation": true, + "confirmationLabel": "Confirm to Proceed", + "workDoneLabel": "Done", + "relatedUiObject": "Data Mine", + "actionFunction": "payload.executeAction" + }, + { + "action": "Delete UI Object", + "askConfirmation": true, + "confirmationLabel": "Confirm to Delete", + "label": "Delete", + "iconPathOn": "delete-entity", + "iconPathOff": "delete-entity", + "actionFunction": "payload.executeAction" + } + ], + "addLeftIcons": true, + "level": 1, + "propertyNameAtParent": "pluginDataMines", + "attachingRules": { + "compatibleTypes": "->Plugin Project->" + }, + "childrenNodesProperties": [ + { + "name": "pluginFiles", + "type": "array", + "childType": "Plugin File", + "autoAdd": false + } + ] +} \ No newline at end of file diff --git a/Projects/Governance/UI/Function-Libraries/PluginsFunctions.js b/Projects/Governance/UI/Function-Libraries/PluginsFunctions.js new file mode 100644 index 000000000..03112b13f --- /dev/null +++ b/Projects/Governance/UI/Function-Libraries/PluginsFunctions.js @@ -0,0 +1,202 @@ +function newGovernanceFunctionLibraryPluginsFunctions() { + let thisObject = { + addMissingPluginDataMines: addMissingPluginDataMines, + addMissingPluginTradingMines: addMissingPluginTradingMines, + addMissingPluginTradingSystems: addMissingPluginTradingSystems, + addMissingPluginTradingEngines: addMissingPluginTradingEngines, + addMissingPluginLearningMines: addMissingPluginLearningMines, + addMissingPluginLearningSystems: addMissingPluginLearningSystems, + addMissingPluginLearningEngines: addMissingPluginLearningEngines, + addMissingPluginTutorials: addMissingPluginTutorials, + addMissingPluginApiMaps: addMissingPluginApiMaps + } + return thisObject + + function getPluginFileNames(projectName, pluginType, callBack) { + httpRequest(undefined, 'PluginFileNames/' + projectName + '/' + pluginType, onResponse) + + function onResponse(err, data) { + if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) { + console.log('Failed to Fetch Plugin ' + pluginType + ' from the Client') + return + } + + let pluginFileNames = JSON.parse(data) + callBack(pluginFileNames) + } + } + + function addPluginFileIfNeeded(node, fileNames) { + for (let i = 0; i < fileNames.length; i++) { + let fileName = fileNames[i] + fileName = fileName.replace('.json', '') + if (UI.projects.foundations.utilities.children.isMissingChildrenByName(node, fileName) === true) { + let child = UI.projects.foundations.functionLibraries.uiObjectsFromNodes.addUIObject(node, 'Plugin File') + child.name = fileName + } + } + } + + function getProjectName(node) { + /* Validations to see if we can do this or not. */ + if (node.payload === undefined) { return } + if (node.payload.uiObject === undefined) { return } + + if (node.payload.parentNode === undefined) { + node.payload.uiObject.setErrorMessage('You need to have a Plugin Project node as a parent to execute this action.') + return + } + if (node.payload.parentNode.payload === undefined) { + node.payload.uiObject.setErrorMessage('You need to have a Plugin Project node as a parent to execute this action.') + return + } + let pluginProject = node.payload.parentNode + let config = JSON.parse(pluginProject.config) + + return config.codeName + } + + function addMissingPluginDataMines(node, rootNodes) { + let projectName = getProjectName(node) + if (projectName === "" || projectName === undefined) { + if (node.payload.parentNode !== undefined) { + node.payload.parentNode.payload.uiObject.setErrorMessage("Config codeName must have the name of the project.") + return + } + } + + getPluginFileNames(projectName, 'Data-Mines', onNamesArrived) + + function onNamesArrived(fileNames) { + addPluginFileIfNeeded(node, fileNames) + } + } + + function addMissingPluginTradingMines(node, rootNodes) { + let projectName = getProjectName(node) + if (projectName === "" || projectName === undefined) { + if (node.payload.parentNode !== undefined) { + node.payload.parentNode.payload.uiObject.setErrorMessage("Config codeName must have the name of the project.") + return + } + } + + getPluginFileNames(projectName, 'Trading-Mines', onNamesArrived) + + function onNamesArrived(fileNames) { + addPluginFileIfNeeded(node, fileNames) + } + } + + function addMissingPluginTradingSystems(node, rootNodes) { + let projectName = getProjectName(node) + if (projectName === "" || projectName === undefined) { + if (node.payload.parentNode !== undefined) { + node.payload.parentNode.payload.uiObject.setErrorMessage("Config codeName must have the name of the project.") + return + } + } + + getPluginFileNames(projectName, 'Trading-Systems', onNamesArrived) + + function onNamesArrived(fileNames) { + addPluginFileIfNeeded(node, fileNames) + } + } + + function addMissingPluginTradingEngines(node, rootNodes) { + let projectName = getProjectName(node) + if (projectName === "" || projectName === undefined) { + if (node.payload.parentNode !== undefined) { + node.payload.parentNode.payload.uiObject.setErrorMessage("Config codeName must have the name of the project.") + return + } + } + + getPluginFileNames(projectName, 'Trading-Engines', onNamesArrived) + + function onNamesArrived(fileNames) { + addPluginFileIfNeeded(node, fileNames) + } + } + + function addMissingPluginLearningMines(node, rootNodes) { + let projectName = getProjectName(node) + if (projectName === "" || projectName === undefined) { + if (node.payload.parentNode !== undefined) { + node.payload.parentNode.payload.uiObject.setErrorMessage("Config codeName must have the name of the project.") + return + } + } + + getPluginFileNames(projectName, 'Learning-Mines', onNamesArrived) + + function onNamesArrived(fileNames) { + addPluginFileIfNeeded(node, fileNames) + } + } + + function addMissingPluginLearningSystems(node, rootNodes) { + let projectName = getProjectName(node) + if (projectName === "" || projectName === undefined) { + if (node.payload.parentNode !== undefined) { + node.payload.parentNode.payload.uiObject.setErrorMessage("Config codeName must have the name of the project.") + return + } + } + + getPluginFileNames(projectName, 'Learning-Systems', onNamesArrived) + + function onNamesArrived(fileNames) { + addPluginFileIfNeeded(node, fileNames) + } + } + + function addMissingPluginLearningEngines(node, rootNodes) { + let projectName = getProjectName(node) + if (projectName === "" || projectName === undefined) { + if (node.payload.parentNode !== undefined) { + node.payload.parentNode.payload.uiObject.setErrorMessage("Config codeName must have the name of the project.") + return + } + } + + getPluginFileNames(projectName, 'Learning-Engines', onNamesArrived) + + function onNamesArrived(fileNames) { + addPluginFileIfNeeded(node, fileNames) + } + } + + function addMissingPluginTutorials(node, rootNodes) { + let projectName = getProjectName(node) + if (projectName === "" || projectName === undefined) { + if (node.payload.parentNode !== undefined) { + node.payload.parentNode.payload.uiObject.setErrorMessage("Config codeName must have the name of the project.") + return + } + } + + getPluginFileNames(projectName, 'Tutorials', onNamesArrived) + + function onNamesArrived(fileNames) { + addPluginFileIfNeeded(node, fileNames) + } + } + + function addMissingPluginApiMaps(node, rootNodes) { + let projectName = getProjectName(node) + if (projectName === "" || projectName === undefined) { + if (node.payload.parentNode !== undefined) { + node.payload.parentNode.payload.uiObject.setErrorMessage("Config codeName must have the name of the project.") + return + } + } + + getPluginFileNames(projectName, 'API-Maps', onNamesArrived) + + function onNamesArrived(fileNames) { + addPluginFileIfNeeded(node, fileNames) + } + } +} diff --git a/Projects/ProjectsSchema.json b/Projects/ProjectsSchema.json index 85e481da7..16c2073c1 100644 --- a/Projects/ProjectsSchema.json +++ b/Projects/ProjectsSchema.json @@ -982,6 +982,11 @@ "name": "Distribution Process", "propertyName": "distributionProcess", "functionName": "newGovernanceFunctionLibraryDistributionProcess" + }, + { + "name": "Plugins Functions", + "propertyName": "pluginsFunctions", + "functionName": "newGovernanceFunctionLibraryPluginsFunctions" } ], "utilities": [],