| 1 | <template> |
| 2 | <EntityDetailsCard :fields> |
| 3 | <template #suffix> |
| 4 | <CardKV label="wazuh_agent_status"> |
| 5 | <Chip |
| 6 | :type="getStatusColor(agent.wazuh_agent_status)" |
| 7 | :value="agent.wazuh_agent_status.toUpperCase()" |
| 8 | /> |
| 9 | </CardKV> |
| 10 | |
| 11 | <CardKV label="critical_asset"> |
| 12 | <AgentCriticalSelect |
| 13 | :agent-id="agent.agent_id" |
| 14 | :critical="agent.critical_asset" |
| 15 | @success="handleCriticalAssetUpdateSuccess" |
| 16 | /> |
| 17 | </CardKV> |
| 18 | </template> |
| 19 | </EntityDetailsCard> |
| 20 | </template> |
| 21 | |
| 22 | <script setup lang="ts"> |
| 23 | import type { AgentCriticalUpdateSuccessPayload } from "../AgentCriticalSelect.vue" |
| 24 | import type { Field } from "@/components/common/entity/EntityDetailsCard.vue" |
| 25 | import type { Agent } from "@/types/agents" |
| 26 | import _omit from "lodash/omit" |
| 27 | import { computed } from "vue" |
| 28 | import CardKV from "@/components/common/cards/CardKV.vue" |
| 29 | import Chip from "@/components/common/Chip.vue" |
| 30 | import EntityDetailsCard from "@/components/common/entity/EntityDetailsCard.vue" |
| 31 | import { getStatusColor } from "@/utils" |
| 32 | import AgentCriticalSelect from "../AgentCriticalSelect.vue" |
| 33 | |
| 34 | const props = defineProps<{ |
| 35 | agent: Agent |
| 36 | }>() |
| 37 | |
| 38 | const emit = defineEmits<{ |
| 39 | (e: "criticalAssetUpdated", value: AgentCriticalUpdateSuccessPayload): void |
| 40 | }>() |
| 41 | |
| 42 | const fields = computed<Field[]>(() => |
| 43 | Object.entries(_omit(props.agent, ["critical_asset", "wazuh_agent_status"])).map(([key, value]) => ({ |
| 44 | label: key, |
| 45 | value |
| 46 | })) |
| 47 | ) |
| 48 | |
| 49 | function handleCriticalAssetUpdateSuccess(payload: AgentCriticalUpdateSuccessPayload) { |
| 50 | emit("criticalAssetUpdated", payload) |
| 51 | } |
| 52 | </script> |