From f01d770fec6a31b452e3bbba3a5383ba3f24c06b Mon Sep 17 00:00:00 2001
From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com>
Date: Tue, 10 Dec 2024 17:55:39 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20Fix=20Missing=20CPU=20and=20Memory=20Li?=
=?UTF-8?q?mit=20Warnings=20When=20Editing=20Installe=E2=80=A6=20(#7313)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../app-store/installed/detail/index.vue | 52 ++++++++++++++++---
1 file changed, 45 insertions(+), 7 deletions(-)
diff --git a/frontend/src/views/app-store/installed/detail/index.vue b/frontend/src/views/app-store/installed/detail/index.vue
index b563741a4..31622e51e 100644
--- a/frontend/src/views/app-store/installed/detail/index.vue
+++ b/frontend/src/views/app-store/installed/detail/index.vue
@@ -67,7 +67,11 @@
{{ $t('app.allowPortHelper') }}
-
+
{{ $t('app.cpuCore') }}
- {{ $t('container.limitHelper') }}
+
+ {{ $t('container.limitHelper', [limits.cpu]) }} {{ $t('commons.units.core') }}
+
-
+
-
+
- {{ $t('container.limitHelper') }}
+
+ {{ $t('container.limitHelper', [limits.memory]) }} {{ paramModel.memoryUnit }}B
+
@@ -137,6 +154,8 @@ import { Codemirror } from 'vue-codemirror';
import { javascript } from '@codemirror/lang-javascript';
import { oneDark } from '@codemirror/theme-one-dark';
import { getLanguage } from '@/utils/util';
+import { Container } from '@/api/interface/container';
+import { loadResourceLimit } from '@/api/modules/container';
const extensions = [javascript(), oneDark];
@@ -163,13 +182,32 @@ const paramModel = ref({
});
const rules = reactive({
params: {},
- cpuQuota: [Rules.requiredInput, checkNumberRange(0, 999)],
- memoryLimit: [Rules.requiredInput, checkNumberRange(0, 9999999999)],
containerName: [Rules.containerName],
});
const submitModel = ref({});
+const oldMemory = ref(0);
+const limits = ref({
+ cpu: null as number,
+ memory: null as number,
+});
+
+const changeUnit = () => {
+ if (paramModel.value.memoryUnit == 'M') {
+ limits.value.memory = oldMemory.value;
+ } else {
+ limits.value.memory = Number((oldMemory.value / 1024).toFixed(2));
+ }
+};
+
+const loadLimit = async () => {
+ const res = await loadResourceLimit();
+ limits.value = res.data;
+ limits.value.memory = Number((limits.value.memory / 1024 / 1024).toFixed(2));
+ oldMemory.value = limits.value.memory;
+};
const acceptParams = async (props: ParamProps) => {
+ loadLimit();
submitModel.value.installId = props.id;
params.value = [];
paramData.value.id = props.id;