Add error handling for file manager
This commit is contained in:
parent
92a9146b61
commit
ceef2edf2e
1 changed files with 28 additions and 1 deletions
|
@ -3,6 +3,9 @@
|
||||||
<div v-if="loading">
|
<div v-if="loading">
|
||||||
<div class="spinner spinner-xl blue"></div>
|
<div class="spinner spinner-xl blue"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else-if="!loading && errorMessage">
|
||||||
|
<div class="alert error" v-text="errorMessage"></div>
|
||||||
|
</div>
|
||||||
<div class="filemanager" v-else>
|
<div class="filemanager" v-else>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<div class="flex-none w-8"></div>
|
<div class="flex-none w-8"></div>
|
||||||
|
@ -34,6 +37,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import filter from 'lodash/filter';
|
import filter from 'lodash/filter';
|
||||||
|
import isObject from 'lodash/isObject';
|
||||||
import format from 'date-fns/format';
|
import format from 'date-fns/format';
|
||||||
import { mapState } from 'vuex';
|
import { mapState } from 'vuex';
|
||||||
import { FileTextIcon, FolderIcon, Link2Icon } from 'vue-feather-icons';
|
import { FileTextIcon, FolderIcon, Link2Icon } from 'vue-feather-icons';
|
||||||
|
@ -44,18 +48,33 @@
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState('server', ['server', 'credentials']),
|
...mapState('server', ['server', 'credentials']),
|
||||||
|
...mapState('socket', ['connected']),
|
||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
|
/**
|
||||||
|
* Watch the current directory setting and when it changes update the file listing.
|
||||||
|
*/
|
||||||
currentDirectory: function () {
|
currentDirectory: function () {
|
||||||
this.listDirectory();
|
this.listDirectory();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When we reconnect to the Daemon make sure we grab a listing of all of the files
|
||||||
|
* so that the error message disappears and we then load in a fresh listing.
|
||||||
|
*/
|
||||||
|
connected: function () {
|
||||||
|
if (this.connected) {
|
||||||
|
this.listDirectory();
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
currentDirectory: '/',
|
currentDirectory: '/',
|
||||||
loading: true,
|
loading: true,
|
||||||
|
errorMessage: null,
|
||||||
|
|
||||||
directories: [],
|
directories: [],
|
||||||
editableFiles: [],
|
editableFiles: [],
|
||||||
|
@ -88,8 +107,16 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
this.editableFiles = response.data.editable;
|
this.editableFiles = response.data.editable;
|
||||||
|
this.errorMessage = null;
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error({ err });
|
||||||
|
if (err.response.data && isObject(err.response.data.errors)) {
|
||||||
|
err.response.data.errors.forEach(error => {
|
||||||
|
this.errorMessage = error.detail;
|
||||||
|
});
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(console.error)
|
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue