Add support for actually creating that folder on the daemon
This commit is contained in:
parent
0b11532a48
commit
866b3a3aac
4 changed files with 62 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<Modal :show="visible" v-on:close="onModalClose" :showCloseIcon="false">
|
||||
<Modal :show="visible" v-on:close="onModalClose" :showCloseIcon="false" :dismissable="!isLoading">
|
||||
<div class="flex items-end">
|
||||
<div class="flex-1">
|
||||
<label class="input-label">
|
||||
|
@ -16,8 +16,15 @@
|
|||
/>
|
||||
</div>
|
||||
<div class="ml-4">
|
||||
<button class="btn btn-primary btn-sm" type="submit" v-on:submit.prevent="submit">
|
||||
Create
|
||||
<button type="submit"
|
||||
class="btn btn-primary btn-sm"
|
||||
v-on:click.prevent="submit"
|
||||
:disabled="errors.any() || isLoading"
|
||||
>
|
||||
<span class="spinner white" v-bind:class="{ hidden: !isLoading }"> </span>
|
||||
<span :class="{ hidden: isLoading }">
|
||||
Create
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -31,17 +38,19 @@
|
|||
import Vue from 'vue';
|
||||
import Modal from '@/components/core/Modal.vue';
|
||||
import {mapState} from "vuex";
|
||||
import {createFolder} from "@/api/server/files/createFolder";
|
||||
|
||||
export default Vue.extend({
|
||||
name: 'CreateFolderModal',
|
||||
components: {Modal},
|
||||
|
||||
computed: {
|
||||
...mapState('server', ['fm']),
|
||||
...mapState('server', ['server', 'credentials', 'fm']),
|
||||
},
|
||||
|
||||
data: function () {
|
||||
return {
|
||||
isLoading: false,
|
||||
visible: false,
|
||||
folderName: '',
|
||||
};
|
||||
|
@ -55,11 +64,17 @@
|
|||
window.events.$on('server:files:open-directory-modal', () => {
|
||||
this.visible = true;
|
||||
this.$nextTick(() => {
|
||||
(this.$refs.folderNameField as HTMLInputElement).focus();
|
||||
if (this.$refs.folderNameField) {
|
||||
(this.$refs.folderNameField as HTMLInputElement).focus();
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
beforeDestroy: function () {
|
||||
window.events.$off('server:files:open-directory-modal');
|
||||
},
|
||||
|
||||
methods: {
|
||||
submit: function () {
|
||||
this.$validator.validate().then((result) => {
|
||||
|
@ -67,7 +82,17 @@
|
|||
return;
|
||||
}
|
||||
|
||||
this.onModalClose();
|
||||
this.isLoading = true;
|
||||
|
||||
console.log(`${this.fm.currentDirectory}/${this.folderName.replace(/^\//, '')}`);
|
||||
|
||||
createFolder(this.server, this.credentials, `${this.fm.currentDirectory}/${this.folderName.replace(/^\//, '')}`)
|
||||
.then(() => {
|
||||
this.$emit('close');
|
||||
this.onModalClose();
|
||||
})
|
||||
.catch(console.error.bind(this))
|
||||
.then(() => this.isLoading = false)
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
<a href="#" class="block btn btn-primary btn-sm">New File</a>
|
||||
</div>
|
||||
</div>
|
||||
<CreateFolderModal/>
|
||||
<CreateFolderModal v-on:close="listDirectory"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue