bfg-common 1.3.40 → 1.3.41

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,33 +1,44 @@
1
- import { UI_I_Resources } from '~/components/common/resource/lib/models/interfaces'
1
+ import type { UI_I_Resources } from '~/components/common/resource/lib/models/interfaces'
2
2
 
3
3
  export const parseResourceUnit = (
4
- arr: UI_I_Resources<number>[]
4
+ arr: UI_I_Resources<number>[],
5
+ isMainValue: boolean = false
5
6
  ): UI_I_Resources[] => {
6
7
  return arr.map((resource: UI_I_Resources<number>) => {
7
8
  return {
8
9
  type: resource.type,
9
10
  free: {
10
11
  value: resource.free || 0,
11
- text: setResourceNumeric(resource.type, resource.free || 0),
12
+ text: isMainValue
13
+ ? String(resource.free) || '0'
14
+ : setResourceNumeric(resource.type, resource.free || 0),
12
15
  },
13
16
  used: {
14
17
  value: resource.used || 0,
15
- text: setResourceNumeric(resource.type, resource.used || 0),
18
+ text: isMainValue
19
+ ? String(resource.used) || '0'
20
+ : setResourceNumeric(resource.type, resource.used || 0),
16
21
  },
17
22
  capacity: {
18
23
  value: resource.capacity || 0,
19
- text: setResourceNumeric(resource.type, resource.capacity || 0),
24
+ text: isMainValue
25
+ ? String(resource.capacity) || '0'
26
+ : setResourceNumeric(resource.type, resource.capacity || 0),
20
27
  },
21
28
  }
22
29
  })
23
30
  }
24
31
 
25
- export const setResourceNumeric = (type: string, value: number): string => {
32
+ export const setResourceNumeric = (
33
+ type: string,
34
+ value: number,
35
+ lang: string = 'en'
36
+ ): string => {
26
37
  if (value === undefined) return ''
27
38
 
28
39
  const { $binary } = useNuxtApp()
29
40
 
30
- if (type === 'cpu') return $binary.roundHz(value)
41
+ if (type === 'cpu') return $binary.roundHz(value, lang)
31
42
 
32
- return $binary.round(value)
43
+ return $binary.round(value, false, lang)
33
44
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.3.40",
4
+ "version": "1.3.41",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",
@@ -1,45 +1,42 @@
1
- import type { UI_I_Localization } from '~/lib/models/interfaces'
2
- import type {
3
- API_UI_I_Task,
4
- UI_I_TaskItem,
5
- UI_I_Task,
6
- API_UI_I_TaskItem,
7
- } from '~/lib/models/store/tasks/interfaces'
8
- import {
9
- UI_E_TaskStatus,
10
- UI_E_IconNameByTaskStatus,
11
- } from '~/lib/models/store/tasks/enums'
12
-
13
- export const tasksConstructor = (
14
- data: API_UI_I_Task<string>
15
- ): UI_I_Task<string> => {
16
- const localization: UI_I_Localization = useLocal()
17
-
18
- const items: UI_I_TaskItem<string>[] =
19
- data.items?.map((task: API_UI_I_TaskItem<string>) => {
20
- return {
21
- // relatedEvents: task?.RelatedEvents || '',
22
- relatedEvents: '',
23
- completion: task.completion || '-',
24
- queuedFor: task.creation_time - task.start_time,
25
- execution: Math.abs(task.start_time - task.completion),
26
- details: task.details,
27
- error: task.error,
28
- initiator: task.initiator,
29
- server: task.server,
30
- startTime: task.start_time || '-',
31
- statusIcon: UI_E_IconNameByTaskStatus[task.status],
32
- statusText: task.error || localization[UI_E_TaskStatus[task.status]],
33
- status: task.status,
34
- target: task.target,
35
- targetType: task.target_type,
36
- taskName: task.task_name,
37
- id: task.id,
38
- zone: task.zone,
39
- }
40
- }) || []
41
- return {
42
- ...data,
43
- items,
44
- }
45
- }
1
+ import type {
2
+ API_UI_I_Task,
3
+ UI_I_TaskItem,
4
+ UI_I_Task,
5
+ API_UI_I_TaskItem,
6
+ } from '~/lib/models/store/tasks/interfaces'
7
+ import {
8
+ UI_E_TaskStatus,
9
+ UI_E_IconNameByTaskStatus,
10
+ } from '~/lib/models/store/tasks/enums'
11
+
12
+ export const tasksConstructor = (
13
+ data: API_UI_I_Task<string>
14
+ ): UI_I_Task<string> => {
15
+ const items: UI_I_TaskItem<string>[] =
16
+ data.items?.map((task: API_UI_I_TaskItem<string>) => {
17
+ return {
18
+ // relatedEvents: task?.RelatedEvents || '',
19
+ relatedEvents: '',
20
+ completion: task.completion || '-',
21
+ queuedFor: task.creation_time - task.start_time,
22
+ execution: Math.abs(task.start_time - task.completion),
23
+ details: task.details,
24
+ error: task.error,
25
+ initiator: task.initiator,
26
+ server: task.server,
27
+ startTime: task.start_time || '-',
28
+ statusIcon: UI_E_IconNameByTaskStatus[task.status],
29
+ statusText: task.error || UI_E_TaskStatus[task.status],
30
+ status: task.status,
31
+ target: task.target,
32
+ targetType: task.target_type,
33
+ taskName: task.task_name,
34
+ id: task.id,
35
+ zone: task.zone,
36
+ }
37
+ }) || []
38
+ return {
39
+ ...data,
40
+ items,
41
+ }
42
+ }