| 1 | <template> |
| 2 | <div> |
| 3 | <CardEntity :embedded hoverable clickable @click.stop="showDetails = true"> |
| 4 | <template #headerMain> |
| 5 | <div class="flex grow flex-wrap gap-2"> |
| 6 | <span> |
| 7 | {{ formatDate(stat.first_active, dFormats.datetimesecmill) }} |
| 8 | </span> |
| 9 | <span>•</span> |
| 10 | <span> |
| 11 | {{ formatDate(stat.last_active, dFormats.datetimesecmill) }} |
| 12 | </span> |
| 13 | </div> |
| 14 | </template> |
| 15 | <template #default> |
| 16 | <div class="flex flex-wrap gap-2"> |
| 17 | <Badge v-for="artifact of stat.names_with_response" :key="artifact" color="primary" type="splitted"> |
| 18 | <template #value> |
| 19 | {{ artifact }} |
| 20 | </template> |
| 21 | </Badge> |
| 22 | </div> |
| 23 | <div v-if="stat.error_message" class="text-error mt-3"> |
| 24 | {{ stat.error_message }} |
| 25 | </div> |
| 26 | </template> |
| 27 | <template #mainExtra> |
| 28 | <div class="flex flex-wrap items-center gap-3"> |
| 29 | <Badge type="splitted" color="primary"> |
| 30 | <template #label>Status</template> |
| 31 | <template #value> |
| 32 | {{ stat.status || "-" }} |
| 33 | </template> |
| 34 | </Badge> |
| 35 | <Badge type="splitted" color="primary"> |
| 36 | <template #label>Duration</template> |
| 37 | <template #value> |
| 38 | {{ duration }} |
| 39 | </template> |
| 40 | </Badge> |
| 41 | </div> |
| 42 | </template> |
| 43 | </CardEntity> |
| 44 | |
| 45 | <n-modal |
| 46 | v-model:show="showDetails" |
| 47 | preset="card" |
| 48 | content-class="p-0!" |
| 49 | :style="{ maxWidth: 'min(800px, 90vw)', minHeight: 'min(550px, 90vh)', overflow: 'hidden' }" |
| 50 | :title="`Agent Query Stat ${stat.Artifact ? `: ${stat.Artifact}` : ''}`" |
| 51 | :bordered="false" |
| 52 | segmented |
| 53 | > |
| 54 | <n-tabs type="line" animated :tabs-padding="24"> |
| 55 | <n-tab-pane name="Info" tab="Info" display-directive="show"> |
| 56 | <div v-if="properties" class="grid-auto-fit-200 grid gap-2 p-6 pt-3"> |
| 57 | <CardKV v-for="(value, key) of properties" :key> |
| 58 | <template #key> |
| 59 | {{ key }} |
| 60 | </template> |
| 61 | <template #value> |
| 62 | {{ value === "" ? "-" : (value ?? "-") }} |
| 63 | </template> |
| 64 | </CardKV> |
| 65 | </div> |
| 66 | </n-tab-pane> |
| 67 | <n-tab-pane name="Backtrace" tab="Backtrace" display-directive="show"> |
| 68 | <div class="p-6 pt-3"> |
| 69 | <n-input |
| 70 | :value="stat.backtrace" |
| 71 | type="textarea" |
| 72 | readonly |
| 73 | placeholder="Empty" |
| 74 | size="large" |
| 75 | :autosize="{ |
| 76 | minRows: 3, |
| 77 | maxRows: 18 |
| 78 | }" |
| 79 | /> |
| 80 | </div> |
| 81 | </n-tab-pane> |
| 82 | </n-tabs> |
| 83 | </n-modal> |
| 84 | </div> |
| 85 | </template> |
| 86 | |
| 87 | <script setup lang="ts"> |
| 88 | import type { FlowQueryStat } from "@/types/flow.d" |
| 89 | import _pick from "lodash/pick" |
| 90 | import { NInput, NModal, NTabPane, NTabs } from "naive-ui" |
| 91 | import { computed, ref } from "vue" |
| 92 | import Badge from "@/components/common/Badge.vue" |
| 93 | import CardEntity from "@/components/common/cards/CardEntity.vue" |
| 94 | import CardKV from "@/components/common/cards/CardKV.vue" |
| 95 | import { useSettingsStore } from "@/stores/settings" |
| 96 | import dayjs from "@/utils/dayjs" |
| 97 | import { formatDate } from "@/utils/format" |
| 98 | |
| 99 | const { stat, embedded } = defineProps<{ stat: FlowQueryStat; embedded?: boolean }>() |
| 100 | |
| 101 | const showDetails = ref(false) |
| 102 | const dFormats = useSettingsStore().dateFormat |
| 103 | |
| 104 | const duration = computed(() => dayjs.duration(stat.duration).humanize()) |
| 105 | |
| 106 | const properties = computed(() => { |
| 107 | return _pick(stat, [ |
| 108 | "Artifact", |
| 109 | "log_rows", |
| 110 | "uploaded_files", |
| 111 | "uploaded_bytes", |
| 112 | "expected_uploaded_bytes", |
| 113 | "result_rows", |
| 114 | "query_id", |
| 115 | "total_queries" |
| 116 | ]) |
| 117 | }) |
| 118 | </script> |