From a78780b8374d93fed0a9be2efa4f6f75fbef81d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Ros?= Date: Thu, 30 Mar 2023 14:38:55 -0700 Subject: [PATCH] Add custom fields to summary view --- src/components/agents/SummaryTab.vue | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/components/agents/SummaryTab.vue b/src/components/agents/SummaryTab.vue index 039b043..dcbc1b2 100644 --- a/src/components/agents/SummaryTab.vue +++ b/src/components/agents/SummaryTab.vue @@ -158,6 +158,20 @@ >
No checks
+ + +

Custom Fields

+ + + + + + + {{ field.name }}: {{ field.value }} + + + +
@@ -193,6 +207,7 @@ import { openAgentWindow, } from "@/api/agents"; import { notifySuccess } from "@/utils/notify"; +import { fetchCustomFields } from "@/api/core"; // ui imports import AgentActionMenu from "@/components/agents/AgentActionMenu.vue"; @@ -210,6 +225,7 @@ export default { // summary tab logic const summary = ref(null); + const customFieldsDefinitions = ref(null); const loading = ref(false); function diskBarColor(percent) { @@ -236,8 +252,30 @@ export default { return ret; }); + const customFields = computed(() => { + if (!summary.value.custom_fields) { + return []; + } + if (!customFieldsDefinitions.value) { + return []; + } + const ret = []; + for (const customField of summary.value.custom_fields) { + const definition = customFieldsDefinitions.value.find((def) => def.id === customField.field) + if (definition) { + ret.push({ + name: definition.name, + value: customField.value, + }) + } + } + + return ret; + }); + async function getSummary() { loading.value = true; + customFieldsDefinitions.value = await fetchCustomFields(); summary.value = await fetchAgent(selectedAgent.value); store.commit("setRefreshSummaryTab", false); store.commit("setAgentPlatform", summary.value.plat); @@ -277,6 +315,7 @@ export default { return { // reactive data summary, + customFields, loading, selectedAgent, disks,