|
3 | 3 | <div v-if="loading"> |
4 | 4 | <div class="spinner spinner-xl blue"></div> |
5 | 5 | </div> |
| 6 | + <div v-else-if="!loading && errorMessage"> |
| 7 | + <div class="alert error" v-text="errorMessage"></div> |
| 8 | + </div> |
6 | 9 | <div class="filemanager" v-else> |
7 | 10 | <div class="header"> |
8 | 11 | <div class="flex-none w-8"></div> |
|
34 | 37 |
|
35 | 38 | <script> |
36 | 39 | import filter from 'lodash/filter'; |
| 40 | + import isObject from 'lodash/isObject'; |
37 | 41 | import format from 'date-fns/format'; |
38 | 42 | import { mapState } from 'vuex'; |
39 | 43 | import { FileTextIcon, FolderIcon, Link2Icon } from 'vue-feather-icons'; |
|
44 | 48 |
|
45 | 49 | computed: { |
46 | 50 | ...mapState('server', ['server', 'credentials']), |
| 51 | + ...mapState('socket', ['connected']), |
47 | 52 | }, |
48 | 53 |
|
49 | 54 | watch: { |
| 55 | + /** |
| 56 | + * Watch the current directory setting and when it changes update the file listing. |
| 57 | + */ |
50 | 58 | currentDirectory: function () { |
51 | 59 | this.listDirectory(); |
52 | 60 | }, |
| 61 | +
|
| 62 | + /** |
| 63 | + * When we reconnect to the Daemon make sure we grab a listing of all of the files |
| 64 | + * so that the error message disappears and we then load in a fresh listing. |
| 65 | + */ |
| 66 | + connected: function () { |
| 67 | + if (this.connected) { |
| 68 | + this.listDirectory(); |
| 69 | + } |
| 70 | + } |
53 | 71 | }, |
54 | 72 |
|
55 | 73 | data: function () { |
56 | 74 | return { |
57 | 75 | currentDirectory: '/', |
58 | 76 | loading: true, |
| 77 | + errorMessage: null, |
59 | 78 |
|
60 | 79 | directories: [], |
61 | 80 | editableFiles: [], |
|
88 | 107 | }); |
89 | 108 |
|
90 | 109 | this.editableFiles = response.data.editable; |
| 110 | + this.errorMessage = null; |
| 111 | + }) |
| 112 | + .catch(err => { |
| 113 | + console.error({ err }); |
| 114 | + if (err.response.data && isObject(err.response.data.errors)) { |
| 115 | + err.response.data.errors.forEach(error => { |
| 116 | + this.errorMessage = error.detail; |
| 117 | + }); |
| 118 | + } |
91 | 119 | }) |
92 | | - .catch(console.error) |
93 | 120 | .finally(() => { |
94 | 121 | this.loading = false; |
95 | 122 | }); |
|
0 commit comments