WebApp Loading all modules declared at Project Schema

This commit is contained in:
Luis Fernando Molina committed 2021-09-06 20:30:05 +02:00
1 parent ecc7b7d7b6
commit 373f0307d8
7 files changed
+82 -33

No files matched your search

+43 -8
View File
@@ -19,13 +19,13 @@ exports.newHttpInterface = function newHttpInterface() {
/*
We will create an HTTP Server and leave it running forever.
*/
SA.nodeModules.http.createServer(onHttpRequest).listen(global.env.DESKTOP_HTTP_INTERFACE_PORT)
/* Starting the browser now is optional */
if (process.argv.includes("noBrowser")) {
//Running Client only with no UI.
} else {
SA.nodeModules.open('http://localhost:' + global.env.DESKTOP_HTTP_INTERFACE_PORT)
}
SA.nodeModules.http.createServer(onHttpRequest).listen(global.env.DESKTOP_HTTP_INTERFACE_PORT)
/* Starting the browser now is optional */
if (process.argv.includes("noBrowser")) {
//Running Client only with no UI.
} else {
SA.nodeModules.open('http://localhost:' + global.env.DESKTOP_HTTP_INTERFACE_PORT)
}
}
function onHttpRequest(httpRequest, httpResponse) {
@@ -35,6 +35,41 @@ exports.newHttpInterface = function newHttpInterface() {
let endpointOrFile = requestPath[1]
switch (endpointOrFile) {
case 'ProjectsSchema':
{
let path = global.env.PATH_TO_PROJECTS + '/' + 'ProjectsSchema.json'
SA.projects.foundations.utilities.httpResponses.respondWithFile(path, httpResponse)
}
break
case 'ListFunctionLibraries':
{
SA.projects.foundations.utilities.httpResponses.respondWithProjectFolderFileList(httpResponse, 'Function-Libraries', 'UI')
}
break
case 'ListUtilitiesFiles':
{
SA.projects.foundations.utilities.httpResponses.respondWithProjectFolderFileList(httpResponse, 'Utilities', 'UI')
}
break
case 'ListGlobalFiles':
{
SA.projects.foundations.utilities.httpResponses.respondWithProjectFolderFileList(httpResponse, 'Globals', 'UI')
}
break
case 'Projects':
{
let path = ''
for (let i = 2; i < 10; i++) {
if (requestPath[i] !== undefined) {
let parameter = unescape(requestPath[i])
path = path + '/' + parameter
}
}
let filePath = global.env.PATH_TO_PROJECTS + path
SA.projects.foundations.utilities.httpResponses.respondWithFile(filePath, httpResponse)
}
break
case 'Images': // This means the Images folder.
{
let path = global.env.PATH_TO_DESKTOP + '/WebServer/Images/' + requestPath[2]
@@ -58,7 +93,7 @@ exports.newHttpInterface = function newHttpInterface() {
break
default:
{
SA.projects.foundations.utilities.httpResponses.respondWithWebFile(httpResponse, endpointOrFile, global.env.PATH_TO_DESKTOP)
SA.projects.foundations.utilities.httpResponses.respondWithWebFile(httpResponse, endpointOrFile, global.env.PATH_TO_DESKTOP)
}
}
} catch (err) {
+4 -21
View File
@@ -10,12 +10,12 @@ function newAppLoader() {
async function loadModules() {
try {
let modulesArray = []
modulesArray = modulesArray.concat([
let modulesArray = [
'WebDebugLog.js',
'AppPostLoader.js',
'Globals.js',
'WebApp.js'
])
]
functionLibraries()
@@ -74,23 +74,6 @@ function newAppLoader() {
urlArray.push('Projects' + '/' + project + '/' + 'UI' + '/' + 'Globals' + '/' + fileName)
}
modulesArray = modulesArray.concat(urlArray)
spaces()
}
}
function spaces() {
let url = 'ListSpaceFiles'
httpRequest(undefined, url, onResponse)
function onResponse(err, fileList) {
let urlArray = []
let fileArray = JSON.parse(fileList)
for (let i = 0; i < fileArray.length; i++) {
let path = fileArray[i]
urlArray.push('Projects' + '/' + path)
}
modulesArray = modulesArray.concat(urlArray)
downloadIncludedFiles()
}
+12 -2
View File
@@ -9,8 +9,18 @@ function newAppPostLoader() {
function start() {
try {
webApp = newWebApp()
webApp.initialize()
setupProjectsSchema()
function setupProjectsSchema() {
httpRequest(undefined, 'ProjectsSchema', onResponse)
function onResponse(err, file) {
PROJECTS_SCHEMA = JSON.parse(file)
webApp = newWebApp()
webApp.initialize()
}
}
} catch (err) {
console.log('[ERROR] err.stack = ' + err.stack)
}
+1 -1
View File
@@ -43,7 +43,7 @@ function httpRequest(pContentToSend, pPath, callBackFunction) {
xmlHttpRequest.onreadystatechange = function () {
if (this.readyState === 4 && this.status === 200) {
try {
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE, xmlHttpRequest.responseText)
callBackFunction(undefined, xmlHttpRequest.responseText)
} catch(err) {
console.log('[ERROR] httpRequest -> httpRequest -> err.stack = '+ err.stack)
console.log('[ERROR] httpRequest -> httpRequest -> pContentToSend = '+ pContentToSend)
+21
View File
@@ -0,0 +1,21 @@
function newWebDebugLog() {
try {
let thisObject = {
write: write,
fileName: 'undefined'
}
return thisObject
function write(pText) {
console.log(spacePad(thisObject.fileName, 50) + ' : ' + pText)
function spacePad(str, max) {
str = str.toString()
return str.length < max ? spacePad(' ' + str, max) : str
}
}
} catch (err) {
console.log(spacePad(MODULE_NAME, 50) + ' : ' + '[ERROR] WebDebugLog --> err = ' + err.stack)
}
}
File renamed without changes.
+1 -1
View File
@@ -6,7 +6,7 @@
<meta name="description" content="Free and Open Source Crypto Social Trading">
<link rel="stylesheet" href="main.css" type="text/css" charset="utf-8" />
<link rel="shortcut icon" type="image/png/ico" href="Images/favicon.ico" />
<script type="text/javascript" src="WebServer/require.js"></script>
<script type="text/javascript" src="require.js"></script>
<script type="text/javascript" src="AppPreLoader.js"></script>
<script type="text/javascript">