feature: move power switches to top corner navi

Signed-off-by: Stefan Dej <meteyou@gmail.com>
This commit is contained in:
Stefan Dej committed 2020-12-09 00:43:31 +01:00
1 parent d1401d321a
commit 57ca568bbe
5 files changed
+90 -49

No files matched your search

+5 -40
View File
@@ -59,29 +59,7 @@
<v-spacer></v-spacer>
<v-btn color="primary" class="mr-5 d-none d-sm-flex" v-if="isConnected && save_config_pending" :loading="loadings.includes['topbarSaveConfig']" @click="clickSaveConfig">SAVE CONFIG</v-btn>
<v-btn color="error" class="button-min-width-auto px-3" v-if="isConnected" :loading="loadings.includes['topbarEmergencyStop']" @click="clickEmergencyStop"><v-icon class="mr-sm-2">mdi-alert-circle-outline</v-icon><span class="d-none d-sm-flex">Emergency Stop</span></v-btn>
<v-menu bottom left :offset-y="true">
<template v-slot:activator="{ on, attrs }">
<v-btn dark icon v-bind="attrs" v-on="on">
<v-icon>mdi-dots-vertical</v-icon>
</v-btn>
</template>
<v-list dense>
<v-list-item link @click="doRestart()">
<v-list-item-title><v-icon class="mr-3">mdi-sync</v-icon>Restart</v-list-item-title>
</v-list-item>
<v-list-item link @click="doFirmwareRestart()">
<v-list-item-title><v-icon class="mr-3">mdi-sync</v-icon>FW Restart</v-list-item-title>
</v-list-item>
<v-divider></v-divider>
<v-list-item link @click="doHostReboot()">
<v-list-item-title><v-icon class="mr-3">mdi-power</v-icon>Reboot Host</v-list-item-title>
</v-list-item>
<v-list-item link @click="doHostShutdown()">
<v-list-item-title><v-icon class="mr-3">mdi-power</v-icon>Shutdown Host</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
<top-corner-menu></top-corner-menu>
</v-app-bar>
<v-main id="content">
@@ -111,15 +89,16 @@
</template>
<script>
import routes from './routes';
import { mapState, mapGetters } from 'vuex';
import routes from './routes'
import { mapState, mapGetters } from 'vuex'
import TopCornerMenu from "@/components/TopCornerMenu";
export default {
props: {
source: String,
},
components: {
TopCornerMenu
},
data: () => ({
overlayDisconnect: true,
@@ -181,20 +160,6 @@ export default {
this.$store.commit('socket/addLoading', { name: 'topbarSaveConfig' });
this.$socket.sendObj('printer.gcode.script', { script: "SAVE_CONFIG" }, 'socket/removeLoading', { name: 'topbarSaveConfig' });
},
doRestart: function() {
this.$store.commit('server/addEvent', "RESTART");
this.$socket.sendObj('printer.gcode.script', { script: "RESTART" });
},
doFirmwareRestart: function() {
this.$store.commit('server/addEvent', "FIRMWARE_RESTART");
this.$socket.sendObj('printer.gcode.script', { script: "FIRMWARE_RESTART" });
},
doHostReboot: function() {
this.$socket.sendObj('machine.reboot', { });
},
doHostShutdown: function() {
this.$socket.sendObj('machine.shutdown', { });
},
drawFavicon(val) {
let favicon16 = document.querySelector("link[rel*='icon'][sizes='16x16']")
let favicon32 = document.querySelector("link[rel*='icon'][sizes='32x32']")
+82
View File
@@ -0,0 +1,82 @@
<template>
<v-menu bottom left :offset-y="true" :close-on-content-click="false">
<template v-slot:activator="{ on, attrs }">
<v-btn dark icon v-bind="attrs" v-on="on">
<v-icon>mdi-dots-vertical</v-icon>
</v-btn>
</template>
<v-list dense>
<v-subheader>Klipper Control</v-subheader>
<v-list-item link @click="doRestart()">
<v-list-item-title><v-icon class="mr-3">mdi-sync</v-icon>Restart</v-list-item-title>
</v-list-item>
<v-list-item link @click="doFirmwareRestart()">
<v-list-item-title><v-icon class="mr-3">mdi-sync</v-icon>Firmware Restart</v-list-item-title>
</v-list-item>
<div v-if="countPowerDevices">
<v-divider class="mt-2"></v-divider>
<v-subheader>Power Devices</v-subheader>
<v-list-item v-for="(device, index) in devices" v-bind:key="index" @click="changeSwitch(device, device.status)" :disabled="(device.status === 'error')">
<v-list-item-title>
<v-icon class="mr-3">mdi-{{ device.status === 'on' ? 'toggle-switch' : 'toggle-switch-off' }}</v-icon>{{ device.device }}
</v-list-item-title>
</v-list-item>
</div>
<v-divider class="mt-2"></v-divider>
<v-subheader>Host Control</v-subheader>
<v-list-item link @click="doHostReboot()">
<v-list-item-title><v-icon class="mr-3">mdi-power</v-icon>Reboot</v-list-item-title>
</v-list-item>
<v-list-item link @click="doHostShutdown()">
<v-list-item-title><v-icon class="mr-3">mdi-power</v-icon>Shutdown</v-list-item-title>
</v-list-item>
</v-list>
</v-menu>
</template>
<script>
import {mapState} from "vuex";
import Vue from "vue";
export default {
name: "TopCornerMenu.vue",
computed: {
...mapState({
devices: (state) => state.server.power.devices,
}),
countPowerDevices: {
get() {
return this.$store.getters["server/power/count"]
}
},
},
methods: {
changeSwitch(device, value) {
this.setPower(device, (value === 'off') ? 1 : 0)
},
setPower(device, value) {
let rpc = value === 1 ? "machine.device_power.on" : "machine.device_power.off"
Vue.prototype.$socket.sendObj(rpc,{ [device.device]: null },"server/power/responseToggle")
},
doRestart: function() {
this.$store.commit('server/addEvent', "RESTART")
this.$socket.sendObj('printer.gcode.script', { script: "RESTART" })
},
doFirmwareRestart: function() {
this.$store.commit('server/addEvent', "FIRMWARE_RESTART")
this.$socket.sendObj('printer.gcode.script', { script: "FIRMWARE_RESTART" })
},
doHostReboot: function() {
this.$socket.sendObj('machine.reboot', { })
},
doHostShutdown: function() {
this.$socket.sendObj('machine.shutdown', { })
},
}
}
</script>
<style scoped>
</style>
+3 -1
View File
@@ -1,6 +1,8 @@
import panels from './panels'
import topCornerMenu from './TopCornerMenu'
export default {
panels
panels,
topCornerMenu
}
-6
View File
@@ -9,7 +9,6 @@
<control-panel class="mt-6" v-if="klippy_state === 'ready'"></control-panel>
<extruder-panel class="mt-6" v-if="klippy_state === 'ready'"></extruder-panel>
<peripherie-panel class="mt-6" v-if="klippy_state === 'ready'"></peripherie-panel>
<power-control-panel class="mt-6" v-if="countPowerDevices > 0"></power-control-panel>
</v-col>
<v-col class="col-sm-12 col-md-7">
<tools-panel v-if="socket_connected && klippy_connected"></tools-panel>
@@ -37,11 +36,6 @@
showDashboardConsole: state => state.gui.dashboard.boolConsole,
config: state => state.printer.configfile.config,
}),
countPowerDevices: {
get() {
return this.$store.getters["server/power/count"]
}
},
existsPrinterConfig: {
get() {
return this.$store.getters["printer/existPrinterConfig"]
-2
View File
@@ -27,12 +27,10 @@ export default {
break
case 'notify_klippy_ready':
window.console.log("ready bla bla")
commit('server/setKlippyReady', null, { root: true })
break
case 'notify_klippy_disconnected':
window.console.log("disconnected bla bla")
commit('server/setKlippyDisconnected', null, { root: true })
break