From dc52e238acd3dc09987c691571f92a4f6ce382d9 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 18 Aug 2018 20:13:40 -0700 Subject: [PATCH] Change socket implementation for servers --- CHANGELOG.md | 4 +- package.json | 2 +- .../scripts/components/server/Server.vue | 19 +++- .../server/components/PowerButtons.vue | 5 +- .../components/server/subpages/Console.vue | 6 +- .../scripts/mixins/socketio/connector.js | 103 ++++++++++++++++++ .../assets/scripts/mixins/socketio/emitter.js | 61 +++++++++++ .../assets/scripts/mixins/socketio/index.js | 53 +++++++++ yarn.lock | 6 - 9 files changed, 242 insertions(+), 17 deletions(-) create mode 100644 resources/assets/scripts/mixins/socketio/connector.js create mode 100644 resources/assets/scripts/mixins/socketio/emitter.js create mode 100644 resources/assets/scripts/mixins/socketio/index.js diff --git a/CHANGELOG.md b/CHANGELOG.md index ab0365a17..d6d3c87fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -171,7 +171,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines. * Nest and Egg listings now show the associated ID in order to make API requests easier. * Added star indicators to user listing in Admin CP to indicate users who are set as a root admin. * Creating a new node will now requires a SSL connection if the Panel is configured to use SSL as well. -* Socketio error messages due to permissions are now rendered correctly in the UI rather than causing a silent failure. +* Connector error messages due to permissions are now rendered correctly in the UI rather than causing a silent failure. * File manager now supports mass deletion option for files and folders. * Support for CS:GO as a default service option selection. * Support for GMOD as a default service option selection. @@ -301,7 +301,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines. * Changed 2FA login process to be more secure. Previously authentication checking happened on the 2FA post page, now it happens prior and is passed along to the 2FA page to avoid storing any credentials. ### Added -* Socketio error messages due to permissions are now rendered correctly in the UI rather than causing a silent failure. +* Connector error messages due to permissions are now rendered correctly in the UI rather than causing a silent failure. ## v0.7.0-beta.1 (Derelict Dermodactylus) ### Added diff --git a/package.json b/package.json index 9069d7a7e..06411972a 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ "vue": "^2.5.7", "vue-axios": "^2.1.1", "vue-router": "^3.0.1", - "vue-socket.io-extended": "^3.1.0", "vuex": "^3.0.1", "vuex-i18n": "^1.10.5", "vuex-router-sync": "^5.0.0", @@ -29,6 +28,7 @@ "babel-plugin-transform-runtime": "^6.23.0", "babel-plugin-transform-strict-mode": "^6.18.0", "babel-register": "^6.26.0", + "camelcase": "^5.0.0", "clean-webpack-plugin": "^0.1.19", "css-loader": "^0.28.11", "extract-text-webpack-plugin": "^4.0.0-beta.0", diff --git a/resources/assets/scripts/components/server/Server.vue b/resources/assets/scripts/components/server/Server.vue index 33885d172..e221fe05e 100644 --- a/resources/assets/scripts/components/server/Server.vue +++ b/resources/assets/scripts/components/server/Server.vue @@ -70,18 +70,19 @@ import Navigation from '../core/Navigation'; import ProgressBar from './components/ProgressBar'; import { mapState } from 'vuex'; - import VueSocketio from 'vue-socket.io-extended'; import io from 'socket.io-client'; - import Vue from 'vue'; + import { Socketio } from './../../mixins/socketio'; import PowerButtons from './components/PowerButtons'; import Flash from '../Flash'; export default { + name: 'server', + mixins: [Socketio], components: { Flash, PowerButtons, ProgressBar, Navigation, - TerminalIcon, FolderIcon, UsersIcon, CalendarIcon, DatabaseIcon, GlobeIcon, SettingsIcon + TerminalIcon, FolderIcon, UsersIcon, CalendarIcon, DatabaseIcon, GlobeIcon, SettingsIcon, }, computed: { @@ -95,10 +96,20 @@ }; }, + sockets: { + 'console': function () { + console.log('server CONSOLE'); + }, + }, + mounted: function () { this.loadServer(); }, + beforeDestroy: function () { + this.removeSocket(); + }, + methods: { /** * Load the core server information needed for these pages to be functional. @@ -115,7 +126,7 @@ query: `token=${this.credentials.key}`, }); - Vue.use(VueSocketio, socket, { store: this.$store }); + this.$socket().connect(socket); this.loadingServerData = false; }) .catch(console.error); diff --git a/resources/assets/scripts/components/server/components/PowerButtons.vue b/resources/assets/scripts/components/server/components/PowerButtons.vue index ad65f4a86..1bc71817b 100644 --- a/resources/assets/scripts/components/server/components/PowerButtons.vue +++ b/resources/assets/scripts/components/server/components/PowerButtons.vue @@ -24,11 +24,12 @@