diff --git a/resources/assets/scripts/components/server/components/PowerButtons.ts b/resources/assets/scripts/components/server/components/PowerButtons.ts index b4c518a91..525632248 100644 --- a/resources/assets/scripts/components/server/components/PowerButtons.ts +++ b/resources/assets/scripts/components/server/components/PowerButtons.ts @@ -1,12 +1,15 @@ import Vue from 'vue'; -import { mapState } from 'vuex'; +import {mapState} from 'vuex'; import Status from '../../../helpers/statuses'; +import {Socketio} from "@/mixins/socketio"; export default Vue.component('power-buttons', { computed: { ...mapState('socket', ['connected', 'status']), }, + mixins: [Socketio], + data: function () { return { statuses: Status, @@ -15,7 +18,7 @@ export default Vue.component('power-buttons', { methods: { sendPowerAction: function (action: string) { - // this.$socket().instance().emit('set status', action) + this.$socket().instance().emit('set status', action) }, }, @@ -28,9 +31,9 @@ export default Vue.component('power-buttons', { v-on:click.prevent="sendPowerAction('start')" >Start
- + - +
diff --git a/resources/assets/scripts/mixins/socketio/emitter.ts b/resources/assets/scripts/mixins/socketio/emitter.ts index 5728de467..8a97772e8 100644 --- a/resources/assets/scripts/mixins/socketio/emitter.ts +++ b/resources/assets/scripts/mixins/socketio/emitter.ts @@ -15,7 +15,7 @@ export default new class SocketEmitter { /** * Add an event listener for socket events. */ - addListener(event: string | number, callback: (data: any) => void, vm: ComponentOptions) { + addListener(event: string | number, callback: (...data: any[]) => void, vm: ComponentOptions) { if (!isFunction(callback)) { return; } @@ -31,7 +31,7 @@ export default new class SocketEmitter { /** * Remove an event listener for socket events based on the context passed through. */ - removeListener(event: string | number, callback: (data: any) => void, vm: ComponentOptions) { + removeListener(event: string | number, callback: (...data: any[]) => void, vm: ComponentOptions) { if (!isFunction(callback) || !this.listeners.has(event)) { return; } @@ -53,7 +53,8 @@ export default new class SocketEmitter { */ emit(event: string | number, ...args: any) { (this.listeners.get(event) || []).forEach((listener) => { - listener.callback.call(listener.vm, args); + // @ts-ignore + listener.callback.call(listener.vm, ...args); }); } }