Skip to content

Commit 5cb57af

Browse files
committed
Fix power button actions
1 parent 8385ec7 commit 5cb57af

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

resources/assets/scripts/components/server/components/PowerButtons.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import Vue from 'vue';
2-
import { mapState } from 'vuex';
2+
import {mapState} from 'vuex';
33
import Status from '../../../helpers/statuses';
4+
import {Socketio} from "@/mixins/socketio";
45

56
export default Vue.component('power-buttons', {
67
computed: {
78
...mapState('socket', ['connected', 'status']),
89
},
910

11+
mixins: [Socketio],
12+
1013
data: function () {
1114
return {
1215
statuses: Status,
@@ -15,7 +18,7 @@ export default Vue.component('power-buttons', {
1518

1619
methods: {
1720
sendPowerAction: function (action: string) {
18-
// this.$socket().instance().emit('set status', action)
21+
this.$socket().instance().emit('set status', action)
1922
},
2023
},
2124

@@ -28,9 +31,9 @@ export default Vue.component('power-buttons', {
2831
v-on:click.prevent="sendPowerAction('start')"
2932
>Start</button>
3033
<div v-else>
31-
<button class="btn btn-red-500 uppercase text-xs px-4 py-2" v-on:click.prevent="sendPowerAction('stop')">Stop</button>
34+
<button class="btn btn-red uppercase text-xs px-4 py-2" v-on:click.prevent="sendPowerAction('stop')">Stop</button>
3235
<button class="btn btn-secondary uppercase text-xs px-4 py-2" v-on:click.prevent="sendPowerAction('restart')">Restart</button>
33-
<button class="btn btn-secondary uppercase text-xs px-4 py-2" v-on:click.prevent="sendPowerAction('kill')">Kill</button>
36+
<button class="btn btn-secondary btn-red uppercase text-xs px-4 py-2" v-on:click.prevent="sendPowerAction('kill')">Kill</button>
3437
</div>
3538
</transition>
3639
</div>

resources/assets/scripts/mixins/socketio/emitter.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default new class SocketEmitter {
1515
/**
1616
* Add an event listener for socket events.
1717
*/
18-
addListener(event: string | number, callback: (data: any) => void, vm: ComponentOptions<Vue>) {
18+
addListener(event: string | number, callback: (...data: any[]) => void, vm: ComponentOptions<Vue>) {
1919
if (!isFunction(callback)) {
2020
return;
2121
}
@@ -31,7 +31,7 @@ export default new class SocketEmitter {
3131
/**
3232
* Remove an event listener for socket events based on the context passed through.
3333
*/
34-
removeListener(event: string | number, callback: (data: any) => void, vm: ComponentOptions<Vue>) {
34+
removeListener(event: string | number, callback: (...data: any[]) => void, vm: ComponentOptions<Vue>) {
3535
if (!isFunction(callback) || !this.listeners.has(event)) {
3636
return;
3737
}
@@ -53,7 +53,8 @@ export default new class SocketEmitter {
5353
*/
5454
emit(event: string | number, ...args: any) {
5555
(this.listeners.get(event) || []).forEach((listener) => {
56-
listener.callback.call(listener.vm, args);
56+
// @ts-ignore
57+
listener.callback.call(listener.vm, ...args);
5758
});
5859
}
5960
}

0 commit comments

Comments
 (0)