feat: socketio event
This commit is contained in:
parent
0a1265b78c
commit
25752dac19
9 changed files with 200 additions and 8 deletions
|
|
@ -23,6 +23,7 @@ import { copyCond, listFolder, listItem, pathExist, replaceIllegalChars } from "
|
|||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import { StorageFile, StorageFolder } from "../interfaces/storage-fs";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { getInstance } from "../lib/websocket";
|
||||
|
||||
const DEFAULT_BUCKET = process.env.MINIO_BUCKET;
|
||||
const DEFAULT_INDEX = process.env.ELASTICSEARCH_INDEX;
|
||||
|
|
@ -101,6 +102,9 @@ export class DrawerController extends Controller {
|
|||
|
||||
if (!created) throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์");
|
||||
|
||||
const io = getInstance();
|
||||
io?.emit("CreateFolder", { pathname: `${basePath}${replaceIllegalChars(body.name)}/` });
|
||||
|
||||
return this.setStatus(HttpStatusCode.CREATED);
|
||||
}
|
||||
|
||||
|
|
@ -172,6 +176,12 @@ export class DrawerController extends Controller {
|
|||
}),
|
||||
);
|
||||
|
||||
const io = getInstance();
|
||||
io?.emit("EditFolder", {
|
||||
from: `${cabinetName}/${drawerName}/`,
|
||||
to: `${cabinetName}/${replaceIllegalChars(body.name)}/`,
|
||||
});
|
||||
|
||||
return this.setStatus(HttpStatusCode.NO_CONTENT);
|
||||
}
|
||||
|
||||
|
|
@ -201,6 +211,11 @@ export class DrawerController extends Controller {
|
|||
stream.on("error", () => reject(new Error("เกิดข้อผิดพลาด ไม่สามารถลบไฟล์ได้")));
|
||||
});
|
||||
|
||||
const io = getInstance();
|
||||
io?.emit("DeleteFolder", {
|
||||
pathname: `${cabinetName}/${drawerName}/`,
|
||||
});
|
||||
|
||||
return this.setStatus(HttpStatusCode.NO_CONTENT);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue