-
-
Notifications
You must be signed in to change notification settings - Fork 600
Expand file tree
/
Copy pathDiagnosticsWatchCard.vue
More file actions
89 lines (83 loc) · 2.47 KB
/
Copy pathDiagnosticsWatchCard.vue
File metadata and controls
89 lines (83 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<template>
<collapsable-card
:title="config.title"
:icon="`$${config.icon}`"
draggable
:layout-path="`diagnostics.${config.id}`"
>
<template #menu>
<app-btn-collapse-group>
<app-btn
small
class="me-1 my-1"
@click="$emit('edit', config)"
>
<v-icon
small
left
>
$edit
</v-icon>
{{ $t('app.general.title.edit_watch_panel') }}
</app-btn>
</app-btn-collapse-group>
</template>
<v-simple-table dense>
<thead>
<tr>
<th>{{ $t('app.setting.label.name') }}</th>
<th>{{ $t('app.setting.label.collector') }}</th>
<th>{{ $t('app.setting.label.value') }}</th>
<th>{{ $t('app.setting.label.type') }}</th>
</tr>
</thead>
<tbody>
<tr
v-for="(metric, i) in config.metrics"
:key="i"
>
<td>{{ metric.name }}</td>
<td>
<code
class="text-truncate d-inline-block"
style="max-width: 300px; vertical-align: middle;"
:title="metric.collector"
>{{ metric.collector }}</code>
</td>
<td><code>{{ formatValue(watchValues[metric.collector]) }}</code></td>
<td><code>{{ valueType(watchValues[metric.collector]) }}</code></td>
</tr>
<tr v-if="config.metrics.length === 0">
<td
colspan="4"
class="text-center text--disabled"
>
{{ $t('app.general.label.no_watch_metrics') }}
</td>
</tr>
</tbody>
</v-simple-table>
</collapsable-card>
</template>
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator'
import type { DiagnosticsWatchesConfig } from '@/store/diagnostics/types'
@Component({})
export default class DiagnosticsWatchCard extends Vue {
@Prop({ type: Object, required: true })
readonly config!: DiagnosticsWatchesConfig
get watchValues (): Record<string, unknown> {
return this.$typedState.diagnostics.watchValues
}
formatValue (value: unknown): string {
if (value === undefined || value === null) return '-'
if (typeof value === 'number') return String(Math.round(value * 1000) / 1000)
return String(value)
}
valueType (value: unknown): string {
if (value === null) return 'null'
if (Array.isArray(value)) return `array(${value.length})`
return typeof value
}
}
</script>