Utilities Loaded at UI
This commit is contained in:
1 parent
441122e4e9
commit
53ceb8a5e0
2 files changed
+82
-63
No files matched your search
+61
-45
@@ -370,12 +370,6 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
|
||||
}
|
||||
break
|
||||
|
||||
case 'Utilities': // This means the DesignSpace folder.
|
||||
{
|
||||
respondWithFile(process.env.PATH_TO_CANVAS_APP + '/Utilities/' + requestParameters[2], response)
|
||||
}
|
||||
break
|
||||
|
||||
case 'WebServer': // This means the WebServer folder.
|
||||
{
|
||||
respondWithFile(process.env.PATH_TO_WEB_SERVER + 'WebServer/' + requestParameters[2], response)
|
||||
@@ -643,43 +637,7 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
|
||||
|
||||
case 'ListFunctionLibraries':
|
||||
{
|
||||
let allLibraries = []
|
||||
let projects = getDirectories(process.env.PROJECTS_PATH)
|
||||
let projectsCount = 0
|
||||
|
||||
for (let i = 0; i < projects.length; i++) {
|
||||
let project = projects[i]
|
||||
|
||||
let dirPath = process.env.PROJECTS_PATH + '/' + project + '/Function-Libraries'
|
||||
try {
|
||||
let fs = require('fs')
|
||||
fs.readdir(dirPath, onDirRead)
|
||||
|
||||
function onDirRead(err, fileList) {
|
||||
if (err) {
|
||||
if (CONSOLE_ERROR_LOG === true) { console.log('[ERROR] Error reading a directory content. filePath = ' + dirPath) }
|
||||
respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), response)
|
||||
return
|
||||
} else {
|
||||
let updatedFileList = []
|
||||
for (let i = 0; i < fileList.length; i++) {
|
||||
let name = fileList[i]
|
||||
updatedFileList.push([project, name])
|
||||
}
|
||||
allLibraries = allLibraries.concat(updatedFileList)
|
||||
projectsCount++
|
||||
if (projectsCount === projects.length) {
|
||||
respondWithContent(JSON.stringify(allLibraries), response)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
if (CONSOLE_ERROR_LOG === true) { console.log('[ERROR] Error reading a directory content. filePath = ' + dirPath) }
|
||||
respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), response)
|
||||
return
|
||||
}
|
||||
}
|
||||
returnProjectFolderFileList('Function-Libraries')
|
||||
}
|
||||
break
|
||||
|
||||
@@ -690,11 +648,21 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
|
||||
let filePath = process.env.PROJECTS_PATH + '/' + project + '/Function-Libraries/' + fileName
|
||||
respondWithFile(filePath, response)
|
||||
}
|
||||
break
|
||||
break
|
||||
|
||||
case 'Utilities':
|
||||
{
|
||||
let project = unescape(requestParameters[2])
|
||||
let fileName = unescape(requestParameters[3])
|
||||
let filePath = process.env.PROJECTS_PATH + '/' + project + '/Utilities/' + fileName
|
||||
console.log(filePath)
|
||||
respondWithFile(filePath, response)
|
||||
}
|
||||
break
|
||||
|
||||
case 'ProjectsSchema':
|
||||
{
|
||||
let path = process.env.PROJECTS_PATH + '/' + 'ProjectsSchema.json'
|
||||
let path = process.env.PROJECTS_PATH + '/' + 'ProjectsSchema.json'
|
||||
respondWithFile(path, response)
|
||||
}
|
||||
break
|
||||
@@ -758,6 +726,12 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
|
||||
}
|
||||
break
|
||||
|
||||
case 'ListUtilitiesFiles':
|
||||
{
|
||||
returnProjectFolderFileList('Utilities')
|
||||
}
|
||||
break
|
||||
|
||||
case 'Projects':
|
||||
{
|
||||
let path = ''
|
||||
@@ -802,6 +776,48 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
|
||||
}
|
||||
}
|
||||
|
||||
function returnProjectFolderFileList(projectFolderName) {
|
||||
{
|
||||
let allLibraries = []
|
||||
let projects = getDirectories(process.env.PROJECTS_PATH)
|
||||
let projectsCount = 0
|
||||
|
||||
for (let i = 0; i < projects.length; i++) {
|
||||
let project = projects[i]
|
||||
|
||||
let dirPath = process.env.PROJECTS_PATH + '/' + project + '/' + projectFolderName
|
||||
try {
|
||||
let fs = require('fs')
|
||||
fs.readdir(dirPath, onDirRead)
|
||||
|
||||
function onDirRead(err, fileList) {
|
||||
if (err) {
|
||||
if (CONSOLE_ERROR_LOG === true) { console.log('[ERROR] Error reading a directory content. filePath = ' + dirPath) }
|
||||
respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), response)
|
||||
return
|
||||
} else {
|
||||
let updatedFileList = []
|
||||
for (let i = 0; i < fileList.length; i++) {
|
||||
let name = fileList[i]
|
||||
updatedFileList.push([project, name])
|
||||
}
|
||||
allLibraries = allLibraries.concat(updatedFileList)
|
||||
projectsCount++
|
||||
if (projectsCount === projects.length) {
|
||||
respondWithContent(JSON.stringify(allLibraries), response)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
if (CONSOLE_ERROR_LOG === true) { console.log('[ERROR] Error reading a directory content. filePath = ' + dirPath) }
|
||||
respondWithContent(JSON.stringify(global.DEFAULT_FAIL_RESPONSE), response)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function executeTerminalCommand(command) {
|
||||
const util = require('util');
|
||||
const exec = util.promisify(require('child_process').exec);
|
||||
|
||||
Reference in new issue
Block a user