Assets extension, factorised using the received json type to organise the assets in the UI/folders.

This commit is contained in:
Tony Ribeiro
2023-08-23 05:10:55 +02:00
parent 8e38229ed4
commit 13dac1f4d3
5 changed files with 89 additions and 177 deletions

View File

@@ -4943,20 +4943,28 @@ app.post('/delete_extension', jsonParser, async (request, response) => {
*
* @returns {void}
*/
app.get('/get_assets_list', jsonParser, function (request, response) {
const folderPath = path.join(directories.assets,request.query.folderPath);
let output = []
app.get('/get_assets', jsonParser, function (request, response) {
const folderPath = path.join(directories.assets);
let output = {}
//console.info("Checking files into",folderPath);
try {
if (fs.existsSync(folderPath) && fs.statSync(folderPath).isDirectory()) {
const files = fs.readdirSync(folderPath)
const folders = fs.readdirSync(folderPath)
.filter(filename => {
return filename != ".placeholder";
return fs.statSync(path.join(folderPath,filename)).isDirectory();
});
for (i of files)
output.push(`/assets/${request.query.folderPath}/${i}`);
for (const folder of folders) {
const files = fs.readdirSync(path.join(folderPath,folder))
.filter(filename => {
return filename != ".placeholder";
});
output[folder] = [];
for (const file of files){
output[folder].push(path.join("assets",folder,file));
}
}
}
}
catch (err) {