Change WebAppPreLoader

Test and refactor
Updated own user-profile
This commit is contained in:
Axel committed 2021-11-29 21:44:46 -03:00
1 parent 7ed3876d19
commit c52629cda2
9 files changed
+220 -290

No files matched your search

+3 -1
View File
@@ -73,10 +73,12 @@ exports.newDesktopApp = function newDesktopApp() {
/* TODO refactor this into something better */
let preloader = require('./UI/WebAppPreLoader');
require('./UI/WebAppPreLoader').loadSuperalgos();
/* let react = require('./scripts/start');
react.start(JSON.parse(DK.desktopApp.p2pNetworkClient.node.config).webPort);*/
/* thisObject.httpInterface = DK.projects.socialTrading.modules.httpInterface.newDesktopModulesHttpInterface()
thisObject.httpInterface.initialize()*/
console.log('Desktop Client Http Interface ................................................ Listening at port ' + JSON.parse(DK.desktopApp.p2pNetworkClient.node.config).webPort)
+23 -29
View File
@@ -1,34 +1,29 @@
function newWebAppLoader() {
exports.newWebAppLoader = (UI) => {
let thisObject = {
loadModules: loadModules
}
try {
let modulesArray = [
'WebDebugLog.js',
'WebApp.js'
]
return thisObject
for (let i = 0; i < UI.schemas.projectSchema.length; i++) {
let project = UI.schemas.projectSchema[i]
async function loadModules() {
try {
let modulesArray = [
'WebDebugLog.js',
'WebApp.js'
]
for (let i = 0; i < UI.schemas.projectSchema.length; i++) {
let project = UI.schemas.projectSchema[i]
if (project.UI !== undefined) {
if (project.UI.functionLibraries !== undefined) {
for (let j = 0; j < project.UI.functionLibraries.length; j++) {
let fileName = project.UI.functionLibraries[j].fileName
if (fileName === undefined) {fileName = project.UI.functionLibraries[j].name.replaceAll(' ', '') + '.js'}
modulesArray.push('Projects' + '/' + project.name + '/' + 'UI' + '/' + 'Function-Libraries' + '/' + fileName)
if (project.UI !== undefined) {
if (project.UI.functionLibraries !== undefined) {
for (let j = 0; j < project.UI.functionLibraries.length; j++) {
let fileName = project.UI.functionLibraries[j].fileName
if (fileName === undefined) {
fileName = project.UI.functionLibraries[j].name.replaceAll(' ', '') + '.js'
}
modulesArray.push('Projects' + '/' + project.name + '/' + 'UI' + '/' + 'Function-Libraries' + '/' + fileName)
}
if (project.UI.utilities !== undefined) {
for (let j = 0; j < project.UI.utilities.length; j++) {
let fileName = project.UI.utilities[j].fileName
if (fileName === undefined) {fileName = project.UI.utilities[j].name.replaceAll(' ', '') + '.js'}
}
if (project.UI.utilities !== undefined) {
for (let j = 0; j < project.UI.utilities.length; j++) {
let fileName = project.UI.utilities[j].fileName
if (fileName === undefined) {fileName = project.UI.utilities[j].name.replaceAll(' ', '') + '.js'}
modulesArray.push('Projects' + '/' + project.name + '/' + 'UI' + '/' + 'Utilities' + '/' + fileName)
}
}
@@ -109,10 +104,9 @@ function newWebAppLoader() {
}
}
}
} catch (err) {
console.log('[ERROR] loadModules -> err = ' + err.stack)
}
} catch (err) {
console.log('[ERROR] loadModules -> err = ' + err.stack)
}
}
+19 -89
View File
@@ -1,103 +1,33 @@
loadSuperalgos();
function loadSuperalgos() {
/*
let browser = checkBrowserVersion()
if ((browser.name !== "Chrome" && browser.name !== "Safari") || (browser.name === "Chrome" && parseInt(browser.version) < 85) || (browser.name === "Safari" && parseInt(browser.version) < 13)) {
alert("Superalgos is officially supported on Google Chrome 85 or Safari 13.1 and above. Your browser version has been detected as potentially beneath this. If you continue you may experience some functionality issues.\n\nDetected Browser: " + browser.name + "\nVersion: " + browser.version)
}
*/
exports.loadSuperalgos = () => {
loadGlobals()
function loadGlobals() {
let globals = require('./Globals');
globals.UI.environment = require('../../Environment')
setupClientNode()
let {UI} = require('./Globals');
setupEnvironment(UI);
}
function setupClientNode() {
httpRequest(undefined, 'ClientNode', onResponse)
function onResponse(err, file) {
UI.clientNode = JSON.parse(file)
setupProjectsSchema()
}
function setupEnvironment(UI) {
let ENVIRONMENT = require('../../Environment');
UI.environment = ENVIRONMENT.newEnvironment();
setupClientNode(UI);
}
function setupProjectsSchema() {
httpRequest(undefined, 'ProjectsSchema', onResponse)
function onResponse(err, file) {
UI.schemas.projectSchema = JSON.parse(file)
loadModules()
}
function setupClientNode(UI) {
UI.clientNode = DK.desktopApp.p2pNetworkClient.node;
setupProjectsSchema(UI);
}
function loadModules() {
let path = "WebAppLoader.js"
REQUIREJS([path], onRequired)
function onRequired(pModule) {
let APP_LOADER_MODULE = newWebAppLoader()
APP_LOADER_MODULE.loadModules()
}
}
}
function httpRequest(pContentToSend, pPath, callBackFunction) {
let xmlHttpRequest = new XMLHttpRequest()
xmlHttpRequest.onreadystatechange = function () {
if (this.readyState === 4 && this.status === 200) {
try {
callBackFunction(undefined, xmlHttpRequest.responseText)
} catch (err) {
console.log('[ERROR] httpRequest -> httpRequest -> err.stack = ' + err.stack)
console.log('[ERROR] httpRequest -> httpRequest -> pContentToSend = ' + pContentToSend)
console.log('[ERROR] httpRequest -> httpRequest -> pPath = ' + pPath)
console.log('[ERROR] httpRequest -> httpRequest -> xmlHttpRequest.responseText = ' + xmlHttpRequest.responseText)
console.log('[ERROR] httpRequest -> httpRequest -> callBackFunction = ' + callBackFunction)
}
return
} else if (this.readyState === 4 && this.status === 404) {
callBackFunction({ result: "Fail", message: xmlHttpRequest.responseText.trim(), code: xmlHttpRequest.responseText.trim() })
return
}
function setupProjectsSchema(UI) {
UI.schemas.projectSchema = require('../../Projects/ProjectsSchema.json');
loadModules(UI)
}
if (pContentToSend === undefined) {
xmlHttpRequest.open("GET", pPath, true)
xmlHttpRequest.send()
} else {
try {
let blob = new Blob([pContentToSend], { type: 'text/plain' })
xmlHttpRequest.open("POST", pPath, true)
xmlHttpRequest.send(blob)
} catch (err) {
if (ERROR_LOG === true) { console.log("[ERROR] callServer -> err.message = " + err.message) }
callBackFunction({ result: "Fail", message: err.message })
}
}
}
function loadModules(UI) {
let react = require('../scripts/start');
react.start(JSON.parse(DK.desktopApp.p2pNetworkClient.node.config).webPort);
function checkBrowserVersion() {
let ua = navigator.userAgent, tem, M = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []
if (/trident/i.test(M[1])) {
tem = /\brv[ :]+(\d+)/g.exec(ua) || []
return { name: 'IE', version: (tem[1] || '') }
/* let APP_LOADER_MODULE = require('./WebAppLoader');
APP_LOADER_MODULE.newWebAppLoader(UI);*/
}
if (M[1] === 'Chrome') {
tem = ua.match(/\bOPR|Edge\/(\d+)/)
if (tem != null) { return { name: 'Opera', version: tem[1] } }
}
M = M[2] ? [M[1], M[2]] : [navigator.appName, navigator.appVersion, '-?']
if ((tem = ua.match(/version\/(\d+)/i)) != null) { M.splice(1, 1, tem[1]) }
return {
name: M[0],
version: M[1]
}
}
}
+5 -8
View File
@@ -22,7 +22,7 @@ const publicUrlOrPath = getPublicUrlOrPath(
process.env.PUBLIC_URL
);
const buildPath = process.env.BUILD_PATH || 'build';
const buildPath = process.env.BUILD_PATH || 'Desktop/build';
const moduleFileExtensions = [
'web.mjs',
@@ -52,7 +52,6 @@ const resolveModule = (resolveFn, filePath) => {
};
// config after eject: we're in ./config/
/* TODO check which is the correct path*/
module.exports = {
dotenv: resolveApp('.env'),
appPath: resolveApp('.'),
@@ -62,13 +61,11 @@ module.exports = {
appIndexJs: resolveModule(resolveApp, 'Desktop/src/index'),
appPackageJson: resolveApp('package.json'),
appSrc: resolveApp('Desktop/src'),
appTsConfig: resolveApp('tsconfig.json'),
appJsConfig: resolveApp('jsconfig.json'),
yarnLockFile: resolveApp('yarn.lock'),
testsSetup: resolveModule(resolveApp, 'Desktop/src/setupTests'),
proxySetup: resolveApp('Desktop/src/setupProxy.js'),
appNodeModules: resolveApp('node_modules'),
swSrc: resolveModule(resolveApp, 'Desktop/src/service-worker'),
globals: resolveApp('Desktop/UI/Globals'),
projects: resolveApp('Projects'),
environment: resolveApp('Environments'),
schema: resolveApp('Projects/ProjectsSchema'),
publicUrlOrPath,
};
+11 -14
View File
@@ -1,19 +1,21 @@
import './index.css';
import React from 'react';
import ReactDOM from 'react-dom';
import reportWebVitals from './reportWebVitals';
// import {SA, UI} from '../UI/Globals';
// import {loadSuperalgos} from '../UI/WebAppPreLoader'
import {Provider} from "react-redux";
import reducers from "./store";
import Root from "./components/Root";
// const store = createStore(reducers);
// loadSuperalgos();
// console.log(UI);
// console.log(SA);
/*
TODO save
exports.UI = {
projects: {},
schemas: { projectSchema: undefined },
environment: undefined,
clientNode: undefined,
webApp: undefined
}
exports.SA = { projects: {} }
*/
ReactDOM.render(
<React.StrictMode>
@@ -23,8 +25,3 @@ ReactDOM.render(
</React.StrictMode>,
document.getElementById('root')
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
+1 -1
View File
@@ -1,6 +1,6 @@
import { configureStore } from '@reduxjs/toolkit';
import ExampleReducer from './slices/Example.slice'
import ExampleReducer from './slices/Globals'
export default configureStore({
reducer:{
-21
View File
@@ -1,21 +0,0 @@
import { createSlice } from '@reduxjs/toolkit'
export const ExampleSlice = createSlice({
name: 'example',
initialState: {
exampleName:'',
token:''
},
reducers: {
exampleAction: (state, action) => {
state.userName = action.payload;
},
},
})
// Action creators are generated for each case reducer function
export const { exampleAction } = ExampleSlice.actions
export default ExampleSlice.reducer
+27
View File
@@ -0,0 +1,27 @@
import {createSlice} from '@reduxjs/toolkit'
export const Globals = createSlice({
name: 'globals',
initialState: {
UI: {
projects: {},
schemas: {projectSchema: undefined},
environment: undefined,
clientNode: undefined,
webApp: undefined
},
SA: {projects: {}}
},
reducers: {
exampleAction: (state, action) => {
state.userName = action.payload;
},
},
})
// Action creators are generated for each case reducer function
export const {exampleAction} = Globals.actions
export default Globals.reducer
@@ -12,12 +12,12 @@
"id": "f439a686-0607-469f-936f-60f0f672d975",
"savedPayload": {
"position": {
"x": 8370.804674504796,
"y": 11356.132034355964
"x": 37287.867965644036,
"y": 19012.132034355964
},
"targetPosition": {
"x": 8582.93670886076,
"y": 11144
"x": 37500,
"y": 18800
},
"floatingObject": {
"isPinned": false,
@@ -39,12 +39,12 @@
"id": "f3c83ef5-fd88-4db5-85b9-2496f483c98e",
"savedPayload": {
"position": {
"x": 8293.158960974039,
"y": 11221.645713530756
"x": 37222.83614024661,
"y": 18914.80502970953
},
"targetPosition": {
"x": 8582.93670886076,
"y": 11144
"x": 37500,
"y": 18800
},
"floatingObject": {
"isPinned": false,
@@ -59,92 +59,65 @@
}
}
},
"signingAccounts": {
"type": "Signing Accounts",
"name": "New Signing Accounts",
"userApps": {
"type": "User Apps",
"name": "New User Apps",
"config": "{}",
"project": "Governance",
"signingAccounts": [
{
"type": "Signing Account",
"name": "New Signing Account",
"config": "{\n \"signature\": {\n \"message\": \"Loui-Molina\",\n \"messageHash\": \"0x6de0af55e96cd9355a0b5ecf1118d8ef9e919dbf03cb1a292f475c515ff35970\",\n \"v\": \"0x1b\",\n \"r\": \"0x20b662a60f3a74895f971e3f9597722e249d1409c105f9ec526aa1c11835b290\",\n \"s\": \"0x2aac4af8db1acaae33674ea184f1d6ac45d31e41631a3cea3a35e076a2fd62af\",\n \"signature\": \"0x20b662a60f3a74895f971e3f9597722e249d1409c105f9ec526aa1c11835b2902aac4af8db1acaae33674ea184f1d6ac45d31e41631a3cea3a35e076a2fd62af1b\"\n }\n}",
"project": "Governance",
"signingAccountChild": {
"type": "P2P Network Node",
"name": "P2P Network Node # 1",
"config": "{\n \"codeName\": \"P2P-Network-Node-1\",\n \"host\": \"localhost\",\n \"webPort\": \"31248\",\n \"webSocketsPort\": \"18042\"\n}",
"project": "Governance",
"id": "3ad8b03c-e301-4767-9e94-55d5010840e8",
"savedPayload": {
"position": {
"x": 7698.292044149752,
"y": 11144.670001801276
},
"targetPosition": {
"x": 7995.725502561895,
"y": 11105.51214413526
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {
"isRunning": false
}
}
},
"id": "359330c8-f24f-42a4-b6c6-b90b09ab9774",
"savedPayload": {
"position": {
"x": 7995.725502561895,
"y": 11105.51214413526
},
"targetPosition": {
"x": 8293.158960974039,
"y": 11066.354286469244
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 3,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {
"isRunning": false
}
}
},
{
"type": "Signing Account",
"name": "New Signing Account",
"config": "{\n \"signature\": {\n \"message\": \"Loui-Molina\",\n \"messageHash\": \"0x6de0af55e96cd9355a0b5ecf1118d8ef9e919dbf03cb1a292f475c515ff35970\",\n \"v\": \"0x1b\",\n \"r\": \"0x1cc898e6f281914282e184e486f116d9a96c1a8826756a0f6d2874b5b2e756ea\",\n \"s\": \"0x291ce017488c78173cc3380d9db8f0768fedf3a72a8409f9c8873297fd6a4261\",\n \"signature\": \"0x1cc898e6f281914282e184e486f116d9a96c1a8826756a0f6d2874b5b2e756ea291ce017488c78173cc3380d9db8f0768fedf3a72a8409f9c8873297fd6a42611b\"\n }\n}",
"project": "Governance",
"signingAccountChild": {
"desktopApps": {
"type": "Desktop Apps",
"name": "New Desktop Apps",
"config": "{}",
"project": "Governance",
"socialTradingDesktopApps": [
{
"type": "Social Trading Desktop App",
"name": "Social Trading Desktop App # 1",
"name": "Social Trading Desktop App #1",
"config": "{\n \"codeName\": \"Social-Trading-Desktop-App-1\",\n \"host\": \"localhost\",\n \"webPort\": \"33248\",\n \"webSocketsPort\": \"17042\"\n}",
"project": "Governance",
"id": "7e413033-5b4d-445d-9852-8d2dadd42bdd",
"signingAccount": {
"type": "Signing Account",
"name": "New Signing Account",
"config": "{\n \"codeName\": \"Social-Trading-Desktop-App-1\",\n \"signature\": {\n \"message\": \"Loui-Molina\",\n \"messageHash\": \"0x6de0af55e96cd9355a0b5ecf1118d8ef9e919dbf03cb1a292f475c515ff35970\",\n \"v\": \"0x1c\",\n \"r\": \"0x4399d38c8fd532a1e84c8ed4682bd5e5da68547e38518a8f7642d396767304cf\",\n \"s\": \"0x600be404cbf141fa209d5633f06c2551893458af65581f1c3e087537156d2e22\",\n \"signature\": \"0x4399d38c8fd532a1e84c8ed4682bd5e5da68547e38518a8f7642d396767304cf600be404cbf141fa209d5633f06c2551893458af65581f1c3e087537156d2e221c\"\n }\n}",
"project": "Governance",
"id": "c0fd597c-751a-49bc-8902-4b4232ba2e0a",
"savedPayload": {
"position": {
"x": 36300,
"y": 18800
},
"targetPosition": {
"x": 36600,
"y": 18800
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 3,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {
"isRunning": false
}
}
},
"id": "5b2ceb2c-3979-4583-937b-f85a7e8bfebb",
"savedPayload": {
"position": {
"x": 7713.603465200598,
"y": 10911.062859407733
"x": 36600,
"y": 18800
},
"targetPosition": {
"x": 8003.381213087318,
"y": 10988.708572938489
"x": 36900,
"y": 18800
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 1,
"angleToParent": 3,
"distanceToParent": 3,
"arrangementStyle": 0
},
@@ -152,55 +125,86 @@
"isRunning": false
}
}
},
"id": "d896dfde-6ce2-43f0-aae5-f65406e3ccb0",
"savedPayload": {
"position": {
"x": 8003.381213087318,
"y": 10988.708572938489
},
"targetPosition": {
"x": 8293.158960974039,
"y": 11066.354286469244
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 3,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {
"isRunning": false
}
}
],
"algoTradesPlatform": [],
"id": "51a98c64-ba95-43d3-bcfc-3f6b6821c5be",
"savedPayload": {
"position": {
"x": 36900,
"y": 18800
},
"targetPosition": {
"x": 37200,
"y": 18800
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 3,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {
"isRunning": false
}
}
},
"id": "0f6d57b2-71a1-4543-82a5-f3560df9090b",
"savedPayload": {
"position": {
"x": 37200,
"y": 18800
},
"targetPosition": {
"x": 37500,
"y": 18800
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 3,
"distanceToParent": 3,
"arrangementStyle": 0
},
"uiObject": {
"isRunning": false
}
}
},
"p2pNetworkNodes": {
"type": "P2P Network Nodes",
"name": "New P2P Network Nodes",
"config": "{}",
"project": "Governance",
"p2pNetworkNodes": [
{
"type": "Signing Account",
"name": "New Signing Account",
"config": "{\n \"signature\": {\n \"message\": \"Loui-Molina\",\n \"messageHash\": \"0x6de0af55e96cd9355a0b5ecf1118d8ef9e919dbf03cb1a292f475c515ff35970\",\n \"v\": \"0x1c\",\n \"r\": \"0x8a5a28c86ceff0ae465c187ba8a22b428f3f10b8a99d4d95195ab471b664914f\",\n \"s\": \"0x66920073303073240bc4ebf6363788e3b76661dfc2366561261fa7812eedf18b\",\n \"signature\": \"0x8a5a28c86ceff0ae465c187ba8a22b428f3f10b8a99d4d95195ab471b664914f66920073303073240bc4ebf6363788e3b76661dfc2366561261fa7812eedf18b1c\"\n }\n}",
"type": "P2P Network Node",
"name": "P2P Network Node #1",
"config": "{\n \"codeName\": \"P2P-Network-Node-1\",\n \"host\": \"localhost\",\n \"webPort\": \"31248\",\n \"webSocketsPort\": \"18042\"\n}",
"project": "Governance",
"signingAccountChild": {
"type": "Social Trading Server App",
"name": "Social Trading Server App # 1",
"config": "{\n \"codeName\": \"Social-Trading-Server-App-1\",\n \"host\": \"localhost\",\n \"webSocketsPort\": \"16042\"\n}",
"signingAccount": {
"type": "Signing Account",
"name": "New Signing Account",
"config": "{\n \"codeName\": \"P2P-Network-Node-1\",\n \"signature\": {\n \"message\": \"Loui-Molina\",\n \"messageHash\": \"0x6de0af55e96cd9355a0b5ecf1118d8ef9e919dbf03cb1a292f475c515ff35970\",\n \"v\": \"0x1b\",\n \"r\": \"0x60e982f313e3a6621199186afb653a89dfc616b333a4e89505a293834f1fc975\",\n \"s\": \"0x794a27d314980510df0bb1ee7fc9bf5d71eac027f02c77e637ba68cb1edb176f\",\n \"signature\": \"0x60e982f313e3a6621199186afb653a89dfc616b333a4e89505a293834f1fc975794a27d314980510df0bb1ee7fc9bf5d71eac027f02c77e637ba68cb1edb176f1b\"\n }\n}",
"project": "Governance",
"id": "39418f01-fba1-4d9b-9484-0cd8642607e0",
"id": "e17583e1-a52f-42e1-86ec-17c1e924a1ff",
"savedPayload": {
"position": {
"x": 7817.146956799297,
"y": 10701.097429064013
"x": 36668.50842073983,
"y": 18455.584910871425
},
"targetPosition": {
"x": 8055.152958886668,
"y": 10883.725857766629
"x": 36945.67228049322,
"y": 18570.38994058095
},
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"angleToParent": 1,
"angleToParent": 3,
"distanceToParent": 3,
"arrangementStyle": 0
},
@@ -209,15 +213,15 @@
}
}
},
"id": "14e9d5eb-cdf9-48e9-ae7a-a2e1ac178c5e",
"id": "9f1b2ef2-9a62-4188-9c3e-7fc890f1d1c1",
"savedPayload": {
"position": {
"x": 8055.152958886668,
"y": 10883.725857766629
"x": 36945.67228049322,
"y": 18570.38994058095
},
"targetPosition": {
"x": 8293.158960974039,
"y": 11066.354286469244
"x": 37222.83614024661,
"y": 18685.194970290475
},
"floatingObject": {
"isPinned": false,
@@ -233,15 +237,15 @@
}
}
],
"id": "deaff2f6-59f5-4c7e-8755-b0bff6ea9157",
"id": "153f9f68-9d5e-4633-bd1a-f29304f27838",
"savedPayload": {
"position": {
"x": 8293.158960974039,
"y": 11066.354286469244
"x": 37222.83614024661,
"y": 18685.194970290475
},
"targetPosition": {
"x": 8582.93670886076,
"y": 11144
"x": 37500,
"y": 18800
},
"floatingObject": {
"isPinned": false,
@@ -269,7 +273,7 @@
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": true,
"isCollapsed": false,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0