102 lines
1.3 KiB
JavaScript
102 lines
1.3 KiB
JavaScript
|
|
|
||
|
|
import icon from "/elements/icon.js";
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
#ifdef SERVER
|
||
|
|
|
||
|
|
import fs from "fs";
|
||
|
|
|
||
|
|
#endif
|
||
|
|
|
||
|
|
|
||
|
|
const delay = time => new Promise(res=>setTimeout(res,time));
|
||
|
|
|
||
|
|
|
||
|
|
export default class deleteFileIconButton extends icon{
|
||
|
|
|
||
|
|
width = 24;
|
||
|
|
|
||
|
|
height = 24;
|
||
|
|
|
||
|
|
propegateEvent = false;
|
||
|
|
|
||
|
|
boxMarginTop = "-12px";
|
||
|
|
|
||
|
|
boxBorderRadius = 14;
|
||
|
|
|
||
|
|
boxBackground = "#ffffffbf";
|
||
|
|
|
||
|
|
boxWidth = "fit-content";
|
||
|
|
|
||
|
|
boxPadding = 2;
|
||
|
|
|
||
|
|
boxPosition = "absolute";
|
||
|
|
|
||
|
|
boxMarginLeft = -8;
|
||
|
|
|
||
|
|
boxDisplay = "none";
|
||
|
|
|
||
|
|
|
||
|
|
async click() {
|
||
|
|
|
||
|
|
this.parent.opacity = "0%";
|
||
|
|
|
||
|
|
await delay(200)
|
||
|
|
|
||
|
|
this.parent.background = "none";
|
||
|
|
|
||
|
|
this.parent.width = 0;
|
||
|
|
|
||
|
|
this.parent.margin = 0;
|
||
|
|
|
||
|
|
this.parent.padding = 0;
|
||
|
|
|
||
|
|
this.parent.border = "none"
|
||
|
|
|
||
|
|
await delay(200)
|
||
|
|
|
||
|
|
this.parent.hide();
|
||
|
|
|
||
|
|
this.parent.remove();
|
||
|
|
|
||
|
|
var fileName = this.parent.value;
|
||
|
|
|
||
|
|
await this.removeFile( fileName );
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
node async removeFile( fileName ) {
|
||
|
|
|
||
|
|
var absolutePath = path.resolve( "./assets/uploads/" + fileName );
|
||
|
|
|
||
|
|
console.log("Removing file test", absolutePath);
|
||
|
|
|
||
|
|
if( fs.existsSync( absolutePath ) ) {
|
||
|
|
|
||
|
|
fs.unlinkSync( absolutePath );
|
||
|
|
|
||
|
|
console.log("File is removed.");
|
||
|
|
|
||
|
|
} else {
|
||
|
|
|
||
|
|
console.log("File does not exist.");
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
constructor() {
|
||
|
|
|
||
|
|
super("close.svg")
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
create() {
|
||
|
|
|
||
|
|
this.hide();
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|