Utilities Loaded at UI
This commit is contained in:
1 parent
441122e4e9
commit
53ceb8a5e0
2 files changed
+82
-63
No files matched your search
+21
-18
@@ -25,25 +25,8 @@ function newAppLoader() {
|
||||
modulesArray = modulesArray.concat([
|
||||
|
||||
'Globals.js',
|
||||
|
||||
'Workspace.js',
|
||||
|
||||
'Utilities/CoordinateTransformations.js',
|
||||
'Utilities/DateRateTransformations.js',
|
||||
'Utilities/Download.js',
|
||||
'Utilities/Clipboard.js',
|
||||
'Utilities/DrawPrint.js',
|
||||
'Utilities/LoadSaveFrame.js',
|
||||
'Utilities/LoadSaveTutorial.js',
|
||||
'Utilities/NodeConfig.js',
|
||||
'Utilities/Hiriarchy.js',
|
||||
'Utilities/Folders.js',
|
||||
'Utilities/Branches.js',
|
||||
'Utilities/Meshes.js',
|
||||
'Utilities/NodeChildren.js',
|
||||
'Utilities/Menu.js',
|
||||
'Utilities/Dates.js',
|
||||
|
||||
'Files/SingleFile.js',
|
||||
'Files/FileCloud.js',
|
||||
'Files/MarketFiles.js',
|
||||
@@ -87,10 +70,30 @@ function newAppLoader() {
|
||||
urlArray.push('FunctionLibraries' + '/' + project + '/' + fileName)
|
||||
}
|
||||
|
||||
modulesArray = modulesArray.concat(urlArray)
|
||||
utilities()
|
||||
}
|
||||
}
|
||||
|
||||
function utilities() {
|
||||
let url = 'ListUtilitiesFiles'
|
||||
callWebServer(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('Utilities' + '/' + project + '/' + fileName)
|
||||
}
|
||||
|
||||
modulesArray = modulesArray.concat(urlArray)
|
||||
spaces()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function spaces() {
|
||||
let url = 'ListSpaceFiles'
|
||||
|
||||
+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