From f20d40460e82228dc532718e762235457a21c649 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Mon, 6 Aug 2018 21:33:43 -0700 Subject: [PATCH] Better handling of connection errors --- .../assets/scripts/components/server/Server.vue | 16 ++++++++++++---- .../components/server/subpages/Console.vue | 14 ++++++++------ resources/assets/scripts/store/modules/socket.js | 9 ++++++++- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/resources/assets/scripts/components/server/Server.vue b/resources/assets/scripts/components/server/Server.vue index a42bf76bb..33885d172 100644 --- a/resources/assets/scripts/components/server/Server.vue +++ b/resources/assets/scripts/components/server/Server.vue @@ -1,6 +1,7 @@ @@ -69,9 +75,11 @@ import Vue from 'vue'; import PowerButtons from './components/PowerButtons'; + import Flash from '../Flash'; export default { components: { + Flash, PowerButtons, ProgressBar, Navigation, TerminalIcon, FolderIcon, UsersIcon, CalendarIcon, DatabaseIcon, GlobeIcon, SettingsIcon }, @@ -81,16 +89,16 @@ ...mapState('socket', ['connected', 'connectionError']), }, - mounted: function () { - this.loadServer(); - }, - data: function () { return { loadingServerData: true, }; }, + mounted: function () { + this.loadServer(); + }, + methods: { /** * Load the core server information needed for these pages to be functional. diff --git a/resources/assets/scripts/components/server/subpages/Console.vue b/resources/assets/scripts/components/server/subpages/Console.vue index 81aff9196..37bea672f 100644 --- a/resources/assets/scripts/components/server/subpages/Console.vue +++ b/resources/assets/scripts/components/server/subpages/Console.vue @@ -45,9 +45,15 @@ */ connected: function (state) { if (state) { + this.terminal.open(this.$refs.terminal); + this.terminal.fit(); + this.terminal.clear(); + this.$socket.emit('send server log'); + } else { + this.terminal.dispose(); } - } + }, }, /** @@ -64,7 +70,7 @@ data.line.split(/\n/g).forEach(line => { this.terminal.writeln(line + '\u001b[0m'); }); - } + }, }, /** @@ -73,10 +79,6 @@ * socket is not connected this will occur automatically when it connects. */ mounted: function () { - this.terminal.open(this.$refs.terminal); - this.terminal.fit(); - this.terminal.clear(); - if (this.connected) { this.$socket.emit('send server log'); } diff --git a/resources/assets/scripts/store/modules/socket.js b/resources/assets/scripts/store/modules/socket.js index a2d17c798..298273d51 100644 --- a/resources/assets/scripts/store/modules/socket.js +++ b/resources/assets/scripts/store/modules/socket.js @@ -4,7 +4,7 @@ export default { namespaced: true, state: { connected: false, - connectionError: null, + connectionError: false, status: Status.STATUS_OFF, }, actions: { @@ -12,9 +12,16 @@ export default { mutations: { SOCKET_CONNECT: (state) => { state.connected = true; + state.connectionError = false; }, SOCKET_ERROR: (state, err) => { + state.connected = false; + state.connectionError = err; + }, + + SOCKET_CONNECT_ERROR: (state, err) => { + state.connected = false; state.connectionError = err; },