@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.
- package/dist/cjs/components/gpu/style/assign-gpu-devices-list.js +1 -0
- package/dist/cjs/components/gpu/style/gpu-form.js +1 -0
- package/dist/components/form-block/FormBlock.d.ts +27 -1
- package/dist/components/form-block/props.d.ts +4 -0
- package/dist/components/form-block/props.js +4 -0
- package/dist/components/form-block/props.mjs +4 -0
- package/dist/components/form-block/src/FormBlock.vue.d.ts +11 -0
- package/dist/components/form-block/src/FormBlock.vue.js +4 -4
- package/dist/components/form-block/src/FormBlock.vue.mjs +4 -4
- package/dist/components/form-block/src/FormBlock.vue2.js +12 -1
- package/dist/components/form-block/src/FormBlock.vue2.mjs +12 -1
- package/dist/components/gpu/props.d.ts +121 -3
- package/dist/components/gpu/props.js +82 -9
- package/dist/components/gpu/props.mjs +82 -9
- package/dist/components/gpu/src/GpuForm.vue.d.ts +283 -50
- package/dist/components/gpu/src/GpuForm.vue.js +25 -24
- package/dist/components/gpu/src/GpuForm.vue.mjs +26 -25
- package/dist/components/gpu/src/GpuForm.vue2.js +115 -218
- package/dist/components/gpu/src/GpuForm.vue2.mjs +116 -219
- package/dist/components/gpu/src/components/AssignGpuDevicesList.vue.d.ts +77 -0
- package/dist/components/gpu/src/components/AssignGpuDevicesList.vue.js +40 -0
- package/dist/components/gpu/src/components/AssignGpuDevicesList.vue.mjs +41 -0
- package/dist/components/gpu/src/components/AssignGpuDevicesList.vue2.js +191 -0
- package/dist/components/gpu/src/components/AssignGpuDevicesList.vue2.mjs +192 -0
- package/dist/components/gpu/src/components/GpuAdvancedForm.vue.d.ts +180 -0
- package/dist/components/gpu/src/{GpuAdvancedForm.vue.js → components/GpuAdvancedForm.vue.js} +92 -37
- package/dist/components/gpu/src/{GpuAdvancedForm.vue.mjs → components/GpuAdvancedForm.vue.mjs} +93 -38
- package/dist/components/gpu/src/components/GpuAdvancedForm.vue2.js +169 -0
- package/dist/components/gpu/src/components/GpuAdvancedForm.vue2.mjs +153 -0
- package/dist/components/gpu/src/{GpuFormDynamicItem.vue.d.ts → components/GpuFormDynamicItem.vue.d.ts} +4 -4
- package/dist/components/gpu/src/{GpuFormDynamicItem.vue.js → components/GpuFormDynamicItem.vue.js} +1 -1
- package/dist/components/gpu/src/{GpuFormDynamicItem.vue.mjs → components/GpuFormDynamicItem.vue.mjs} +1 -1
- package/dist/components/gpu/src/{GpuFormDynamicItem.vue2.js → components/GpuFormDynamicItem.vue2.js} +1 -1
- package/dist/components/gpu/src/{GpuFormDynamicItem.vue2.mjs → components/GpuFormDynamicItem.vue2.mjs} +1 -1
- package/dist/components/gpu/src/components/GpuFormItem.vue.d.ts +310 -0
- package/dist/components/gpu/src/{GpuFormItem.vue.js → components/GpuFormItem.vue.js} +22 -26
- package/dist/components/gpu/src/{GpuFormItem.vue.mjs → components/GpuFormItem.vue.mjs} +23 -27
- package/dist/components/gpu/src/components/GpuFormItem.vue2.js +61 -0
- package/dist/components/gpu/src/components/GpuFormItem.vue2.mjs +45 -0
- package/dist/components/gpu/src/{GpuResources.vue.d.ts → components/GpuResources.vue.d.ts} +38 -18
- package/dist/components/gpu/src/components/GpuResources.vue.js +153 -0
- package/dist/components/gpu/src/components/GpuResources.vue.mjs +154 -0
- package/dist/components/gpu/src/components/GpuResources.vue2.js +278 -0
- package/dist/components/gpu/src/components/GpuResources.vue2.mjs +262 -0
- package/dist/components/gpu/src/gpuForm.constants.d.ts +3 -0
- package/dist/components/gpu/src/gpuForm.constants.js +10 -0
- package/dist/components/gpu/src/gpuForm.constants.mjs +10 -0
- package/dist/components/gpu/src/gpuForm.internal-types.d.ts +49 -0
- package/dist/components/gpu/src/gpuForm.mapper.d.ts +16 -0
- package/dist/components/gpu/src/gpuForm.mapper.js +199 -0
- package/dist/components/gpu/src/gpuForm.mapper.mjs +199 -0
- package/dist/components/gpu/src/gpuFormItem.mapper.d.ts +38 -0
- package/dist/components/gpu/src/gpuFormItem.mapper.js +153 -0
- package/dist/components/gpu/src/gpuFormItem.mapper.mjs +153 -0
- package/dist/components/gpu/src/useGPUOptions.d.ts +2 -2
- package/dist/components/gpu/src/useGPUOptions.js +15 -20
- package/dist/components/gpu/src/useGPUOptions.mjs +16 -21
- package/dist/components/gpu/src/useGpuFormItemState.d.ts +42 -0
- package/dist/components/gpu/src/useGpuFormItemState.js +178 -0
- package/dist/components/gpu/src/useGpuFormItemState.mjs +178 -0
- package/dist/components/gpu/src/useGpuFormSideState.d.ts +52 -0
- package/dist/components/gpu/src/useGpuFormSideState.js +71 -0
- package/dist/components/gpu/src/useGpuFormSideState.mjs +71 -0
- package/dist/components/gpu/src/useGpuFormState.d.ts +560 -0
- package/dist/components/gpu/src/useGpuFormState.js +52 -0
- package/dist/components/gpu/src/useGpuFormState.mjs +52 -0
- package/dist/components/gpu/src/validations/nvidiaVgpuMemoryDecimal.d.ts +5 -1
- package/dist/components/gpu/style/assign-gpu-devices-list.d.ts +1 -0
- package/dist/components/gpu/style/assign-gpu-devices-list.scss.js +3 -0
- package/dist/components/gpu/style/assign-gpu-devices-list.scss.mjs +4 -0
- package/dist/components/gpu/style/gpu-form.d.ts +1 -0
- package/dist/components/gpu/types.d.ts +6 -0
- package/dist/components/gpu/types.js +2 -0
- package/dist/components/gpu/types.mjs +2 -0
- package/dist/components/gpu/utils.d.ts +4 -0
- package/dist/components/gpu/utils.js +14 -0
- package/dist/components/gpu/utils.mjs +14 -0
- package/dist/components/instance-cluster/src/InstanceCluster.vue.d.ts +1 -1
- package/dist/components/instance-namespace/src/InstanceNamespace.vue.d.ts +1 -1
- package/dist/components/instance-storage-class/src/InstanceStorageClass.vue.d.ts +1 -1
- package/dist/components/network-config/src/NetworkConfig.vue.d.ts +1 -1
- package/dist/components/network-config/src/NetworkConfig.vue.js +13 -6
- package/dist/components/network-config/src/NetworkConfig.vue.mjs +14 -7
- package/dist/dialogs/create-network-config-dialog/src/CreateNetworkConfigDialog.vue.d.ts +1 -1
- package/dist/es/components/gpu/style/assign-gpu-devices-list.mjs +1 -0
- package/dist/es/components/gpu/style/gpu-form.mjs +1 -0
- package/dist/forms/import-parameter-template/props.d.ts +8 -8
- package/dist/forms/import-parameter-template/src/ImportParameterTemplate.vue.d.ts +24 -24
- package/dist/group-mapping.json +1 -1
- package/dist/index.js +34 -23
- package/dist/index.mjs +15 -4
- package/dist/locales/en-US/components/Gpu.json.js +36 -9
- package/dist/locales/en-US/components/Gpu.json.mjs +37 -10
- package/dist/locales/en-US/index.js +2 -0
- package/dist/locales/en-US/index.mjs +2 -0
- package/dist/locales/en-US/uses/UseCancelFormDialog.json.js +11 -0
- package/dist/locales/en-US/uses/UseCancelFormDialog.json.mjs +11 -0
- package/dist/locales/ja/components/Gpu.json.js +36 -9
- package/dist/locales/ja/components/Gpu.json.mjs +37 -10
- package/dist/locales/ja/components/InstancePassword.json.js +1 -1
- package/dist/locales/ja/components/InstancePassword.json.mjs +1 -1
- package/dist/locales/ja/components/MatchExpressionsEditor.json.js +1 -1
- package/dist/locales/ja/components/MatchExpressionsEditor.json.mjs +1 -1
- package/dist/locales/ja/components/NetworkConfig.json.js +1 -1
- package/dist/locales/ja/components/NetworkConfig.json.mjs +1 -1
- package/dist/locales/ja/index.js +2 -0
- package/dist/locales/ja/index.mjs +2 -0
- package/dist/locales/ja/uses/UseCancelFormDialog.json.js +11 -0
- package/dist/locales/ja/uses/UseCancelFormDialog.json.mjs +11 -0
- package/dist/locales/ja/workloads/DnsConfig.json.js +1 -1
- package/dist/locales/ja/workloads/DnsConfig.json.mjs +1 -1
- package/dist/locales/ja/workloads/workload-advanced/NetworkConfig.json.js +1 -1
- package/dist/locales/ja/workloads/workload-advanced/NetworkConfig.json.mjs +1 -1
- package/dist/locales/zh-CN/components/Gpu.json.js +36 -9
- package/dist/locales/zh-CN/components/Gpu.json.mjs +37 -10
- package/dist/locales/zh-CN/index.js +2 -0
- package/dist/locales/zh-CN/index.mjs +2 -0
- package/dist/locales/zh-CN/uses/UseCancelFormDialog.json.js +11 -0
- package/dist/locales/zh-CN/uses/UseCancelFormDialog.json.mjs +11 -0
- package/dist/style.css +692 -664
- package/dist/styles/components/gpu/assign-gpu-devices-list.css +10 -0
- package/dist/styles/components/gpu/gpu-form-item.css +16 -0
- package/dist/styles/components/gpu/gpu-form.css +4 -0
- package/dist/styles/components/network-config/network-config.css +3 -0
- package/dist/styles/components/resource-config/resource-config.css +0 -8
- package/dist/styles/styles/common.css +4 -0
- package/dist/uses/index.d.ts +1 -0
- package/dist/uses/useCancelFormDialog/index.d.ts +11 -0
- package/dist/uses/useCancelFormDialog/index.js +40 -0
- package/dist/uses/useCancelFormDialog/index.mjs +40 -0
- package/dist/uses/useCancelFormDialog/src/CancelFormDialog.vue.d.ts +8 -0
- package/dist/uses/useCancelFormDialog/src/CancelFormDialog.vue.js +25 -0
- package/dist/uses/useCancelFormDialog/src/CancelFormDialog.vue.mjs +26 -0
- package/dist/uses/useCancelFormDialog/src/CancelFormDialog.vue2.js +3 -0
- package/dist/uses/useCancelFormDialog/src/CancelFormDialog.vue2.mjs +4 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/injectWithSelf.d.ts +6 -0
- package/dist/utils/injectWithSelf.js +8 -0
- package/dist/utils/injectWithSelf.mjs +8 -0
- package/dist/utils/multiRowEditorValidate.d.ts +5 -5
- package/dist/utils/useResetFieldValue.d.ts +13 -0
- package/dist/utils/useResetFieldValue.js +28 -0
- package/dist/utils/useResetFieldValue.mjs +28 -0
- package/dist/utils/useSetFieldValue.d.ts +6 -0
- package/dist/utils/useSetFieldValue.js +2 -5
- package/dist/utils/useSetFieldValue.mjs +2 -5
- package/dist/workloads/container-basic-info/props.d.ts +13 -0
- package/dist/workloads/container-basic-info/props.js +4 -0
- package/dist/workloads/container-basic-info/props.mjs +4 -0
- package/dist/workloads/container-basic-info/src/ContainerBasicInfo.vue.d.ts +10 -0
- package/dist/workloads/container-basic-info/src/ContainerBasicInfo.vue.js +54 -29
- package/dist/workloads/container-basic-info/src/ContainerBasicInfo.vue.mjs +54 -29
- package/dist/workloads/container-basic-info/src/ContainerBasicInfo.vue2.js +18 -8
- package/dist/workloads/container-basic-info/src/ContainerBasicInfo.vue2.mjs +19 -9
- package/dist/workloads/container-image/src/dialogs/SelectImageDialog.vue.d.ts +1 -1
- package/dist/workloads/containers/demo/data.d.ts +8 -1
- package/dist/workloads/containers/src/ContainerItem.vue.d.ts +23 -0
- package/dist/workloads/containers/src/Containers.vue.d.ts +4 -0
- package/dist/workloads/containers/src/Containers.vue2.js +18 -1
- package/dist/workloads/containers/src/Containers.vue2.mjs +19 -2
- package/dist/workloads/health-check/props.d.ts +4 -0
- package/dist/workloads/health-check/props.js +4 -0
- package/dist/workloads/health-check/props.mjs +4 -0
- package/dist/workloads/health-check/src/HealthCheck.vue.d.ts +9 -0
- package/dist/workloads/health-check/src/HealthCheck.vue.js +6 -6
- package/dist/workloads/health-check/src/HealthCheck.vue.mjs +6 -6
- package/dist/workloads/health-check/src/HealthCheckHandler.vue.js +3 -1
- package/dist/workloads/health-check/src/HealthCheckHandler.vue.mjs +3 -1
- package/dist/workloads/http-get-action/src/HttpGetAction.vue.js +1 -1
- package/dist/workloads/http-get-action/src/HttpGetAction.vue.mjs +1 -1
- package/dist/workloads/workload-annotations/props.d.ts +1 -0
- package/dist/workloads/workload-annotations/props.js +1 -0
- package/dist/workloads/workload-annotations/props.mjs +2 -1
- package/package.json +12 -13
- package/dist/components/gpu/src/GpuAdvancedForm.vue.d.ts +0 -131
- package/dist/components/gpu/src/GpuAdvancedForm.vue2.js +0 -92
- package/dist/components/gpu/src/GpuAdvancedForm.vue2.mjs +0 -76
- package/dist/components/gpu/src/GpuFormItem.vue.d.ts +0 -232
- package/dist/components/gpu/src/GpuFormItem.vue2.js +0 -235
- package/dist/components/gpu/src/GpuFormItem.vue2.mjs +0 -219
- package/dist/components/gpu/src/GpuResources.vue.js +0 -125
- package/dist/components/gpu/src/GpuResources.vue.mjs +0 -126
- package/dist/components/gpu/src/GpuResources.vue2.js +0 -197
- package/dist/components/gpu/src/GpuResources.vue2.mjs +0 -181
- package/dist/components/gpu/src/validations/nvidiaVgpuMemoryDecimal.js +0 -19
- package/dist/components/gpu/src/validations/nvidiaVgpuMemoryDecimal.mjs +0 -20
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const vue = require("vue");
|
|
3
|
+
const extend = require("@dao-style/extend");
|
|
4
|
+
const vueI18n = require("vue-i18n");
|
|
5
|
+
const yup = require("yup");
|
|
6
|
+
const veeValidate = require("vee-validate");
|
|
7
|
+
const props = require("../../props.js");
|
|
8
|
+
const utils = require("../../utils.js");
|
|
9
|
+
const useSetFieldValue = require("../../../../utils/useSetFieldValue.js");
|
|
10
|
+
function _interopNamespaceDefault(e) {
|
|
11
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
12
|
+
if (e) {
|
|
13
|
+
for (const k in e) {
|
|
14
|
+
if (k !== "default") {
|
|
15
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
16
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: () => e[k]
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
n.default = e;
|
|
24
|
+
return Object.freeze(n);
|
|
25
|
+
}
|
|
26
|
+
const yup__namespace = /* @__PURE__ */ _interopNamespaceDefault(yup);
|
|
27
|
+
const hamiQuotaOverrideTypes = ["cores", "memory"];
|
|
28
|
+
const mibPerGib = 1024;
|
|
29
|
+
const vgpuMemoryUnits = ["Gi", "Mi"];
|
|
30
|
+
const _sfc_main = vue.defineComponent({
|
|
31
|
+
name: "DaoGpuResources",
|
|
32
|
+
components: {
|
|
33
|
+
DaoFormItemValidate: extend.DaoFormItemValidate
|
|
34
|
+
},
|
|
35
|
+
props: props.gpuResourceItemProps,
|
|
36
|
+
setup(props$1) {
|
|
37
|
+
const isIluvatar = vue.computed(() => {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
return (_b = (_a = props$1.quotaItem.type) == null ? void 0 : _a.toLocaleLowerCase) == null ? void 0 : _b.call(_a).includes("iluvatar");
|
|
40
|
+
});
|
|
41
|
+
const getIsIluvatarMemory = (alias) => isIluvatar.value && (alias == null ? void 0 : alias.includes("Memory"));
|
|
42
|
+
const isHami = vue.computed(() => utils.isHamiGpu(props$1.gpuProvider));
|
|
43
|
+
const isHamiQuota = vue.computed(() => isHami.value && props$1.gpuUsage === "quota");
|
|
44
|
+
const isVgpuMemoryResource = (resource) => {
|
|
45
|
+
var _a;
|
|
46
|
+
return isHami.value && resource.type === "memory" || props$1.quotaItem.type === props.nvidiaVgpuKey && ((_a = resource.alias) == null ? void 0 : _a.includes("Memory"));
|
|
47
|
+
};
|
|
48
|
+
const i18nInstance = vueI18n.useI18n();
|
|
49
|
+
const { t, locale } = i18nInstance;
|
|
50
|
+
const resourcePlaceholder = vue.computed(() => !props$1.enableRangeValidate ? t("biz.components.Gpu.unlimited") : "");
|
|
51
|
+
const getResHelper = (available, key, alias) => {
|
|
52
|
+
const resHelperList = [];
|
|
53
|
+
if ((available == null ? void 0 : available.available) && Number(available.available) > -1) {
|
|
54
|
+
resHelperList.push(t("biz.components.Gpu.available", {
|
|
55
|
+
available: available == null ? void 0 : available.available
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
if (isIluvatar.value && (alias == null ? void 0 : alias.includes("Computing")) && alias.includes("Power")) {
|
|
59
|
+
resHelperList.push(t("biz.components.Gpu.iluvatar.computeTip"));
|
|
60
|
+
} else if (isIluvatar.value && (alias == null ? void 0 : alias.includes("Memory"))) {
|
|
61
|
+
resHelperList.push(t("biz.components.Gpu.iluvatar.memoryTip"));
|
|
62
|
+
}
|
|
63
|
+
return resHelperList.join(";");
|
|
64
|
+
};
|
|
65
|
+
const hamiQuotaDisplayKeys = {
|
|
66
|
+
cores: {
|
|
67
|
+
label: "biz.components.Gpu.hamiCoreQuota",
|
|
68
|
+
message: "biz.components.Gpu.hamiCoreQuotaTip"
|
|
69
|
+
},
|
|
70
|
+
memory: {
|
|
71
|
+
label: "biz.components.Gpu.hamiMemoryQuota",
|
|
72
|
+
message: "biz.components.Gpu.hamiMemoryQuotaTip"
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const isHamiQuotaOverrideType = (type) => hamiQuotaOverrideTypes.includes(
|
|
76
|
+
type
|
|
77
|
+
);
|
|
78
|
+
const isHamiQuotaOverrideResource = (resource) => isHamiQuota.value && isHamiQuotaOverrideType(resource.type);
|
|
79
|
+
const getResIconMessage = (resource) => {
|
|
80
|
+
var _a;
|
|
81
|
+
if (isHamiQuotaOverrideResource(resource)) {
|
|
82
|
+
const messageKey = (_a = hamiQuotaDisplayKeys[resource.type]) == null ? void 0 : _a.message;
|
|
83
|
+
return messageKey ? t(messageKey) : resource.descriptionZh ?? resource.description ?? "";
|
|
84
|
+
}
|
|
85
|
+
return locale.value.includes("zh") && resource.descriptionZh || resource.description || "";
|
|
86
|
+
};
|
|
87
|
+
const getResLabel = (resource) => {
|
|
88
|
+
var _a;
|
|
89
|
+
if (isHamiQuotaOverrideResource(resource)) {
|
|
90
|
+
const labelKey = (_a = hamiQuotaDisplayKeys[resource.type]) == null ? void 0 : _a.label;
|
|
91
|
+
return labelKey ? t(labelKey) : resource.aliasZh ?? resource.alias ?? "";
|
|
92
|
+
}
|
|
93
|
+
return locale.value.includes("zh") && resource.aliasZh || resource.alias || "";
|
|
94
|
+
};
|
|
95
|
+
const getResRequired = (resource) => {
|
|
96
|
+
var _a, _b;
|
|
97
|
+
if (props$1.availableQuotaItem) {
|
|
98
|
+
const available = (_a = props$1.availableQuotaItem.resources) == null ? void 0 : _a[utils.sanitizeGPUKey((resource == null ? void 0 : resource.key) ?? "") ?? ""];
|
|
99
|
+
if (available !== void 0) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (!props$1.enableRangeValidate) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
return (((_b = resource.range) == null ? void 0 : _b.min) ?? 0) > 0;
|
|
107
|
+
};
|
|
108
|
+
const getResourceYup = (resource) => {
|
|
109
|
+
var _a, _b;
|
|
110
|
+
if (!props$1.enableRangeValidate) {
|
|
111
|
+
const { key } = resource;
|
|
112
|
+
const parsedKey = utils.sanitizeGPUKey(key);
|
|
113
|
+
if (props$1.availableQuotaItem) {
|
|
114
|
+
const available = (_a = props$1.availableQuotaItem.resources) == null ? void 0 : _a[parsedKey ?? ""];
|
|
115
|
+
if (available) {
|
|
116
|
+
return yup__namespace.number().integer().max(Number(available)).min(1);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (props$1.usedQuotaItem) {
|
|
120
|
+
const used = (_b = props$1.usedQuotaItem.resources) == null ? void 0 : _b[parsedKey ?? ""];
|
|
121
|
+
if (used) {
|
|
122
|
+
return yup__namespace.number().integer().min(Number(used));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return yup__namespace.number().integer().min(1);
|
|
126
|
+
}
|
|
127
|
+
const { range } = resource;
|
|
128
|
+
if (range == null ? void 0 : range.max) {
|
|
129
|
+
return yup__namespace.number().integer().min((range == null ? void 0 : range.min) ?? 1).max(range.max);
|
|
130
|
+
}
|
|
131
|
+
return yup__namespace.number().integer().min((range == null ? void 0 : range.min) ?? 1);
|
|
132
|
+
};
|
|
133
|
+
const nvidiaVgpuMemoryResource = vue.computed(() => {
|
|
134
|
+
var _a;
|
|
135
|
+
return (_a = props$1.resources) == null ? void 0 : _a.find((res) => isVgpuMemoryResource(res));
|
|
136
|
+
});
|
|
137
|
+
const nvidiaVgpuMemoryField = vue.computed(() => {
|
|
138
|
+
var _a;
|
|
139
|
+
const key = (_a = nvidiaVgpuMemoryResource.value) == null ? void 0 : _a.key;
|
|
140
|
+
if (key) {
|
|
141
|
+
return `resources.${utils.sanitizeGPUKey(key)}`;
|
|
142
|
+
}
|
|
143
|
+
return "";
|
|
144
|
+
});
|
|
145
|
+
const nvidiaVgpuMemoryValue = veeValidate.useFieldValue(
|
|
146
|
+
nvidiaVgpuMemoryField
|
|
147
|
+
);
|
|
148
|
+
const setNvidiaVgpuMemoryValue = useSetFieldValue.useSetFieldValue(
|
|
149
|
+
nvidiaVgpuMemoryField
|
|
150
|
+
);
|
|
151
|
+
const validateNvidiaVgpuMemoryField = veeValidate.useValidateField(nvidiaVgpuMemoryField);
|
|
152
|
+
const normalizeMemoryValue = (value) => {
|
|
153
|
+
if (value === void 0 || value === null || value === "") {
|
|
154
|
+
return void 0;
|
|
155
|
+
}
|
|
156
|
+
const numberValue = Number(value);
|
|
157
|
+
return Number.isFinite(numberValue) ? numberValue : void 0;
|
|
158
|
+
};
|
|
159
|
+
const getMemoryDisplayUnit = (value) => {
|
|
160
|
+
const memoryValue = normalizeMemoryValue(value);
|
|
161
|
+
return memoryValue === void 0 || memoryValue % mibPerGib === 0 ? "Gi" : "Mi";
|
|
162
|
+
};
|
|
163
|
+
const initialMemoryValue = normalizeMemoryValue(nvidiaVgpuMemoryValue.value);
|
|
164
|
+
if (nvidiaVgpuMemoryResource.value && initialMemoryValue !== void 0 && typeof nvidiaVgpuMemoryValue.value !== "number") {
|
|
165
|
+
setNvidiaVgpuMemoryValue(initialMemoryValue);
|
|
166
|
+
}
|
|
167
|
+
const nvidiaVgpuMemoryUnitValue = vue.ref(
|
|
168
|
+
getMemoryDisplayUnit(initialMemoryValue)
|
|
169
|
+
);
|
|
170
|
+
const nvidiaVgpuMemoryUnit = vue.computed({
|
|
171
|
+
get: () => nvidiaVgpuMemoryUnitValue.value,
|
|
172
|
+
set(unit) {
|
|
173
|
+
if (unit === nvidiaVgpuMemoryUnitValue.value) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
const memoryValue = normalizeMemoryValue(nvidiaVgpuMemoryValue.value);
|
|
177
|
+
if (unit === "Gi" && memoryValue !== void 0) {
|
|
178
|
+
const gibValue = Math.max(1, Math.round(memoryValue / mibPerGib));
|
|
179
|
+
setNvidiaVgpuMemoryValue(gibValue * mibPerGib);
|
|
180
|
+
}
|
|
181
|
+
nvidiaVgpuMemoryUnitValue.value = unit;
|
|
182
|
+
if (nvidiaVgpuMemoryField.value) {
|
|
183
|
+
validateNvidiaVgpuMemoryField();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
const getQuotaResourceValue = (resource) => {
|
|
188
|
+
var _a, _b;
|
|
189
|
+
return (_b = (_a = props$1.quota) == null ? void 0 : _a.resources) == null ? void 0 : _b[utils.sanitizeGPUKey(resource.key) ?? ""];
|
|
190
|
+
};
|
|
191
|
+
const getSideResUnit = (resource) => {
|
|
192
|
+
if (isVgpuMemoryResource(resource)) {
|
|
193
|
+
return getMemoryDisplayUnit(getQuotaResourceValue(resource));
|
|
194
|
+
}
|
|
195
|
+
return resource.unit;
|
|
196
|
+
};
|
|
197
|
+
const getNvidiaVgpuMemoryResourceYup = (resource) => {
|
|
198
|
+
var _a, _b, _c, _d, _e, _f;
|
|
199
|
+
const schema = yup__namespace.number().integer().test({
|
|
200
|
+
name: "nvidiaVgpuMemoryUnitInteger",
|
|
201
|
+
message: t("biz.components.Gpu.numberIntegerError"),
|
|
202
|
+
test(value) {
|
|
203
|
+
return value == null || nvidiaVgpuMemoryUnit.value === "Mi" || Number.isInteger(value / mibPerGib);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
const parsedKey = utils.sanitizeGPUKey(resource.key) ?? "";
|
|
207
|
+
const available = normalizeMemoryValue(
|
|
208
|
+
(_b = (_a = props$1.availableQuotaItem) == null ? void 0 : _a.resources) == null ? void 0 : _b[parsedKey]
|
|
209
|
+
);
|
|
210
|
+
const used = normalizeMemoryValue((_d = (_c = props$1.usedQuotaItem) == null ? void 0 : _c.resources) == null ? void 0 : _d[parsedKey]);
|
|
211
|
+
const minimums = [1];
|
|
212
|
+
const maximums = [];
|
|
213
|
+
if (available !== void 0) {
|
|
214
|
+
maximums.push(available);
|
|
215
|
+
}
|
|
216
|
+
if (used !== void 0) {
|
|
217
|
+
minimums.push(used);
|
|
218
|
+
}
|
|
219
|
+
if (props$1.enableRangeValidate) {
|
|
220
|
+
const rangeMin = normalizeMemoryValue((_e = resource.range) == null ? void 0 : _e.min);
|
|
221
|
+
const rangeMax = normalizeMemoryValue((_f = resource.range) == null ? void 0 : _f.max);
|
|
222
|
+
if (rangeMin !== void 0) {
|
|
223
|
+
minimums.push(rangeMin);
|
|
224
|
+
}
|
|
225
|
+
if (rangeMax !== void 0) {
|
|
226
|
+
maximums.push(rangeMax);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const schemaWithMinimum = schema.min(Math.max(...minimums));
|
|
230
|
+
return maximums.length > 0 ? schemaWithMinimum.max(Math.min(...maximums)) : schemaWithMinimum;
|
|
231
|
+
};
|
|
232
|
+
const nvidiaVgpuMemory = vue.computed({
|
|
233
|
+
get() {
|
|
234
|
+
const memoryValue = normalizeMemoryValue(nvidiaVgpuMemoryValue.value);
|
|
235
|
+
if (memoryValue === void 0) {
|
|
236
|
+
return void 0;
|
|
237
|
+
}
|
|
238
|
+
return nvidiaVgpuMemoryUnit.value === "Gi" ? memoryValue / mibPerGib : memoryValue;
|
|
239
|
+
},
|
|
240
|
+
set(v) {
|
|
241
|
+
if (v === void 0 || v === "") {
|
|
242
|
+
setNvidiaVgpuMemoryValue(void 0);
|
|
243
|
+
} else {
|
|
244
|
+
const memoryValue = Number(v) * (nvidiaVgpuMemoryUnit.value === "Gi" ? mibPerGib : 1);
|
|
245
|
+
setNvidiaVgpuMemoryValue(memoryValue);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
const getSideValue = (resource) => {
|
|
250
|
+
const val = getQuotaResourceValue(resource);
|
|
251
|
+
if (isVgpuMemoryResource(resource) && val != null) {
|
|
252
|
+
const memoryValue = Number(val);
|
|
253
|
+
return getMemoryDisplayUnit(memoryValue) === "Gi" ? memoryValue / mibPerGib : memoryValue;
|
|
254
|
+
}
|
|
255
|
+
return val ?? "";
|
|
256
|
+
};
|
|
257
|
+
return {
|
|
258
|
+
getIsIluvatarMemory,
|
|
259
|
+
isVgpuMemoryResource,
|
|
260
|
+
getResHelper,
|
|
261
|
+
getSideResUnit,
|
|
262
|
+
resourcePlaceholder,
|
|
263
|
+
getResRequired,
|
|
264
|
+
nvidiaVgpuMemory,
|
|
265
|
+
vgpuMemoryUnits,
|
|
266
|
+
nvidiaVgpuMemoryUnit,
|
|
267
|
+
sanitizeGPUKey: utils.sanitizeGPUKey,
|
|
268
|
+
getResLabel,
|
|
269
|
+
getResIconMessage,
|
|
270
|
+
isHamiQuota,
|
|
271
|
+
yup: yup__namespace,
|
|
272
|
+
getResourceYup,
|
|
273
|
+
getNvidiaVgpuMemoryResourceYup,
|
|
274
|
+
getSideValue
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
module.exports = _sfc_main;
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { defineComponent, computed, ref } from "vue";
|
|
2
|
+
import { DaoFormItemValidate } from "@dao-style/extend";
|
|
3
|
+
import { useI18n } from "vue-i18n";
|
|
4
|
+
import * as yup from "yup";
|
|
5
|
+
import { useFieldValue, useValidateField } from "vee-validate";
|
|
6
|
+
import { gpuResourceItemProps, nvidiaVgpuKey } from "../../props.mjs";
|
|
7
|
+
import { isHamiGpu, sanitizeGPUKey } from "../../utils.mjs";
|
|
8
|
+
import { useSetFieldValue } from "../../../../utils/useSetFieldValue.mjs";
|
|
9
|
+
const hamiQuotaOverrideTypes = ["cores", "memory"];
|
|
10
|
+
const mibPerGib = 1024;
|
|
11
|
+
const vgpuMemoryUnits = ["Gi", "Mi"];
|
|
12
|
+
const _sfc_main = defineComponent({
|
|
13
|
+
name: "DaoGpuResources",
|
|
14
|
+
components: {
|
|
15
|
+
DaoFormItemValidate
|
|
16
|
+
},
|
|
17
|
+
props: gpuResourceItemProps,
|
|
18
|
+
setup(props) {
|
|
19
|
+
const isIluvatar = computed(() => {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
return (_b = (_a = props.quotaItem.type) == null ? void 0 : _a.toLocaleLowerCase) == null ? void 0 : _b.call(_a).includes("iluvatar");
|
|
22
|
+
});
|
|
23
|
+
const getIsIluvatarMemory = (alias) => isIluvatar.value && (alias == null ? void 0 : alias.includes("Memory"));
|
|
24
|
+
const isHami = computed(() => isHamiGpu(props.gpuProvider));
|
|
25
|
+
const isHamiQuota = computed(() => isHami.value && props.gpuUsage === "quota");
|
|
26
|
+
const isVgpuMemoryResource = (resource) => {
|
|
27
|
+
var _a;
|
|
28
|
+
return isHami.value && resource.type === "memory" || props.quotaItem.type === nvidiaVgpuKey && ((_a = resource.alias) == null ? void 0 : _a.includes("Memory"));
|
|
29
|
+
};
|
|
30
|
+
const i18nInstance = useI18n();
|
|
31
|
+
const { t, locale } = i18nInstance;
|
|
32
|
+
const resourcePlaceholder = computed(() => !props.enableRangeValidate ? t("biz.components.Gpu.unlimited") : "");
|
|
33
|
+
const getResHelper = (available, key, alias) => {
|
|
34
|
+
const resHelperList = [];
|
|
35
|
+
if ((available == null ? void 0 : available.available) && Number(available.available) > -1) {
|
|
36
|
+
resHelperList.push(t("biz.components.Gpu.available", {
|
|
37
|
+
available: available == null ? void 0 : available.available
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
if (isIluvatar.value && (alias == null ? void 0 : alias.includes("Computing")) && alias.includes("Power")) {
|
|
41
|
+
resHelperList.push(t("biz.components.Gpu.iluvatar.computeTip"));
|
|
42
|
+
} else if (isIluvatar.value && (alias == null ? void 0 : alias.includes("Memory"))) {
|
|
43
|
+
resHelperList.push(t("biz.components.Gpu.iluvatar.memoryTip"));
|
|
44
|
+
}
|
|
45
|
+
return resHelperList.join(";");
|
|
46
|
+
};
|
|
47
|
+
const hamiQuotaDisplayKeys = {
|
|
48
|
+
cores: {
|
|
49
|
+
label: "biz.components.Gpu.hamiCoreQuota",
|
|
50
|
+
message: "biz.components.Gpu.hamiCoreQuotaTip"
|
|
51
|
+
},
|
|
52
|
+
memory: {
|
|
53
|
+
label: "biz.components.Gpu.hamiMemoryQuota",
|
|
54
|
+
message: "biz.components.Gpu.hamiMemoryQuotaTip"
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const isHamiQuotaOverrideType = (type) => hamiQuotaOverrideTypes.includes(
|
|
58
|
+
type
|
|
59
|
+
);
|
|
60
|
+
const isHamiQuotaOverrideResource = (resource) => isHamiQuota.value && isHamiQuotaOverrideType(resource.type);
|
|
61
|
+
const getResIconMessage = (resource) => {
|
|
62
|
+
var _a;
|
|
63
|
+
if (isHamiQuotaOverrideResource(resource)) {
|
|
64
|
+
const messageKey = (_a = hamiQuotaDisplayKeys[resource.type]) == null ? void 0 : _a.message;
|
|
65
|
+
return messageKey ? t(messageKey) : resource.descriptionZh ?? resource.description ?? "";
|
|
66
|
+
}
|
|
67
|
+
return locale.value.includes("zh") && resource.descriptionZh || resource.description || "";
|
|
68
|
+
};
|
|
69
|
+
const getResLabel = (resource) => {
|
|
70
|
+
var _a;
|
|
71
|
+
if (isHamiQuotaOverrideResource(resource)) {
|
|
72
|
+
const labelKey = (_a = hamiQuotaDisplayKeys[resource.type]) == null ? void 0 : _a.label;
|
|
73
|
+
return labelKey ? t(labelKey) : resource.aliasZh ?? resource.alias ?? "";
|
|
74
|
+
}
|
|
75
|
+
return locale.value.includes("zh") && resource.aliasZh || resource.alias || "";
|
|
76
|
+
};
|
|
77
|
+
const getResRequired = (resource) => {
|
|
78
|
+
var _a, _b;
|
|
79
|
+
if (props.availableQuotaItem) {
|
|
80
|
+
const available = (_a = props.availableQuotaItem.resources) == null ? void 0 : _a[sanitizeGPUKey((resource == null ? void 0 : resource.key) ?? "") ?? ""];
|
|
81
|
+
if (available !== void 0) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (!props.enableRangeValidate) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
return (((_b = resource.range) == null ? void 0 : _b.min) ?? 0) > 0;
|
|
89
|
+
};
|
|
90
|
+
const getResourceYup = (resource) => {
|
|
91
|
+
var _a, _b;
|
|
92
|
+
if (!props.enableRangeValidate) {
|
|
93
|
+
const { key } = resource;
|
|
94
|
+
const parsedKey = sanitizeGPUKey(key);
|
|
95
|
+
if (props.availableQuotaItem) {
|
|
96
|
+
const available = (_a = props.availableQuotaItem.resources) == null ? void 0 : _a[parsedKey ?? ""];
|
|
97
|
+
if (available) {
|
|
98
|
+
return yup.number().integer().max(Number(available)).min(1);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (props.usedQuotaItem) {
|
|
102
|
+
const used = (_b = props.usedQuotaItem.resources) == null ? void 0 : _b[parsedKey ?? ""];
|
|
103
|
+
if (used) {
|
|
104
|
+
return yup.number().integer().min(Number(used));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return yup.number().integer().min(1);
|
|
108
|
+
}
|
|
109
|
+
const { range } = resource;
|
|
110
|
+
if (range == null ? void 0 : range.max) {
|
|
111
|
+
return yup.number().integer().min((range == null ? void 0 : range.min) ?? 1).max(range.max);
|
|
112
|
+
}
|
|
113
|
+
return yup.number().integer().min((range == null ? void 0 : range.min) ?? 1);
|
|
114
|
+
};
|
|
115
|
+
const nvidiaVgpuMemoryResource = computed(() => {
|
|
116
|
+
var _a;
|
|
117
|
+
return (_a = props.resources) == null ? void 0 : _a.find((res) => isVgpuMemoryResource(res));
|
|
118
|
+
});
|
|
119
|
+
const nvidiaVgpuMemoryField = computed(() => {
|
|
120
|
+
var _a;
|
|
121
|
+
const key = (_a = nvidiaVgpuMemoryResource.value) == null ? void 0 : _a.key;
|
|
122
|
+
if (key) {
|
|
123
|
+
return `resources.${sanitizeGPUKey(key)}`;
|
|
124
|
+
}
|
|
125
|
+
return "";
|
|
126
|
+
});
|
|
127
|
+
const nvidiaVgpuMemoryValue = useFieldValue(
|
|
128
|
+
nvidiaVgpuMemoryField
|
|
129
|
+
);
|
|
130
|
+
const setNvidiaVgpuMemoryValue = useSetFieldValue(
|
|
131
|
+
nvidiaVgpuMemoryField
|
|
132
|
+
);
|
|
133
|
+
const validateNvidiaVgpuMemoryField = useValidateField(nvidiaVgpuMemoryField);
|
|
134
|
+
const normalizeMemoryValue = (value) => {
|
|
135
|
+
if (value === void 0 || value === null || value === "") {
|
|
136
|
+
return void 0;
|
|
137
|
+
}
|
|
138
|
+
const numberValue = Number(value);
|
|
139
|
+
return Number.isFinite(numberValue) ? numberValue : void 0;
|
|
140
|
+
};
|
|
141
|
+
const getMemoryDisplayUnit = (value) => {
|
|
142
|
+
const memoryValue = normalizeMemoryValue(value);
|
|
143
|
+
return memoryValue === void 0 || memoryValue % mibPerGib === 0 ? "Gi" : "Mi";
|
|
144
|
+
};
|
|
145
|
+
const initialMemoryValue = normalizeMemoryValue(nvidiaVgpuMemoryValue.value);
|
|
146
|
+
if (nvidiaVgpuMemoryResource.value && initialMemoryValue !== void 0 && typeof nvidiaVgpuMemoryValue.value !== "number") {
|
|
147
|
+
setNvidiaVgpuMemoryValue(initialMemoryValue);
|
|
148
|
+
}
|
|
149
|
+
const nvidiaVgpuMemoryUnitValue = ref(
|
|
150
|
+
getMemoryDisplayUnit(initialMemoryValue)
|
|
151
|
+
);
|
|
152
|
+
const nvidiaVgpuMemoryUnit = computed({
|
|
153
|
+
get: () => nvidiaVgpuMemoryUnitValue.value,
|
|
154
|
+
set(unit) {
|
|
155
|
+
if (unit === nvidiaVgpuMemoryUnitValue.value) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const memoryValue = normalizeMemoryValue(nvidiaVgpuMemoryValue.value);
|
|
159
|
+
if (unit === "Gi" && memoryValue !== void 0) {
|
|
160
|
+
const gibValue = Math.max(1, Math.round(memoryValue / mibPerGib));
|
|
161
|
+
setNvidiaVgpuMemoryValue(gibValue * mibPerGib);
|
|
162
|
+
}
|
|
163
|
+
nvidiaVgpuMemoryUnitValue.value = unit;
|
|
164
|
+
if (nvidiaVgpuMemoryField.value) {
|
|
165
|
+
validateNvidiaVgpuMemoryField();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
const getQuotaResourceValue = (resource) => {
|
|
170
|
+
var _a, _b;
|
|
171
|
+
return (_b = (_a = props.quota) == null ? void 0 : _a.resources) == null ? void 0 : _b[sanitizeGPUKey(resource.key) ?? ""];
|
|
172
|
+
};
|
|
173
|
+
const getSideResUnit = (resource) => {
|
|
174
|
+
if (isVgpuMemoryResource(resource)) {
|
|
175
|
+
return getMemoryDisplayUnit(getQuotaResourceValue(resource));
|
|
176
|
+
}
|
|
177
|
+
return resource.unit;
|
|
178
|
+
};
|
|
179
|
+
const getNvidiaVgpuMemoryResourceYup = (resource) => {
|
|
180
|
+
var _a, _b, _c, _d, _e, _f;
|
|
181
|
+
const schema = yup.number().integer().test({
|
|
182
|
+
name: "nvidiaVgpuMemoryUnitInteger",
|
|
183
|
+
message: t("biz.components.Gpu.numberIntegerError"),
|
|
184
|
+
test(value) {
|
|
185
|
+
return value == null || nvidiaVgpuMemoryUnit.value === "Mi" || Number.isInteger(value / mibPerGib);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
const parsedKey = sanitizeGPUKey(resource.key) ?? "";
|
|
189
|
+
const available = normalizeMemoryValue(
|
|
190
|
+
(_b = (_a = props.availableQuotaItem) == null ? void 0 : _a.resources) == null ? void 0 : _b[parsedKey]
|
|
191
|
+
);
|
|
192
|
+
const used = normalizeMemoryValue((_d = (_c = props.usedQuotaItem) == null ? void 0 : _c.resources) == null ? void 0 : _d[parsedKey]);
|
|
193
|
+
const minimums = [1];
|
|
194
|
+
const maximums = [];
|
|
195
|
+
if (available !== void 0) {
|
|
196
|
+
maximums.push(available);
|
|
197
|
+
}
|
|
198
|
+
if (used !== void 0) {
|
|
199
|
+
minimums.push(used);
|
|
200
|
+
}
|
|
201
|
+
if (props.enableRangeValidate) {
|
|
202
|
+
const rangeMin = normalizeMemoryValue((_e = resource.range) == null ? void 0 : _e.min);
|
|
203
|
+
const rangeMax = normalizeMemoryValue((_f = resource.range) == null ? void 0 : _f.max);
|
|
204
|
+
if (rangeMin !== void 0) {
|
|
205
|
+
minimums.push(rangeMin);
|
|
206
|
+
}
|
|
207
|
+
if (rangeMax !== void 0) {
|
|
208
|
+
maximums.push(rangeMax);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
const schemaWithMinimum = schema.min(Math.max(...minimums));
|
|
212
|
+
return maximums.length > 0 ? schemaWithMinimum.max(Math.min(...maximums)) : schemaWithMinimum;
|
|
213
|
+
};
|
|
214
|
+
const nvidiaVgpuMemory = computed({
|
|
215
|
+
get() {
|
|
216
|
+
const memoryValue = normalizeMemoryValue(nvidiaVgpuMemoryValue.value);
|
|
217
|
+
if (memoryValue === void 0) {
|
|
218
|
+
return void 0;
|
|
219
|
+
}
|
|
220
|
+
return nvidiaVgpuMemoryUnit.value === "Gi" ? memoryValue / mibPerGib : memoryValue;
|
|
221
|
+
},
|
|
222
|
+
set(v) {
|
|
223
|
+
if (v === void 0 || v === "") {
|
|
224
|
+
setNvidiaVgpuMemoryValue(void 0);
|
|
225
|
+
} else {
|
|
226
|
+
const memoryValue = Number(v) * (nvidiaVgpuMemoryUnit.value === "Gi" ? mibPerGib : 1);
|
|
227
|
+
setNvidiaVgpuMemoryValue(memoryValue);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
const getSideValue = (resource) => {
|
|
232
|
+
const val = getQuotaResourceValue(resource);
|
|
233
|
+
if (isVgpuMemoryResource(resource) && val != null) {
|
|
234
|
+
const memoryValue = Number(val);
|
|
235
|
+
return getMemoryDisplayUnit(memoryValue) === "Gi" ? memoryValue / mibPerGib : memoryValue;
|
|
236
|
+
}
|
|
237
|
+
return val ?? "";
|
|
238
|
+
};
|
|
239
|
+
return {
|
|
240
|
+
getIsIluvatarMemory,
|
|
241
|
+
isVgpuMemoryResource,
|
|
242
|
+
getResHelper,
|
|
243
|
+
getSideResUnit,
|
|
244
|
+
resourcePlaceholder,
|
|
245
|
+
getResRequired,
|
|
246
|
+
nvidiaVgpuMemory,
|
|
247
|
+
vgpuMemoryUnits,
|
|
248
|
+
nvidiaVgpuMemoryUnit,
|
|
249
|
+
sanitizeGPUKey,
|
|
250
|
+
getResLabel,
|
|
251
|
+
getResIconMessage,
|
|
252
|
+
isHamiQuota,
|
|
253
|
+
yup,
|
|
254
|
+
getResourceYup,
|
|
255
|
+
getNvidiaVgpuMemoryResourceYup,
|
|
256
|
+
getSideValue
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
export {
|
|
261
|
+
_sfc_main as default
|
|
262
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const randomStr = require("../../../utils/randomStr.js");
|
|
4
|
+
const gpuFormRowIdLength = 3;
|
|
5
|
+
const createEmptyRow = () => ({
|
|
6
|
+
id: randomStr.randomStr(gpuFormRowIdLength),
|
|
7
|
+
type: ""
|
|
8
|
+
});
|
|
9
|
+
exports.createEmptyRow = createEmptyRow;
|
|
10
|
+
exports.gpuFormRowIdLength = gpuFormRowIdLength;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { GPUResourceSetting, GPUSetting, GpuQuota, GpuQuotaItem, UpdateGpuQuota, VgpuSchedulePolicy } from '../types';
|
|
2
|
+
export type GpuFormRows = GpuQuotaItem[];
|
|
3
|
+
export type GpuFormVgpuExtraState = {
|
|
4
|
+
nvidiaVgpuModel?: string;
|
|
5
|
+
nvidiaVgpuDevices?: string[];
|
|
6
|
+
nvidiaVgpuPriority?: string;
|
|
7
|
+
nvidiaVgpuGpuSchedule?: VgpuSchedulePolicy;
|
|
8
|
+
nvidiaVgpuNodeSchedule?: VgpuSchedulePolicy;
|
|
9
|
+
};
|
|
10
|
+
export type GpuFormFormattedUpdate = {
|
|
11
|
+
change: UpdateGpuQuota;
|
|
12
|
+
vgpu: GpuFormVgpuExtraState;
|
|
13
|
+
};
|
|
14
|
+
export type GpuFormVgpuEmitProps = {
|
|
15
|
+
enableNvidiaVgpuModel?: boolean;
|
|
16
|
+
nvidiaVgpuModel?: string;
|
|
17
|
+
enableNvidiaVgpuDevices?: boolean;
|
|
18
|
+
nvidiaVgpuDevices?: string[];
|
|
19
|
+
enableNvidiaVgpuPriority?: boolean;
|
|
20
|
+
nvidiaVgpuPriority?: string;
|
|
21
|
+
enableNvidiaVgpuSchedulePolicy?: boolean;
|
|
22
|
+
nvidiaVgpuGpuSchedule?: VgpuSchedulePolicy;
|
|
23
|
+
nvidiaVgpuNodeSchedule?: VgpuSchedulePolicy;
|
|
24
|
+
};
|
|
25
|
+
export type GpuFormVgpuUpdateEmit = ['update:nvidiaVgpuModel', string | undefined] | ['update:nvidiaVgpuDevices', string[] | undefined] | ['update:nvidiaVgpuPriority', string | undefined] | ['update:nvidiaVgpuGpuSchedule', VgpuSchedulePolicy | undefined] | ['update:nvidiaVgpuNodeSchedule', VgpuSchedulePolicy | undefined];
|
|
26
|
+
export type CreateGpuFormRowId = () => string;
|
|
27
|
+
export type GpuFormOptionsMap = Map<string, GPUSetting>;
|
|
28
|
+
export type GetGpuDisplayResource = (type: string) => GPUResourceSetting[];
|
|
29
|
+
export type GpuFormInitialRowsParams = {
|
|
30
|
+
quota: GpuQuota;
|
|
31
|
+
availableQuota?: GpuQuota;
|
|
32
|
+
sideQuota?: GpuQuota;
|
|
33
|
+
gpuOptionsMap: GpuFormOptionsMap;
|
|
34
|
+
getDisplayResource: GetGpuDisplayResource;
|
|
35
|
+
withPrefixRequest?: boolean;
|
|
36
|
+
showSide?: boolean;
|
|
37
|
+
isLimitOne?: boolean;
|
|
38
|
+
vgpu?: GpuFormVgpuExtraState;
|
|
39
|
+
};
|
|
40
|
+
export type GpuFormInitialRowsResult = {
|
|
41
|
+
rows: GpuFormRows;
|
|
42
|
+
sideRows: GpuFormRows;
|
|
43
|
+
};
|
|
44
|
+
export type GpuFormSideRowParams = {
|
|
45
|
+
row: GpuQuotaItem;
|
|
46
|
+
gpuOptionsMap: GpuFormOptionsMap;
|
|
47
|
+
sideQuota?: GpuQuota;
|
|
48
|
+
withPrefixRequest?: boolean;
|
|
49
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { GpuFormFormattedUpdate, GpuFormInitialRowsParams, GpuFormInitialRowsResult, GpuFormRows, GpuFormSideRowParams, GpuFormVgpuExtraState, GpuFormVgpuEmitProps, GpuFormVgpuUpdateEmit } from './gpuForm.internal-types';
|
|
2
|
+
export declare const buildGpuFormFormattedUpdate: (rows: GpuFormRows, existTypes: string[], withPrefixRequest?: boolean) => GpuFormFormattedUpdate;
|
|
3
|
+
export declare const filterGpuFormRows: (items: GpuFormRows, gpuOptionsMap: GpuFormSideRowParams['gpuOptionsMap']) => GpuFormRows;
|
|
4
|
+
export declare const buildGpuFormVgpuUpdateEmits: (vgpu: GpuFormVgpuExtraState, props: GpuFormVgpuEmitProps, vgpuExist: boolean) => GpuFormVgpuUpdateEmit[];
|
|
5
|
+
export declare const buildGpuFormSideRow: ({ row, gpuOptionsMap, sideQuota, withPrefixRequest, }: GpuFormSideRowParams) => {
|
|
6
|
+
type: string | undefined;
|
|
7
|
+
resources: {};
|
|
8
|
+
id?: string | undefined;
|
|
9
|
+
removable?: boolean | undefined;
|
|
10
|
+
nvidiaVgpuModel?: string | undefined;
|
|
11
|
+
nvidiaVgpuDevices?: string[] | undefined;
|
|
12
|
+
nvidiaVgpPriority?: string | undefined;
|
|
13
|
+
nvidiaVgpuGpuSchedule?: import("../types").VgpuSchedulePolicy | undefined;
|
|
14
|
+
nvidiaVgpuNodeSchedule?: import("../types").VgpuSchedulePolicy | undefined;
|
|
15
|
+
};
|
|
16
|
+
export declare const buildGpuFormInitialRows: ({ quota, availableQuota, sideQuota, gpuOptionsMap, getDisplayResource, withPrefixRequest, showSide, isLimitOne, vgpu, }: GpuFormInitialRowsParams) => GpuFormInitialRowsResult;
|