bfg-common 1.1.80 → 1.1.82

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.
Files changed (84) hide show
  1. package/components/atoms/alert/Notification.vue +167 -167
  2. package/components/atoms/autocomplete/Autocomplete.vue +236 -236
  3. package/components/atoms/datepicker/Datepicker.vue +612 -612
  4. package/components/atoms/list/SelectList.vue +62 -62
  5. package/components/atoms/nav/NavBar.vue +116 -116
  6. package/components/atoms/nav/VerticalNavBar.vue +89 -89
  7. package/components/atoms/notificationBar/NotificationBar.vue +175 -175
  8. package/components/atoms/perPage/PerPage.vue +52 -52
  9. package/components/atoms/popup/SimplePopup.vue +90 -90
  10. package/components/atoms/step/VerticalStep.vue +104 -104
  11. package/components/atoms/switch/Switch.vue +107 -107
  12. package/components/atoms/table/dataGrid/DataGridColumnSwitch.vue +206 -206
  13. package/components/atoms/table/dataGrid/DataGridPage.vue +189 -189
  14. package/components/atoms/tabs/Tabs.vue +189 -189
  15. package/components/atoms/tooltip/Signpost.vue +224 -224
  16. package/components/common/adapterManager/AddAdapterWarningModal.vue +82 -82
  17. package/components/common/adapterManager/NoActiveAdaptersModal.vue +62 -62
  18. package/components/common/adapterManager/NoConnectedActiveAdaptersModal.vue +62 -62
  19. package/components/common/browse/Browse.vue +182 -182
  20. package/components/common/browse/blocks/Title.vue +66 -66
  21. package/components/common/diagramMain/Diagram.vue +186 -186
  22. package/components/common/diagramMain/DiagramMain.vue +986 -986
  23. package/components/common/diagramMain/adapter/AdapterItem.vue +227 -227
  24. package/components/common/diagramMain/adapter/AdapterItems.vue +57 -57
  25. package/components/common/diagramMain/modals/editSettings/tabs/port/IpvFourSettings.vue +339 -339
  26. package/components/common/diagramMain/modals/editSettings/tabs/port/PortProperties.vue +202 -202
  27. package/components/common/diagramMain/modals/remove/RemoveModal.vue +226 -226
  28. package/components/common/diagramMain/network/Contents.vue +238 -238
  29. package/components/common/feedback/Buttons.vue +232 -232
  30. package/components/common/feedback/Message.vue +468 -468
  31. package/components/common/feedback/VisitPortal.vue +54 -54
  32. package/components/common/help/navbar/left/Left.vue +159 -159
  33. package/components/common/help/navbar/left/utils/constructAccordion.ts +27 -27
  34. package/components/common/mainNavigationPanel/MainNavigationPanel.vue +359 -359
  35. package/components/common/modals/Rename.vue +165 -165
  36. package/components/common/monitor/advanced/Advanced.vue +234 -221
  37. package/components/common/monitor/advanced/tools/Tools.vue +428 -441
  38. package/components/common/monitor/advanced/tools/chartOptionsModal/ChartOptionsModal.vue +484 -424
  39. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/Counters.vue +8 -0
  40. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/Table.vue +9 -0
  41. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/config/utils.ts +3 -2
  42. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/Timespan.vue +79 -73
  43. package/components/common/monitor/advanced/tools/chartOptionsModal/counters/timespan/object/Object.vue +66 -19
  44. package/components/common/monitor/advanced/tools/chartOptionsModal/models/models.ts +19 -0
  45. package/components/common/monitor/models/interfaces.ts +1 -0
  46. package/components/common/perPage/PerPage.vue +51 -51
  47. package/components/common/recursionTree/RecursionTree.vue +201 -201
  48. package/components/common/vm/actions/add/config/capabilities.ts +777 -777
  49. package/components/common/vm/actions/add/customizeHardware/virtualHardware/VirtualHardware.vue +646 -646
  50. package/components/common/vm/actions/add/customizeHardware/virtualHardware/cdDvdDrive/CdDvdDrive.vue +246 -246
  51. package/components/common/vm/actions/add/customizeHardware/virtualHardware/cpu/CoresPerSocket.vue +108 -108
  52. package/components/common/vm/actions/add/customizeHardware/virtualHardware/cpu/Cpu.vue +382 -375
  53. package/components/common/vm/actions/add/customizeHardware/virtualHardware/limit/Limit.vue +234 -234
  54. package/components/common/vm/actions/add/customizeHardware/virtualHardware/limit/config/options.ts +28 -28
  55. package/components/common/vm/actions/add/customizeHardware/virtualHardware/memory/Memory.vue +316 -316
  56. package/components/common/vm/actions/add/customizeHardware/virtualHardware/memory/config/memoryOptions.ts +35 -35
  57. package/components/common/vm/actions/add/customizeHardware/virtualHardware/newHardDisk/NewHardDisk.vue +445 -445
  58. package/components/common/vm/actions/add/customizeHardware/virtualHardware/reservation/Reservation.vue +235 -235
  59. package/components/common/vm/actions/add/customizeHardware/virtualHardware/videoCard/VideoCard.vue +177 -177
  60. package/components/common/vm/actions/add/customizeHardware/vmoptions/bootOptions/order/Order.vue +197 -197
  61. package/components/common/vm/actions/add/customizeHardware/vmoptions/generalOptions/GeneralOptions.vue +180 -180
  62. package/components/common/vm/actions/add/customizeHardware/vmoptions/remoteConsoleOptions/CopyPaste.vue +51 -51
  63. package/components/common/vm/actions/add/customizeHardware/vmoptions/remoteConsoleOptions/keymap/Keymap.vue +55 -55
  64. package/components/common/vm/actions/add/select/storage/config/config.ts +154 -154
  65. package/components/common/wizards/datastore/add/nfs/configuration/Configuration.vue +373 -373
  66. package/components/common/wizards/datastore/add/nfs/configuration/serversList/ServersList.vue +123 -123
  67. package/components/common/wizards/datastore/add/nfs/kerberosAuthentication/KerberosAuthentication.vue +54 -54
  68. package/components/common/wizards/datastore/add/sharedStorm/deviceSelection/hostTable/HostTable.vue +131 -131
  69. package/components/common/wizards/datastore/add/sharedStorm/partitionConfiguration/PartitionConfiguration.vue +230 -230
  70. package/models/store/interfaces.ts +37 -37
  71. package/models/store/storage/interfaces.ts +32 -32
  72. package/models/store/types.ts +32 -32
  73. package/modules/fixContentBuild/utils/methods.ts +114 -114
  74. package/package.json +1 -1
  75. package/public/spice-console/application/codec.js +257 -257
  76. package/public/spice-console/lib/rasterEngine.js +907 -907
  77. package/public/spice-console/network/spicechannel.js +369 -369
  78. package/public/spice-console-minify/lib/decoder/dixie.min.js +4 -4
  79. package/public/spice-console-minify/lib/jgestures.min.js +24 -24
  80. package/public/spice-console-minify/lib/jquery-2.0.3.min.js +24 -24
  81. package/public/spice-console-minify/lib/jquery-mousewheel.min.js +11 -11
  82. package/public/spice-console-minify/lib/jquery-visibility.min.js +1 -1
  83. package/public/spice-console-minify/lib/lodash.4.0.0.min.js +5 -5
  84. package/utils/contentBuild.ts +34 -34
@@ -1,424 +1,484 @@
1
- <template>
2
- <div class="chart-options-modal">
3
- <atoms-modal
4
- width="1150px"
5
- :show="true"
6
- :title="localization.chartOptions"
7
- @hide="onHide"
8
- @submit="onSubmit"
9
- >
10
- <template #modalBody>
11
- <common-monitor-advanced-tools-chart-options-modal-notification
12
- v-show="isShowAlerts"
13
- :alerts="alerts"
14
- @remove="onRemoveAlerts"
15
- />
16
- <div>
17
- <common-monitor-advanced-tools-chart-options-modal-actions
18
- :is-disabled-save="!selectedRows.length"
19
- :options-names="optionsNames"
20
- :selected-chart-option-name="localSelectedChartOptionName"
21
- @save="onSaveOptions"
22
- @check-validation="checkValidations"
23
- @select-local-option-name="onSelectLocalOptionName"
24
- @delete-chart-name="onDeleteChartName"
25
- />
26
-
27
- <div class="horizontal-flex-container chart-options-content">
28
- <common-monitor-advanced-tools-chart-options-modal-metrics
29
- v-model:selected-metric="selectedMetric"
30
- :metrics-items="metricsItems"
31
- />
32
- <common-monitor-advanced-tools-chart-options-modal-counters
33
- :chart="selectedMetric"
34
- :language="props.language"
35
- :type="props.type"
36
- :selected-keys="localSelectedCountersKeys"
37
- :selected-chart-type="localSelectedChartType"
38
- :selected-timespan-type="localSelectedTimespanType"
39
- :units-count="localUnitsCount"
40
- :period-type="localPeriodType"
41
- :selected-custom-time="localCustomTime"
42
- :custom-date-from="props.customDateFrom"
43
- :custom-date-to="props.customDateTo"
44
- :custom-time-from="props.customTimeFrom"
45
- :custom-time-to="props.customTimeTo"
46
- :total-cores="props.totalCores"
47
- :host-id="props.hostId"
48
- @select-row="selectedRows = $event"
49
- @update-chart-type="selectedChartTypeLocal = $event"
50
- @update-custom-time="localCustomTime = $event"
51
- @update-timespan-type="timespanType = $event"
52
- @update-unit-count="unitCount = $event"
53
- @update-period-type="localPeriodType = $event"
54
- @update-custom-date-from="onUpdateCustomDateFrom"
55
- @update-custom-date-to="onUpdateCustomDateTo"
56
- @update-custom-time-from="onUpdateCustomTimeFrom"
57
- @update-custom-time-to="onUpdateCustomTimeTo"
58
- />
59
- </div>
60
- </div>
61
- </template>
62
- </atoms-modal>
63
- </div>
64
- </template>
65
-
66
- <script setup lang="ts">
67
- import { UI_I_Localization } from '~/models/interfaces'
68
- import { UI_T_AdvancedType } from '~/components/common/monitor/advanced/models/types'
69
- import { UI_I_VerticalTabs } from '~/components/atoms/tabs/models/interfaces'
70
- import { UI_I_AdvancedCounterItem } from '~/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/models/interfaces'
71
- import {
72
- T_ChartHost,
73
- T_ChartVm,
74
- } from '~/components/common/monitor/advanced/tools/chartOptionsModal/models/types'
75
- import { metricsFunc } from '~/components/common/monitor/advanced/tools/chartOptionsModal/metrics/config/optionsMetrics'
76
- import { getCurrentOptionsStorageFunc } from '~/components/common/monitor/advanced/tools/config/advancedToolbar'
77
- import { checkDateFunc } from '~/components/common/monitor/overview/filters/customIntervalModal/config/dateChecker'
78
-
79
- const props = defineProps<{
80
- type: UI_T_AdvancedType
81
- language: string
82
- selectedCountersKeys: number[]
83
- selectedMetric: T_ChartHost | T_ChartVm
84
- selectedChartType: string
85
- selectedTimespanType: string
86
- unitsCount: number
87
- periodType: string
88
- selectedCustomTime: string
89
- selectedChartOptionName: string
90
- customDateFrom: string
91
- customDateTo: string
92
- customTimeFrom: string
93
- customTimeTo: string
94
- totalCores: number
95
- hostId: string
96
- }>()
97
-
98
- const emits = defineEmits<{
99
- (event: 'hide'): void
100
- (event: 'select-row', value: UI_I_AdvancedCounterItem[]): void
101
- (event: 'select-metric', value: string): void
102
- (event: 'update-chart-type', value: string): void
103
- (event: 'update-timespan-type', value: string): void
104
- (event: 'update-unit-count', value: number): void
105
- (event: 'update-period-type', value: string): void
106
- (event: 'update-custom-time', value: string): void
107
- (event: 'select-chart-name', value: string): void
108
- (event: 'delete-option'): void
109
- (event: 'save-option-name'): void
110
- (event: 'update-custom-date-from', value: string): void
111
- (event: 'update-custom-date-to', value: string): void
112
- (event: 'update-custom-time-from', value: string): void
113
- (event: 'update-custom-time-to', value: string): void
114
- (event: 'submit-options', value: string): void
115
- (event: 'select-objects', value: string): void
116
- }>()
117
-
118
- const routeType = '' + useRoute().params.type
119
-
120
- const localization = computed<UI_I_Localization>(() => useLocal())
121
-
122
- const localCustomDateFrom = ref<string>('')
123
- const onUpdateCustomDateFrom = (value: string): void => {
124
- localCustomDateFrom.value = value
125
- }
126
- const localCustomDateTo = ref<string>('')
127
- const onUpdateCustomDateTo = (value: string): void => {
128
- localCustomDateTo.value = value
129
- }
130
- const localCustomTimeFrom = ref<string>('')
131
- const onUpdateCustomTimeFrom = (value: string): void => {
132
- localCustomTimeFrom.value = value
133
- }
134
- const localCustomTimeTo = ref<string>('')
135
- const onUpdateCustomTimeTo = (value: string): void => {
136
- localCustomTimeTo.value = value
137
- }
138
-
139
- const metricsItems = computed<UI_I_VerticalTabs[]>(() =>
140
- metricsFunc(localization.value, props.type)
141
- )
142
- const selectedMetric = ref<T_ChartHost | T_ChartVm>(
143
- props.selectedMetric || '' + metricsItems.value[0]?.value
144
- )
145
-
146
- const localSelectedCountersKeys = ref<number[]>([])
147
- watch(
148
- () => props.selectedCountersKeys,
149
- (newValue) => {
150
- localSelectedCountersKeys.value = newValue
151
- },
152
- { immediate: true, deep: true }
153
- )
154
-
155
- const localSelectedChartType = ref<string>('')
156
- watch(
157
- () => props.selectedChartType,
158
- (newValue) => {
159
- localSelectedChartType.value = newValue
160
- },
161
- { immediate: true }
162
- )
163
-
164
- const localSelectedTimespanType = ref<string>('')
165
- watch(
166
- () => props.selectedTimespanType,
167
- (newValue) => {
168
- localSelectedTimespanType.value = newValue
169
- },
170
- { immediate: true }
171
- )
172
-
173
- const localUnitsCount = ref<number>(0)
174
- watch(
175
- () => props.unitsCount,
176
- (newValue) => {
177
- localUnitsCount.value = newValue
178
- },
179
- { immediate: true }
180
- )
181
-
182
- const localPeriodType = ref<string>('')
183
- watch(
184
- () => props.periodType,
185
- (newValue) => {
186
- localPeriodType.value = newValue
187
- },
188
- { immediate: true }
189
- )
190
-
191
- const localCustomTime = ref<string>('')
192
- watch(
193
- () => props.selectedCustomTime,
194
- (newValue) => {
195
- localCustomTime.value = newValue
196
- },
197
- { immediate: true }
198
- )
199
-
200
- const isShowAlerts = ref<boolean>(false)
201
- const alerts = ref<string[]>([''])
202
-
203
- const onRemoveAlerts = (): void => {
204
- isShowAlerts.value = false
205
- alerts.value = []
206
- }
207
-
208
- const onHide = (): void => {
209
- emits('hide')
210
- }
211
-
212
- const selectedRows = ref<UI_I_AdvancedCounterItem[]>([])
213
- const selectedChartTypeLocal = ref<string>('')
214
-
215
- const checkValidations = (): boolean => {
216
- const checkDateResult = checkDateFunc(
217
- localization.value,
218
- localCustomDateFrom.value,
219
- localCustomDateTo.value,
220
- localCustomTimeFrom.value,
221
- localCustomTimeTo.value
222
- )
223
-
224
- if (!selectedRows.value.length) {
225
- alerts.value = [localization.value.noCountersSelected]
226
- isShowAlerts.value = true
227
- return false
228
- } else if (
229
- timespanType.value === 'custom_interval' &&
230
- localPeriodType.value === 'period' &&
231
- checkDateResult !== '' &&
232
- typeof checkDateResult === 'string'
233
- ) {
234
- alerts.value = [checkDateResult]
235
- isShowAlerts.value = true
236
- return false
237
- }
238
-
239
- return true
240
- }
241
-
242
- const localSelectedChartOptionName = ref<string>('')
243
- watch(
244
- () => props.selectedChartOptionName,
245
- (newValue) => {
246
- localSelectedChartOptionName.value = newValue
247
- },
248
- { immediate: true }
249
- )
250
-
251
- const selectedLocalOptionName = ref<string>('')
252
-
253
- const selectedObjects = ref<string>('')
254
-
255
- const onSubmit = (): void => {
256
- if (!checkValidations()) return
257
-
258
- if (['select_options', 'default'].includes(selectedLocalOptionName.value))
259
- selectedLocalOptionName.value = 'custom'
260
-
261
- onSaveOptions(selectedLocalOptionName.value)
262
-
263
- // emits('select-chart-name', selectedLocalOptionName.value) +
264
- // emits('select-metric', selectedMetric.value) +
265
- // emits('select-row', selectedRows.value) +
266
- // emits('update-timespan-type', timespanType.value) +
267
- // emits('update-period-type', localPeriodType.value) +
268
- // emits('update-unit-count', unitCount.value) +
269
- // emits('update-custom-time', localCustomTime.value) +
270
- // emits('update-custom-date-from', localCustomDateFrom.value) +
271
- // emits('update-custom-date-to', localCustomDateTo.value) +
272
- // emits('update-custom-time-from', localCustomTimeFrom.value) +
273
- // emits('update-custom-time-to', localCustomTimeTo.value) +
274
- // emits('update-chart-type', selectedChartTypeLocal.value) +
275
- // emits('submit-options')
276
-
277
- const savedObject = {
278
- optionName: selectedLocalOptionName.value,
279
- metric: selectedMetric.value,
280
- counters: selectedRows.value,
281
- timespanType: timespanType.value,
282
- periodType: localPeriodType.value,
283
- unitCount: unitCount.value,
284
- localTimespanType: localCustomTime.value,
285
- dateFrom: localCustomDateFrom.value,
286
- timeFrom: localCustomTimeFrom.value,
287
- dateTo: localCustomDateTo.value,
288
- timeTo: localCustomTimeTo.value,
289
- chartType: selectedChartTypeLocal.value,
290
- objects: selectedObjects.value,
291
- }
292
-
293
- emits('submit-options', savedObject)
294
- onHide()
295
- }
296
-
297
- const timespanType = ref<string>('')
298
- const unitCount = ref<number>(1)
299
-
300
- const optionsNames = ref<string[]>([])
301
-
302
- const onSaveOptions = (name: string): void => {
303
- const counters = selectedRows.value.map((item) => {
304
- return {
305
- id: item.id,
306
- name: item.nameEn,
307
- }
308
- })
309
- let chartType = 'line_graph'
310
- if (selectedChartTypeLocal.value === 'spline') chartType = 'line_graph'
311
- else if (selectedChartTypeLocal.value === 'area') chartType = 'stacked_graph'
312
-
313
- const saveOptionsData = {
314
- routeType,
315
- chartType,
316
- counters,
317
- metric: selectedMetric.value,
318
- timespan: {
319
- periodType: localPeriodType.value,
320
- units: localCustomTime.value,
321
- unitsCount: unitCount.value,
322
- type: timespanType.value,
323
- },
324
- }
325
- useLocalStorage(`${name}ChartOptions`, saveOptionsData, false)
326
- optionsNames.value = getCurrentOptionsStorageFunc(routeType)
327
- localSelectedChartOptionName.value = name
328
- emits('save-option-name')
329
- }
330
-
331
- const setSelectOptions = (): void => {
332
- selectedMetric.value = props.selectedMetric || metricsItems.value[0]?.value
333
- localSelectedCountersKeys.value = props.selectedCountersKeys
334
- localSelectedChartType.value = props.selectedChartType
335
- localSelectedTimespanType.value = props.selectedTimespanType
336
- localUnitsCount.value = props.unitsCount
337
- localPeriodType.value = props.periodType
338
- localCustomTime.value = props.selectedCustomTime
339
- }
340
-
341
- const setDefaultOptions = (): void => {
342
- selectedMetric.value = metricsItems.value[0]?.value
343
- localSelectedCountersKeys.value = []
344
- localSelectedChartType.value = 'spline'
345
- localSelectedTimespanType.value = ''
346
- localUnitsCount.value = 0
347
- localPeriodType.value = ''
348
- localCustomTime.value = ''
349
- }
350
-
351
- const setCustomOptions = (name: string): void => {
352
- const selectedValue = useLocalStorage(name + 'ChartOptions', undefined, false)
353
-
354
- if (selectedValue.routeType !== routeType) return
355
-
356
- let currentChartType = ''
357
- if (selectedValue.chartType === 'line_graph') currentChartType = 'spline'
358
- else if (selectedValue.chartType === 'stacked_graph')
359
- currentChartType = 'area'
360
-
361
- selectedMetric.value = selectedValue.metric
362
- localSelectedCountersKeys.value = selectedValue.counters.map(
363
- (item) => item.id
364
- )
365
- localSelectedChartType.value = currentChartType
366
- localSelectedTimespanType.value = selectedValue.timespan.type
367
- localUnitsCount.value = selectedValue.timespan.unitsCount
368
- localPeriodType.value = selectedValue.timespan.periodType
369
- localCustomTime.value = selectedValue.timespan.units
370
- }
371
-
372
- const onSelectLocalOptionName = (name: string): void => {
373
- selectedLocalOptionName.value = name
374
-
375
- if (optionsNames.value.includes(name)) setCustomOptions(name)
376
- else if (name === 'default') setDefaultOptions()
377
- else if (name === 'select_options') setSelectOptions()
378
- }
379
-
380
- watch(
381
- localSelectedChartOptionName,
382
- (newValue) => {
383
- if (!newValue) return
384
-
385
- setCustomOptions(newValue)
386
- },
387
- { immediate: true }
388
- )
389
-
390
- const onDeleteChartName = (name: string): void => {
391
- window.localStorage.removeItem(name + 'ChartOptions')
392
- optionsNames.value = getCurrentOptionsStorageFunc(routeType)
393
- setSelectOptions()
394
- emits('delete-option')
395
- }
396
-
397
- onMounted(() => {
398
- optionsNames.value = getCurrentOptionsStorageFunc(routeType)
399
- })
400
- </script>
401
-
402
- <style scoped lang="scss">
403
- .chart-options-modal {
404
- .loader-on :deep(.modal-body) {
405
- display: flex;
406
- align-items: center;
407
- justify-content: center;
408
- }
409
- :deep(.modal-title) {
410
- text-transform: capitalize;
411
- }
412
-
413
- #loader {
414
- min-height: 90px;
415
- text-align: center;
416
- }
417
-
418
- .chart-options-content {
419
- display: flex;
420
- flex-direction: row;
421
- flex-basis: 90%;
422
- }
423
- }
424
- </style>
1
+ <template>
2
+ <div class="chart-options-modal">
3
+ <atoms-modal
4
+ width="1150px"
5
+ :show="true"
6
+ :title="localization.chartOptions"
7
+ :disabled-submit="isDisabledSubmit"
8
+ @hide="onHide"
9
+ @submit="onSubmit"
10
+ >
11
+ <template #modalBody>
12
+ <common-monitor-advanced-tools-chart-options-modal-notification
13
+ v-show="isShowAlerts"
14
+ :alerts="alerts"
15
+ @remove="onRemoveAlerts"
16
+ />
17
+ <div>
18
+ <common-monitor-advanced-tools-chart-options-modal-actions
19
+ :is-disabled-save="!selectedRows.length"
20
+ :options-names="optionsNames"
21
+ :selected-chart-option-name="localSelectedChartOptionName"
22
+ @save="onSaveOptions"
23
+ @check-validation="checkValidations"
24
+ @select-local-option-name="onSelectLocalOptionName"
25
+ @delete-chart-name="onDeleteChartName"
26
+ />
27
+
28
+ <div class="horizontal-flex-container chart-options-content">
29
+ <common-monitor-advanced-tools-chart-options-modal-metrics
30
+ v-model:selected-metric="selectedMetric"
31
+ :metrics-items="metricsItems"
32
+ />
33
+ <common-monitor-advanced-tools-chart-options-modal-counters
34
+ :chart="selectedMetric"
35
+ :language="props.language"
36
+ :type="props.type"
37
+ :selected-keys="localSelectedCountersKeys"
38
+ :selected-chart-type="localSelectedChartType"
39
+ :selected-timespan-type="localSelectedTimespanType"
40
+ :units-count="localUnitsCount"
41
+ :period-type="localPeriodType"
42
+ :selected-custom-time="localCustomTime"
43
+ :custom-date-from="props.customDateFrom"
44
+ :custom-date-to="props.customDateTo"
45
+ :custom-time-from="props.customTimeFrom"
46
+ :custom-time-to="props.customTimeTo"
47
+ :total-cores="props.totalCores"
48
+ :host-id="props.hostId"
49
+ :selected-metrics-keys="selectedMetricsKeys"
50
+ :selected-objects="props.selectedObjects"
51
+ @select-row="selectedRows = $event"
52
+ @update-chart-type="selectedChartTypeLocal = $event"
53
+ @update-custom-time="localCustomTime = $event"
54
+ @update-timespan-type="timespanType = $event"
55
+ @update-unit-count="unitCount = $event"
56
+ @update-period-type="localPeriodType = $event"
57
+ @update-custom-date-from="onUpdateCustomDateFrom"
58
+ @update-custom-date-to="onUpdateCustomDateTo"
59
+ @update-custom-time-from="onUpdateCustomTimeFrom"
60
+ @update-custom-time-to="onUpdateCustomTimeTo"
61
+ @select-objects="localSelectedObjects = $event"
62
+ />
63
+ </div>
64
+ </div>
65
+ </template>
66
+ </atoms-modal>
67
+ </div>
68
+ </template>
69
+
70
+ <script setup lang="ts">
71
+ import { UI_I_Localization } from '~/models/interfaces'
72
+ import { UI_T_AdvancedType } from '~/components/common/monitor/advanced/models/types'
73
+ import { UI_I_VerticalTabs } from '~/components/atoms/tabs/models/interfaces'
74
+ import { UI_I_AdvancedCounterItem } from '~/components/common/monitor/advanced/tools/chartOptionsModal/counters/table/models/interfaces'
75
+ import {
76
+ T_ChartHost,
77
+ T_ChartVm,
78
+ } from '~/components/common/monitor/advanced/tools/chartOptionsModal/models/types'
79
+ import { UI_I_OptionsForm } from '~/components/common/monitor/advanced/tools/chartOptionsModal/models/models'
80
+ import { metricsFunc } from '~/components/common/monitor/advanced/tools/chartOptionsModal/metrics/config/optionsMetrics'
81
+ import { getCurrentOptionsStorageFunc } from '~/components/common/monitor/advanced/tools/config/advancedToolbar'
82
+ import { checkDateFunc } from '~/components/common/monitor/overview/filters/customIntervalModal/config/dateChecker'
83
+ import { getValidDateByOptionFunc } from '~/components/common/monitor/config/getValidDateByOption'
84
+
85
+ const props = defineProps<{
86
+ type: UI_T_AdvancedType
87
+ language: string
88
+ selectedCountersKeys: number[]
89
+ selectedMetric: T_ChartHost | T_ChartVm
90
+ selectedChartType: string
91
+ selectedTimespanType: string
92
+ unitsCount: number
93
+ periodType: string
94
+ selectedCustomTime: string
95
+ selectedChartOptionName: string
96
+ customDateFrom: string
97
+ customDateTo: string
98
+ customTimeFrom: string
99
+ customTimeTo: string
100
+ totalCores: number
101
+ hostId: string
102
+ selectedObjects: string
103
+ }>()
104
+
105
+ const emits = defineEmits<{
106
+ (event: 'hide'): void
107
+ (event: 'select-row', value: UI_I_AdvancedCounterItem[]): void
108
+ (event: 'select-metric', value: string): void
109
+ (event: 'update-chart-type', value: string): void
110
+ (event: 'update-timespan-type', value: string): void
111
+ (event: 'update-unit-count', value: number): void
112
+ (event: 'update-period-type', value: string): void
113
+ (event: 'update-custom-time', value: string): void
114
+ (event: 'delete-option'): void
115
+ (event: 'save-option-name'): void
116
+ (event: 'update-custom-date-from', value: string): void
117
+ (event: 'update-custom-date-to', value: string): void
118
+ (event: 'update-custom-time-from', value: string): void
119
+ (event: 'update-custom-time-to', value: string): void
120
+ (event: 'submit-options', value: UI_I_OptionsForm): void
121
+ (event: 'select-objects', value: string): void
122
+ }>()
123
+
124
+ const routeType = '' + useRoute().params.type
125
+
126
+ const localization = computed<UI_I_Localization>(() => useLocal())
127
+
128
+ const localCustomDateFrom = ref<string>('')
129
+ const onUpdateCustomDateFrom = (value: string): void => {
130
+ localCustomDateFrom.value = value
131
+ }
132
+ const localCustomDateTo = ref<string>('')
133
+ const onUpdateCustomDateTo = (value: string): void => {
134
+ localCustomDateTo.value = value
135
+ }
136
+ const localCustomTimeFrom = ref<string>('')
137
+ const onUpdateCustomTimeFrom = (value: string): void => {
138
+ localCustomTimeFrom.value = value
139
+ }
140
+ const localCustomTimeTo = ref<string>('')
141
+ const onUpdateCustomTimeTo = (value: string): void => {
142
+ localCustomTimeTo.value = value
143
+ }
144
+
145
+ const metricsItems = computed<UI_I_VerticalTabs[]>(() =>
146
+ metricsFunc(localization.value, props.type)
147
+ )
148
+ const selectedMetric = ref<T_ChartHost | T_ChartVm>(
149
+ props.selectedMetric || '' + metricsItems.value[0]?.value
150
+ )
151
+
152
+ const localSelectedCountersKeys = ref<number[]>([])
153
+ watch(
154
+ () => props.selectedCountersKeys,
155
+ (newValue) => {
156
+ localSelectedCountersKeys.value = newValue
157
+ },
158
+ { immediate: true, deep: true }
159
+ )
160
+
161
+ const localSelectedChartType = ref<string>('')
162
+ watch(
163
+ () => props.selectedChartType,
164
+ (newValue) => {
165
+ localSelectedChartType.value = newValue
166
+ },
167
+ { immediate: true }
168
+ )
169
+
170
+ const localSelectedTimespanType = ref<string>('')
171
+ watch(
172
+ () => props.selectedTimespanType,
173
+ (newValue) => {
174
+ localSelectedTimespanType.value = newValue
175
+ },
176
+ { immediate: true }
177
+ )
178
+
179
+ const localUnitsCount = ref<number>(0)
180
+ watch(
181
+ () => props.unitsCount,
182
+ (newValue) => {
183
+ localUnitsCount.value = newValue
184
+ },
185
+ { immediate: true }
186
+ )
187
+
188
+ const localPeriodType = ref<string>('')
189
+ watch(
190
+ () => props.periodType,
191
+ (newValue) => {
192
+ localPeriodType.value = newValue
193
+ },
194
+ { immediate: true }
195
+ )
196
+
197
+ const localCustomTime = ref<string>('')
198
+ watch(
199
+ () => props.selectedCustomTime,
200
+ (newValue) => {
201
+ localCustomTime.value = newValue
202
+ },
203
+ { immediate: true }
204
+ )
205
+
206
+ const isShowAlerts = ref<boolean>(false)
207
+ const alerts = ref<string[]>([''])
208
+
209
+ const onRemoveAlerts = (): void => {
210
+ isShowAlerts.value = false
211
+ alerts.value = []
212
+ }
213
+
214
+ const onHide = (): void => {
215
+ emits('hide')
216
+ }
217
+
218
+ const selectedRows = ref<UI_I_AdvancedCounterItem[]>([])
219
+ const selectedMetricsKeys = computed<number[]>(() =>
220
+ selectedRows.value.map((item) => item.id)
221
+ )
222
+ const selectedChartTypeLocal = ref<string>('')
223
+
224
+ const checkValidations = (): boolean => {
225
+ const checkDateResult = checkDateFunc(
226
+ localization.value,
227
+ localCustomDateFrom.value,
228
+ localCustomDateTo.value,
229
+ localCustomTimeFrom.value,
230
+ localCustomTimeTo.value
231
+ )
232
+
233
+ if (!selectedRows.value.length) {
234
+ alerts.value = [localization.value.noCountersSelected]
235
+ isShowAlerts.value = true
236
+ return false
237
+ } else if (
238
+ timespanType.value === 'custom_interval' &&
239
+ localPeriodType.value === 'period' &&
240
+ checkDateResult !== '' &&
241
+ typeof checkDateResult === 'string'
242
+ ) {
243
+ alerts.value = [checkDateResult]
244
+ isShowAlerts.value = true
245
+ return false
246
+ }
247
+
248
+ return true
249
+ }
250
+
251
+ const localSelectedChartOptionName = ref<string>('')
252
+ watch(
253
+ () => props.selectedChartOptionName,
254
+ (newValue) => {
255
+ localSelectedChartOptionName.value = newValue
256
+ },
257
+ { immediate: true }
258
+ )
259
+
260
+ const selectedLocalOptionName = ref<string>('')
261
+
262
+ const localSelectedObjects = ref<string>('')
263
+
264
+ const currentFieldsByArray = (data: UI_I_AdvancedCounterItem[]): string => {
265
+ const result: string[] = []
266
+ data.forEach((item) => {
267
+ result.push(item.nameEn)
268
+ })
269
+ return result.join(',')
270
+ }
271
+
272
+ const onSubmit = (): void => {
273
+ if (!checkValidations()) return
274
+
275
+ if (['select_options', 'default'].includes(selectedLocalOptionName.value))
276
+ selectedLocalOptionName.value = 'custom'
277
+
278
+ onSaveOptions(selectedLocalOptionName.value)
279
+
280
+ // emits('select-metric', selectedMetric.value) +
281
+ // emits('select-row', selectedRows.value) +
282
+ // emits('update-timespan-type', timespanType.value) +
283
+ // emits('update-period-type', localPeriodType.value) +
284
+ // emits('update-unit-count', unitCount.value) +
285
+ // emits('update-custom-time', localCustomTime.value) +
286
+ // emits('update-custom-date-from', localCustomDateFrom.value) +
287
+ // emits('update-custom-date-to', localCustomDateTo.value) +
288
+ // emits('update-custom-time-from', localCustomTimeFrom.value) +
289
+ // emits('update-custom-time-to', localCustomTimeTo.value) +
290
+ // emits('update-chart-type', selectedChartTypeLocal.value) +
291
+ // emits('submit-options')
292
+
293
+ // const periodValue = getValidDateByOptionFunc(
294
+ // periodValue,
295
+ // selectedValue,
296
+ // props.unitsCount,
297
+ // props.selectedCustomTime
298
+ // )
299
+ //
300
+
301
+ const currentFields =
302
+ localSelectedObjects.value || currentFieldsByArray(selectedRows.value)
303
+
304
+ const validPeriod = getValidDateByOptionFunc(
305
+ timespanType.value,
306
+ null,
307
+ unitCount.value,
308
+ localCustomTime.value
309
+ ).map((item) => Math.round(item / 1000))
310
+
311
+ if (
312
+ timespanType.value === 'custom_interval' &&
313
+ localPeriodType.value === 'period'
314
+ ) {
315
+ const checkDateResult = checkDateFunc(
316
+ localization.value,
317
+ localCustomDateFrom.value,
318
+ localCustomDateTo.value,
319
+ localCustomTimeFrom.value,
320
+ localCustomTimeTo.value
321
+ )
322
+ if (Array.isArray(checkDateResult)) {
323
+ validPeriod[0] = Math.round(checkDateResult[0] / 1000)
324
+ validPeriod[1] = Math.round(checkDateResult[1] / 1000)
325
+ }
326
+ }
327
+
328
+ const savedObject = {
329
+ fields: currentFields,
330
+ optionName: selectedLocalOptionName.value,
331
+ metric: selectedMetric.value,
332
+ counters: selectedRows.value,
333
+ timespanType: timespanType.value,
334
+ periodType: localPeriodType.value,
335
+ unitCount: unitCount.value,
336
+ localTimespanType: localCustomTime.value,
337
+ dateFrom: localCustomDateFrom.value,
338
+ timeFrom: localCustomTimeFrom.value,
339
+ dateTo: localCustomDateTo.value,
340
+ timeTo: localCustomTimeTo.value,
341
+ chartType: selectedChartTypeLocal.value,
342
+ objects: localSelectedObjects.value,
343
+ periodValue: validPeriod,
344
+ }
345
+
346
+ emits('submit-options', savedObject)
347
+ onHide()
348
+ }
349
+
350
+ const timespanType = ref<string>('')
351
+ const unitCount = ref<number>(1)
352
+
353
+ const optionsNames = ref<string[]>([])
354
+
355
+ const onSaveOptions = (name: string): void => {
356
+ const counters = selectedRows.value.map((item) => {
357
+ return {
358
+ id: item.id,
359
+ name: item.nameEn,
360
+ }
361
+ })
362
+ let chartType = 'line_graph'
363
+ if (selectedChartTypeLocal.value === 'spline') chartType = 'line_graph'
364
+ else if (selectedChartTypeLocal.value === 'area') chartType = 'stacked_graph'
365
+
366
+ const saveOptionsData = {
367
+ routeType,
368
+ chartType,
369
+ counters,
370
+ metric: selectedMetric.value,
371
+ timespan: {
372
+ periodType: localPeriodType.value,
373
+ units: localCustomTime.value,
374
+ unitsCount: unitCount.value,
375
+ type: timespanType.value,
376
+ },
377
+ }
378
+ useLocalStorage(`${name}ChartOptions`, saveOptionsData, false)
379
+ optionsNames.value = getCurrentOptionsStorageFunc(routeType)
380
+ localSelectedChartOptionName.value = name
381
+ emits('save-option-name')
382
+ }
383
+
384
+ const setSelectOptions = (): void => {
385
+ selectedMetric.value = props.selectedMetric || metricsItems.value[0]?.value
386
+ localSelectedCountersKeys.value = props.selectedCountersKeys
387
+ localSelectedChartType.value = props.selectedChartType
388
+ localSelectedTimespanType.value = props.selectedTimespanType
389
+ localUnitsCount.value = props.unitsCount
390
+ localPeriodType.value = props.periodType
391
+ localCustomTime.value = props.selectedCustomTime
392
+ }
393
+
394
+ const setDefaultOptions = (): void => {
395
+ selectedMetric.value = metricsItems.value[0]?.value
396
+ localSelectedCountersKeys.value = []
397
+ localSelectedChartType.value = 'spline'
398
+ localSelectedTimespanType.value = ''
399
+ localUnitsCount.value = 0
400
+ localPeriodType.value = ''
401
+ localCustomTime.value = ''
402
+ }
403
+
404
+ const setCustomOptions = (name: string): void => {
405
+ const selectedValue = useLocalStorage(name + 'ChartOptions', undefined, false)
406
+
407
+ if (selectedValue.routeType !== routeType) return
408
+
409
+ let currentChartType = ''
410
+ if (selectedValue.chartType === 'line_graph') currentChartType = 'spline'
411
+ else if (selectedValue.chartType === 'stacked_graph')
412
+ currentChartType = 'area'
413
+
414
+ selectedMetric.value = selectedValue.metric
415
+ localSelectedCountersKeys.value = selectedValue.counters.map(
416
+ (item) => item.id
417
+ )
418
+ localSelectedChartType.value = currentChartType
419
+ localSelectedTimespanType.value = selectedValue.timespan.type
420
+ localUnitsCount.value = selectedValue.timespan.unitsCount
421
+ localPeriodType.value = selectedValue.timespan.periodType
422
+ localCustomTime.value = selectedValue.timespan.units
423
+ }
424
+
425
+ const onSelectLocalOptionName = (name: string): void => {
426
+ selectedLocalOptionName.value = name
427
+
428
+ if (optionsNames.value.includes(name)) setCustomOptions(name)
429
+ else if (name === 'default') setDefaultOptions()
430
+ else if (name === 'select_options') setSelectOptions()
431
+ }
432
+
433
+ watch(
434
+ localSelectedChartOptionName,
435
+ (newValue) => {
436
+ if (!newValue) return
437
+
438
+ setCustomOptions(newValue)
439
+ },
440
+ { immediate: true }
441
+ )
442
+
443
+ const onDeleteChartName = (name: string): void => {
444
+ window.localStorage.removeItem(name + 'ChartOptions')
445
+ optionsNames.value = getCurrentOptionsStorageFunc(routeType)
446
+ setSelectOptions()
447
+ emits('delete-option')
448
+ }
449
+
450
+ const isDisabledSubmit = computed<boolean>(
451
+ () =>
452
+ props.type === 'host' &&
453
+ selectedMetric.value === 'cpu' &&
454
+ !localSelectedObjects.value
455
+ )
456
+
457
+ onMounted(() => {
458
+ optionsNames.value = getCurrentOptionsStorageFunc(routeType)
459
+ })
460
+ </script>
461
+
462
+ <style scoped lang="scss">
463
+ .chart-options-modal {
464
+ .loader-on :deep(.modal-body) {
465
+ display: flex;
466
+ align-items: center;
467
+ justify-content: center;
468
+ }
469
+ :deep(.modal-title) {
470
+ text-transform: capitalize;
471
+ }
472
+
473
+ #loader {
474
+ min-height: 90px;
475
+ text-align: center;
476
+ }
477
+
478
+ .chart-options-content {
479
+ display: flex;
480
+ flex-direction: row;
481
+ flex-basis: 90%;
482
+ }
483
+ }
484
+ </style>