Files
mainsail/src/components/TheTopCornerMenu.vue
T
steadyjaw 8a4a4ce234 refactor: button overhaul and minor changes to the ui (#413)
* refactor(appbar): change buttons to new design

* refactor(appbar): change height and add pritnername

* refactor: small sidebar

* refactor(vuetify): define parts of the mainsail theme and expose colors to css

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* refactor: ui settings add missing divider

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* refactor: add farm printer selection and menu to new top and sidebar, added icons to version-tooltip

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* refactor: make topbar buttons hideable via ui settings

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* refactor: move miniConsole buttons to toolbar and make'em collapsible

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* refactor: set matching colors for buttons on console page

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* refactor: use colornames from theme and set play/resume button to green

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* fix: correct visibility of hide buttons on collapse

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* feature: add virtual tab button to console-input on touch devices

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* refactor: remove hide e-stop button setting

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* fix: add reactivity to hide upload and print button functionality

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* refactor: move logo to topbar and clip menu under topbar

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* refactor: remove unused TheSidebarPrinterMenu

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* feature: create and add about component to sidebar ...no dialog on click yet

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* fix: correct appearance of the close icon from interface settings dialog

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* Revert "fix: correct appearance of the close icon from interface settings dialog"

This reverts commit f66e29d4f2.

* refactor: close ui settings on ESC and change close icon to tile

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* refactor: change font style in wide sidebar and extend width of wide menu

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* refactor: change menu style ui-settings-entry to dropdown

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* refactor: correct variablenames in locales

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* refactor: re-do menuStyle setting implementation

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* refactor(miniconsole): change collapse button to tile and remove empty cols and row in template

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* refactor: gui variables and button appearance in toolbars

* move some vars to configure gui appearance to variables.ts

* force buttons in bars to 100% height

* set icon button width to toolbar-heigth

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* refactor(heightmap): add autofocus and close on ESC to dialogs

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* refactor(throttledStates): bigger dropdownlist in favor of readability

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* refactor(confFiles): change imageviewer topbar to darkcolor and move close button to left

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* fix: camera-dropdown visability condition

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* refactor(history): ad close on ESC on dialogs

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* refactor: button overhaul

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* fix: correct navigation width and change variablenames

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>

* fix: change more close buttons to tiles

Signed-off-by: steadyjaw <martin.keilaus@gmail.com>
2021-11-19 21:07:22 +01:00

195 lines
9.1 KiB
Vue

<style scoped>
.minheight30 {
min-height: 30px;
}
</style>
<template>
<div>
<v-menu bottom left :offset-y="true" :close-on-content-click="false" v-model="showMenu">
<template v-slot:activator="{ on, attrs }">
<v-btn icon tile v-bind="attrs" v-on="on">
<v-icon>mdi-power-standby</v-icon>
</v-btn>
</template>
<v-list dense>
<template v-if="klipperState !== 'disconnected'">
<v-subheader class="" style="height: auto;">{{ $t("App.TopCornerMenu.KlipperControl") }}</v-subheader>
<v-list-item class="minheight30 pr-2" link @click="klipperRestart()">
<v-list-item-title>{{ $t("App.TopCornerMenu.KlipperRestart") }}</v-list-item-title>
<v-list-item-action class="my-0 d-flex flex-row" style="min-width: auto;">
<v-icon class="mr-2" small>mdi-restart</v-icon>
</v-list-item-action>
</v-list-item>
<v-list-item class="minheight30 pr-2" link @click="klipperFirmwareRestart()">
<v-list-item-title>{{ $t("App.TopCornerMenu.KlipperFirmwareRestart") }}</v-list-item-title>
<v-list-item-action class="my-0 d-flex flex-row" style="min-width: auto;">
<v-icon class="mr-2" small>mdi-restart</v-icon>
</v-list-item-action>
</v-list-item>
</template>
<template v-if="services.length">
<v-divider class="mt-0" v-if="klipperState !== 'disconnected'"></v-divider>
<v-subheader class="pt-2" style="height: auto;">{{ $t("App.TopCornerMenu.ServiceControl") }}</v-subheader>
<v-list-item class="minheight30 pr-2" v-for="service in services" v-bind:key="service">
<v-list-item-title>
<v-tooltip left>
<template v-slot:activator="{ on, attrs }">
<span v-bind="attrs" v-on="on">{{ service.charAt(0).toUpperCase() + service.slice(1) }}</span>
</template>
<span>{{ getServiceState(service) }} ({{ getServiceSubState(service) }})</span>
</v-tooltip>
</v-list-item-title>
<v-list-item-action class="my-0 d-flex flex-row" style="min-width: auto;">
<v-btn icon small v-if="getServiceState(service) === 'inactive'" @click="serviceStart(service)"><v-icon small>mdi-play</v-icon></v-btn>
<v-btn icon small v-else @click="serviceRestart(service)"><v-icon small>mdi-restart</v-icon></v-btn>
<v-btn icon small :disabled="getServiceState(service) === 'inactive'" @click="serviceStop(service)"><v-icon small>mdi-stop</v-icon></v-btn>
</v-list-item-action>
</v-list-item>
</template>
<template v-if="powerDevices.length">
<v-divider class="mt-0"></v-divider>
<v-subheader class="pt-2" style="height: auto;">{{ $t("App.TopCornerMenu.PowerDevices") }}</v-subheader>
<v-list-item v-for="(device, index) in powerDevices" v-bind:key="index" class="minheight30 pr-2" @click="changeSwitch(device, device.status)" :disabled="(device.status === 'error' || device.locked_while_printing && ['printing', 'paused'].includes(printer_state))">
<v-list-item-title>{{ device.device }}</v-list-item-title>
<v-list-item-action class="my-0 d-flex flex-row" style="min-width: auto;">
<v-icon class="mr-2" :color="device.status === 'on' ? '' : 'grey darken-2'">mdi-{{ device.status === 'on' ? 'toggle-switch' : 'toggle-switch-off' }}</v-icon>
</v-list-item-action>
</v-list-item>
</template>
<v-divider class="mt-0"></v-divider>
<v-subheader class="pt-2" style="height: auto;">{{ $t("App.TopCornerMenu.HostControl") }}</v-subheader>
<v-list-item class="minheight30 pr-2" link @click="hostReboot()">
<v-list-item-title>{{ $t("App.TopCornerMenu.Reboot") }}</v-list-item-title>
<v-list-item-action class="my-0 d-flex flex-row" style="min-width: auto;">
<v-icon class="mr-2" small>mdi-power</v-icon>
</v-list-item-action>
</v-list-item>
<v-list-item class="minheight30 pr-2" link @click="hostShutdown()">
<v-list-item-title>{{ $t("App.TopCornerMenu.Shutdown") }}</v-list-item-title>
<v-list-item-action class="my-0 d-flex flex-row" style="min-width: auto;">
<v-icon class="mr-2" small>mdi-power</v-icon>
</v-list-item-action>
</v-list-item>
</v-list>
</v-menu>
<v-dialog v-model="dialogPowerDeviceChange.show" width="400" :fullscreen="isMobile">
<v-card>
<v-card-title class="headline">{{ $t(this.dialogPowerDeviceChange.value === 'off' ? 'PowerDeviceChangeDialog.TurnDeviceOn' : 'PowerDeviceChangeDialog.TurnDeviceOff', {'device': dialogPowerDeviceChange.device}) }}</v-card-title>
<v-card-text>{{ $t('PowerDeviceChangeDialog.AreYouSure') }}</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="red darken-1" text @click="dialogPowerDeviceChange.show = false">{{ $t('PowerDeviceChangeDialog.No')}}</v-btn>
<v-btn color="green darken-1" text @click="powerDeviceToggle">{{$t('PowerDeviceChangeDialog.Yes')}}</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</div>
</template>
<script lang="ts">
import Component from 'vue-class-component'
import { Mixins } from 'vue-property-decorator'
import BaseMixin from '@/components/mixins/base'
import {ServerPowerStateDevice} from '@/store/server/power/types'
interface dialogPowerDeviceChange {
show: boolean
device: string
value: string
}
@Component
export default class TheTopCornerMenu extends Mixins(BaseMixin) {
showMenu = false
dialogPowerDeviceChange : dialogPowerDeviceChange = {
show: false,
device: '',
value: ''
}
get services() {
const services = this.$store.state.server.system_info?.available_services?.filter((name: string) => name !== 'klipper_mcu') ?? []
services.sort()
return services
}
get powerDevices() {
return this.$store.getters['server/power/getDevices']
}
get service_states() {
return this.$store.state.server.system_info?.service_state ?? {}
}
getServiceState(name: string) {
if (name in this.service_states) return this.service_states[name].active_state
return null
}
getServiceSubState(name: string) {
if (name in this.service_states) return this.service_states[name].sub_state
return null
}
klipperRestart() {
this.showMenu = false
this.$store.dispatch('server/addEvent', { message: 'RESTART', type: 'command' })
this.$socket.emit('printer.gcode.script', { script: 'RESTART' })
}
klipperFirmwareRestart() {
this.showMenu = false
this.$store.dispatch('server/addEvent', { message: 'FIRMWARE_RESTART', type: 'command' })
this.$socket.emit('printer.gcode.script', { script: 'FIRMWARE_RESTART' })
}
serviceStart(service: string) {
this.showMenu = false
this.$socket.emit('machine.services.start', { service: service })
}
serviceRestart(service: string) {
this.showMenu = false
this.$socket.emit('machine.services.restart', { service: service })
}
serviceStop(service: string) {
this.showMenu = false
this.$socket.emit('machine.services.stop', { service: service })
}
changeSwitch(device: ServerPowerStateDevice, value: string) {
this.dialogPowerDeviceChange.device = device.device
this.dialogPowerDeviceChange.value = value
const confirmOnPowerDeviceChange = this.$store.state.gui.general.confirmOnPowerDeviceChange
if (confirmOnPowerDeviceChange) {
this.dialogPowerDeviceChange.show = true
}
else {
this.powerDeviceToggle()
}
}
powerDeviceToggle() {
this.dialogPowerDeviceChange.show = false
const rpc = (this.dialogPowerDeviceChange.value === 'off' ? 'machine.device_power.on' : 'machine.device_power.off')
this.$socket.emit(rpc,{ [this.dialogPowerDeviceChange.device]: null },{ action: 'server/power/responseToggle' })
}
hostReboot() {
this.showMenu = false
this.$socket.emit('machine.reboot', { })
}
hostShutdown() {
this.showMenu = false
this.$socket.emit('machine.shutdown', { })
}
}
</script>