@dao-style/biz 0.6.0 → 0.7.0

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 (186) hide show
  1. package/dist/cjs/components/gpu/style/assign-gpu-devices-list.js +1 -0
  2. package/dist/cjs/components/gpu/style/gpu-form.js +1 -0
  3. package/dist/components/form-block/FormBlock.d.ts +27 -1
  4. package/dist/components/form-block/props.d.ts +4 -0
  5. package/dist/components/form-block/props.js +4 -0
  6. package/dist/components/form-block/props.mjs +4 -0
  7. package/dist/components/form-block/src/FormBlock.vue.d.ts +11 -0
  8. package/dist/components/form-block/src/FormBlock.vue.js +4 -4
  9. package/dist/components/form-block/src/FormBlock.vue.mjs +4 -4
  10. package/dist/components/form-block/src/FormBlock.vue2.js +12 -1
  11. package/dist/components/form-block/src/FormBlock.vue2.mjs +12 -1
  12. package/dist/components/gpu/props.d.ts +121 -3
  13. package/dist/components/gpu/props.js +82 -9
  14. package/dist/components/gpu/props.mjs +82 -9
  15. package/dist/components/gpu/src/GpuForm.vue.d.ts +283 -50
  16. package/dist/components/gpu/src/GpuForm.vue.js +25 -24
  17. package/dist/components/gpu/src/GpuForm.vue.mjs +26 -25
  18. package/dist/components/gpu/src/GpuForm.vue2.js +115 -218
  19. package/dist/components/gpu/src/GpuForm.vue2.mjs +116 -219
  20. package/dist/components/gpu/src/components/AssignGpuDevicesList.vue.d.ts +77 -0
  21. package/dist/components/gpu/src/components/AssignGpuDevicesList.vue.js +40 -0
  22. package/dist/components/gpu/src/components/AssignGpuDevicesList.vue.mjs +41 -0
  23. package/dist/components/gpu/src/components/AssignGpuDevicesList.vue2.js +191 -0
  24. package/dist/components/gpu/src/components/AssignGpuDevicesList.vue2.mjs +192 -0
  25. package/dist/components/gpu/src/components/GpuAdvancedForm.vue.d.ts +180 -0
  26. package/dist/components/gpu/src/{GpuAdvancedForm.vue.js → components/GpuAdvancedForm.vue.js} +92 -37
  27. package/dist/components/gpu/src/{GpuAdvancedForm.vue.mjs → components/GpuAdvancedForm.vue.mjs} +93 -38
  28. package/dist/components/gpu/src/components/GpuAdvancedForm.vue2.js +169 -0
  29. package/dist/components/gpu/src/components/GpuAdvancedForm.vue2.mjs +153 -0
  30. package/dist/components/gpu/src/{GpuFormDynamicItem.vue.d.ts → components/GpuFormDynamicItem.vue.d.ts} +4 -4
  31. package/dist/components/gpu/src/{GpuFormDynamicItem.vue.js → components/GpuFormDynamicItem.vue.js} +1 -1
  32. package/dist/components/gpu/src/{GpuFormDynamicItem.vue.mjs → components/GpuFormDynamicItem.vue.mjs} +1 -1
  33. package/dist/components/gpu/src/{GpuFormDynamicItem.vue2.js → components/GpuFormDynamicItem.vue2.js} +1 -1
  34. package/dist/components/gpu/src/{GpuFormDynamicItem.vue2.mjs → components/GpuFormDynamicItem.vue2.mjs} +1 -1
  35. package/dist/components/gpu/src/components/GpuFormItem.vue.d.ts +310 -0
  36. package/dist/components/gpu/src/{GpuFormItem.vue.js → components/GpuFormItem.vue.js} +22 -26
  37. package/dist/components/gpu/src/{GpuFormItem.vue.mjs → components/GpuFormItem.vue.mjs} +23 -27
  38. package/dist/components/gpu/src/components/GpuFormItem.vue2.js +61 -0
  39. package/dist/components/gpu/src/components/GpuFormItem.vue2.mjs +45 -0
  40. package/dist/components/gpu/src/{GpuResources.vue.d.ts → components/GpuResources.vue.d.ts} +38 -18
  41. package/dist/components/gpu/src/components/GpuResources.vue.js +153 -0
  42. package/dist/components/gpu/src/components/GpuResources.vue.mjs +154 -0
  43. package/dist/components/gpu/src/components/GpuResources.vue2.js +278 -0
  44. package/dist/components/gpu/src/components/GpuResources.vue2.mjs +262 -0
  45. package/dist/components/gpu/src/gpuForm.constants.d.ts +3 -0
  46. package/dist/components/gpu/src/gpuForm.constants.js +10 -0
  47. package/dist/components/gpu/src/gpuForm.constants.mjs +10 -0
  48. package/dist/components/gpu/src/gpuForm.internal-types.d.ts +49 -0
  49. package/dist/components/gpu/src/gpuForm.mapper.d.ts +16 -0
  50. package/dist/components/gpu/src/gpuForm.mapper.js +199 -0
  51. package/dist/components/gpu/src/gpuForm.mapper.mjs +199 -0
  52. package/dist/components/gpu/src/gpuFormItem.mapper.d.ts +38 -0
  53. package/dist/components/gpu/src/gpuFormItem.mapper.js +153 -0
  54. package/dist/components/gpu/src/gpuFormItem.mapper.mjs +153 -0
  55. package/dist/components/gpu/src/useGPUOptions.d.ts +2 -2
  56. package/dist/components/gpu/src/useGPUOptions.js +15 -20
  57. package/dist/components/gpu/src/useGPUOptions.mjs +16 -21
  58. package/dist/components/gpu/src/useGpuFormItemState.d.ts +42 -0
  59. package/dist/components/gpu/src/useGpuFormItemState.js +178 -0
  60. package/dist/components/gpu/src/useGpuFormItemState.mjs +178 -0
  61. package/dist/components/gpu/src/useGpuFormSideState.d.ts +52 -0
  62. package/dist/components/gpu/src/useGpuFormSideState.js +71 -0
  63. package/dist/components/gpu/src/useGpuFormSideState.mjs +71 -0
  64. package/dist/components/gpu/src/useGpuFormState.d.ts +560 -0
  65. package/dist/components/gpu/src/useGpuFormState.js +52 -0
  66. package/dist/components/gpu/src/useGpuFormState.mjs +52 -0
  67. package/dist/components/gpu/src/validations/nvidiaVgpuMemoryDecimal.d.ts +5 -1
  68. package/dist/components/gpu/style/assign-gpu-devices-list.d.ts +1 -0
  69. package/dist/components/gpu/style/assign-gpu-devices-list.scss.js +3 -0
  70. package/dist/components/gpu/style/assign-gpu-devices-list.scss.mjs +4 -0
  71. package/dist/components/gpu/style/gpu-form.d.ts +1 -0
  72. package/dist/components/gpu/types.d.ts +6 -0
  73. package/dist/components/gpu/types.js +2 -0
  74. package/dist/components/gpu/types.mjs +2 -0
  75. package/dist/components/gpu/utils.d.ts +4 -0
  76. package/dist/components/gpu/utils.js +14 -0
  77. package/dist/components/gpu/utils.mjs +14 -0
  78. package/dist/components/instance-cluster/src/InstanceCluster.vue.d.ts +1 -1
  79. package/dist/components/instance-namespace/src/InstanceNamespace.vue.d.ts +1 -1
  80. package/dist/components/instance-storage-class/src/InstanceStorageClass.vue.d.ts +1 -1
  81. package/dist/components/network-config/src/NetworkConfig.vue.d.ts +1 -1
  82. package/dist/components/network-config/src/NetworkConfig.vue.js +13 -6
  83. package/dist/components/network-config/src/NetworkConfig.vue.mjs +14 -7
  84. package/dist/dialogs/create-network-config-dialog/src/CreateNetworkConfigDialog.vue.d.ts +1 -1
  85. package/dist/es/components/gpu/style/assign-gpu-devices-list.mjs +1 -0
  86. package/dist/es/components/gpu/style/gpu-form.mjs +1 -0
  87. package/dist/forms/import-parameter-template/props.d.ts +8 -8
  88. package/dist/forms/import-parameter-template/src/ImportParameterTemplate.vue.d.ts +24 -24
  89. package/dist/group-mapping.json +1 -1
  90. package/dist/index.js +34 -23
  91. package/dist/index.mjs +15 -4
  92. package/dist/locales/en-US/components/Gpu.json.js +36 -9
  93. package/dist/locales/en-US/components/Gpu.json.mjs +37 -10
  94. package/dist/locales/en-US/index.js +2 -0
  95. package/dist/locales/en-US/index.mjs +2 -0
  96. package/dist/locales/en-US/uses/UseCancelFormDialog.json.js +11 -0
  97. package/dist/locales/en-US/uses/UseCancelFormDialog.json.mjs +11 -0
  98. package/dist/locales/ja/components/Gpu.json.js +36 -9
  99. package/dist/locales/ja/components/Gpu.json.mjs +37 -10
  100. package/dist/locales/ja/components/InstancePassword.json.js +1 -1
  101. package/dist/locales/ja/components/InstancePassword.json.mjs +1 -1
  102. package/dist/locales/ja/components/MatchExpressionsEditor.json.js +1 -1
  103. package/dist/locales/ja/components/MatchExpressionsEditor.json.mjs +1 -1
  104. package/dist/locales/ja/components/NetworkConfig.json.js +1 -1
  105. package/dist/locales/ja/components/NetworkConfig.json.mjs +1 -1
  106. package/dist/locales/ja/index.js +2 -0
  107. package/dist/locales/ja/index.mjs +2 -0
  108. package/dist/locales/ja/uses/UseCancelFormDialog.json.js +11 -0
  109. package/dist/locales/ja/uses/UseCancelFormDialog.json.mjs +11 -0
  110. package/dist/locales/ja/workloads/DnsConfig.json.js +1 -1
  111. package/dist/locales/ja/workloads/DnsConfig.json.mjs +1 -1
  112. package/dist/locales/ja/workloads/workload-advanced/NetworkConfig.json.js +1 -1
  113. package/dist/locales/ja/workloads/workload-advanced/NetworkConfig.json.mjs +1 -1
  114. package/dist/locales/zh-CN/components/Gpu.json.js +36 -9
  115. package/dist/locales/zh-CN/components/Gpu.json.mjs +37 -10
  116. package/dist/locales/zh-CN/index.js +2 -0
  117. package/dist/locales/zh-CN/index.mjs +2 -0
  118. package/dist/locales/zh-CN/uses/UseCancelFormDialog.json.js +11 -0
  119. package/dist/locales/zh-CN/uses/UseCancelFormDialog.json.mjs +11 -0
  120. package/dist/style.css +692 -664
  121. package/dist/styles/components/gpu/assign-gpu-devices-list.css +10 -0
  122. package/dist/styles/components/gpu/gpu-form-item.css +16 -0
  123. package/dist/styles/components/gpu/gpu-form.css +4 -0
  124. package/dist/styles/components/network-config/network-config.css +3 -0
  125. package/dist/styles/components/resource-config/resource-config.css +0 -8
  126. package/dist/styles/styles/common.css +4 -0
  127. package/dist/uses/index.d.ts +1 -0
  128. package/dist/uses/useCancelFormDialog/index.d.ts +11 -0
  129. package/dist/uses/useCancelFormDialog/index.js +40 -0
  130. package/dist/uses/useCancelFormDialog/index.mjs +40 -0
  131. package/dist/uses/useCancelFormDialog/src/CancelFormDialog.vue.d.ts +8 -0
  132. package/dist/uses/useCancelFormDialog/src/CancelFormDialog.vue.js +25 -0
  133. package/dist/uses/useCancelFormDialog/src/CancelFormDialog.vue.mjs +26 -0
  134. package/dist/uses/useCancelFormDialog/src/CancelFormDialog.vue2.js +3 -0
  135. package/dist/uses/useCancelFormDialog/src/CancelFormDialog.vue2.mjs +4 -0
  136. package/dist/utils/index.d.ts +1 -0
  137. package/dist/utils/injectWithSelf.d.ts +6 -0
  138. package/dist/utils/injectWithSelf.js +8 -0
  139. package/dist/utils/injectWithSelf.mjs +8 -0
  140. package/dist/utils/multiRowEditorValidate.d.ts +5 -5
  141. package/dist/utils/useResetFieldValue.d.ts +13 -0
  142. package/dist/utils/useResetFieldValue.js +28 -0
  143. package/dist/utils/useResetFieldValue.mjs +28 -0
  144. package/dist/utils/useSetFieldValue.d.ts +6 -0
  145. package/dist/utils/useSetFieldValue.js +2 -5
  146. package/dist/utils/useSetFieldValue.mjs +2 -5
  147. package/dist/workloads/container-basic-info/props.d.ts +13 -0
  148. package/dist/workloads/container-basic-info/props.js +4 -0
  149. package/dist/workloads/container-basic-info/props.mjs +4 -0
  150. package/dist/workloads/container-basic-info/src/ContainerBasicInfo.vue.d.ts +10 -0
  151. package/dist/workloads/container-basic-info/src/ContainerBasicInfo.vue.js +54 -29
  152. package/dist/workloads/container-basic-info/src/ContainerBasicInfo.vue.mjs +54 -29
  153. package/dist/workloads/container-basic-info/src/ContainerBasicInfo.vue2.js +18 -8
  154. package/dist/workloads/container-basic-info/src/ContainerBasicInfo.vue2.mjs +19 -9
  155. package/dist/workloads/container-image/src/dialogs/SelectImageDialog.vue.d.ts +1 -1
  156. package/dist/workloads/containers/demo/data.d.ts +8 -1
  157. package/dist/workloads/containers/src/ContainerItem.vue.d.ts +23 -0
  158. package/dist/workloads/containers/src/Containers.vue.d.ts +4 -0
  159. package/dist/workloads/containers/src/Containers.vue2.js +18 -1
  160. package/dist/workloads/containers/src/Containers.vue2.mjs +19 -2
  161. package/dist/workloads/health-check/props.d.ts +4 -0
  162. package/dist/workloads/health-check/props.js +4 -0
  163. package/dist/workloads/health-check/props.mjs +4 -0
  164. package/dist/workloads/health-check/src/HealthCheck.vue.d.ts +9 -0
  165. package/dist/workloads/health-check/src/HealthCheck.vue.js +6 -6
  166. package/dist/workloads/health-check/src/HealthCheck.vue.mjs +6 -6
  167. package/dist/workloads/health-check/src/HealthCheckHandler.vue.js +3 -1
  168. package/dist/workloads/health-check/src/HealthCheckHandler.vue.mjs +3 -1
  169. package/dist/workloads/http-get-action/src/HttpGetAction.vue.js +1 -1
  170. package/dist/workloads/http-get-action/src/HttpGetAction.vue.mjs +1 -1
  171. package/dist/workloads/workload-annotations/props.d.ts +1 -0
  172. package/dist/workloads/workload-annotations/props.js +1 -0
  173. package/dist/workloads/workload-annotations/props.mjs +2 -1
  174. package/package.json +12 -13
  175. package/dist/components/gpu/src/GpuAdvancedForm.vue.d.ts +0 -131
  176. package/dist/components/gpu/src/GpuAdvancedForm.vue2.js +0 -92
  177. package/dist/components/gpu/src/GpuAdvancedForm.vue2.mjs +0 -76
  178. package/dist/components/gpu/src/GpuFormItem.vue.d.ts +0 -232
  179. package/dist/components/gpu/src/GpuFormItem.vue2.js +0 -235
  180. package/dist/components/gpu/src/GpuFormItem.vue2.mjs +0 -219
  181. package/dist/components/gpu/src/GpuResources.vue.js +0 -125
  182. package/dist/components/gpu/src/GpuResources.vue.mjs +0 -126
  183. package/dist/components/gpu/src/GpuResources.vue2.js +0 -197
  184. package/dist/components/gpu/src/GpuResources.vue2.mjs +0 -181
  185. package/dist/components/gpu/src/validations/nvidiaVgpuMemoryDecimal.js +0 -19
  186. package/dist/components/gpu/src/validations/nvidiaVgpuMemoryDecimal.mjs +0 -20
@@ -0,0 +1,153 @@
1
+ import { set } from "lodash-es";
2
+ import { nvidiaVgpuDevicesKey, nvidiaVgpuModelKey, nvidiaVgpuPriorityKey, nvidiaVgpuGpuScheduleKey, nvidiaVgpuNodeScheduleKey } from "../types.mjs";
3
+ import { isValidGPUResourceValue, deSanitizeGPUObjectKey, isNvidiaVgpu, isHamiGpu, sanitizeGPUKey } from "../utils.mjs";
4
+ function buildGpuFormItemDefaultResources(gpuOption, gpuUsage) {
5
+ var _a;
6
+ if (gpuUsage !== "workload" || !isHamiGpu(gpuOption == null ? void 0 : gpuOption.provider)) {
7
+ return {};
8
+ }
9
+ const cardResource = (_a = gpuOption == null ? void 0 : gpuOption.resource) == null ? void 0 : _a.find((resource) => {
10
+ var _a2;
11
+ return resource.type === "cardNum" && typeof ((_a2 = resource.range) == null ? void 0 : _a2.max) === "number" && resource.range.max > 0;
12
+ });
13
+ if (!(cardResource == null ? void 0 : cardResource.key)) {
14
+ return {};
15
+ }
16
+ return {
17
+ [sanitizeGPUKey(cardResource.key) ?? cardResource.key]: 1
18
+ };
19
+ }
20
+ function buildGpuFormItemInitialState({
21
+ quotaItem,
22
+ gpuOptionsMap,
23
+ advanced
24
+ }) {
25
+ var _a;
26
+ const { id, type, resources } = quotaItem;
27
+ if (!id) {
28
+ return void 0;
29
+ }
30
+ const values = {
31
+ id,
32
+ type
33
+ };
34
+ let dynamicQuota;
35
+ let openNvidiaAssignGpu = false;
36
+ let openNvidiaVgpuSchedulePolicy = false;
37
+ const isDynamic = type && ((_a = gpuOptionsMap.get(type)) == null ? void 0 : _a.isDynamic);
38
+ if (isDynamic) {
39
+ dynamicQuota = deSanitizeGPUObjectKey(resources);
40
+ } else {
41
+ Object.entries(resources ?? {}).forEach(([key, val]) => {
42
+ set(values, ["resources", key], val);
43
+ });
44
+ }
45
+ const isVgpu = isNvidiaVgpu(type ?? "");
46
+ if (isVgpu && (advanced.enableNvidiaVgpuModel || advanced.enableNvidiaVgpuDevices)) {
47
+ const devices = quotaItem[nvidiaVgpuDevicesKey];
48
+ const model = quotaItem[nvidiaVgpuModelKey];
49
+ const hasDevices = !!(devices == null ? void 0 : devices.length);
50
+ const hasModel = !!model;
51
+ openNvidiaAssignGpu = !!(hasDevices || hasModel);
52
+ if (openNvidiaAssignGpu) {
53
+ if (hasModel) {
54
+ values[nvidiaVgpuModelKey] = model;
55
+ } else if (hasDevices) {
56
+ values[nvidiaVgpuDevicesKey] = devices;
57
+ }
58
+ }
59
+ }
60
+ if (isVgpu && advanced.enableNvidiaVgpuSchedulePolicy) {
61
+ const gpuSchedule = quotaItem[nvidiaVgpuGpuScheduleKey];
62
+ const nodeSchedule = quotaItem[nvidiaVgpuNodeScheduleKey];
63
+ openNvidiaVgpuSchedulePolicy = !!gpuSchedule || !!nodeSchedule;
64
+ if (openNvidiaVgpuSchedulePolicy) {
65
+ values[nvidiaVgpuGpuScheduleKey] = gpuSchedule;
66
+ values[nvidiaVgpuNodeScheduleKey] = nodeSchedule;
67
+ }
68
+ }
69
+ if (advanced.enableNvidiaVgpuPriority) {
70
+ values[nvidiaVgpuPriorityKey] = quotaItem[nvidiaVgpuPriorityKey];
71
+ }
72
+ return {
73
+ values,
74
+ dynamicQuota,
75
+ openNvidiaAssignGpu,
76
+ openNvidiaVgpuSchedulePolicy
77
+ };
78
+ }
79
+ function buildGpuFormItemChangePayload({
80
+ quota,
81
+ dynamicQuota,
82
+ quotaItem,
83
+ showDynamicForm,
84
+ advanced,
85
+ openNvidiaAssignGpu,
86
+ openNvidiaVgpuSchedulePolicy
87
+ }) {
88
+ if (showDynamicForm) {
89
+ return {
90
+ type: quota.type,
91
+ id: quota.id,
92
+ resources: dynamicQuota,
93
+ removable: quotaItem.removable
94
+ };
95
+ }
96
+ const validResources = Object.fromEntries(
97
+ Object.entries(quota.resources ?? {}).filter(([, value]) => isValidGPUResourceValue(value))
98
+ );
99
+ const newQuota = {
100
+ type: quota.type,
101
+ id: quota.id,
102
+ resources: deSanitizeGPUObjectKey(validResources),
103
+ removable: quotaItem.removable
104
+ };
105
+ if (isNvidiaVgpu(quota.type)) {
106
+ if (openNvidiaAssignGpu) {
107
+ const devices = quota[nvidiaVgpuDevicesKey];
108
+ const model = quota[nvidiaVgpuModelKey];
109
+ if (model) {
110
+ newQuota[nvidiaVgpuModelKey] = model;
111
+ } else if (devices == null ? void 0 : devices.length) {
112
+ newQuota[nvidiaVgpuDevicesKey] = devices;
113
+ }
114
+ }
115
+ if (advanced.enableNvidiaVgpuPriority) {
116
+ newQuota[nvidiaVgpuPriorityKey] = quota[nvidiaVgpuPriorityKey];
117
+ }
118
+ if (advanced.enableNvidiaVgpuSchedulePolicy) {
119
+ if (openNvidiaVgpuSchedulePolicy) {
120
+ Object.assign(newQuota, {
121
+ [nvidiaVgpuGpuScheduleKey]: quota[nvidiaVgpuGpuScheduleKey],
122
+ [nvidiaVgpuNodeScheduleKey]: quota[nvidiaVgpuNodeScheduleKey]
123
+ });
124
+ } else {
125
+ Object.assign(newQuota, {
126
+ [nvidiaVgpuGpuScheduleKey]: void 0,
127
+ [nvidiaVgpuNodeScheduleKey]: void 0
128
+ });
129
+ }
130
+ }
131
+ }
132
+ return newQuota;
133
+ }
134
+ function filterGpuFormItemOptions({
135
+ gpuOptionsMap,
136
+ quotaType,
137
+ existTypes,
138
+ targetType
139
+ }) {
140
+ const map = /* @__PURE__ */ new Map();
141
+ gpuOptionsMap.forEach((option, key) => {
142
+ if (key === quotaType || !existTypes.includes(key) && (!targetType || targetType && key === targetType)) {
143
+ map.set(key, option);
144
+ }
145
+ });
146
+ return map;
147
+ }
148
+ export {
149
+ buildGpuFormItemChangePayload,
150
+ buildGpuFormItemDefaultResources,
151
+ buildGpuFormItemInitialState,
152
+ filterGpuFormItemOptions
153
+ };
@@ -1,6 +1,6 @@
1
1
  import { type Ref } from 'vue';
2
2
  import { GPUSettings } from '../props';
3
- import { GPUResourceSetting, GPUSetting } from '../types';
3
+ import { GPUSetting } from '../types';
4
4
  export interface UseGPUOptionsParams {
5
5
  shouldFetchData?: boolean;
6
6
  availableEnable?: boolean;
@@ -14,7 +14,7 @@ export declare const useGPUOptions: (params?: UseGPUOptionsParams) => {
14
14
  gpuOptions: GpuOptions;
15
15
  gpuOptionsMap: GpuOptionsMap;
16
16
  fetchingGpuOptions: FetchingGpuOptions;
17
- getDisplayResource: (type: string) => GPUResourceSetting[];
17
+ getDisplayResource: (type: string) => import("../types").GPUResourceSetting[];
18
18
  fetchGpuOptions: () => Promise<GPUSetting[] | undefined>;
19
19
  gpuKeyTypeMap: GpuKeyTypeMap;
20
20
  };
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const vue = require("vue");
4
- const vueI18n = require("vue-i18n");
5
4
  const lodashEs = require("lodash-es");
6
5
  const props = require("../props.js");
7
6
  const gpuFormsMap = /* @__PURE__ */ new Map();
@@ -36,8 +35,6 @@ const useGPUOptions = (params) => {
36
35
  gpuFormsMap.delete(id);
37
36
  }
38
37
  });
39
- const i18nInstance = vueI18n.useI18n();
40
- const nvidiaVgpuResOrder = props.getNvidiaVgpuResOrder(i18nInstance);
41
38
  const fetchGpuOptions = async () => {
42
39
  var _a;
43
40
  fetchingGpuOptions.value = true;
@@ -82,8 +79,8 @@ const useGPUOptions = (params) => {
82
79
  fetchGpuOptions();
83
80
  }
84
81
  const getDisplayResource = (type) => {
85
- var _a;
86
- const resource = ((_a = gpuOptionsMap.value.get(type)) == null ? void 0 : _a.resource) ?? [];
82
+ const gpuSetting = gpuOptionsMap.value.get(type);
83
+ const resource = (gpuSetting == null ? void 0 : gpuSetting.resource) ?? [];
87
84
  const alloResource = resource.filter(
88
85
  (rs) => rs.isAllocatable === true || rs.isAllocatable === void 0
89
86
  );
@@ -99,23 +96,21 @@ const useGPUOptions = (params) => {
99
96
  });
100
97
  });
101
98
  });
102
- if (type === props.nvidiaVgpuKey) {
103
- const resourceOrder = [...nvidiaVgpuResOrder.keys()];
104
- const preRes = [];
105
- const resRes = [];
106
- alloResource.forEach((res) => {
107
- if (!nvidiaVgpuResOrder.get(res.key ?? "")) {
108
- resRes.push(res);
109
- } else {
110
- const idx = resourceOrder.indexOf(res.key ?? "");
111
- if (idx > -1) {
112
- preRes[idx] = res;
113
- } else {
114
- resRes.push(res);
115
- }
99
+ if ((gpuSetting == null ? void 0 : gpuSetting.provider) === "hami") {
100
+ alloResource.sort((a, b) => {
101
+ const aIdx = props.hamiResOrder.indexOf(a.type ?? "");
102
+ const bIdx = props.hamiResOrder.indexOf(b.type ?? "");
103
+ if (aIdx === -1 && bIdx === -1) {
104
+ return 0;
105
+ }
106
+ if (aIdx === -1) {
107
+ return 1;
108
+ }
109
+ if (bIdx === -1) {
110
+ return -1;
116
111
  }
112
+ return aIdx - bIdx;
117
113
  });
118
- return [...preRes, ...resRes];
119
114
  }
120
115
  return alloResource;
121
116
  };
@@ -1,7 +1,6 @@
1
1
  import { ref, onBeforeUnmount } from "vue";
2
- import { useI18n } from "vue-i18n";
3
2
  import { isEqual, merge } from "lodash-es";
4
- import { getNvidiaVgpuResOrder, nvidiaVgpuKey } from "../props.mjs";
3
+ import { hamiResOrder } from "../props.mjs";
5
4
  const gpuFormsMap = /* @__PURE__ */ new Map();
6
5
  const useGPUOptions = (params) => {
7
6
  const { shouldFetchData = true, gpuSettings } = params ?? {};
@@ -34,8 +33,6 @@ const useGPUOptions = (params) => {
34
33
  gpuFormsMap.delete(id);
35
34
  }
36
35
  });
37
- const i18nInstance = useI18n();
38
- const nvidiaVgpuResOrder = getNvidiaVgpuResOrder(i18nInstance);
39
36
  const fetchGpuOptions = async () => {
40
37
  var _a;
41
38
  fetchingGpuOptions.value = true;
@@ -80,8 +77,8 @@ const useGPUOptions = (params) => {
80
77
  fetchGpuOptions();
81
78
  }
82
79
  const getDisplayResource = (type) => {
83
- var _a;
84
- const resource = ((_a = gpuOptionsMap.value.get(type)) == null ? void 0 : _a.resource) ?? [];
80
+ const gpuSetting = gpuOptionsMap.value.get(type);
81
+ const resource = (gpuSetting == null ? void 0 : gpuSetting.resource) ?? [];
85
82
  const alloResource = resource.filter(
86
83
  (rs) => rs.isAllocatable === true || rs.isAllocatable === void 0
87
84
  );
@@ -97,23 +94,21 @@ const useGPUOptions = (params) => {
97
94
  });
98
95
  });
99
96
  });
100
- if (type === nvidiaVgpuKey) {
101
- const resourceOrder = [...nvidiaVgpuResOrder.keys()];
102
- const preRes = [];
103
- const resRes = [];
104
- alloResource.forEach((res) => {
105
- if (!nvidiaVgpuResOrder.get(res.key ?? "")) {
106
- resRes.push(res);
107
- } else {
108
- const idx = resourceOrder.indexOf(res.key ?? "");
109
- if (idx > -1) {
110
- preRes[idx] = res;
111
- } else {
112
- resRes.push(res);
113
- }
97
+ if ((gpuSetting == null ? void 0 : gpuSetting.provider) === "hami") {
98
+ alloResource.sort((a, b) => {
99
+ const aIdx = hamiResOrder.indexOf(a.type ?? "");
100
+ const bIdx = hamiResOrder.indexOf(b.type ?? "");
101
+ if (aIdx === -1 && bIdx === -1) {
102
+ return 0;
103
+ }
104
+ if (aIdx === -1) {
105
+ return 1;
106
+ }
107
+ if (bIdx === -1) {
108
+ return -1;
114
109
  }
110
+ return aIdx - bIdx;
115
111
  });
116
- return [...preRes, ...resRes];
117
112
  }
118
113
  return alloResource;
119
114
  };
@@ -0,0 +1,42 @@
1
+ import { type ExtractPropTypes, type Slots } from 'vue';
2
+ import type { VueI18nLike } from '@dao-style/extend';
3
+ import { gpuFormItemProps } from '../props';
4
+ import { type GpuQuotaItem } from '../types';
5
+ type GpuFormItemProps = ExtractPropTypes<typeof gpuFormItemProps>;
6
+ type GpuFormItemEmit = (event: 'change', value: GpuQuotaItem) => void;
7
+ export declare function useGpuFormItemState(props: GpuFormItemProps, emits: GpuFormItemEmit, slots: Slots, i18nInstance: VueI18nLike): {
8
+ quota: GpuQuotaItem;
9
+ dynamicQuota: import("vue").Ref<Record<string, string | number | undefined> | undefined>;
10
+ currentDisplayResource: import("vue").ComputedRef<import("../types").GPUResourceSetting[] | undefined>;
11
+ currentGpuProvider: import("vue").ComputedRef<string>;
12
+ isShowHamiGpuHelper: import("vue").ComputedRef<boolean>;
13
+ filteredGpuOptionsMap: import("vue").ComputedRef<Map<string, import("../types").GPUSetting>>;
14
+ getGPUTypeInSide: (quotaType?: string) => string;
15
+ handleTypeChange: (val: unknown) => void;
16
+ validate: () => Promise<import("vee-validate").FormValidationResult<GpuQuotaItem>> | {
17
+ valid: boolean;
18
+ };
19
+ deSanitizeGPUObjectKey: <T extends Record<string, unknown>>(obj?: T | undefined) => T;
20
+ gpuResourceHelperSlot: () => string[] | undefined;
21
+ openNvidiaVgpuModel: import("vue").Ref<boolean>;
22
+ openNvidiaAssignGpu: import("vue").Ref<boolean>;
23
+ openNvidiaVgpuSchedulePolicy: import("vue").Ref<boolean>;
24
+ gpuAdvancedFormProps: import("vue").ComputedRef<{
25
+ enableRemoteCall: boolean;
26
+ enableNvidiaVgpuModel: boolean;
27
+ enableNvidiaVgpuDevices: boolean;
28
+ assignGpuDisabled: boolean;
29
+ enableNvidiaVgpuPriority: boolean;
30
+ enableNvidiaVgpuSchedulePolicy: boolean;
31
+ nvidiaGpuModels: string[] | undefined;
32
+ nvidiaVgpuModelsAdaptor: {
33
+ data: import("../types").GPUSummary[];
34
+ loading: boolean;
35
+ refresh: () => import("../types").GPUSummary[] | Promise<import("../types").GPUSummary[]>;
36
+ } | undefined;
37
+ nvidiaVgpuDevicesAdaptor: import("../props").GpuDevicesAdaptor | undefined;
38
+ isSide: boolean;
39
+ }>;
40
+ showDynamicForm: import("vue").ComputedRef<boolean | undefined>;
41
+ };
42
+ export {};
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const vue = require("vue");
4
+ const veeValidate = require("vee-validate");
5
+ const props = require("../props.js");
6
+ const types = require("../types.js");
7
+ const utils = require("../utils.js");
8
+ const gpuFormItem_mapper = require("./gpuFormItem.mapper.js");
9
+ function useGpuFormItemState(props$1, emits, slots, i18nInstance) {
10
+ const {
11
+ values: quota,
12
+ setValues,
13
+ validate
14
+ } = veeValidate.useForm({
15
+ initialValues: {}
16
+ });
17
+ const dynamicQuota = vue.ref({});
18
+ const currentDisplayResource = vue.computed(() => {
19
+ var _a;
20
+ return (_a = props$1.getDisplayResource) == null ? void 0 : _a.call(props$1, quota.type ?? "");
21
+ });
22
+ const currentGpuProvider = vue.computed(() => {
23
+ var _a, _b;
24
+ return ((_b = (_a = props$1.gpuOptionsMap) == null ? void 0 : _a.get(quota.type ?? "")) == null ? void 0 : _b.provider) ?? "";
25
+ });
26
+ const openNvidiaAssignGpu = vue.ref(false);
27
+ const openNvidiaVgpuModel = vue.ref(false);
28
+ const openNvidiaVgpuSchedulePolicy = vue.ref(false);
29
+ const showDynamicForm = vue.computed(() => {
30
+ var _a, _b;
31
+ return (_b = (_a = props$1.gpuOptionsMap) == null ? void 0 : _a.get(quota.type ?? "")) == null ? void 0 : _b.isDynamic;
32
+ });
33
+ const gpuAdvancedFeatures = vue.computed(() => ({
34
+ enableNvidiaVgpuModel: props$1.enableNvidiaVgpuModel,
35
+ enableNvidiaVgpuDevices: props$1.enableNvidiaVgpuDevices,
36
+ enableNvidiaVgpuPriority: props$1.enableNvidiaVgpuPriority,
37
+ enableNvidiaVgpuSchedulePolicy: props$1.enableNvidiaVgpuSchedulePolicy
38
+ }));
39
+ const initValues = () => {
40
+ var _a;
41
+ const initialState = gpuFormItem_mapper.buildGpuFormItemInitialState({
42
+ quotaItem: props$1.quotaItem,
43
+ gpuOptionsMap: props$1.gpuOptionsMap ?? /* @__PURE__ */ new Map(),
44
+ advanced: gpuAdvancedFeatures.value
45
+ });
46
+ if (!initialState) {
47
+ return;
48
+ }
49
+ if (initialState.dynamicQuota) {
50
+ dynamicQuota.value = initialState.dynamicQuota;
51
+ }
52
+ openNvidiaAssignGpu.value = initialState.openNvidiaAssignGpu;
53
+ openNvidiaVgpuSchedulePolicy.value = initialState.openNvidiaVgpuSchedulePolicy;
54
+ if (!props$1.isSide) {
55
+ initialState.values.resources = {
56
+ ...gpuFormItem_mapper.buildGpuFormItemDefaultResources(
57
+ (_a = props$1.gpuOptionsMap) == null ? void 0 : _a.get(initialState.values.type ?? ""),
58
+ props$1.gpuUsage
59
+ ),
60
+ ...initialState.values.resources
61
+ };
62
+ }
63
+ setValues(initialState.values);
64
+ };
65
+ if (utils.isNvidiaVgpu(props$1.quotaItem.type ?? "")) {
66
+ initValues();
67
+ } else {
68
+ const unwatchInit = vue.watch(() => props$1.gpuOptionsMap, (newGpuOptions) => {
69
+ if (newGpuOptions == null ? void 0 : newGpuOptions.size) {
70
+ initValues();
71
+ setTimeout(() => {
72
+ unwatchInit == null ? void 0 : unwatchInit();
73
+ });
74
+ }
75
+ }, {
76
+ immediate: true
77
+ });
78
+ }
79
+ if (props$1.isSide) {
80
+ vue.watch(() => props$1.quotaItem, () => {
81
+ initValues();
82
+ }, {
83
+ deep: true
84
+ });
85
+ } else {
86
+ vue.watch([() => quota, dynamicQuota], () => {
87
+ emits("change", gpuFormItem_mapper.buildGpuFormItemChangePayload({
88
+ quota,
89
+ dynamicQuota: dynamicQuota.value,
90
+ quotaItem: props$1.quotaItem,
91
+ showDynamicForm: showDynamicForm.value,
92
+ advanced: gpuAdvancedFeatures.value,
93
+ openNvidiaAssignGpu: openNvidiaAssignGpu.value,
94
+ openNvidiaVgpuSchedulePolicy: openNvidiaVgpuSchedulePolicy.value
95
+ }));
96
+ }, {
97
+ deep: true
98
+ });
99
+ }
100
+ const filteredGpuOptionsMap = vue.computed(() => gpuFormItem_mapper.filterGpuFormItemOptions({
101
+ gpuOptionsMap: props$1.gpuOptionsMap ?? /* @__PURE__ */ new Map(),
102
+ quotaType: quota.type,
103
+ existTypes: props$1.existTypes,
104
+ targetType: props$1.targetType
105
+ }));
106
+ const priorityOpts = props.getPriorityOpts(i18nInstance);
107
+ const gpuAdvancedFormProps = vue.computed(() => ({
108
+ enableRemoteCall: props$1.enableRemoteCall,
109
+ enableNvidiaVgpuModel: props$1.enableNvidiaVgpuModel,
110
+ enableNvidiaVgpuDevices: props$1.enableNvidiaVgpuDevices,
111
+ assignGpuDisabled: props$1.assignGpuDisabled,
112
+ enableNvidiaVgpuPriority: props$1.enableNvidiaVgpuPriority,
113
+ enableNvidiaVgpuSchedulePolicy: props$1.enableNvidiaVgpuSchedulePolicy,
114
+ nvidiaGpuModels: props$1.nvidiaGpuModels,
115
+ nvidiaVgpuModelsAdaptor: props$1.nvidiaVgpuModelsAdaptor,
116
+ nvidiaVgpuDevicesAdaptor: props$1.nvidiaVgpuDevicesAdaptor,
117
+ isSide: props$1.isSide
118
+ }));
119
+ const isShowHamiGpuHelper = vue.computed(() => utils.isHamiGpu(currentGpuProvider.value) && props$1.gpuUsage === "workload" && !props$1.isSide);
120
+ const handleTypeChange = (val) => {
121
+ var _a;
122
+ quota.resources = gpuFormItem_mapper.buildGpuFormItemDefaultResources(
123
+ (_a = props$1.gpuOptionsMap) == null ? void 0 : _a.get(val),
124
+ props$1.gpuUsage
125
+ );
126
+ const isNextNvidiaVgpu = utils.isNvidiaVgpu(val);
127
+ if (gpuAdvancedFeatures.value.enableNvidiaVgpuPriority && isNextNvidiaVgpu) {
128
+ quota[types.nvidiaVgpuPriorityKey] = priorityOpts[0].value;
129
+ }
130
+ if (!isNextNvidiaVgpu && gpuAdvancedFeatures.value.enableNvidiaVgpuSchedulePolicy) {
131
+ openNvidiaVgpuSchedulePolicy.value = false;
132
+ }
133
+ };
134
+ const validateWrapper = () => {
135
+ if (props$1.isSide) {
136
+ return {
137
+ valid: true
138
+ };
139
+ }
140
+ return validate();
141
+ };
142
+ const gpuResourceHelperSlot = () => {
143
+ var _a;
144
+ return (_a = currentDisplayResource.value) == null ? void 0 : _a.reduce((acc, res) => {
145
+ const helperKey = `helper-${res.key}`;
146
+ if (slots[helperKey]) {
147
+ acc.push(helperKey);
148
+ }
149
+ return acc;
150
+ }, []);
151
+ };
152
+ const getGPUTypeInSide = (quotaType) => {
153
+ var _a;
154
+ if (!quotaType) {
155
+ return "";
156
+ }
157
+ return ((_a = filteredGpuOptionsMap.value.get(quotaType)) == null ? void 0 : _a.alias) ?? quotaType;
158
+ };
159
+ return {
160
+ quota,
161
+ dynamicQuota,
162
+ currentDisplayResource,
163
+ currentGpuProvider,
164
+ isShowHamiGpuHelper,
165
+ filteredGpuOptionsMap,
166
+ getGPUTypeInSide,
167
+ handleTypeChange,
168
+ validate: validateWrapper,
169
+ deSanitizeGPUObjectKey: utils.deSanitizeGPUObjectKey,
170
+ gpuResourceHelperSlot,
171
+ openNvidiaVgpuModel,
172
+ openNvidiaAssignGpu,
173
+ openNvidiaVgpuSchedulePolicy,
174
+ gpuAdvancedFormProps,
175
+ showDynamicForm
176
+ };
177
+ }
178
+ exports.useGpuFormItemState = useGpuFormItemState;