bfg-common 1.5.883 → 1.5.885

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.
@@ -1,5 +1,4 @@
1
1
  import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
2
- import type { API_UI_I_DataTable } from '~/lib/models/table/interfaces'
3
2
 
4
3
  export interface UI_I_ModalPayloadSchedulerData<T = UI_I_ScheduleNewTasksForm> {
5
4
  isSchedulerTask: false
@@ -32,9 +31,6 @@ export interface API_UI_I_ScheduledTasksTableItem {
32
31
  export interface UI_I_ScheduledTasksTableItem
33
32
  extends API_UI_I_ScheduledTasksTableItem {}
34
33
 
35
- export interface UI_I_ScheduledTasks
36
- extends API_UI_I_DataTable<UI_I_ScheduledTasksTableItem[]> {}
37
-
38
34
  export interface UI_I_CreateScheduledTaskArgs {
39
35
  name: string
40
36
  description: string
@@ -1,12 +1,38 @@
1
1
  <template>
2
- <component
3
- :is="currentComponent"
4
- v-model="selectedScheduledTaskLocal"
5
- :table-items="props.schedulerData?.items || []"
6
- :total-items="props.schedulerData?.total_items || 0"
7
- :total-pages="props.schedulerData?.total_pages || 1"
8
- :is-loading="props.isLoading"
9
- />
2
+ <div class="data-table-view">
3
+ <atoms-table-data-grid
4
+ v-model:selected-row="selectedScheduledTaskLocal"
5
+ v-model:page-size="pagination.pageSize"
6
+ v-model:page="pagination.page"
7
+ :head-items="headItems"
8
+ :body-items="bodyItems"
9
+ :total-items="props.totalItems"
10
+ :total-pages="props.totalPages"
11
+ :items-per-page="itemsPerPage"
12
+ :z-index-header-shift="2"
13
+ :loading="loading"
14
+ type="radio"
15
+ class="data-table"
16
+ test-id="scheduled-tasks-table"
17
+ hide-pagination
18
+ hide-page-size
19
+ off-select-by-row
20
+ server-off
21
+ >
22
+ <template #icon="{ item }">
23
+ <atoms-the-icon :name="item.data.iconClassName" class="icon" />
24
+ <span :title="item.text" class="text-ellipsis">
25
+ {{ item.text }}
26
+ </span>
27
+ </template>
28
+
29
+ <template #toggleBlock="{ item }">
30
+ <common-pages-scheduled-tasks-table-expand-details
31
+ :data="item[0].data.expandData"
32
+ />
33
+ </template>
34
+ </atoms-table-data-grid>
35
+ </div>
10
36
  </template>
11
37
 
12
38
  <script lang="ts" setup>
@@ -14,25 +40,21 @@ import type {
14
40
  UI_I_HeadItem,
15
41
  UI_I_BodyItem,
16
42
  } from '~/components/atoms/table/dataGrid/lib/models/interfaces'
43
+ import { itemsPerPage } from '~/components/atoms/table/dataGrid/lib/config/itemsPerPage'
17
44
  import type { UI_I_Localization } from '~/lib/models/interfaces'
18
45
  import type { UI_I_Pagination } from '~/lib/models/table/interfaces'
19
- import type { UI_I_ScheduledTasks } from '~/components/common/pages/scheduledTasks/lib/models/interfaces'
46
+ import type { UI_I_ScheduledTasksTableItem } from '~/components/common/pages/scheduledTasks/lib/models/interfaces'
47
+ import * as scheduledTaskTable from '~/components/common/pages/scheduledTasks/table/lib/config/scheduledTasksTable'
20
48
 
21
- const selectedScheduledTaskLocal = defineModel<string | null>()
22
49
  const props = defineProps<{
23
- schedulerData: UI_I_ScheduledTasks
24
- isLoading: boolean
50
+ dataTable: UI_I_ScheduledTasksTableItem[]
51
+ loading: boolean
52
+ totalItems: number
53
+ totalPages: number
25
54
  }>()
55
+ const selectedScheduledTaskLocal = defineModel<string | null>()
26
56
 
27
57
  const localization = computed<UI_I_Localization>(() => useLocal())
28
- const { $store }: any = useNuxtApp()
29
-
30
- const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
31
- const currentComponent = computed(() =>
32
- isNewView.value
33
- ? defineAsyncComponent(() => import('./new/New.vue'))
34
- : defineAsyncComponent(() => import('./old/Old.vue'))
35
- )
36
58
 
37
59
  const pagination = ref<UI_I_Pagination>({
38
60
  page: 1,
@@ -9,8 +9,8 @@ import {
9
9
  } from '~/lib/models/store/tasks/enums'
10
10
  import * as defaultSettings from '~/components/atoms/table/dataGrid/lib/config/settingsTable'
11
11
  import type { UI_I_ScheduledTasksTableItem } from '~/components/common/pages/scheduledTasks/lib/models/interfaces'
12
- import { UI_E_SchedulerRunStatus } from '~/components/common/pages/scheduledTasks/table/lib/models/enums'
13
- import { scheduledTaskTableItemsKeys } from '~/components/common/pages/scheduledTasks/table/old/lib/config/tableKeys'
12
+ import { scheduledTaskTableItemsKeys } from '~/components/common/pages/scheduledTasks/table/lib/config/tableKeys'
13
+ import { schedulerRunStatus } from '~/components/common/pages/scheduledTasks/table/lib/config/schedulerStatus'
14
14
 
15
15
  const getItems = (
16
16
  localization: UI_I_Localization
@@ -67,20 +67,16 @@ export const bodyItems = (
67
67
  const statusText =
68
68
  historyLastRun &&
69
69
  UI_E_RecentTaskStatus[
70
- historyLastRun?.result?.toLowerCase() ===
71
- UI_E_SchedulerRunStatus.SUCCESS
72
- ? 2
73
- : -1
70
+ historyLastRun?.result?.toLowerCase() === 'success' ? 2 : -1
74
71
  ]
75
72
 
76
73
  const statusData = {
77
74
  iconClassName:
78
75
  historyLastRun &&
79
76
  UI_E_IconNameByRecentTaskStatus[
80
- historyLastRun?.result.toLowerCase() ===
81
- UI_E_SchedulerRunStatus.SUCCESS
77
+ historyLastRun?.result.toLowerCase() === schedulerRunStatus.SUCCESS
82
78
  ? 2
83
- : historyLastRun?.result === UI_E_SchedulerRunStatus.RUNNING
79
+ : historyLastRun?.result === schedulerRunStatus.RUNNING
84
80
  ? 1
85
81
  : 3
86
82
  ],
@@ -117,8 +113,8 @@ export const bodyItems = (
117
113
  id: task.rid,
118
114
  testId: `adapter-table-${key}-row-item`,
119
115
  data: {
120
- sortValue: lastRun || 0,
121
- },
116
+ sortValue: lastRun || 0
117
+ }
122
118
  },
123
119
  {
124
120
  key: 'icon',
@@ -133,8 +129,8 @@ export const bodyItems = (
133
129
  id: task.rid,
134
130
  testId: `adapter-table-${key}-row-item`,
135
131
  data: {
136
- sortValue: task[scheduledTaskTableItemsKeys[4]],
137
- },
132
+ sortValue: task[scheduledTaskTableItemsKeys[4]]
133
+ }
138
134
  },
139
135
  ])
140
136
  })
@@ -0,0 +1,4 @@
1
+ export const schedulerRunStatus = {
2
+ RUNNING: 'this task has been started',
3
+ SUCCESS: 'success',
4
+ }
@@ -1,4 +1,4 @@
1
- import type { UI_T_ScheduledTaskTableItemsTuple } from '~/components/common/pages/scheduledTasks/table/old/lib/models/types'
1
+ import type { UI_T_ScheduledTaskTableItemsTuple } from '~/components/common/pages/scheduledTasks/table/lib/models/types'
2
2
 
3
3
  export const scheduledTaskTableItemsKeys: UI_T_ScheduledTaskTableItemsTuple = [
4
4
  'name',
@@ -78,7 +78,7 @@
78
78
  :index="props.hardDisksIndex[key]"
79
79
  :type="props.hardDisksType[key]"
80
80
  :main-storage="props.storage"
81
- :main-storage-free="props.storageFree"
81
+ :max-size="props.hardDisksMaxSize[props.hardDisksIndex[key]]"
82
82
  :error-validation-fields="props.errorValidationFields"
83
83
  :get-datastore-table-func="props.getDatastoreTableFunc"
84
84
  :datastore="props.datastore"
@@ -201,19 +201,19 @@
201
201
  "
202
202
  />
203
203
  </div>
204
- <div v-for="(item, key) in model.passthrough_usb_devices" :key="key">
205
- <common-vm-actions-common-customize-hardware-virtual-hardware-new-usb-device
206
- :item="item"
207
- :index="props.usbDevicesIndex[key]"
208
- :type="props.usbDevicesType[key]"
209
- :available-usb-devices="props.availableUsbDevices"
210
- :state="props.state"
211
- @change="
212
- emits('change-usb-device', [props.usbDevicesIndex[key], $event])
213
- "
214
- @remove="emits('remove-usb-device', props.usbDevicesIndex[key])"
215
- />
216
- </div>
204
+ <div v-for="(item, key) in model.passthrough_usb_devices" :key="key">
205
+ <common-vm-actions-common-customize-hardware-virtual-hardware-new-usb-device
206
+ :item="item"
207
+ :index="props.usbDevicesIndex[key]"
208
+ :type="props.usbDevicesType[key]"
209
+ :available-usb-devices="props.availableUsbDevices"
210
+ :state="props.state"
211
+ @change="
212
+ emits('change-usb-device', [props.usbDevicesIndex[key], $event])
213
+ "
214
+ @remove="emits('remove-usb-device', props.usbDevicesIndex[key])"
215
+ />
216
+ </div>
217
217
  <div v-for="(item, key) in model.usb_controllers" :key="key">
218
218
  <common-vm-actions-common-customize-hardware-virtual-hardware-new-usb-controller
219
219
  v-model="item.type"
@@ -299,7 +299,10 @@ import type {
299
299
  UI_T_PciDeviceType,
300
300
  } from '~/components/common/vm/actions/common/customizeHardware/virtualHardware/lib/models/types'
301
301
  import type { UI_I_OptionItem } from '~/components/atoms/lib/models/interfaces'
302
- import type { UI_I_Localization } from '~/lib/models/interfaces'
302
+ import type {
303
+ UI_I_ArbitraryObject,
304
+ UI_I_Localization,
305
+ } from '~/lib/models/interfaces'
303
306
  import type {
304
307
  API_UI_I_VmEditCpu,
305
308
  UI_I_MediatedDevice,
@@ -323,7 +326,7 @@ const props = withDefaults(
323
326
  files: UI_I_FileTreeNode[]
324
327
  isEdit: boolean
325
328
  storage: UI_I_DatastoreTableItem | null
326
- storageFree: number
329
+ hardDisksMaxSize: UI_I_ArbitraryObject<number>
327
330
  project: UI_T_Project
328
331
  maxMemory: number
329
332
  cpuModels: UI_I_OptionItem[]
@@ -369,7 +372,7 @@ const props = withDefaults(
369
372
  vmCpuHelpTextSecond: undefined,
370
373
  computeResource: undefined,
371
374
  compatibilityInfo: undefined,
372
- nums: null
375
+ nums: null,
373
376
  }
374
377
  )
375
378
  const emits = defineEmits<{
@@ -58,7 +58,7 @@
58
58
  :index="props.hardDisksIndex[key]"
59
59
  :type="props.hardDisksType[key]"
60
60
  :main-storage="props.storage"
61
- :main-storage-free="props.storageFree"
61
+ :max-size="props.hardDisksMaxSize[props.hardDisksIndex[key]]"
62
62
  :error-validation-fields="props.errorValidationFields"
63
63
  :get-datastore-table-func="props.getDatastoreTableFunc"
64
64
  :datastore="props.datastore"
@@ -276,7 +276,10 @@ import type {
276
276
  UI_I_DropdownTreeItem,
277
277
  UI_I_DropdownTreeItemChild,
278
278
  } from '~/components/atoms/dropdown/tree/lib/models/interfaces'
279
- import type { UI_I_Localization } from '~/lib/models/interfaces'
279
+ import type {
280
+ UI_I_ArbitraryObject,
281
+ UI_I_Localization,
282
+ } from '~/lib/models/interfaces'
280
283
  import type {
281
284
  API_UI_I_VmEditCpu,
282
285
  UI_I_MediatedDevice,
@@ -299,7 +302,7 @@ const props = withDefaults(
299
302
  files: UI_I_FileTreeNode[]
300
303
  isEdit: boolean
301
304
  storage: UI_I_DatastoreTableItem | null
302
- storageFree: number
305
+ hardDisksMaxSize: UI_I_ArbitraryObject<number>
303
306
  project: UI_T_Project
304
307
  maxMemory: number
305
308
  cpuModels: UI_I_OptionItem[]
@@ -341,7 +344,7 @@ const props = withDefaults(
341
344
  mediatedDevices: () => [],
342
345
  vmCpuHelpTextSecond: undefined,
343
346
  computeResource: undefined,
344
- nums: null
347
+ nums: null,
345
348
  }
346
349
  )
347
350
  const emits = defineEmits<{
@@ -9,7 +9,7 @@
9
9
  :files="props.files"
10
10
  :is-edit="props.isEdit"
11
11
  :storage="props.storage"
12
- :storage-free="storageFree"
12
+ :hard-disks-max-size="hardDisksMaxSize"
13
13
  :project="props.project"
14
14
  :max-memory="props.maxMemory"
15
15
  :cpu-models="props.cpuModels"
@@ -91,7 +91,10 @@ import type {
91
91
  UI_I_DropdownTreeItem,
92
92
  UI_I_DropdownTreeItemChild,
93
93
  } from '~/components/atoms/dropdown/tree/lib/models/interfaces'
94
- import type { UI_I_Localization } from '~/lib/models/interfaces'
94
+ import type {
95
+ UI_I_ArbitraryObject,
96
+ UI_I_Localization,
97
+ } from '~/lib/models/interfaces'
95
98
  import type {
96
99
  UI_I_MediatedDevice,
97
100
  UI_I_PciDevice,
@@ -252,22 +255,45 @@ if (!model.value.disk_devices?.length) {
252
255
  // { immediate: true }
253
256
  // )
254
257
 
255
- const getDisksSize = (): number => {
256
- return (
257
- model.value.disk_devices.reduce(
258
- (acum, disk) => (acum += disk.size || 0),
259
- 0
260
- ) || 0
261
- )
262
- }
263
- const initialDisksSize = getDisksSize()
264
- const storageFree = computed<number>(() => {
265
- if (!props.storage) return 0
266
- const free = (props.storage.capacity.free_mb || props.storage.free) as number // TODO fix
258
+ const hardDisksMaxSize = ref<UI_I_ArbitraryObject<number>>({})
259
+ const disksInitialSize: UI_I_ArbitraryObject<number> = {}
260
+ watchEffect(() => {
261
+ hardDisksMaxSize.value = {}
262
+ const datastoreFree: UI_I_ArbitraryObject<string> = {}
263
+
264
+ model.value.disk_devices.forEach((disk, i) => {
265
+ if (disk.device_type !== 'disk') return
266
+
267
+ if (!disk.create && !disksInitialSize[i]) {
268
+ disksInitialSize[i] = disk.size
269
+ }
267
270
 
268
- const disksSize = getDisksSize()
271
+ const storageLocal = disk.storage || props.storage
269
272
 
270
- return free + initialDisksSize - (disksSize - initialDisksSize)
273
+ const hasStorage = datastoreFree[storageLocal.id]
274
+ const storage = props.datastore.find((item) => item.id === storageLocal.id)
275
+ const storageFree = storage?.capacity?.free_mb || storage?.free || 0
276
+
277
+ const newSize = disk.create ? disk.size : disk.size - disksInitialSize[i]
278
+ if (!hasStorage) {
279
+ datastoreFree[storageLocal.id] = storageFree - newSize
280
+ } else {
281
+ datastoreFree[storageLocal.id] = datastoreFree[storageLocal.id] - newSize
282
+ }
283
+ })
284
+ model.value.disk_devices.forEach((disk, i) => {
285
+ if (disk.device_type !== 'disk') return
286
+
287
+ const storageLocal = disk.storage || props.storage
288
+
289
+ const isExisting = hardDisksType.value[hardDisksIndex.value[i]] === 'exist'
290
+ if (isExisting) {
291
+ hardDisksMaxSize.value[hardDisksIndex.value[i]] = disksInitialSize[i]
292
+ } else {
293
+ const free = datastoreFree[storageLocal.id]
294
+ hardDisksMaxSize.value[hardDisksIndex.value[i]] = free + disk.size
295
+ }
296
+ })
271
297
  })
272
298
 
273
299
  const addHardDisk = (
@@ -27,7 +27,7 @@
27
27
  :is-disabled-cache="isDisabledCache"
28
28
  :is-disabled-bus="isDisabledBus"
29
29
  :hard-disk-type-options="hardDiskTypeOptions"
30
- :max-hard-disk="maxHardDisk"
30
+ :max-hard-disk="props.maxSize"
31
31
  :location="location"
32
32
  :is-running="isRunning"
33
33
  :is-new-hard-disk="isNewHardDisk"
@@ -66,7 +66,9 @@ import { minLimitIops } from '~/components/common/vm/actions/common/customizeHar
66
66
 
67
67
  const size = defineModel<number>('size', { required: true })
68
68
  const initialSize = size.value
69
- const vmStoragePolicy = defineModel<boolean>('vmStoragePolicy', { required: true })
69
+ const vmStoragePolicy = defineModel<boolean>('vmStoragePolicy', {
70
+ required: true,
71
+ })
70
72
  // const provisionType = ref<string>('thick')
71
73
  const provisionType = defineModel<string>('provisionType', { required: true })
72
74
  // const sharing = ref<string>('')
@@ -136,7 +138,7 @@ const detach = defineModel<boolean>('detach', { required: true })
136
138
  const props = withDefaults(
137
139
  defineProps<{
138
140
  mainStorage: UI_I_DatastoreTableItem | null
139
- mainStorageFree: number
141
+ maxSize: number
140
142
  // hardDisk: UI_I_SendDataNewHardDisk
141
143
  type: UI_T_HardDiskType
142
144
  index: number
@@ -217,26 +219,15 @@ const label = computed<string>(() => {
217
219
  return `${localization.value.common.newHardDisk} *`
218
220
  })
219
221
 
220
- const maxHardDisk = computed<number>(() => {
221
- // // const hardDiskSizeMb = $binary.gbToMb(props.hardDisk.size)
222
- //
223
- // if (props.type === 'exist') return initialSize
224
- //
225
- // if (!storageLocal.value) return 0
226
- // const free = (storageLocal.value.capacity.free_mb ||
227
- // storageLocal.value.free) as number // TODO fix
228
- //
229
- // if (props.type === 'edit') return free + initialSize
230
- //
231
- // return free
232
- if (props.type === 'exist') return initialSize
233
-
234
- if (!storageLocal.value) return 0
235
-
236
- return props.mainStorageFree + size.value
237
- })
222
+ // const maxHardDisk = computed<number>(() => {
223
+ // if (props.type === 'exist') return initialSize
224
+ //
225
+ // if (!storageLocal.value) return 0
226
+ //
227
+ // return props.hardDisksMaxSize[props.index]
228
+ // })
238
229
  const hardDiskTypeErrorLocalText = computed<string>(() => {
239
- if (size.value > maxHardDisk.value) {
230
+ if (size.value > props.maxSize) {
240
231
  return localization.value.common.diskCapacitySpecifiedGreater
241
232
  }
242
233
 
@@ -149,7 +149,7 @@ const checkCustomizeHardware = async (): Promise<boolean> => {
149
149
  }
150
150
 
151
151
  let modelJson = ''
152
- // Нухен для того чтоби со второго раза сработал, так как в первый раз попадает в watch когда получаем данные от радителя
152
+ // Нужен для того чтоби со второго раза сработал, так как в первый раз попадает в watch когда получаем данные от радителя
153
153
  // а второй раз правки от дочерных и сохраняем его
154
154
  let helper = 1
155
155
  watch(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.5.883",
4
+ "version": "1.5.885",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",
@@ -1,4 +0,0 @@
1
- export enum UI_E_SchedulerRunStatus {
2
- RUNNING = 'this task has been started',
3
- SUCCESS = 'success',
4
- }
@@ -1,336 +0,0 @@
1
- <template>
2
- <ui-data-table
3
- :data="data"
4
- :options="options"
5
- :loading="props.isLoading"
6
- :total-pages="props.totalPages"
7
- :total-items="props.totalItems"
8
- :texts="texts"
9
- :skeleton="skeletonData"
10
- test-id="task-table"
11
- @sort="onSorting"
12
- @pagination="onPagination"
13
- @column-filter="onColumnFilter"
14
- @main-filter="onSearchEvents"
15
- @select-row="onSelectRow"
16
- >
17
- <template #insteadOfTitleActions>
18
- <!-- <common-pages-events-tools-panel-->
19
- <!-- v-model="filterFormModel"-->
20
- <!-- :selected-events="props.selectedEvents"-->
21
- <!-- @filter="onFilterEvents"-->
22
- <!-- />-->
23
- </template>
24
-
25
- <template #icon="{ item }">
26
- <span class="flex-align-center">
27
- <span :class="['icon', item.data.iconClassName]" />
28
-
29
- <span
30
- :data-id="`rtask-${item.data.testId}`"
31
- :class="item.data.isLink && 'target-link'"
32
- @click.stop="onSelectNodeOfTree(item.data)"
33
- >
34
- {{ item.text }}
35
- </span>
36
- </span>
37
- </template>
38
-
39
- <template #status="{ item }">
40
- <ui-chip :test-id="item.data.testId" :color="item.data.chipColor" rounded>
41
- <ui-icon
42
- :name="item.data.icon"
43
- width="14px"
44
- height="14px"
45
- class="chip-icon"
46
- ></ui-icon>
47
- {{ item.text }}
48
- </ui-chip>
49
- </template>
50
-
51
- <template #default-actions="{ item }">
52
- <div class="actions">
53
- <ui-button
54
- :id="`event-table-action-${item.data.id}`"
55
- :test-id="`event-table-action-${item.data.id}`"
56
- variant="text"
57
- is-without-height
58
- is-without-sizes
59
- @click.stop="onToggleActions(item.data.id)"
60
- >
61
- <span
62
- :class="['action-icon', { active: actionsShowId === item.data.id }]"
63
- >
64
- <ui-icon name="vertical-dotes" width="20" height="20" />
65
- </span>
66
- </ui-button>
67
- <ui-dropdown
68
- :show="actionsShowId === item.data.id"
69
- :test-id="`event-table-action-dropdown-${item.data.id}`"
70
- :items="actions"
71
- :elem-id="`event-table-action-${item.data.id}`"
72
- width="max-content"
73
- left
74
- @select="onSelectAction(item.data, $event)"
75
- @hide="onHideActionsDropdown"
76
- >
77
- <template #row="{ item: dropMenu }">
78
- <ui-icon :name="dropMenu.iconName" width="16" height="16" />
79
- <span class="action-text">
80
- {{ dropMenu.text }}
81
- </span>
82
- </template>
83
- </ui-dropdown>
84
- </div>
85
- </template>
86
-
87
- <template #expand="{ item }">
88
- <common-pages-scheduled-tasks-table-expand-details
89
- :data="item[0].data.expandData"
90
- />
91
-
92
- <common-pages-events-table-expand-details :data="item.data">
93
- <template #objectTarget="{ target }">
94
- <span
95
- :data-id="`${target?.testId}-link`"
96
- :class="target.data.isLink && 'target-link'"
97
- @click.stop="onSelectNodeOfTree(target.data)"
98
- >
99
- {{ target.text }}
100
- </span>
101
- </template>
102
- </common-pages-events-table-expand-details>
103
- </template>
104
-
105
- <template #skeleton-header>
106
- <div class="skeleton-header">
107
- <div class="left-skeleton">
108
- <ui-skeleton-item width="70" height="16" />
109
- <div class="vertical-line"></div>
110
- <ui-skeleton-item width="70" height="16" />
111
- <ui-skeleton-item width="70" height="16" />
112
- </div>
113
- <div class="right-skeleton">
114
- <ui-skeleton-item width="128" height="36" border-radius="8" />
115
- </div>
116
- </div>
117
- </template>
118
- </ui-data-table>
119
- </template>
120
-
121
- <script setup lang="ts">
122
- import { useDebounceFn } from '@vueuse/core'
123
- import type { UI_I_Dropdown } from '~/node_modules/bfg-uikit/components/ui/dropdown/models/interfaces'
124
- import type {
125
- UI_I_DataTable,
126
- UI_I_DataTableHeader,
127
- UI_I_DataTableBody,
128
- UI_I_DataTableBodyData,
129
- UI_I_DataTableSkeleton,
130
- UI_I_Pagination,
131
- UI_I_TableTexts,
132
- } from '~/node_modules/bfg-uikit/components/ui/dataTable/models/interfaces'
133
- import type { UI_T_ArbitraryObject } from '~/node_modules/bfg-uikit/models/types'
134
- import type { UI_I_TableTarget } from '~/lib/models/table/interfaces'
135
- import type { UI_I_Localization } from '~/lib/models/interfaces'
136
- import type { UI_I_ScheduledTasksTableItem } from '~/components/common/pages/scheduledTasks/lib/models/interfaces'
137
- import {
138
- options,
139
- getTargetActionsFunc,
140
- getHeaderDataFunc,
141
- getBodyDataFunc,
142
- } from '~/components/common/pages/scheduledTasks/table/new/lib/config/scheduledTasksTable'
143
-
144
- const selectedScheduledTaskLocal = defineModel<string | null>({
145
- required: true,
146
- })
147
- const props = defineProps<{
148
- tableItems: UI_I_ScheduledTasksTableItem[]
149
- totalItems: number
150
- totalPages: number
151
- selectedEvents: UI_I_ScheduledTasksTableItem
152
- isLoading: boolean
153
- }>()
154
- const emits = defineEmits<{
155
- (event: 'sort', value: string): void
156
- (event: 'pagination', value: UI_I_Pagination): void
157
- (event: 'col-search', value: string): void
158
- (event: 'select-node', value: UI_I_TableTarget<'sphere'>): void
159
- }>()
160
-
161
- const localization = computed<UI_I_Localization>(() => useLocal())
162
-
163
- const texts = computed<UI_I_TableTexts>(() => ({
164
- searchHere: localization.value.common.searchHere,
165
- rowsPerPage: localization.value.common.rowsPerPage,
166
- of: localization.value.common.of,
167
- selected: localization.value.common.selected,
168
- columns: localization.value.common.columns,
169
- previous: localization.value.common.previous,
170
- next: localization.value.common.next,
171
- noItemsFound: localization.value.common.noItemsFound,
172
- exportAll: localization.value.common.exportAll,
173
- exportSelected: localization.value.common.exportSelected,
174
- all: localization.value.common.all,
175
- filter: localization.value.common.filter,
176
- }))
177
- const skeletonData = ref<UI_I_DataTableSkeleton>({
178
- columnsCount: 6,
179
- headColumns: [],
180
- bodyColumns: [],
181
- })
182
-
183
- const actionsShowId = ref<number>(-1)
184
-
185
- const data = computed<UI_I_DataTable>(() => ({
186
- id: 'scheduled-tasks-table',
187
- header: taskHeadItems.value,
188
- body: taskBodyItems.value,
189
- }))
190
-
191
- const taskHeadItems = computed<UI_I_DataTableHeader[]>(() =>
192
- getHeaderDataFunc(localization.value)
193
- )
194
- const taskBodyItems = computed<UI_I_DataTableBody[]>(() => {
195
- return getBodyDataFunc(props.tableItems || [], localization.value)
196
- })
197
-
198
- const onSorting = (value: string): void => {
199
- emits('sort', value)
200
- }
201
- const onPagination = (value: UI_I_Pagination): void => {
202
- emits('pagination', value)
203
- }
204
- const sendFilter = useDebounceFn((searchText: string) => {
205
- emits('col-search', searchText)
206
- }, 1000)
207
- const onColumnFilter = (obj: UI_T_ArbitraryObject<string>): void => {
208
- let searchText = ''
209
-
210
- for (const [key, value] of Object.entries(obj)) {
211
- const currentFilter = searchText
212
- ? ',' + key + '.' + value
213
- : key + '.' + value
214
-
215
- searchText = searchText + (value ? currentFilter : '')
216
- }
217
- sendFilter(searchText)
218
- }
219
-
220
- const actions = computed<UI_I_Dropdown[]>(() =>
221
- getTargetActionsFunc(localization.value)
222
- )
223
- const onToggleActions = (id: number): void => {
224
- if (actionsShowId.value === id) {
225
- actionsShowId.value = -1
226
- } else {
227
- actionsShowId.value = id
228
- }
229
- }
230
- const onSelectAction = (
231
- data: UI_I_DataTableBodyData['data'],
232
- action: 'view-target' | 'copy-clipboard' | 'export'
233
- ): void => {
234
- const { target, event } = data
235
-
236
- switch (action) {
237
- case 'view-target':
238
- onSelectNodeOfTree(target)
239
- break
240
- case 'copy-clipboard': {
241
- const clipboardText =
242
- [event]?.map((item) => Object.values(item).join(',')).join('\n') || ''
243
-
244
- navigator.clipboard.writeText(clipboardText)
245
- break
246
- }
247
- case 'export':
248
- break
249
- }
250
- onHideActionsDropdown()
251
- }
252
- const onHideActionsDropdown = (): void => {
253
- actionsShowId.value = -1
254
- }
255
-
256
- const onSearchEvents = useDebounceFn((searchText: string) => {
257
- emits('search')
258
- }, 400)
259
-
260
- const onSelectNodeOfTree = (data: UI_I_TableTarget<'sphere'>): void => {
261
- emits('select-node', data)
262
- }
263
- const onSelectRow = (value: UI_I_DataTableBody[]): void => {
264
- selectedScheduledTaskLocal.value = value[0]?.row
265
- }
266
- </script>
267
-
268
- <style scoped lang="scss">
269
- .task-table {
270
- height: inherit;
271
-
272
- .target-link {
273
- font-family: 'Inter', sans-serif;
274
- font-size: 13px;
275
- color: var(--bottom-pannel-rtask-link-text);
276
- font-weight: 400;
277
- line-height: 15.73px;
278
- cursor: pointer;
279
- &:hover {
280
- color: var(--bottom-pannel-rtask-link-hover-text);
281
- }
282
- }
283
- .chip-icon {
284
- min-width: 14px;
285
- }
286
- .icon {
287
- margin-right: 4px;
288
- }
289
-
290
- .actions {
291
- width: 100%;
292
-
293
- .action-icon {
294
- width: 20px;
295
- height: 20px;
296
- color: var(--tasks-actions-icon-color);
297
-
298
- &:hover {
299
- color: var(--tasks-actions-icon-hover-color);
300
- }
301
- &.active {
302
- color: var(--tasks-actions-icon-icative-color);
303
- }
304
- }
305
-
306
- .action-text {
307
- margin-left: 8px;
308
- }
309
- }
310
- &__tooltip {
311
- margin-left: 8px;
312
- }
313
- }
314
-
315
- .skeleton-header {
316
- display: flex;
317
- justify-content: space-between;
318
- align-items: center;
319
-
320
- .left-skeleton {
321
- display: flex;
322
- align-items: center;
323
- column-gap: 16px;
324
- .vertical-line {
325
- height: 24px;
326
- border-right: 1px solid var(--table-line);
327
- }
328
- }
329
-
330
- .right-skeleton {
331
- display: flex;
332
- align-items: center;
333
- column-gap: 16px;
334
- }
335
- }
336
- </style>
@@ -1,217 +0,0 @@
1
- import type {
2
- UI_I_DataTableBody,
3
- UI_I_DataTableHeader,
4
- UI_I_DataTableOptions,
5
- } from '~/node_modules/bfg-uikit/components/ui/dataTable/models/interfaces'
6
- import type { UI_I_Localization } from '~/lib/models/interfaces'
7
- import type { UI_I_Dropdown } from '~/node_modules/bfg-uikit/components/ui/dropdown/models/interfaces'
8
- import type { UI_I_ScheduledTasksTableItem } from '~/components/common/pages/scheduledTasks/lib/models/interfaces'
9
- import { UI_E_SchedulerRunStatus } from '~/components/common/pages/scheduledTasks/table/lib/models/enums'
10
- import {
11
- E_SchedulerStatus,
12
- E_SchedulerChipColor,
13
- E_SchedulerChipIcon,
14
- } from '~/components/common/pages/scheduledTasks/table/new/lib/models/enums'
15
-
16
- // Маппинг для статусов
17
- const STATUS_MAPPING = {
18
- [E_SchedulerStatus.Completed]: {
19
- textKey: 'complete',
20
- icon: E_SchedulerChipIcon.StatusCheck,
21
- chipColor: E_SchedulerChipColor.Green,
22
- },
23
- [E_SchedulerStatus.Running]: {
24
- textKey: 'running',
25
- icon: E_SchedulerChipIcon.StatusCheck,
26
- chipColor: E_SchedulerChipColor.Green,
27
- },
28
- [E_SchedulerStatus.Failed]: {
29
- textKey: 'failed',
30
- icon: E_SchedulerChipIcon.Information,
31
- chipColor: E_SchedulerChipColor.Red,
32
- },
33
- }
34
-
35
- export const getHeaderDataFunc = (
36
- localization: UI_I_Localization
37
- ): UI_I_DataTableHeader[] => [
38
- {
39
- col: 'col0',
40
- colName: 'name',
41
- text: localization.common.scheduledTask,
42
- isSortable: true,
43
- sort: 'asc',
44
- width: '240px',
45
- show: true,
46
- filter: true,
47
- },
48
- {
49
- col: 'col1',
50
- colName: 'sheduler',
51
- text: localization.common.schedule,
52
- isSortable: true,
53
- sort: 'asc',
54
- width: '180px',
55
- show: true,
56
- filter: true,
57
- },
58
- {
59
- col: 'col2',
60
- colName: 'last_modified',
61
- text: localization.common.lastRun,
62
- isSortable: true,
63
- sort: 'asc',
64
- width: '180px',
65
- show: true,
66
- filter: true,
67
- },
68
- {
69
- col: 'col3',
70
- colName: 'last_run_result',
71
- text: localization.common.lastRunResult,
72
- isSortable: true,
73
- sort: 'asc',
74
- width: '110px',
75
- show: true,
76
- filter: true,
77
- },
78
-
79
- {
80
- col: 'col4',
81
- colName: 'next_run',
82
- text: localization.common.nextRun,
83
- isSortable: true,
84
- sort: 'asc',
85
- width: '160px',
86
- show: true,
87
- filter: true,
88
- },
89
- ]
90
-
91
- export const getTargetActionsFunc = (
92
- localization: UI_I_Localization
93
- ): UI_I_Dropdown[] => {
94
- return [
95
- {
96
- value: 'view-target',
97
- text: localization.common.viewTarget,
98
- iconName: 'password-hide',
99
- selected: false,
100
- },
101
- {
102
- value: 'copy-clipboard',
103
- text: localization.events.copyToClipboard,
104
- iconName: 'copy-to-clipboard',
105
- selected: false,
106
- },
107
- // {
108
- // value: 'export',
109
- // text: localization.common.export,
110
- // iconName: 'download-2',
111
- // selected: false,
112
- // },
113
- ]
114
- }
115
-
116
- export const options: UI_I_DataTableOptions = {
117
- perPageOptions: [
118
- { text: '10', value: 10 },
119
- { text: '25', value: 25 },
120
- { text: '50', value: 50 },
121
- { text: '100', value: 100, default: true },
122
- ],
123
- isSelectable: true,
124
- isFocusable: false,
125
- showPagination: true,
126
- showPaginationOnTop: false,
127
- showPageInfo: true,
128
- isSortable: true,
129
- server: true,
130
- isResizable: true,
131
- showSearch: true,
132
- showSelectedRows: true,
133
- showColumnManager: true,
134
- withActions: true,
135
- inBlock: true,
136
- showExport: true,
137
- withCollapse: true,
138
- }
139
-
140
- export const getBodyDataFunc = (
141
- bodyData: UI_I_ScheduledTasksTableItem[],
142
- localization: UI_I_Localization
143
- ): UI_I_DataTableBody[] => {
144
- const { $formattedDatetime }: any = useNuxtApp()
145
- return bodyData.map((scheduler, index: number) => {
146
- const historyLastRun = scheduler?.last_5_run?.at(-1)
147
-
148
- const lastRun = historyLastRun?.start
149
- const formattedLastRun =
150
- lastRun && $formattedDatetime(+lastRun * 1000, { hasSeconds: true })
151
-
152
- const nextRun = scheduler.next_run
153
- const formattedNextRun =
154
- nextRun && $formattedDatetime(+nextRun * 1000, { hasSeconds: true })
155
-
156
- const statusKey =
157
- historyLastRun?.result.toLowerCase() === UI_E_SchedulerRunStatus.SUCCESS
158
- ? E_SchedulerStatus.Completed
159
- : historyLastRun?.result === UI_E_SchedulerRunStatus.RUNNING
160
- ? E_SchedulerStatus.Running
161
- : E_SchedulerStatus.Failed
162
- const statusData = {
163
- ...STATUS_MAPPING[statusKey],
164
- testId: `${scheduler.rid}-${index}-status`,
165
- }
166
-
167
- return {
168
- row: scheduler.rid,
169
- collapse: true,
170
- isHiddenCollapse: false,
171
- collapseToggle: false,
172
- data: [
173
- {
174
- key: 'icon',
175
- col: 'col0',
176
- text: scheduler.name,
177
- data: {
178
- iconClassName: 'icon-events',
179
- expandData: scheduler,
180
- },
181
- testId: `table-item-${scheduler.rid}`,
182
- },
183
- {
184
- col: 'col1',
185
- text: scheduler.sheduler || '--',
186
- data: 'statusData',
187
- testId: `table-item-${scheduler.rid}`,
188
- },
189
- {
190
- col: 'col2',
191
- text: formattedLastRun,
192
- testId: `table-item-${scheduler.rid}`,
193
- },
194
- {
195
- key: 'status',
196
- col: 'col3',
197
- text: localization.common[statusData.textKey],
198
- data: statusData,
199
- testId: `table-item-${scheduler.rid}`,
200
- },
201
- {
202
- key: 'icon',
203
- col: 'col4',
204
- text: formattedNextRun,
205
- data: 'dataTarget',
206
- testId: `table-item-${scheduler.rid}`,
207
- },
208
- {
209
- key: 'default-actions',
210
- col: 'default-actions',
211
- text: '',
212
- data: { id: index, target: 'dataTarget', scheduler },
213
- },
214
- ],
215
- }
216
- })
217
- }
@@ -1,14 +0,0 @@
1
- export enum E_SchedulerStatus {
2
- Completed = 'completed',
3
- Running = 'running',
4
- Failed = 'failed',
5
- }
6
-
7
- export enum E_SchedulerChipColor {
8
- Green = 'green',
9
- Red = 'red',
10
- }
11
- export enum E_SchedulerChipIcon {
12
- StatusCheck = 'status-check',
13
- Information = 'info-stroke',
14
- }
@@ -1,93 +0,0 @@
1
- <template>
2
- <div class="data-table-view">
3
- <atoms-table-data-grid
4
- v-model:selected-row="selectedScheduledTaskLocal"
5
- v-model:page-size="pagination.pageSize"
6
- v-model:page="pagination.page"
7
- :head-items="headItems"
8
- :body-items="bodyItems"
9
- :total-items="props.totalItems"
10
- :total-pages="props.totalPages"
11
- :items-per-page="itemsPerPage"
12
- :z-index-header-shift="2"
13
- :loading="props.isLoading"
14
- type="radio"
15
- class="data-table"
16
- test-id="scheduled-tasks-table"
17
- hide-pagination
18
- hide-page-size
19
- off-select-by-row
20
- server-off
21
- >
22
- <template #icon="{ item }">
23
- <atoms-the-icon :name="item.data.iconClassName" class="icon" />
24
- <span :title="item.text" class="text-ellipsis">
25
- {{ item.text }}
26
- </span>
27
- </template>
28
-
29
- <template #toggleBlock="{ item }">
30
- <common-pages-scheduled-tasks-table-expand-details
31
- :data="item[0].data.expandData"
32
- />
33
- </template>
34
- </atoms-table-data-grid>
35
- </div>
36
- </template>
37
-
38
- <script lang="ts" setup>
39
- import type {
40
- UI_I_HeadItem,
41
- UI_I_BodyItem,
42
- } from '~/components/atoms/table/dataGrid/lib/models/interfaces'
43
- import { itemsPerPage } from '~/components/atoms/table/dataGrid/lib/config/itemsPerPage'
44
- import type { UI_I_Localization } from '~/lib/models/interfaces'
45
- import type { UI_I_Pagination } from '~/lib/models/table/interfaces'
46
- import type { UI_I_ScheduledTasksTableItem } from '~/components/common/pages/scheduledTasks/lib/models/interfaces'
47
- import * as scheduledTaskTable from '~/components/common/pages/scheduledTasks/table/old/lib/config/scheduledTasksTable'
48
-
49
- const selectedScheduledTaskLocal = defineModel<string | null>()
50
- const props = defineProps<{
51
- tableItems: UI_I_ScheduledTasksTableItem[]
52
- totalItems: number
53
- totalPages: number
54
- isLoading: boolean
55
- }>()
56
-
57
- const localization = computed<UI_I_Localization>(() => useLocal())
58
-
59
- const pagination = ref<UI_I_Pagination>({
60
- page: 1,
61
- pageSize: 100,
62
- })
63
-
64
- const headItems = computed<UI_I_HeadItem[]>(() =>
65
- scheduledTaskTable.headItems(localization.value)
66
- )
67
- const bodyItems = computed<UI_I_BodyItem[][]>(() => {
68
- return scheduledTaskTable.bodyItems(props.tableItems || [])
69
- })
70
- </script>
71
-
72
- <style lang="scss" scoped>
73
- .data-table-view {
74
- overflow: hidden;
75
- height: inherit;
76
- margin-bottom: 10px;
77
- :deep(.data-table) {
78
- height: inherit;
79
- .datagrid-outer-wrapper {
80
- height: inherit;
81
- padding-top: 0;
82
- //.datagrid {
83
- // margin-top: 0;
84
- //}
85
- }
86
- }
87
- .icon {
88
- width: 18px;
89
- min-width: 18px;
90
- margin-right: 3px;
91
- }
92
- }
93
- </style>