diff --git a/resources/assets/scripts/api/server/files/createFolder.ts b/resources/assets/scripts/api/server/files/createFolder.ts new file mode 100644 index 00000000..5ad60748 --- /dev/null +++ b/resources/assets/scripts/api/server/files/createFolder.ts @@ -0,0 +1,27 @@ +import {ServerApplicationCredentials} from "@/store/types"; +import http from "@/api/http"; +import {AxiosError, AxiosRequestConfig} from "axios"; +import {ServerData} from "@/models/server"; + +/** + * Connects to the remote daemon and creates a new folder on the server. + */ +export function createFolder(server: ServerData, credentials: ServerApplicationCredentials, path: string): Promise { + const config: AxiosRequestConfig = { + baseURL: credentials.node, + headers: { + 'X-Access-Server': server.uuid, + 'X-Access-Token': credentials.key, + }, + }; + + return new Promise((resolve, reject) => { + http.post('/v1/server/file/folder', { path }, config) + .then(() => { + resolve(); + }) + .catch((error: AxiosError) => { + reject(error); + }); + }); +} diff --git a/resources/assets/scripts/components/server/components/filemanager/modals/CreateFolderModal.vue b/resources/assets/scripts/components/server/components/filemanager/modals/CreateFolderModal.vue index 744b629e..d04d3489 100644 --- a/resources/assets/scripts/components/server/components/filemanager/modals/CreateFolderModal.vue +++ b/resources/assets/scripts/components/server/components/filemanager/modals/CreateFolderModal.vue @@ -1,5 +1,5 @@ @@ -112,8 +112,6 @@ * Watch the current directory setting and when it changes update the file listing. */ currentDirectory: function () { - this.$store.dispatch('server/updateCurrentDirectory', this.currentDirectory); - this.listDirectory(); }, @@ -152,6 +150,8 @@ this.loading = true; const directory = encodeURI(this.currentDirectory.replace(/^\/|\/$/, '')); + this.$store.dispatch('server/updateCurrentDirectory', `/${directory}`); + getDirectoryContents(this.$route.params.id, directory) .then((response) => { this.files = response.files; diff --git a/resources/assets/scripts/store/modules/server.ts b/resources/assets/scripts/store/modules/server.ts index 8864aa04..abe43505 100644 --- a/resources/assets/scripts/store/modules/server.ts +++ b/resources/assets/scripts/store/modules/server.ts @@ -2,7 +2,7 @@ import route from '../../../../../vendor/tightenco/ziggy/src/js/route'; import {ActionContext} from "vuex"; import {ServerData} from "@/models/server"; -import {FileManagerState, ServerApplicationCredentials, ServerState} from "../types"; +import {ServerApplicationCredentials, ServerState} from "../types"; export default { namespaced: true,