Icons can now be organized in subdirectories.
This commit is contained in:
1 parent
69c59eddc3
commit
16d36a670e
33 files changed
+106
-67
No files matched your search
+85
-49
@@ -948,6 +948,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
}
|
||||
|
||||
path = unescape(path)
|
||||
|
||||
respondWithImage(path, httpResponse)
|
||||
}
|
||||
break
|
||||
@@ -1068,7 +1069,9 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
|
||||
const folder = global.env.PATH_TO_PROJECTS + '/' + project + '/Icons/'
|
||||
|
||||
fs.readdir(folder, (err, files) => {
|
||||
getAllFilesInDirectoryAndSubdirectories(folder, onFilesReady)
|
||||
|
||||
function onFilesReady(files) {
|
||||
for (let j = 0; j < files.length; j++) {
|
||||
let file = files[j]
|
||||
icons.push([project, file])
|
||||
@@ -1078,7 +1081,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
if (projectCounter === totalProjects) {
|
||||
respondWithContent(JSON.stringify(icons), httpResponse)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
@@ -1496,57 +1499,57 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
|
||||
function sendSchema(filePath, schemaType) {
|
||||
let fs = require('fs')
|
||||
try {
|
||||
let folder = ''
|
||||
switch (schemaType) {
|
||||
case 'AppSchema': {
|
||||
folder = 'App-Schema'
|
||||
break
|
||||
}
|
||||
case 'DocsNodeSchema': {
|
||||
folder = 'Docs-Nodes'
|
||||
break
|
||||
}
|
||||
case 'DocsConceptSchema': {
|
||||
folder = 'Docs-Concepts'
|
||||
break
|
||||
}
|
||||
case 'DocsTopicSchema': {
|
||||
folder = 'Docs-Topics'
|
||||
break
|
||||
}
|
||||
case 'DocsTutorialSchema': {
|
||||
folder = 'Docs-Tutorials'
|
||||
break
|
||||
}
|
||||
case 'DocsReviewSchema': {
|
||||
folder = 'Docs-Reviews'
|
||||
break
|
||||
}
|
||||
case 'DocsBookSchema': {
|
||||
folder = 'Docs-Books'
|
||||
break
|
||||
}
|
||||
try {
|
||||
let folder = ''
|
||||
switch (schemaType) {
|
||||
case 'AppSchema': {
|
||||
folder = 'App-Schema'
|
||||
break
|
||||
}
|
||||
|
||||
let schemaArray = []
|
||||
let fileList = fs.readdirSync(filePath + '/' + folder)
|
||||
for (let k = 0; k < fileList.length; k++) {
|
||||
let name = fileList[k]
|
||||
let fileContent = fs.readFileSync(filePath + '/' + folder + '/' + name)
|
||||
let schemaDocument = JSON.parse(fileContent)
|
||||
schemaArray.push(schemaDocument)
|
||||
case 'DocsNodeSchema': {
|
||||
folder = 'Docs-Nodes'
|
||||
break
|
||||
}
|
||||
let schema = JSON.stringify(schemaArray)
|
||||
respondWithContent(schema, httpResponse)
|
||||
} catch (err) {
|
||||
if (err.message.indexOf('no such file or directory') < 0) {
|
||||
console.log('Could not send Schema:', filePath, schemaType)
|
||||
console.log(err.stack)
|
||||
case 'DocsConceptSchema': {
|
||||
folder = 'Docs-Concepts'
|
||||
break
|
||||
}
|
||||
case 'DocsTopicSchema': {
|
||||
folder = 'Docs-Topics'
|
||||
break
|
||||
}
|
||||
case 'DocsTutorialSchema': {
|
||||
folder = 'Docs-Tutorials'
|
||||
break
|
||||
}
|
||||
case 'DocsReviewSchema': {
|
||||
folder = 'Docs-Reviews'
|
||||
break
|
||||
}
|
||||
case 'DocsBookSchema': {
|
||||
folder = 'Docs-Books'
|
||||
break
|
||||
}
|
||||
respondWithContent("[]", httpResponse)
|
||||
}
|
||||
|
||||
|
||||
let schemaArray = []
|
||||
let fileList = fs.readdirSync(filePath + '/' + folder)
|
||||
for (let k = 0; k < fileList.length; k++) {
|
||||
let name = fileList[k]
|
||||
let fileContent = fs.readFileSync(filePath + '/' + folder + '/' + name)
|
||||
let schemaDocument = JSON.parse(fileContent)
|
||||
schemaArray.push(schemaDocument)
|
||||
}
|
||||
let schema = JSON.stringify(schemaArray)
|
||||
respondWithContent(schema, httpResponse)
|
||||
} catch (err) {
|
||||
if (err.message.indexOf('no such file or directory') < 0) {
|
||||
console.log('Could not send Schema:', filePath, schemaType)
|
||||
console.log(err.stack)
|
||||
}
|
||||
respondWithContent("[]", httpResponse)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function sendStyleSheet(fileName) {
|
||||
@@ -1727,4 +1730,37 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
function getAllFilesInDirectoryAndSubdirectories(dir, callback) {
|
||||
const { promisify } = require('util');
|
||||
const { resolve } = require('path');
|
||||
const fs = require('fs');
|
||||
const readdir = promisify(fs.readdir);
|
||||
const stat = promisify(fs.stat);
|
||||
|
||||
getFiles(dir)
|
||||
.then(files => {
|
||||
let splittedDir = dir.split('/')
|
||||
let lastFolder = splittedDir[splittedDir.length - 2]
|
||||
let pathAndNames = []
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
let file = files[i]
|
||||
let filesSplitted = file.split(lastFolder)
|
||||
let pathName = filesSplitted[1]
|
||||
pathName = pathName.substring(1, pathName.length)
|
||||
pathAndNames.push(pathName)
|
||||
}
|
||||
callback(pathAndNames)
|
||||
})
|
||||
.catch(e => console.error(e));
|
||||
|
||||
async function getFiles(dir) {
|
||||
const subdirs = await readdir(dir);
|
||||
const files = await Promise.all(subdirs.map(async (subdir) => {
|
||||
const res = resolve(dir, subdir);
|
||||
return (await stat(res)).isDirectory() ? getFiles(res) : res;
|
||||
}));
|
||||
return files.reduce((a, f) => a.concat(f), []);
|
||||
}
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
|
Before Width: | Height: | Size: 9.5 KiB |
File renamed without changes.
@@ -27,10 +27,10 @@
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"disableIfPropertyIsDefined": true,
|
||||
"propertyToCheckFor": "referrer",
|
||||
"propertyToCheckFor": "userReferrer",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"label": "Add Referrer",
|
||||
"relatedUiObject": "Referrer"
|
||||
"label": "Add User Referrer",
|
||||
"relatedUiObject": "User Referrer"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
@@ -66,9 +66,9 @@
|
||||
"autoAdd": false
|
||||
},
|
||||
{
|
||||
"name": "referrer",
|
||||
"name": "userReferrer",
|
||||
"type": "node",
|
||||
"childType": "Referrer",
|
||||
"childType": "User Referrer",
|
||||
"autoAdd": false
|
||||
}
|
||||
]
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"type": "Referrer",
|
||||
"type": "User Referrer",
|
||||
"menuItems": [
|
||||
{
|
||||
"action": "Configure",
|
||||
@@ -35,5 +35,5 @@
|
||||
"referencingRules": {
|
||||
"compatibleTypes": "->User Profile->"
|
||||
},
|
||||
"propertyNameAtParent": "referrer"
|
||||
"propertyNameAtParent": "userReferrer"
|
||||
}
|
||||
@@ -17,10 +17,10 @@
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"disableIfPropertyIsDefined": true,
|
||||
"propertyToCheckFor": "referrer",
|
||||
"propertyToCheckFor": "userReferrer",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"label": "Add Referrer",
|
||||
"relatedUiObject": "Referrer"
|
||||
"label": "Add User Referrer",
|
||||
"relatedUiObject": "User Referrer"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"type": "Referrer",
|
||||
"type": "User Referrer",
|
||||
"definition": {
|
||||
"text": "This node is used by users to reference other users defining in this way who was the user who brought them into the project. The referrer could have acted by word of mouth, or producing some marketing material with it's referral id. These references are later used at the token distribution process to reward referrers and also users declaring who these referrers are.",
|
||||
"text": "This node is used by users to reference other users defining in this way who was the user who brought them into the project. The userReferrer could have acted by word of mouth, or producing some marketing material with it's referral id. These references are later used at the token distribution process to reward referrers and also users declaring who these referrers are.",
|
||||
"updated": 1622990015308
|
||||
},
|
||||
"paragraphs": [
|
||||
|
||||
@@ -38,7 +38,7 @@ function newSuperalgosDesignSpace() {
|
||||
/* Take types-icons relationships defined at the schema */
|
||||
for (let i = 0; i < PROJECTS_ARRAY.length; i++) {
|
||||
let project = PROJECTS_ARRAY[i]
|
||||
|
||||
|
||||
addSchemaTypes(SCHEMAS_BY_PROJECT.get(project).array.appSchema)
|
||||
addSchemaTypes(SCHEMAS_BY_PROJECT.get(project).array.docsNodeSchema)
|
||||
addSchemaTypes(SCHEMAS_BY_PROJECT.get(project).array.docsConceptSchema)
|
||||
@@ -78,21 +78,24 @@ function newSuperalgosDesignSpace() {
|
||||
|
||||
for (let i = 0; i < iconsArray.length; i++) {
|
||||
let project = iconsArray[i][0]
|
||||
let name = iconsArray[i][1]
|
||||
loadImage(project, name)
|
||||
let path = iconsArray[i][1]
|
||||
loadImage(project, path)
|
||||
}
|
||||
|
||||
function loadImage(project, name) {
|
||||
function loadImage(project, path) {
|
||||
imageLoadedCounter++
|
||||
const PATH = 'Icons/' + project + '/'
|
||||
let image = new Image()
|
||||
image.onload = onImageLoad
|
||||
image.fileName = name
|
||||
image.fileName = path
|
||||
|
||||
function onImageLoad() {
|
||||
image.canDrawIcon = true
|
||||
}
|
||||
image.src = PATH + name
|
||||
image.src = PATH + path
|
||||
let splittedPath = path.split('\\')
|
||||
let name = splittedPath[splittedPath.length - 1]
|
||||
|
||||
let key = project + '-' + name.substring(0, name.length - 4)
|
||||
thisObject.iconsByProjectAndName.set(key, image)
|
||||
|
||||
|
||||
Reference in new issue
Block a user