Add support for renaming files on the fly in the file manager
This commit is contained in:
parent
52115b5c77
commit
ff820f30ad
10 changed files with 230 additions and 37 deletions
23
resources/assets/scripts/api/server/files/renameElement.ts
Normal file
23
resources/assets/scripts/api/server/files/renameElement.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
import {withCredentials} from "@/api/http";
|
||||
import {ServerApplicationCredentials} from "@/store/types";
|
||||
import { join } from 'path';
|
||||
|
||||
type RenameObject = {
|
||||
path: string,
|
||||
fromName: string,
|
||||
toName: string,
|
||||
}
|
||||
|
||||
/**
|
||||
* Renames a file or folder on the server using the node.
|
||||
*/
|
||||
export function renameElement(server: string, credentials: ServerApplicationCredentials, data: RenameObject): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
withCredentials(server, credentials).post('/v1/server/file/rename', {
|
||||
from: join(data.path, data.fromName),
|
||||
to: join(data.path, data.toName),
|
||||
})
|
||||
.then(() => resolve())
|
||||
.catch(reject);
|
||||
});
|
||||
}
|
Reference in a new issue