diff --git a/web/app/src/clipboard.js b/web/app/src/clipboard.js
index 3ccee2ad..6ce430eb 100644
--- a/web/app/src/clipboard.js
+++ b/web/app/src/clipboard.js
@@ -7,6 +7,7 @@
*/
const flashAfterCopyDuration = 150;
+
/**
* Copy the inner text of an element to the clipboard.
*
@@ -14,9 +15,24 @@ const flashAfterCopyDuration = 150;
*/
export function copyElementText(clickEvent) {
const sourceElement = clickEvent.target;
+ copyElementValue(sourceElement, sourceElement.innerText);
+}
+
+/**
+ * Copy the inner text of an element to the clipboard.
+ *
+ * @param {Event } clickEvent the click event that triggered this function call.
+ */
+export function copyElementData(clickEvent) {
+ const sourceElement = clickEvent.target;
+ window.sourceElement = sourceElement;
+ copyElementValue(sourceElement, sourceElement.dataset.clipboard);
+}
+
+function copyElementValue(sourceElement, value) {
const inputElement = document.createElement("input");
document.body.appendChild(inputElement);
- inputElement.setAttribute("value", sourceElement.innerText);
+ inputElement.setAttribute("value", value);
inputElement.select();
// Note that the `navigator.clipboard` interface is only available when using
@@ -27,7 +43,6 @@ export function copyElementText(clickEvent) {
document.execCommand("copy");
document.body.removeChild(inputElement);
-
flashElement(sourceElement);
}
diff --git a/web/app/src/components/SwitchCheckbox.vue b/web/app/src/components/SwitchCheckbox.vue
index b8a61053..0c79f70f 100644
--- a/web/app/src/components/SwitchCheckbox.vue
+++ b/web/app/src/components/SwitchCheckbox.vue
@@ -1,5 +1,5 @@
-
diff --git a/web/app/src/stores/workers.js b/web/app/src/stores/workers.js
index d90a9788..5e3e82d0 100644
--- a/web/app/src/stores/workers.js
+++ b/web/app/src/stores/workers.js
@@ -1,5 +1,8 @@
import { defineStore } from 'pinia'
+import { WorkerMgtApi } from '@/manager-api';
+import { getAPIClient } from "@/api-client";
+
// 'use' prefix is idiomatic for Pinia stores.
// See https://pinia.vuejs.org/core-concepts/
export const useWorkers = defineStore('workers', {
@@ -11,6 +14,12 @@ export const useWorkers = defineStore('workers', {
* @type {string}
*/
activeWorkerID: "",
+
+ /** @type {API.WorkerCluster[]} */
+ clusters: [],
+
+ /* Mapping from cluster UUID to API.WorkerCluster. */
+ clustersByID: {},
}),
actions: {
setActiveWorkerID(workerID) {
@@ -37,5 +46,23 @@ export const useWorkers = defineStore('workers', {
activeWorkerID: "",
});
},
+ /**
+ * Fetch the available worker clusters from the Manager.
+ *
+ * @returns a promise.
+ */
+ refreshClusters() {
+ const api = new WorkerMgtApi(getAPIClient());
+ return api.fetchWorkerClusters()
+ .then((resp) => {
+ this.clusters = resp.clusters;
+
+ let clustersByID = {};
+ for (let cluster of this.clusters) {
+ clustersByID[cluster.id] = cluster;
+ }
+ this.clustersByID = clustersByID;
+ })
+ },
},
})