From a36c4cd4e4e5aaf09157d5ed1eaae42b9a90621f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 4 Apr 2023 13:21:12 +0200 Subject: [PATCH] Web: clarify the cluster assignment result in the worker details view Now the hint is no longer generically explaining things, but is dynamic and specific for the current assignment of the worker's clusters. --- .../src/components/workers/WorkerDetails.vue | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/web/app/src/components/workers/WorkerDetails.vue b/web/app/src/components/workers/WorkerDetails.vue index 7148901f..b3e951ac 100644 --- a/web/app/src/components/workers/WorkerDetails.vue +++ b/web/app/src/components/workers/WorkerDetails.vue @@ -43,8 +43,11 @@ -

- When a worker is assigned to one or more cluster, it will ignore jobs assigned to other clusters. +

+ This worker will only pick up jobs assigned to one of its clusters, and clusterless jobs. +

+

+ This worker will only pick up clusterless jobs.

@@ -207,6 +210,10 @@ export default { workerSleepScheduleStatusLabel() { return this.workerSleepSchedule.is_active ? 'Enabled' : 'Disabled'; }, + hasClustersAssigned() { + const clusterIDs = this.getAssignedClusterIDs(); + return clusterIDs && clusterIDs.length > 0; + } }, methods: { fetchWorkerSleepSchedule() { @@ -272,15 +279,10 @@ export default { console.log("New assignment:", plain(this.thisWorkerClusters)) // Construct cluster change request. - const clusterIDs = []; - for (clusterID in this.thisWorkerClusters) { - // Values can exist and be set to 'false'. - const isAssigned = this.thisWorkerClusters[clusterID]; - if (isAssigned) clusterIDs.push(clusterID); - } + const clusterIDs = this.getAssignedClusterIDs(); + const changeRequest = new WorkerClusterChangeRequest(clusterIDs); // Send to the Manager. - const changeRequest = new WorkerClusterChangeRequest(clusterIDs); this.api.setWorkerClusters(this.workerData.id, changeRequest) .then(() => { this.notifs.add('Cluster assignment updated'); @@ -290,6 +292,15 @@ export default { this.notifs.add(`Error: ${errorMsg}`); }); }, + getAssignedClusterIDs() { + const clusterIDs = []; + for (let clusterID in this.thisWorkerClusters) { + // Values can exist and be set to 'false'. + const isAssigned = this.thisWorkerClusters[clusterID]; + if (isAssigned) clusterIDs.push(clusterID); + } + return clusterIDs; + } } };