forked from pterodactyl/panel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloadDirectory.ts
More file actions
36 lines (34 loc) · 1.17 KB
/
loadDirectory.ts
File metadata and controls
36 lines (34 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import http from '@/api/http';
import v4 from 'uuid/v4';
export interface FileObject {
uuid: string;
name: string;
mode: string;
size: number;
isFile: boolean;
isSymlink: boolean;
isEditable: boolean;
mimetype: string;
createdAt: Date;
modifiedAt: Date;
}
export default (uuid: string, directory?: string): Promise<FileObject[]> => {
return new Promise((resolve, reject) => {
http.get(`/api/client/servers/${uuid}/files/list`, {
params: { directory },
})
.then(response => resolve((response.data.data || []).map((item: any): FileObject => ({
uuid: v4(),
name: item.attributes.name,
mode: item.attributes.mode,
size: Number(item.attributes.size),
isFile: item.attributes.is_file,
isSymlink: item.attributes.is_symlink,
isEditable: item.attributes.is_editable,
mimetype: item.attributes.mimetype,
createdAt: new Date(item.attributes.created_at),
modifiedAt: new Date(item.attributes.modified_at),
}))))
.catch(reject);
});
};