| 1 | <template> |
| 2 | <div> |
| 3 | <CardEntity hoverable :embedded> |
| 4 | <template #default> |
| 5 | {{ serviceName }} |
| 6 | </template> |
| 7 | |
| 8 | <template v-if="networkConnector.deployed" #footerMain> |
| 9 | <Badge type="active"> |
| 10 | <template #iconLeft> |
| 11 | <Icon :name="DeployIcon" :size="13" /> |
| 12 | </template> |
| 13 | <template #value>Deployed</template> |
| 14 | </Badge> |
| 15 | </template> |
| 16 | <template #footerExtra> |
| 17 | <div class="flex flex-wrap gap-3"> |
| 18 | <n-button size="small" @click.stop="showDetails = true"> |
| 19 | <template #icon> |
| 20 | <Icon :name="InfoIcon" /> |
| 21 | </template> |
| 22 | Details |
| 23 | </n-button> |
| 24 | |
| 25 | <CustomerIntegrationMetaButton |
| 26 | size="small" |
| 27 | :customer-code="networkConnector.customer_code" |
| 28 | :integration-name="serviceName" |
| 29 | /> |
| 30 | |
| 31 | <CustomerNetworkConnectorActions |
| 32 | class="flex flex-wrap gap-3" |
| 33 | :network-connector |
| 34 | hide-delete-button |
| 35 | size="small" |
| 36 | @deployed="emit('deployed')" |
| 37 | @deleted="emit('deleted')" |
| 38 | @decommissioned="emit('decommissioned')" |
| 39 | /> |
| 40 | </div> |
| 41 | </template> |
| 42 | </CardEntity> |
| 43 | |
| 44 | <n-modal |
| 45 | v-model:show="showDetails" |
| 46 | preset="card" |
| 47 | :style="{ maxWidth: 'min(800px, 90vw)', minHeight: 'min(400px, 90vh)', overflow: 'hidden' }" |
| 48 | :title="serviceName" |
| 49 | :bordered="false" |
| 50 | segmented |
| 51 | > |
| 52 | <div class="grid-auto-fit-200 grid gap-2"> |
| 53 | <CardKV v-for="ak of authKeys" :key="ak.key"> |
| 54 | <template #key> |
| 55 | {{ ak.key }} |
| 56 | </template> |
| 57 | <template #value> |
| 58 | {{ ak.value || "-" }} |
| 59 | </template> |
| 60 | </CardKV> |
| 61 | </div> |
| 62 | </n-modal> |
| 63 | </div> |
| 64 | </template> |
| 65 | |
| 66 | <script setup lang="ts"> |
| 67 | import type { CustomerNetworkConnector } from "@/types/networkConnectors.d" |
| 68 | import _uniqBy from "lodash/uniqBy" |
| 69 | import { NButton, NModal } from "naive-ui" |
| 70 | import { computed, ref, toRefs } from "vue" |
| 71 | import Badge from "@/components/common/Badge.vue" |
| 72 | import CardEntity from "@/components/common/cards/CardEntity.vue" |
| 73 | import CardKV from "@/components/common/cards/CardKV.vue" |
| 74 | import Icon from "@/components/common/Icon.vue" |
| 75 | import CustomerIntegrationMetaButton from "../metadata/CustomerIntegrationMetaButton.vue" |
| 76 | import CustomerNetworkConnectorActions from "./CustomerNetworkConnectorActions.vue" |
| 77 | |
| 78 | const props = defineProps<{ |
| 79 | networkConnector: CustomerNetworkConnector |
| 80 | embedded?: boolean |
| 81 | }>() |
| 82 | const emit = defineEmits<{ |
| 83 | (e: "deployed"): void |
| 84 | (e: "decommissioned"): void |
| 85 | (e: "deleted"): void |
| 86 | }>() |
| 87 | |
| 88 | const { networkConnector, embedded } = toRefs(props) |
| 89 | |
| 90 | const DeployIcon = "carbon:deploy" |
| 91 | const InfoIcon = "carbon:information" |
| 92 | |
| 93 | const showDetails = ref(false) |
| 94 | const serviceName = computed(() => networkConnector.value.network_connector_service_name) |
| 95 | const authKeys = computed(() => { |
| 96 | const keys: { key: string; value: string }[] = [] |
| 97 | |
| 98 | for (const subscriptions of networkConnector.value.network_connectors_subscriptions) { |
| 99 | for (const ak of subscriptions.network_connectors_keys) { |
| 100 | keys.push({ |
| 101 | key: ak.auth_key_name, |
| 102 | value: ak.auth_value |
| 103 | }) |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | return _uniqBy(keys, "key") |
| 108 | }) |
| 109 | </script> |