Line data Source code
1 4 : <template>
2 5 : <div class="system-stats">
3 : <div class="mb-6">
4 : <div class="mb-4 flex items-center gap-2">
5 : <h2 class="text-2xl font-semibold">
6 : {{ $t('g.systemInfo') }}
7 : </h2>
8 : <Button variant="secondary" @click="copySystemInfo">
9 : <i class="icon-[lucide--copy]" />
10 : {{ $t('g.copySystemInfo') }}
11 : </Button>
12 : </div>
13 : <div class="grid grid-cols-2 gap-2">
14 40 : <template v-for="col in systemStatsColumns" :key="col.field">
15 : <div
16 : :class="cn('font-medium', isOutdated(col) && 'text-destructive')"
17 : >
18 : {{ $t(col.headerKey) }}
19 : </div>
20 : <div :class="cn(isOutdated(col) && 'text-destructive')">
21 : {{ getColumnDisplayValue(stats, col) }}
22 : </div>
23 : </template>
24 : </div>
25 : </div>
26 :
27 : <template v-if="hasDevices">
28 : <div class="my-4 border-t" />
29 :
30 : <div>
31 : <h2 class="mb-4 text-2xl font-semibold">
32 : {{ $t('g.devices') }}
33 : </h2>
34 : <Tabs
35 : v-if="stats.devices.length > 1"
36 : :default-value="String(stats.devices[0].index)"
37 : >
38 : <TabsList variant="bordered" class="mb-4">
39 0 : <TabsTrigger
40 : v-for="device in stats.devices"
41 : :key="device.index"
42 : :value="String(device.index)"
43 : >
44 : {{ device.name }}
45 : </TabsTrigger>
46 : </TabsList>
47 0 : <TabsContent
48 : v-for="device in stats.devices"
49 : :key="device.index"
50 : :value="String(device.index)"
51 : >
52 : <DeviceInfo :device="device" />
53 : </TabsContent>
54 : </Tabs>
55 : <DeviceInfo v-else :device="stats.devices[0]" />
56 : </div>
57 : </template>
58 : </div>
59 : </template>
60 :
61 : <script setup lang="ts">
62 : import { computed } from 'vue'
63 :
64 : import DeviceInfo from '@/components/common/DeviceInfo.vue'
65 : import type { SystemStatsColumn } from '@/components/common/systemStatsColumns'
66 : import {
67 : getColumnDisplayValue,
68 : systemStatsColumns
69 : } from '@/components/common/systemStatsColumns'
70 : import Button from '@comfyorg/design-system/button/Button'
71 : import Tabs from '@comfyorg/design-system/tabs/Tabs'
72 : import TabsContent from '@comfyorg/design-system/tabs/TabsContent'
73 : import TabsList from '@comfyorg/design-system/tabs/TabsList'
74 : import TabsTrigger from '@comfyorg/design-system/tabs/TabsTrigger'
75 : import { useCopySystemInfo } from '@/composables/useCopySystemInfo'
76 : import type { SystemStats } from '@comfyorg/api-client/types'
77 : import { cn } from '@comfyorg/tailwind-utils'
78 :
79 : const { stats } = defineProps<{
80 : stats: SystemStats
81 : }>()
82 :
83 5 : const hasDevices = computed(() => stats.devices.length > 0)
84 :
85 5 : const { copySystemInfo } = useCopySystemInfo(() => stats)
86 :
87 80 : function isOutdated(column: SystemStatsColumn): boolean {
88 80 : if (column.field !== 'installed_templates_version') return false
89 10 : const installed = stats.system.installed_templates_version
90 10 : const required = stats.system.required_templates_version
91 80 : return !!installed && !!required && installed !== required
92 : }
93 : </script>
|