6
:title="$t('app.general.title.diagnostics')"
10
<app-btn-collapse-group>
13
@click="handleAddCard"
21
{{ $t('app.general.title.add_chart') }}
23
</app-btn-collapse-group>
29
<v-row :dense="$vuetify.breakpoint.smAndDown">
30
<template v-for="(container, containerIndex) in containers">
32
v-if="inLayout || hasCards(container)"
33
:key="`container${containerIndex}`"
37
:class="{ 'drag': inLayout }"
40
v-model="containers[containerIndex]"
50
@end.stop="updateLayout"
54
:name="!inLayout ? 'flip-list' : undefined"
56
<template v-for="c in container">
58
v-if="c.enabled || inLayout"
62
@edit="handleEditCard"
71
<diagnostics-card-config-dialog
72
v-if="dialogState.active"
73
v-model="dialogState.active"
74
:config="dialogState.card"
75
@save="handleSaveCard"
76
@delete="handleDeleteCard"
82
import { Component, Mixins, Watch } from 'vue-property-decorator'
83
import { v4 as uuidv4 } from 'uuid'
84
import StateMixin from '@/mixins/state'
85
import type { DiagnosticsCardConfig, DiagnosticsCardContainer } from '@/store/diagnostics/types'
86
import DiagnosticsCard from '@/components/widgets/diagnostics/DiagnosticsCard.vue'
87
import DiagnosticsCardConfigDialog from '@/components/widgets/diagnostics/DiagnosticsCardConfigDialog.vue'
88
import type { LayoutConfig } from '@/store/layout/types'
89
import { defaultState } from '@/store/layout/state'
94
DiagnosticsCardConfigDialog
97
export default class Diagnostics extends Mixins(StateMixin) {
98
dialogState: { active: boolean, card: DiagnosticsCardConfig | null } = {
103
containers: Array<DiagnosticsCardConfig[]> = []
106
this.onLayoutChange()
110
const clonedDefaultCard = JSON.parse(JSON.stringify(defaultState().layouts.diagnostics.container1[0]))
111
clonedDefaultCard.id = ''
112
this.dialogState.card = clonedDefaultCard
113
this.dialogState.active = true
116
handleEditCard (card: DiagnosticsCardConfig) {
117
this.dialogState.card = JSON.parse(JSON.stringify(card))
118
this.dialogState.active = true
121
handleDeleteCard (id: string) {
122
for (const container of Object.values(this.layout)) {
123
const index = container.findIndex(card => card.id === id)
125
container.splice(index, 1)
133
handleSaveCard (card: DiagnosticsCardConfig) {
134
if (card.id === '') {
136
this.layout.container1.push(card)
138
for (const container of Object.values(this.layout)) {
139
const index = container.findIndex(existingCard => existingCard.id === card.id)
141
container[index] = card
151
if (this.inLayout) return 4
153
return this.containers.reduce((count, container) => +this.hasCards(container) + count, 0)
157
return 12 / this.columnCount
160
get inLayout (): boolean {
161
return (this.$store.state.config.layoutMode)
164
get layout (): DiagnosticsCardContainer {
165
return this.$store.getters['layout/getLayout']('diagnostics')
168
@Watch('layout', { deep: true })
170
const containers = Object.values(this.layout)
172
while (containers.length < 4) {
176
this.containers = containers.slice(0, 4)
180
this.$store.dispatch('layout/onLayoutChange', {
183
container1: this.containers[0],
184
container2: this.containers[1],
185
container3: this.containers[2],
186
container4: this.containers[3]
191
hasCards (container: LayoutConfig[]) {
192
return container.some(card => card.enabled)
197
<style lang="scss" scoped>
198
@import '@/scss/draggable.scss';