Support saving existing files

This commit is contained in:
Dane Everitt 2019-05-27 15:30:49 -07:00
parent a8f523e2aa
commit bfdc1f766b
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
6 changed files with 95 additions and 2 deletions

View file

@ -19,7 +19,7 @@
<button class="btn btn-secondary btn-sm" v-on:click="closeModal">
Cancel
</button>
<button class="ml-2 btn btn-primary btn-sm">
<button class="ml-2 btn btn-primary btn-sm" v-on:click="submit">
Save
</button>
</div>
@ -39,6 +39,8 @@
import {DirectoryContentObject} from "@/api/server/types";
import getFileContents from '@/api/server/files/getFileContents';
import SpinnerModal from "@/components/core/SpinnerModal.vue";
import writeFileContents from '@/api/server/files/writeFileContents';
import {httpErrorToHuman} from '@/api/http';
interface Data {
file?: DirectoryContentObject,
@ -120,7 +122,16 @@
methods: {
submit: function () {
this.isLoading = true;
const content = this.editor!.getValue();
writeFileContents(this.serverUuid!, join(this.fm!.currentDirectory, this.file!.name), content)
.then(() => this.error = null)
.catch(error => {
console.log(error);
this.error = httpErrorToHuman(error);
})
.then(() => this.isLoading = false);
},
loadFileContent: function (): Promise<void> {