Skip to content

Commit f20d404

Browse files
committed
Better handling of connection errors
1 parent f1ec968 commit f20d404

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

resources/assets/scripts/components/server/Server.vue

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
22
<div>
33
<navigation></navigation>
4+
<flash class="m-6"/>
45
<div v-if="loadingServerData">
56
<div class="mt-6 h-16">
67
<div class="spinner spinner-xl spinner-thick blue"></div>
@@ -56,6 +57,11 @@
5657
</div>
5758
</div>
5859
</div>
60+
<div class="fixed pin-r pin-b m-6 max-w-sm" v-show="connectionError">
61+
<div class="alert error">
62+
There was an error while attempting to connect to the Daemon websocket. Error reported was: "{{connectionError.message}}"
63+
</div>
64+
</div>
5965
</div>
6066
</template>
6167

@@ -69,9 +75,11 @@
6975
import Vue from 'vue';
7076
7177
import PowerButtons from './components/PowerButtons';
78+
import Flash from '../Flash';
7279
7380
export default {
7481
components: {
82+
Flash,
7583
PowerButtons, ProgressBar, Navigation,
7684
TerminalIcon, FolderIcon, UsersIcon, CalendarIcon, DatabaseIcon, GlobeIcon, SettingsIcon
7785
},
@@ -81,16 +89,16 @@
8189
...mapState('socket', ['connected', 'connectionError']),
8290
},
8391
84-
mounted: function () {
85-
this.loadServer();
86-
},
87-
8892
data: function () {
8993
return {
9094
loadingServerData: true,
9195
};
9296
},
9397
98+
mounted: function () {
99+
this.loadServer();
100+
},
101+
94102
methods: {
95103
/**
96104
* Load the core server information needed for these pages to be functional.

resources/assets/scripts/components/server/subpages/Console.vue

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,15 @@
4545
*/
4646
connected: function (state) {
4747
if (state) {
48+
this.terminal.open(this.$refs.terminal);
49+
this.terminal.fit();
50+
this.terminal.clear();
51+
4852
this.$socket.emit('send server log');
53+
} else {
54+
this.terminal.dispose();
4955
}
50-
}
56+
},
5157
},
5258
5359
/**
@@ -64,7 +70,7 @@
6470
data.line.split(/\n/g).forEach(line => {
6571
this.terminal.writeln(line + '\u001b[0m');
6672
});
67-
}
73+
},
6874
},
6975
7076
/**
@@ -73,10 +79,6 @@
7379
* socket is not connected this will occur automatically when it connects.
7480
*/
7581
mounted: function () {
76-
this.terminal.open(this.$refs.terminal);
77-
this.terminal.fit();
78-
this.terminal.clear();
79-
8082
if (this.connected) {
8183
this.$socket.emit('send server log');
8284
}

resources/assets/scripts/store/modules/socket.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,24 @@ export default {
44
namespaced: true,
55
state: {
66
connected: false,
7-
connectionError: null,
7+
connectionError: false,
88
status: Status.STATUS_OFF,
99
},
1010
actions: {
1111
},
1212
mutations: {
1313
SOCKET_CONNECT: (state) => {
1414
state.connected = true;
15+
state.connectionError = false;
1516
},
1617

1718
SOCKET_ERROR: (state, err) => {
19+
state.connected = false;
20+
state.connectionError = err;
21+
},
22+
23+
SOCKET_CONNECT_ERROR: (state, err) => {
24+
state.connected = false;
1825
state.connectionError = err;
1926
},
2027

0 commit comments

Comments
 (0)