diff --git a/src/components/TopCornerMenu.vue b/src/components/TopCornerMenu.vue index d19273f8..11d7bfaf 100644 --- a/src/components/TopCornerMenu.vue +++ b/src/components/TopCornerMenu.vue @@ -20,17 +20,13 @@ mdi-restart{{ $t("App.FirmwareRestart") }} - - {{ $t("App.RestartServices") }} - - mdi-restart{{ $t("App.Klipper") }} - - - mdi-restart{{ $t("App.Moonraker") }} - - - mdi-restartWebcam - +
{{ $t("App.PowerDevices") }} @@ -68,15 +64,16 @@ export default { printer_state: state => state.printer.print_stats.state, devices: (state) => state.server.power.devices, }), - countPowerDevices: { - get() { - return this.$store.getters["server/power/count"] - } + countPowerDevices() { + return this.$store.getters["server/power/count"] }, - boolWebcam: { - get() { - return this.$store.state.gui.dashboard.boolWebcam || this.$store.state.gui.webcam.bool - } + boolWebcam() { + return this.$store.state.gui.dashboard.boolWebcam || this.$store.state.gui.webcam.bool + }, + services() { + let services = this.$store.state.server.system_info.available_services + services.sort() + return services } }, methods: { @@ -87,33 +84,25 @@ export default { 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() { + doRestart() { this.showMenu = false this.$store.commit('server/addEvent', { message: "RESTART", type: 'command' }) this.$socket.sendObj('printer.gcode.script', { script: "RESTART" }) }, - doFirmwareRestart: function() { + doFirmwareRestart() { this.showMenu = false this.$store.commit('server/addEvent', { message: "FIRMWARE_RESTART", type: 'command' }) this.$socket.sendObj('printer.gcode.script', { script: "FIRMWARE_RESTART" }) }, - doServiceRestartKlipper: function() { + doServiceRestart(service) { this.showMenu = false - this.$socket.sendObj('machine.services.restart', { service: "klipper" }) + this.$socket.sendObj('machine.services.restart', { service: service }) }, - doServiceRestartMoonraker: function() { - this.showMenu = false - this.$socket.sendObj('machine.services.restart', { service: "moonraker" }) - }, - doServiceRestartWebcam: function() { - this.showMenu = false - this.$socket.sendObj('machine.services.restart', { service: "webcamd" }) - }, - doHostReboot: function() { + doHostReboot() { this.showMenu = false this.$socket.sendObj('machine.reboot', { }) }, - doHostShutdown: function() { + doHostShutdown() { this.showMenu = false this.$socket.sendObj('machine.shutdown', { }) }, diff --git a/src/store/server/actions.js b/src/store/server/actions.js index f6dfda5c..f91e3cba 100644 --- a/src/store/server/actions.js +++ b/src/store/server/actions.js @@ -10,6 +10,7 @@ export default { init() { Vue.prototype.$socket.sendObj('server.info', {}, 'server/getInfo') Vue.prototype.$socket.sendObj('server.config', {}, 'server/getConfig') + Vue.prototype.$socket.sendObj('machine.system_info', {}, 'server/getSystemInfo') Vue.prototype.$socket.sendObj('server.database.list', { root: 'config' }, 'server/checkDatabases') }, @@ -101,6 +102,12 @@ export default { commit('addEvent', data); }, + getSystemInfo({ commit }, payload) { + if ('system_info' in payload) { + commit('setSystemInfo', payload.system_info) + } + }, + addRootDirectory({ commit, state }, data) { if (!state.registered_directories.includes(data.item.root)) { commit('addRootDirectory', { name: data.item.root }) diff --git a/src/store/server/index.js b/src/store/server/index.js index 33694f5d..62106cb7 100644 --- a/src/store/server/index.js +++ b/src/store/server/index.js @@ -19,6 +19,9 @@ export function getDefaultState() { registered_directories: [], events: [], config: {}, + system_info: { + available_services: [] + }, } } diff --git a/src/store/server/mutations.js b/src/store/server/mutations.js index 38fb4346..eb439383 100644 --- a/src/store/server/mutations.js +++ b/src/store/server/mutations.js @@ -77,6 +77,10 @@ export default { }) }, + setSystemInfo(state, payload) { + Vue.set(state, 'system_info', payload) + }, + addRootDirectory(state, payload) { state.registered_directories.push(payload.name) }