Massive speed improvements to filemanager
This commit is contained in:
parent
fdec3cea80
commit
2692e98cd8
4 changed files with 138 additions and 143 deletions
|
@ -14,23 +14,21 @@ export interface FileObject {
|
|||
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);
|
||||
export default async (uuid: string, directory?: string): Promise<FileObject[]> => {
|
||||
const { data } = await http.get(`/api/client/servers/${uuid}/files/list`, {
|
||||
params: { directory },
|
||||
});
|
||||
|
||||
return (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),
|
||||
}));
|
||||
};
|
||||
|
|
Reference in a new issue