From 866b3a3aac0d37626501f974c6bb0749b28e910e Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 17 Feb 2019 13:29:11 -0800 Subject: [PATCH] Add support for actually creating that folder on the daemon --- .../scripts/api/server/files/createFolder.ts | 27 ++++++++++++++ .../filemanager/modals/CreateFolderModal.vue | 37 ++++++++++++++++--- .../server/subpages/FileManager.vue | 6 +-- .../assets/scripts/store/modules/server.ts | 2 +- 4 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 resources/assets/scripts/api/server/files/createFolder.ts 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 000000000..5ad60748b --- /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 744b629e8..d04d34898 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 8864aa045..abe435056 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,