diff --git a/Desktop/DesktopApp.js b/Desktop/DesktopApp.js index 71ac1779d..2115de147 100644 --- a/Desktop/DesktopApp.js +++ b/Desktop/DesktopApp.js @@ -15,7 +15,7 @@ exports.newDesktopApp = function newDesktopApp() { /* This is the Web Sockets client that interacts with the Superalgos Network. */ - DK.running.socialGraph = DK.projects.socialTrading.modules.socialTrading.newSocialTradingModulesSocialGraph() + DK.running.socialGraph = DK.projects.socialTrading.modules.socialGraph.newSocialTradingModulesSocialGraph() await DK.running.socialGraph.initialize() /* @@ -23,17 +23,18 @@ exports.newDesktopApp = function newDesktopApp() { */ DK.running.webSocketsClient = SA.projects.network.modules.webSocketsClient.newNetworkModulesWebSocketsClient() await DK.running.webSocketsClient.initialize() + console.log('Desktop App Client Connected to Network Node via Web Sockets ................... Connected to port ' + global.env.NETWORK_WEB_SOCKETS_INTERFACE_PORT) /* These are the Network Interfaces by which the UI interacts with the Desktop App.*/ DK.running.webSocketsInterface = DK.projects.socialTrading.modules.webSocketsInterface.newDesktopModulesWebSocketsInterface() DK.running.webSocketsInterface.initialize() - console.log('Web Sockets Interface ....................................... Listening at port ' + global.env.CLIENT_WEB_SOCKETS_INTERFACE_PORT) + console.log('Desktop App Client Web Sockets Interface ....................................... Listening at port ' + global.env.CLIENT_WEB_SOCKETS_INTERFACE_PORT) DK.running.httpInterface = DK.projects.socialTrading.modules.httpInterface.newDesktopModulesHttpInterface() DK.running.httpInterface.initialize() - console.log('Http Interface .............................................. Listening at port ' + global.env.DESKTOP_HTTP_INTERFACE_PORT) + console.log('Desktop App Client Http Interface .............................................. Listening at port ' + global.env.DESKTOP_HTTP_INTERFACE_PORT) return diff --git a/Desktop/UI/WebApp.js b/Desktop/UI/WebApp.js index 50e4fe172..80e92cca4 100644 --- a/Desktop/UI/WebApp.js +++ b/Desktop/UI/WebApp.js @@ -34,7 +34,7 @@ function newWebApp() { projectInstance.utilities = {} projectInstance.globals = {} projectInstance.functionLibraries = {} - + projectInstance.modules = {} if (projectDefinition.UI === undefined) { continue } @@ -64,6 +64,15 @@ function newWebApp() { projectInstance.functionLibraries[functionLibraryDefinition.propertyName] = eval(functionLibraryDefinition.functionName + '()') } } + + /* Set up Modules of this Project */ + if (projectDefinition.UI.modules !== undefined) { + for (let j = 0; j < projectDefinition.UI.modules.length; j++) { + let functionLibraryDefinition = projectDefinition.UI.modules[j] + + projectInstance.modules[functionLibraryDefinition.propertyName] = eval(functionLibraryDefinition.functionName + '()') + } + } } } @@ -101,7 +110,7 @@ function newWebApp() { console.log(profile) } } - + /* Error Handling */ diff --git a/Desktop/UI/WebAppLoader.js b/Desktop/UI/WebAppLoader.js index e7d5fb02e..b86797e6d 100644 --- a/Desktop/UI/WebAppLoader.js +++ b/Desktop/UI/WebAppLoader.js @@ -74,6 +74,26 @@ function newWebAppLoader() { urlArray.push('Projects' + '/' + project + '/' + 'UI' + '/' + 'Globals' + '/' + fileName) } + modulesArray = modulesArray.concat(urlArray) + modules() + } + } + + function modules() { + let url = 'ListModulesFiles' + httpRequest(undefined, url, onResponse) + + function onResponse(err, fileList) { + let urlArray = [] + let fileArray = JSON.parse(fileList) + for (let i = 0; i < fileArray.length; i++) { + let item = fileArray[i] + + project = item[0] + fileName = item[1] + urlArray.push('Projects' + '/' + project + '/' + 'UI' + '/' + 'Modules' + '/' + fileName) + } + modulesArray = modulesArray.concat(urlArray) downloadIncludedFiles() } diff --git a/Projects/Network/SA/Modules/WebSocketsClient.js b/Projects/Network/SA/Modules/WebSocketsClient.js index 5c4556fc5..7385b5cd7 100644 --- a/Projects/Network/SA/Modules/WebSocketsClient.js +++ b/Projects/Network/SA/Modules/WebSocketsClient.js @@ -185,7 +185,6 @@ exports.newNetworkModulesWebSocketsClient = function newNetworkModulesWebSockets reject() return } - console.log('[INFO] Web Sockets Client -> stepTwoResponse -> response.message = ' + response.message) /* This was the end of the Handshake producere. We are connected to the Network Node and from now on, all response messages will be received diff --git a/Projects/Social-Trading/DK/modules/SocialGraph.js b/Projects/Social-Trading/DK/modules/SocialGraph.js index d451f6179..1b67a534a 100644 --- a/Projects/Social-Trading/DK/modules/SocialGraph.js +++ b/Projects/Social-Trading/DK/modules/SocialGraph.js @@ -8,7 +8,6 @@ exports.newSocialTradingModulesSocialGraph = function newSocialTradingModulesSoc as in the Network Node. */ let thisObject = { - messageReceived: messageReceived, initialize: initialize, finalize: finalize } diff --git a/Projects/Social-Trading/DK/modules/WebSocketsInterface.js b/Projects/Social-Trading/DK/modules/WebSocketsInterface.js index 0aa2f381b..dd2cd723c 100644 --- a/Projects/Social-Trading/DK/modules/WebSocketsInterface.js +++ b/Projects/Social-Trading/DK/modules/WebSocketsInterface.js @@ -33,15 +33,15 @@ exports.newDesktopModulesWebSocketsInterface = function newDesktopModulesWebSock socketServer.on('connection', onConnectionOpened) function onConnectionOpened(socket) - - if (webApp !== undefined) { - console.log('[ERROR] Only one websockets client allowed.') - return - } /* This function is executed every time a new Websockets connection is stablished. */ { + if (webApp !== undefined) { + console.log('[ERROR] Only one websockets client allowed.') + return + } + webApp = { socket: socket } @@ -79,9 +79,9 @@ exports.newDesktopModulesWebSocketsInterface = function newDesktopModulesWebSock } catch (err) { console.log('[ERROR] Web Sockets Interface -> setUpWebSocketServer -> err.stack = ' + err.stack) } + } - function sendToWebApp(message) { - webApp.socket.send(JSON.stringify(message)) - } + function sendToWebApp(message) { + webApp.socket.send(JSON.stringify(message)) } } \ No newline at end of file diff --git a/Projects/Social-Trading/DK/modules/httpInterface.js b/Projects/Social-Trading/DK/modules/httpInterface.js index 1959bf289..c5526164e 100644 --- a/Projects/Social-Trading/DK/modules/httpInterface.js +++ b/Projects/Social-Trading/DK/modules/httpInterface.js @@ -61,6 +61,11 @@ exports.newDesktopModulesHttpInterface = function newDesktopModulesHttpInterface SA.projects.foundations.utilities.httpResponses.respondWithProjectFolderFileList(httpResponse, 'Globals', 'UI') } break + case 'ListModulesFiles': + { + SA.projects.foundations.utilities.httpResponses.respondWithProjectFolderFileList(httpResponse, 'Modules', 'UI') + } + break case 'Projects': { let path = '' diff --git a/Projects/Social-Trading/UI/modules/WebSocketsClient.js b/Projects/Social-Trading/UI/modules/WebSocketsClient.js index 40eef9917..ffa070c31 100644 --- a/Projects/Social-Trading/UI/modules/WebSocketsClient.js +++ b/Projects/Social-Trading/UI/modules/WebSocketsClient.js @@ -1,4 +1,4 @@ -exports.newSocialTradingModulesWebSocketsClient = function newSocialTradingModulesWebSocketsClient() { +function newSocialTradingModulesWebSocketsClient() { let thisObject = { sendMessage: sendMessage, diff --git a/desktop.js b/desktop.js index ced762c1a..3fe46bcf2 100644 --- a/desktop.js +++ b/desktop.js @@ -60,7 +60,10 @@ DK.TEST_NETWORK_CLIENT_USER_PROFILE_ID = "baa2f02c-2920-4edb-a103-d452fc61d82f" DK.TEST_NETWORK_CLIENT_USER_PROFILE_HANDLE = "Test-Network-Client-Profile" DK.TEST_NETWORK_CLIENT_USER_PROFILE_PRIVATE_KEY = "0x5fed4817a87431c8a328d0936561e63f45b6db289adac6125b9306ded644dfe9" -DK.app = require('./Desktop/DesktopApp.js').newDesktopApp() -DK.app.run() +run() -console.log('Superalgos Desktop is Running.') \ No newline at end of file +async function run() { + DK.app = require('./Desktop/DesktopApp.js').newDesktopApp() + await DK.app.run() + console.log('Superalgos Desktop App is Running.') +}