55 lines
701 B
JavaScript
55 lines
701 B
JavaScript
|
|
|
||
|
|
|
||
|
|
import fileIcon from "./fileManager.icon.js";
|
||
|
|
|
||
|
|
import panel from "/elements/panel/row.js";
|
||
|
|
|
||
|
|
#ifdef SERVER
|
||
|
|
|
||
|
|
import fs from "fs";
|
||
|
|
|
||
|
|
import path from "path";
|
||
|
|
|
||
|
|
#endif
|
||
|
|
|
||
|
|
export default class fileList extends panel{
|
||
|
|
|
||
|
|
margin = 20;
|
||
|
|
|
||
|
|
padding = 20;
|
||
|
|
|
||
|
|
display = "block";
|
||
|
|
|
||
|
|
async create() {
|
||
|
|
|
||
|
|
this.empty();
|
||
|
|
|
||
|
|
var files = await this.readFiles();
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
node async readFiles() {
|
||
|
|
|
||
|
|
var absolutePath = path.resolve( "./assets/uploads/" );
|
||
|
|
|
||
|
|
var files = fs.readdirSync( absolutePath );
|
||
|
|
|
||
|
|
for (var i = 0; i < files.length; i++) {
|
||
|
|
|
||
|
|
var file = files[i];
|
||
|
|
|
||
|
|
|
||
|
|
var currentFileIcon = new fileIcon();
|
||
|
|
|
||
|
|
currentFileIcon.value = file;
|
||
|
|
|
||
|
|
this.add( currentFileIcon );
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
return files;
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|