bfg-common 1.4.706 → 1.4.708

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,258 @@
1
+ <template>
2
+ <ui-data-table
3
+ test-id="task-table"
4
+ :data="data"
5
+ :options="options"
6
+ :loading="props.loading"
7
+ :total-pages="props.totalPages"
8
+ :total-items="props.totalItems"
9
+ class="task-table"
10
+ @sorting="onSorting"
11
+ @pagination="onPagination"
12
+ >
13
+ <template #icon="{ item }">
14
+ <span class="flex-align-center">
15
+ <span :class="['icon', item.data.icon]" />
16
+
17
+ <span
18
+ :data-id="`rtask-${item.data.testId}`"
19
+ :class="item.data.isLink && 'target-link'"
20
+ @click.stop="onSelectNodeOfTree(item.data)"
21
+ >
22
+ {{ item.text }}
23
+ </span>
24
+ </span>
25
+ </template>
26
+
27
+ <template #status="{ item }">
28
+ <ui-chip :test-id="item.data.testId" :color="item.data.chipColor" rounded>
29
+ <ui-icon
30
+ :name="item.data.icon"
31
+ width="14px"
32
+ height="14px"
33
+ class="chip-icon"
34
+ ></ui-icon>
35
+ {{ item.text }}
36
+ </ui-chip>
37
+
38
+ <common-pages-tasks-table-error-info
39
+ v-if="item.data.error"
40
+ :id="item.data.testId"
41
+ :error="item.data.error"
42
+ />
43
+ </template>
44
+
45
+ <template #default-actions="{ item }">
46
+ <div class="actions">
47
+ <ui-button
48
+ variant="text"
49
+ :test-id="`resent-task-item-${item.data.id}-action`"
50
+ is-without-height
51
+ is-without-sizes
52
+ @click.stop="onToggleActions(item.data.id)"
53
+ >
54
+ <span
55
+ :class="['action-icon', { active: actionsIsShow[item.data.id] }]"
56
+ >
57
+ <ui-icon name="vertical-dotes" width="20" height="20" />
58
+ </span>
59
+ </ui-button>
60
+ <ui-dropdown
61
+ :show="actionsIsShow[item.data.id]"
62
+ :test-id="`resent-task-item-action-${item.data.id}`"
63
+ :items="actions"
64
+ :elem-id="`resent-task-item-${item.data.id}-action`"
65
+ left
66
+ width="max-content"
67
+ @select="onSelectAction(item.data.target, $event, item.data.id)"
68
+ @hide="onHideActionsDropdown(item.data.id)"
69
+ >
70
+ <template #row="{ item: dropMenu }">
71
+ <ui-icon
72
+ v-if="dropMenu.iconName === 'hide'"
73
+ name="password-hide"
74
+ width="16"
75
+ height="16"
76
+ />
77
+ <span class="action-text">
78
+ {{ dropMenu.text }}
79
+ </span>
80
+ </template>
81
+ </ui-dropdown>
82
+ </div>
83
+ </template>
84
+
85
+ <template #expand="{ item }">
86
+ <common-pages-tasks-table-expand-details :data="item.data" />
87
+ </template>
88
+ </ui-data-table>
89
+ </template>
90
+
91
+ <script setup lang="ts">
92
+ import type { UI_I_Dropdown } from '~/node_modules/bfg-uikit/components/ui/dropdown/models/interfaces'
93
+ import type {
94
+ UI_I_DataTable,
95
+ UI_I_DataTableHeader,
96
+ UI_I_DataTableBody,
97
+ UI_I_Pagination,
98
+ } from '~/node_modules/bfg-uikit/components/ui/dataTable/models/interfaces'
99
+ import type { UI_T_Project, UI_T_ProcuratorTypeNodes } from '~/lib/models/types'
100
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
101
+ import type { UI_I_TaskItem } from '~/lib/models/store/tasks/interfaces'
102
+ import type { UI_I_TableTarget } from '~/lib/models/table/interfaces'
103
+ import {
104
+ options,
105
+ getTargetActionsFunc,
106
+ getHeaderDataFunc,
107
+ getBodyDataFunc,
108
+ } from '~/components/common/pages/tasks/table/lib/config/config'
109
+
110
+ const props = defineProps<{
111
+ project: UI_T_Project
112
+ tableData: UI_I_TaskItem<UI_T_ProcuratorTypeNodes>[]
113
+ totalPages: number
114
+ totalItems: number
115
+ loading: boolean
116
+ }>()
117
+ const emits = defineEmits<{
118
+ (event: 'sort', value: string): void
119
+ (event: 'pagination', value: UI_I_Pagination): void
120
+ }>()
121
+
122
+ const localization = computed<UI_I_Localization>(() => useLocal())
123
+ const { $store }: any = useNuxtApp()
124
+
125
+ const actionsIsShow = ref<boolean[]>([])
126
+
127
+ const data = computed<UI_I_DataTable>(() => ({
128
+ id: 'tasks-table',
129
+ header: taskHeadItems.value,
130
+ body: taskBodyItems.value,
131
+ }))
132
+
133
+ const taskHeadItems = computed<UI_I_DataTableHeader[]>(() =>
134
+ getHeaderDataFunc(localization.value)
135
+ )
136
+
137
+ const taskBodyItems = ref<UI_I_DataTableBody[]>([])
138
+ watch(
139
+ () => props.tableData,
140
+ (newValue: UI_I_TaskItem<UI_T_ProcuratorTypeNodes>[]) => {
141
+ if (!newValue?.length) {
142
+ taskBodyItems.value = []
143
+ return
144
+ }
145
+
146
+ taskBodyItems.value = getBodyDataFunc(newValue, localization.value)
147
+ },
148
+ { deep: true, immediate: true }
149
+ )
150
+ const onSorting = (value: string): void => {
151
+ emits('sort', value)
152
+ }
153
+ const onPagination = (value: UI_I_Pagination): void => {
154
+ emits('pagination', value)
155
+ }
156
+
157
+ const actions = computed<UI_I_Dropdown[]>(() =>
158
+ getTargetActionsFunc(localization.value, props.project)
159
+ )
160
+ const onToggleActions = (id: number): void => {
161
+ actionsIsShow.value[id] = !actionsIsShow.value[id]
162
+ }
163
+ const onSelectAction = (
164
+ data: UI_I_TableTarget<typeof props.project>,
165
+ action: 'view-target' | 'view-zone',
166
+ actionId: number
167
+ ): void => {
168
+ switch (action) {
169
+ case 'view-target':
170
+ onSelectNodeOfTree(data)
171
+ break
172
+ case 'view-zone':
173
+ onSelectNodeOfTree({ ...data, type: 'zone', nav: 'h' })
174
+ break
175
+ }
176
+ onHideActionsDropdown(actionId)
177
+ }
178
+ const onHideActionsDropdown = (id: number): void => {
179
+ actionsIsShow.value[id] = false
180
+ }
181
+
182
+ const onSelectNodeOfTree = (
183
+ data: UI_I_TableTarget<typeof props.project>
184
+ ): void => {
185
+ if (!data.isLink) return
186
+
187
+ const { type, id, nav } = data
188
+
189
+ const node = {
190
+ id,
191
+ type,
192
+ }
193
+
194
+ const path = `/inventory/type=${type};nav=${nav};id=${id}/summary`
195
+ navigateTo(path)
196
+
197
+ $store.dispatch('inventory/A_SELECT_NODE', { node, type })
198
+ }
199
+ </script>
200
+
201
+ <style>
202
+ /*TODO move up*/
203
+ :root {
204
+ --actions-icon-color: #4d5d69;
205
+ --actions-icon-hover-color: #213444;
206
+ --actions-icon-icative-color: #008fd6;
207
+ }
208
+ :root.dark-theme {
209
+ --actions-icon-color: #e9eaec;
210
+ --actions-icon-hover-color: #ffffff;
211
+ --actions-icon-icative-color: #2ba2de;
212
+ }
213
+ </style>
214
+ <style scoped lang="scss">
215
+ .task-table {
216
+ height: inherit;
217
+
218
+ .target-link {
219
+ font-family: Inter, serif;
220
+ font-size: 13px;
221
+ color: var(--bottom-pannel-rtask-link-text);
222
+ font-weight: 400;
223
+ line-height: 15.73px;
224
+ cursor: pointer;
225
+ &:hover {
226
+ color: var(--bottom-pannel-rtask-link-hover-text);
227
+ }
228
+ }
229
+ .chip-icon {
230
+ min-width: 14px;
231
+ margin-right: 6px;
232
+ }
233
+ .icon {
234
+ margin-right: 4px;
235
+ }
236
+
237
+ .actions {
238
+ width: 100%;
239
+
240
+ .action-icon {
241
+ width: 16px;
242
+ height: 16px;
243
+ color: var(--actions-icon-color);
244
+
245
+ &:hover {
246
+ color: var(--actions-icon-hover-color);
247
+ }
248
+ &.active {
249
+ color: var(--actions-icon-icative-color);
250
+ }
251
+ }
252
+
253
+ .action-text {
254
+ margin-left: 8px;
255
+ }
256
+ }
257
+ }
258
+ </style>
@@ -0,0 +1,90 @@
1
+ <template>
2
+ <div class="error-info">
3
+ <ui-icon
4
+ :id="`resent-task-error-info-icon-${props.id}`"
5
+ name="info"
6
+ width="16px"
7
+ height="16px"
8
+ :class="['info-icon pointer', { show: isShowInfo }]"
9
+ @click.stop="isShowInfo = !isShowInfo"
10
+ />
11
+ <ui-popup-window
12
+ v-model="isShowInfo"
13
+ width="232px"
14
+ top
15
+ left
16
+ :elem-id="`resent-task-error-info-icon-${props.id}`"
17
+ >
18
+ <div class="common-widget-info">
19
+ <div class="headline justify-between flex-align-center">
20
+ <div class="flex-align-center">
21
+ <ui-icon name="error" width="16px" height="16px" />
22
+ <span class="title">{{ localization.common.failureReason }}</span>
23
+ </div>
24
+ <ui-icon
25
+ name="close"
26
+ class="pointer hide-icon"
27
+ width="16px"
28
+ height="16px"
29
+ @click.stop="isShowInfo = false"
30
+ />
31
+ </div>
32
+
33
+ <div class="common-widget-info-description">
34
+ {{ props.error }}
35
+ </div>
36
+ </div>
37
+ </ui-popup-window>
38
+ </div>
39
+ </template>
40
+
41
+ <script lang="ts" setup>
42
+ import type { UI_I_Localization } from '~/node_modules/bfg-common/lib/models/interfaces'
43
+
44
+ const props = defineProps<{
45
+ id: string
46
+ error: string
47
+ }>()
48
+
49
+ const localization = computed<UI_I_Localization>(() => useLocal())
50
+
51
+ const isShowInfo = ref<boolean>(false)
52
+ </script>
53
+
54
+ <style lang="scss" scoped>
55
+ .error-info {
56
+ display: flex;
57
+ justify-content: space-between;
58
+ margin-left: 8px;
59
+
60
+ .info-icon {
61
+ color: #9da6ad;
62
+
63
+ &:hover {
64
+ color: #4d5d69;
65
+ }
66
+ &.show {
67
+ color: #008fd6;
68
+ }
69
+ }
70
+
71
+ .common-widget-info {
72
+ padding: 16px;
73
+
74
+ .title {
75
+ font-size: 14px;
76
+ font-weight: 500;
77
+ line-height: 16px;
78
+ color: var(--zabbix-text-color);
79
+ margin-left: 8px;
80
+ }
81
+
82
+ .common-widget-info-description {
83
+ font-size: 13px;
84
+ line-height: 15.73px;
85
+ color: var(--zabbix-text-color);
86
+ margin-top: 12px;
87
+ }
88
+ }
89
+ }
90
+ </style>
@@ -0,0 +1,168 @@
1
+ <template>
2
+ <div class="expand-details">
3
+ <div class="expand-details__row">
4
+ <span class="expand-details__label">
5
+ {{ localization.tasks.taskName }}:
6
+ </span>
7
+ <span class="expand-details__value">
8
+ <ui-icon name="shortcuts-tasks" width="18" height="18" class="icon" />
9
+ {{ normalizedTaskDetails[0].text }}
10
+ </span>
11
+ </div>
12
+
13
+ <div class="expand-details__row">
14
+ <span class="expand-details__label">
15
+ {{ localization.common.status }}:
16
+ </span>
17
+ <span class="expand-details__status">
18
+ <ui-chip
19
+ :test-id="normalizedTaskDetails[2].data.testId"
20
+ :color="normalizedTaskDetails[2].data.chipColor"
21
+ rounded
22
+ >
23
+ <ui-icon
24
+ :name="normalizedTaskDetails[2].data.icon"
25
+ width="14px"
26
+ height="14px"
27
+ class="chip-icon"
28
+ ></ui-icon>
29
+ {{ normalizedTaskDetails[2].text }}
30
+ </ui-chip>
31
+
32
+ <common-pages-tasks-table-error-info
33
+ v-if="normalizedTaskDetails[2].data.error"
34
+ :id="normalizedTaskDetails[2].testId"
35
+ :error="normalizedTaskDetails[2].data.error"
36
+ />
37
+ </span>
38
+ </div>
39
+
40
+ <div class="expand-details__row">
41
+ <span class="expand-details__label">
42
+ {{ localization.common.initiator }}:
43
+ </span>
44
+ <span class="expand-details__value">
45
+ <ui-icon name="user-icon" width="18" height="18" class="icon" />
46
+ {{ normalizedTaskDetails[3].text }}
47
+ </span>
48
+ </div>
49
+
50
+ <div class="expand-details__row">
51
+ <span class="expand-details__label">
52
+ {{ localization.common.target }}:
53
+ </span>
54
+ <span
55
+ class="expand-details__value"
56
+ :class="normalizedTaskDetails[1].data.isLink && 'target-link'"
57
+ @click.stop="onSelectNodeOfTree(normalizedTaskDetails[1].data)"
58
+ >
59
+ <span :class="['icon', normalizedTaskDetails[1].data.icon]" />
60
+ {{ normalizedTaskDetails[1].text }}
61
+ </span>
62
+ </div>
63
+
64
+ <div class="expand-details__row">
65
+ <span class="expand-details__label">
66
+ {{ localization.common.server }}:
67
+ </span>
68
+ <span class="expand-details__value">
69
+ <ui-icon name="server-icon" width="18" height="18" class="icon" />
70
+ {{ normalizedTaskDetails[4].text }}
71
+ </span>
72
+ </div>
73
+
74
+ <div class="expand-details__row">
75
+ <span class="expand-details__label">
76
+ {{ localization.common.relatedEvents }}:
77
+ </span>
78
+ <span class="expand-details__value disabled">
79
+ {{ localization.common.emptyRelatedEvents }}
80
+ </span>
81
+ </div>
82
+ </div>
83
+ </template>
84
+
85
+ <script lang="ts" setup>
86
+ import type { UI_I_DataTableBodyData } from '~/node_modules/bfg-uikit/components/ui/dataTable/models/interfaces'
87
+ import type { UI_I_Localization } from '~/lib/models/interfaces'
88
+
89
+ const props = defineProps<{
90
+ data: UI_I_DataTableBodyData[]
91
+ }>()
92
+
93
+ const localization = computed<UI_I_Localization>(() => useLocal())
94
+ const { $store }: any = useNuxtApp()
95
+
96
+ const normalizedTaskDetails = computed<UI_I_DataTableBodyData[]>(() => {
97
+ return props.data.filter((column: UI_I_DataTableBodyData) =>
98
+ ['col0', 'col1', 'col2', 'col4', 'col9'].includes(column.col as string)
99
+ ) // Фильтр по номерам колонок
100
+ })
101
+
102
+ const onSelectNodeOfTree = (data: any): void => {
103
+ if (!data.isLink) return
104
+
105
+ const { type, id, nav } = data
106
+
107
+ const node = {
108
+ id,
109
+ type,
110
+ }
111
+
112
+ const path = `/inventory/type=${type};nav=${nav};id=${id}/summary`
113
+ navigateTo(path)
114
+
115
+ $store.dispatch('inventory/A_SELECT_NODE', { node, type })
116
+ }
117
+ </script>
118
+
119
+ <style lang="scss" scoped>
120
+ @import 'assets/scss/common/mixins.scss';
121
+ %properties {
122
+ @include flex($align: center);
123
+ font-family: Inter, serif;
124
+ font-weight: 400;
125
+ font-size: 12px;
126
+ line-height: 14.52px;
127
+ }
128
+ .expand-details {
129
+ &__row {
130
+ display: grid;
131
+ grid-template-columns: 110px 1fr;
132
+ column-gap: 12px;
133
+ margin-bottom: 8px;
134
+ }
135
+ &__label {
136
+ @extend %properties;
137
+ color: #9da6ad;
138
+ }
139
+ &__value {
140
+ @extend %properties;
141
+ color: var(--title-form-first-color);
142
+ &.target-link {
143
+ color: var(--bottom-pannel-rtask-link-text);
144
+ cursor: pointer;
145
+ &:hover {
146
+ color: var(--bottom-pannel-rtask-link-hover-text);
147
+ }
148
+ }
149
+ &.disabled {
150
+ color: var(--table-disabled-btn);
151
+ }
152
+
153
+ .icon {
154
+ margin-right: 4px;
155
+ }
156
+ }
157
+ &__status {
158
+ @include flex($align: center);
159
+ .ui-chip {
160
+ width: max-content;
161
+ :deep(.ui-chip__label) {
162
+ // TODO надо удалить потом (clr style)
163
+ grid-gap: 4px;
164
+ }
165
+ }
166
+ }
167
+ }
168
+ </style>