Merge remote-tracking branch 'Superalgos/develop' into develop
This commit is contained in:
commit
de26391096
4 files changed
+14
-236
No files matched your search
@@ -66,9 +66,6 @@
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Scripts\require.js" />
|
||||
<Compile Include="Server\CloudScripts.js">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Server\ConfigReader.js">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
||||
@@ -35,14 +35,8 @@ function newAppLoader() {
|
||||
|
||||
"BottomSpace/DeleteTradingHistory.js",
|
||||
"BottomSpace/ChartAspectRatio.js",
|
||||
"BottomSpace/PlayStopButton.js",
|
||||
|
||||
"TopSpace/CompanyLogo.js",
|
||||
"TopSpace/CurrentEvent.js",
|
||||
"TopSpace/CurrentStartMode.js",
|
||||
"TopSpace/CurrentProcess.js",
|
||||
"TopSpace/CurrentBot.js",
|
||||
"TopSpace/DevTeam.js",
|
||||
"TopSpace/EndUser.js",
|
||||
"TopSpace/Login.js",
|
||||
|
||||
@@ -72,11 +66,6 @@ function newAppLoader() {
|
||||
|
||||
"Exchange/ExchangeAPI.js",
|
||||
|
||||
"CloudAppWrapper/CloudSupport.js",
|
||||
"CloudAppWrapper/CloudRequire.js",
|
||||
"CloudAppWrapper/WebFS.js",
|
||||
"CloudAppWrapper/BrowserRun.js",
|
||||
|
||||
"Scales/ChartGrid.js",
|
||||
"Scales/RightScale.js",
|
||||
|
||||
|
||||
@@ -1,172 +0,0 @@
|
||||
exports.newCloudScripts = function newCloudScripts() {
|
||||
|
||||
let thisObject = {
|
||||
loadCloudScripts: loadCloudScripts,
|
||||
initialize: initialize
|
||||
}
|
||||
|
||||
const GITHUB = require('../Server/Github');
|
||||
let github = GITHUB.newGithub();
|
||||
|
||||
const STORAGE = require('../Server/Storage');
|
||||
let storage = STORAGE.newStorage();
|
||||
|
||||
let serverConfig;
|
||||
let storageData;
|
||||
let ecosystem;
|
||||
let ecosystemObject;
|
||||
|
||||
return thisObject;
|
||||
|
||||
function initialize(pEcosystem, pEcosystemObject, pServerConfig, pStorageData, callBackFunction) {
|
||||
|
||||
serverConfig = pServerConfig;
|
||||
storageData = pStorageData;
|
||||
ecosystem = pEcosystem;
|
||||
ecosystemObject = pEcosystemObject;
|
||||
|
||||
storage.initialize(storageData, serverConfig);
|
||||
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE);
|
||||
}
|
||||
|
||||
function loadCloudScripts(callBackFunction) {
|
||||
|
||||
try {
|
||||
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] CloudScripts -> loadCloudScripts -> Entering function."); }
|
||||
|
||||
/*
|
||||
|
||||
First we will get a list of the scripts to be loaded, and then we will load them into the cache.
|
||||
|
||||
*/
|
||||
|
||||
storage.readData('AdvancedAlgos', 'AACloud', 'web.config.json', true, onDataArrived);
|
||||
|
||||
function onDataArrived(err, pData) {
|
||||
|
||||
try {
|
||||
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] CloudScripts -> loadCloudScripts -> Cloud -> onDataArrived -> Entering function."); }
|
||||
|
||||
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
console.log("[ERROR] CloudScripts -> loadCloudScripts -> Cloud -> onDataArrived -> Could not read a file. ");
|
||||
console.log("[ERROR] CloudScripts -> loadCloudScripts -> Cloud -> onDataArrived -> err.message = " + err.message);
|
||||
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
return;
|
||||
}
|
||||
|
||||
let data = pData.toString();
|
||||
data = data.trim(); // remove first byte with some encoding.
|
||||
|
||||
dataObject = JSON.parse(data);
|
||||
retrieveScripts(dataObject, callBackFunction);
|
||||
}
|
||||
catch (err) {
|
||||
console.log("[ERROR] CloudScripts -> loadCloudScripts -> Cloud -> onDataArrived -> Error = " + err);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
console.log("[ERROR] CloudScripts -> loadCloudScripts -> Error = " + err);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
||||
function retrieveScripts(pCloudWebConfig, callBackFunction) {
|
||||
|
||||
try {
|
||||
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] CloudScripts -> retrieveScripts -> Entering function."); }
|
||||
|
||||
/*
|
||||
|
||||
Here we go through the webModules Array and bring them all.
|
||||
|
||||
*/
|
||||
|
||||
let modulesRetrieved = 0;
|
||||
|
||||
for (let i = 0; i < pCloudWebConfig.webModules.length; i++) {
|
||||
|
||||
let webModule = pCloudWebConfig.webModules[i].name;
|
||||
|
||||
storage.readData('AdvancedAlgos', 'AACloud', webModule, true, onDataArrived);
|
||||
|
||||
function onDataArrived(err, pData) {
|
||||
|
||||
try {
|
||||
|
||||
if (CONSOLE_LOG === true) { console.log("[INFO] CloudScripts -> retrieveScripts -> Cloud -> onDataArrived -> Entering function."); }
|
||||
|
||||
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
console.log("[ERROR] CloudScripts -> retrieveScripts -> Cloud -> onDataArrived -> Could not read a file. ");
|
||||
console.log("[ERROR] CloudScripts -> retrieveScripts -> Cloud -> onDataArrived -> err.message = " + err.message);
|
||||
console.log("[ERROR] CloudScripts -> retrieveScripts -> Cloud -> onDataArrived -> ewebModule = " + webModule);
|
||||
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
return;
|
||||
}
|
||||
|
||||
let data = pData.toString();
|
||||
data = data.trim(); // remove first byte with some encoding.
|
||||
|
||||
data = browserify(data);
|
||||
|
||||
storageData.set(webModule, data);
|
||||
|
||||
modulesRetrieved++;
|
||||
if (modulesRetrieved === pCloudWebConfig.webModules.length) {
|
||||
createJS(callBackFunction);
|
||||
}
|
||||
|
||||
}
|
||||
catch (err) {
|
||||
console.log("[ERROR] CloudScripts -> retrieveScripts -> Cloud -> onDataArrived -> Error = " + err);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function browserify(pData) {
|
||||
|
||||
let result = pData.substring(pData.indexOf('=') + 2);
|
||||
|
||||
result = replaceAll(result, "require", "webRequire");
|
||||
result = replaceAll(result, "global", "window");
|
||||
|
||||
return result;
|
||||
|
||||
function replaceAll(text, search, replacement) {
|
||||
return text.replace(new RegExp(search, 'g'), replacement);
|
||||
}
|
||||
}
|
||||
|
||||
function createJS(callBackFunction) {
|
||||
|
||||
let lines = "";
|
||||
let jsLine = '' + '\n' + ' "AACloud/@module@",'
|
||||
|
||||
for (let i = 0; i < pCloudWebConfig.webModules.length; i++) {
|
||||
|
||||
let webModule = pCloudWebConfig.webModules[i].name;
|
||||
let htmlLineCopy = jsLine;
|
||||
let newLink = htmlLineCopy.replace('@module@', webModule);
|
||||
|
||||
lines = lines + newLink;
|
||||
}
|
||||
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE, lines);
|
||||
}
|
||||
|
||||
}
|
||||
catch (err) {
|
||||
console.log("[ERROR] CloudScripts -> retrieveScripts -> Error = " + err);
|
||||
callBackFunction(global.DEFAULT_FAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,6 @@ global.CUSTOM_FAIL_RESPONSE = {
|
||||
|
||||
let storageData = new Map()
|
||||
|
||||
let HTMLCloudScripts // This are the html script tags needed to download the cloud web scripts.
|
||||
let botScripts // This module is the one which grabs user bots scrips from the storage, and browserifys them.
|
||||
|
||||
let ecosystem
|
||||
@@ -95,54 +94,29 @@ function initialize () {
|
||||
|
||||
storage.initialize(storageData, serverConfig)
|
||||
|
||||
const CLOUD_SCRIPTS = require('./Server/CloudScripts')
|
||||
let cloudScripts = CLOUD_SCRIPTS.newCloudScripts()
|
||||
const SESSION_MANAGER = require('./Server/SessionManager')
|
||||
sessionManager = SESSION_MANAGER.newSessionManager()
|
||||
|
||||
cloudScripts.initialize(ecosystem, ecosystemObject, serverConfig, storageData, onInitialized)
|
||||
sessionManager.initialize(serverConfig, onInitialized)
|
||||
|
||||
function onInitialized (err) {
|
||||
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
|
||||
console.log('[ERROR] server -> initialize -> onInitialized -> onConfigsLoaded -> onInitialized -> err.message = ' + err.message)
|
||||
console.log('[ERROR] server -> initialize -> onInitialized -> onConfigsLoaded -> onInitialized -> Terminating Execution. ')
|
||||
function onInitialized () {
|
||||
const STORAGE_ACCESS_MANAGER = require('./Server/StorageAccessManager')
|
||||
storageAccessManager = STORAGE_ACCESS_MANAGER.newStorageAccessManager()
|
||||
|
||||
return
|
||||
}
|
||||
storageAccessManager.initialize(serverConfig, onInitialized)
|
||||
|
||||
cloudScripts.loadCloudScripts(onLoadCompeted)
|
||||
function onInitialized () {
|
||||
const BOT_SCRIPTS = require('./Server/BotsScripts')
|
||||
botScripts = BOT_SCRIPTS.newBotScripts()
|
||||
|
||||
function onLoadCompeted (err, pHTMLCloudScripts) {
|
||||
if (err.result !== global.DEFAULT_OK_RESPONSE.result) {
|
||||
console.log('[ERROR] server -> initialize -> onInitialized -> onConfigsLoaded -> onInitialized -> onLoadCompeted -> err.message = ' + err.message)
|
||||
console.log('[ERROR] server -> initialize -> onInitialized -> onConfigsLoaded -> onInitialized -> onLoadCompeted -> Terminating Execution. ')
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
const SESSION_MANAGER = require('./Server/SessionManager')
|
||||
sessionManager = SESSION_MANAGER.newSessionManager()
|
||||
|
||||
sessionManager.initialize(serverConfig, onInitialized)
|
||||
|
||||
function onInitialized () {
|
||||
const STORAGE_ACCESS_MANAGER = require('./Server/StorageAccessManager')
|
||||
storageAccessManager = STORAGE_ACCESS_MANAGER.newStorageAccessManager()
|
||||
|
||||
storageAccessManager.initialize(serverConfig, onInitialized)
|
||||
botScripts.initialize(serverConfig, onInitialized)
|
||||
|
||||
function onInitialized () {
|
||||
const BOT_SCRIPTS = require('./Server/BotsScripts')
|
||||
botScripts = BOT_SCRIPTS.newBotScripts()
|
||||
|
||||
botScripts.initialize(serverConfig, onInitialized)
|
||||
|
||||
function onInitialized () {
|
||||
HTMLCloudScripts = pHTMLCloudScripts
|
||||
startHtttpServer()
|
||||
}
|
||||
startHtttpServer()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -618,18 +592,8 @@ function onBrowserRequest (request, response) {
|
||||
try {
|
||||
let fileContent = file.toString()
|
||||
|
||||
addCloudWebScripts()
|
||||
addPlotters()
|
||||
|
||||
function addCloudWebScripts () {
|
||||
if (CONSOLE_LOG === true) { console.log('[INFO] server -> onBrowserRequest -> onFileRead -> addCloudWebScripts -> Entering function.') }
|
||||
|
||||
let firstPart = fileContent.substring(0, fileContent.indexOf('/* CloudWebScripts */') + 21)
|
||||
let secondPart = fileContent.substring(fileContent.indexOf('/* CloudWebScripts */') + 21)
|
||||
|
||||
fileContent = firstPart + HTMLCloudScripts + secondPart
|
||||
}
|
||||
|
||||
function addPlotters () {
|
||||
if (CONSOLE_LOG === true) { console.log('[INFO] server -> onBrowserRequest -> onFileRead -> addPlotters -> Entering function.') }
|
||||
|
||||
|
||||
Reference in new issue
Block a user