From 375a6666c21c8b23b580b833eb2696bbf0d333cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 3 Jun 2022 13:01:47 +0200 Subject: [PATCH] Web: move Worker status change requests to drop-down This basically copies the drop-down approach from Flamenco Manager 2. --- web/app/src/assets/base.css | 6 +- .../components/workers/WorkerActionsBar.vue | 102 ++++++++++++------ web/app/src/stores/notifications.js | 2 +- web/app/src/stores/workers.js | 24 ----- 4 files changed, 72 insertions(+), 62 deletions(-) diff --git a/web/app/src/assets/base.css b/web/app/src/assets/base.css index dc0810a4..beb70ef7 100644 --- a/web/app/src/assets/base.css +++ b/web/app/src/assets/base.css @@ -264,7 +264,7 @@ footer { margin-left: var(--spacer-sm); } -.btn-bar .btn[disabled] { +.btn[disabled] { background-color: transparent; border-color: var(--color-text-muted); color: var(--color-text-muted); @@ -272,12 +272,12 @@ footer { pointer-events: none; } -.btn-bar .btn:hover:not([disabled]) { +.btn:hover:not([disabled]) { transition: all 100ms; color: white; } -.btn-bar .btn:focus { +.btn:focus { /* Make sure the outline is clearly visible inside the button. */ outline-offset: -0.5em; } diff --git a/web/app/src/components/workers/WorkerActionsBar.vue b/web/app/src/components/workers/WorkerActionsBar.vue index 620800b4..af37d913 100644 --- a/web/app/src/components/workers/WorkerActionsBar.vue +++ b/web/app/src/components/workers/WorkerActionsBar.vue @@ -1,48 +1,82 @@ - - - diff --git a/web/app/src/stores/notifications.js b/web/app/src/stores/notifications.js index 405dbf87..537b17cf 100644 --- a/web/app/src/stores/notifications.js +++ b/web/app/src/stores/notifications.js @@ -74,8 +74,8 @@ export const useNotifs = defineStore('notifications', { let msg = `Worker ${workerUpdate.name}`; if (workerUpdate.previous_status && workerUpdate.previous_status != workerUpdate.status) { msg += ` changed status ${workerUpdate.previous_status} ➜ ${workerUpdate.status}`; + this.add(msg); } - this.add(msg) }, /* Ensure there is only 1000 items in the history. */ diff --git a/web/app/src/stores/workers.js b/web/app/src/stores/workers.js index 315c09a0..d90a9788 100644 --- a/web/app/src/stores/workers.js +++ b/web/app/src/stores/workers.js @@ -1,11 +1,5 @@ import { defineStore } from 'pinia' -import { WorkerMgtApi, WorkerStatusChangeRequest } from '@/manager-api'; -import { apiClient } from '@/stores/api-query-count'; - - -const api = new WorkerMgtApi(apiClient); - // 'use' prefix is idiomatic for Pinia stores. // See https://pinia.vuejs.org/core-concepts/ export const useWorkers = defineStore('workers', { @@ -43,23 +37,5 @@ export const useWorkers = defineStore('workers', { activeWorkerID: "", }); }, - - reqStatusAwake() { return this.requestStatus("awake"); }, - reqStatusAsleep() { return this.requestStatus("asleep"); }, - reqStatusOffline() { return this.requestStatus("offline"); }, - - /** - * Transition the active worker to the new status. - * @param {string} newStatus - * @returns a Promise for the API request. - */ - requestStatus(newStatus) { - if (!this.activeWorkerID) { - console.warn(`requestStatus(${newStatus}) impossible, no active worker ID`); - return; - } - const statuschange = new WorkerStatusChangeRequest(newStatus, false); - return api.requestWorkerStatusChange(this.activeWorkerID, statuschange); - }, }, })