mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-02-08 01:20:07 +08:00
feat: 应用创建增加 cpu 和内存最大值提示 (#1535)
This commit is contained in:
parent
bd2facebee
commit
319afd2d51
@ -66,10 +66,7 @@ func (w WebsiteSSLService) Search(search request.WebsiteSSLSearch) ([]response.W
|
|||||||
opts []repo.DBOption
|
opts []repo.DBOption
|
||||||
result []response.WebsiteSSLDTO
|
result []response.WebsiteSSLDTO
|
||||||
)
|
)
|
||||||
opts = append(opts, commonRepo.WithOrderBy("created_at desc"))
|
opts = append(opts, commonRepo.WithOrderBy("created_at desc"), websiteSSLRepo.WithByAcmeAccountId(search.AcmeAccountID))
|
||||||
if search.AcmeAccountID >= 0 {
|
|
||||||
opts = append(opts, websiteSSLRepo.WithByAcmeAccountId(search.AcmeAccountID))
|
|
||||||
}
|
|
||||||
sslList, err := websiteSSLRepo.List(opts...)
|
sslList, err := websiteSSLRepo.List(opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -1177,8 +1177,7 @@ const message = {
|
|||||||
containerName: 'Container Name',
|
containerName: 'Container Name',
|
||||||
containerNameHelper: 'can be empty, it will be automatically generated',
|
containerNameHelper: 'can be empty, it will be automatically generated',
|
||||||
allowPort: 'Port external access',
|
allowPort: 'Port external access',
|
||||||
allowPortHelper:
|
allowPortHelper: 'Allowing external port access will release the firewall port',
|
||||||
'Allowing external port access will release the firewall port, please do not release the php operating environment',
|
|
||||||
appInstallWarn:
|
appInstallWarn:
|
||||||
'The application does not release the external access port by default, you can choose to release it in the advanced settings',
|
'The application does not release the external access port by default, you can choose to release it in the advanced settings',
|
||||||
upgradeStart: 'Start upgrading! Please refresh the page later',
|
upgradeStart: 'Start upgrading! Please refresh the page later',
|
||||||
@ -1191,7 +1190,7 @@ const message = {
|
|||||||
installHelper: 'Configuring image acceleration can solve the problem of image pull failure',
|
installHelper: 'Configuring image acceleration can solve the problem of image pull failure',
|
||||||
upgradeHelper: 'The abnormal application needs to be synchronized to the normal state first',
|
upgradeHelper: 'The abnormal application needs to be synchronized to the normal state first',
|
||||||
installWarn:
|
installWarn:
|
||||||
' Port external access is not enabled, and cannot be accessed through the external network IP:port. Do you want to continue?',
|
'Currently, if the port external access is not checked, it will not be able to access through the external network IP: port. Do you want to continue?',
|
||||||
restoreWarn:
|
restoreWarn:
|
||||||
'The restore operation will delete the current data of the application and restart it. This operation cannot be rolled back, continue?',
|
'The restore operation will delete the current data of the application and restart it. This operation cannot be rolled back, continue?',
|
||||||
},
|
},
|
||||||
|
@ -1121,7 +1121,7 @@ const message = {
|
|||||||
containerName: '容器名稱',
|
containerName: '容器名稱',
|
||||||
containerNameHelper: '可以為空,為空自動生成',
|
containerNameHelper: '可以為空,為空自動生成',
|
||||||
allowPort: '端口外部訪問',
|
allowPort: '端口外部訪問',
|
||||||
allowPortHelper: '允許端口外部訪問會放開防火墻端口,php運行環境請勿放開',
|
allowPortHelper: '允許端口外部訪問會放開防火墻端口',
|
||||||
appInstallWarn: '應用端口默認不允許外部訪問,可以在下方高級設置中選擇放開',
|
appInstallWarn: '應用端口默認不允許外部訪問,可以在下方高級設置中選擇放開',
|
||||||
upgradeStart: '開始升級!請稍後刷新頁面',
|
upgradeStart: '開始升級!請稍後刷新頁面',
|
||||||
toFolder: '進入安裝目錄',
|
toFolder: '進入安裝目錄',
|
||||||
@ -1132,7 +1132,7 @@ const message = {
|
|||||||
allReadyInstalled: '已安裝',
|
allReadyInstalled: '已安裝',
|
||||||
installHelper: '配置鏡像加速可以解決鏡像拉取失敗的問題',
|
installHelper: '配置鏡像加速可以解決鏡像拉取失敗的問題',
|
||||||
upgradeHelper: '異常應用需要先同步到正常狀態',
|
upgradeHelper: '異常應用需要先同步到正常狀態',
|
||||||
installWarn: '未開啟端口外部訪問,無法通過外網IP:端口訪問,是否繼續? ',
|
installWarn: '當前未勾選端口外部訪問,將無法通過外網IP:端口訪問,是否繼續? ',
|
||||||
restoreWarn: '恢復操作將刪除該應用當前數據並重啟。此操作不可回滾,是否繼續?',
|
restoreWarn: '恢復操作將刪除該應用當前數據並重啟。此操作不可回滾,是否繼續?',
|
||||||
},
|
},
|
||||||
website: {
|
website: {
|
||||||
|
@ -1127,7 +1127,7 @@ const message = {
|
|||||||
containerName: '容器名称',
|
containerName: '容器名称',
|
||||||
containerNameHelper: '可以为空,为空自动生成',
|
containerNameHelper: '可以为空,为空自动生成',
|
||||||
allowPort: '端口外部访问',
|
allowPort: '端口外部访问',
|
||||||
allowPortHelper: '允许端口外部访问会放开防火墙端口,php运行环境请勿放开',
|
allowPortHelper: '允许端口外部访问会放开防火墙端口',
|
||||||
appInstallWarn: '应用端口默认不允许外部访问,可以在下方高级设置中选择放开',
|
appInstallWarn: '应用端口默认不允许外部访问,可以在下方高级设置中选择放开',
|
||||||
upgradeStart: '开始升级!请稍后刷新页面',
|
upgradeStart: '开始升级!请稍后刷新页面',
|
||||||
toFolder: '进入安装目录',
|
toFolder: '进入安装目录',
|
||||||
@ -1138,7 +1138,7 @@ const message = {
|
|||||||
allReadyInstalled: '已安装',
|
allReadyInstalled: '已安装',
|
||||||
installHelper: '配置镜像加速可以解决镜像拉取失败的问题',
|
installHelper: '配置镜像加速可以解决镜像拉取失败的问题',
|
||||||
upgradeHelper: '异常应用需要先同步到正常状态',
|
upgradeHelper: '异常应用需要先同步到正常状态',
|
||||||
installWarn: '未开启端口外部访问,无法通过外网IP:端口访问,是否继续?',
|
installWarn: '当前未勾选端口外部访问,将无法通过外网IP:端口访问,是否继续?',
|
||||||
restoreWarn: '恢复操作将删除该应用当前数据并重启。此操作不可回滚,是否继续?',
|
restoreWarn: '恢复操作将删除该应用当前数据并重启。此操作不可回滚,是否继续?',
|
||||||
},
|
},
|
||||||
website: {
|
website: {
|
||||||
|
@ -41,23 +41,39 @@
|
|||||||
:placeholder="$t('app.containerNameHelper')"
|
:placeholder="$t('app.containerNameHelper')"
|
||||||
></el-input>
|
></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('container.cpuQuota')" prop="cpuQuota">
|
<el-form-item
|
||||||
|
:label="$t('container.cpuQuota')"
|
||||||
|
prop="cpuQuota"
|
||||||
|
:rules="checkNumberRange(0, limits.cpu)"
|
||||||
|
>
|
||||||
<el-input type="number" style="width: 40%" v-model.number="req.cpuQuota" maxlength="5">
|
<el-input type="number" style="width: 40%" v-model.number="req.cpuQuota" maxlength="5">
|
||||||
<template #append>{{ $t('app.cpuCore') }}</template>
|
<template #append>{{ $t('app.cpuCore') }}</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
<span class="input-help">{{ $t('container.limitHelper') }}</span>
|
<span class="input-help">
|
||||||
|
{{ $t('container.limitHelper', [limits.cpu]) }}{{ $t('commons.units.core') }}
|
||||||
|
</span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t('container.memoryLimit')" prop="memoryLimit">
|
<el-form-item
|
||||||
|
:label="$t('container.memoryLimit')"
|
||||||
|
prop="memoryLimit"
|
||||||
|
:rules="checkNumberRange(0, limits.memory)"
|
||||||
|
>
|
||||||
<el-input style="width: 40%" v-model.number="req.memoryLimit" maxlength="10">
|
<el-input style="width: 40%" v-model.number="req.memoryLimit" maxlength="10">
|
||||||
<template #append>
|
<template #append>
|
||||||
<el-select v-model="req.memoryUnit" placeholder="Select" style="width: 85px">
|
<el-select
|
||||||
<el-option label="KB" value="K" />
|
v-model="req.memoryUnit"
|
||||||
|
placeholder="Select"
|
||||||
|
style="width: 85px"
|
||||||
|
@change="changeUnit"
|
||||||
|
>
|
||||||
<el-option label="MB" value="M" />
|
<el-option label="MB" value="M" />
|
||||||
<el-option label="GB" value="G" />
|
<el-option label="GB" value="G" />
|
||||||
</el-select>
|
</el-select>
|
||||||
</template>
|
</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
<span class="input-help">{{ $t('container.limitHelper') }}</span>
|
<span class="input-help">
|
||||||
|
{{ $t('container.limitHelper', [limits.memory]) }}{{ req.memoryUnit }}B
|
||||||
|
</span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item prop="allowPort" v-if="canEditPort(installData.app)">
|
<el-form-item prop="allowPort" v-if="canEditPort(installData.app)">
|
||||||
<el-checkbox v-model="req.allowPort" :label="$t('app.allowPort')" size="large" />
|
<el-checkbox v-model="req.allowPort" :label="$t('app.allowPort')" size="large" />
|
||||||
@ -104,7 +120,7 @@ import { InstallApp } from '@/api/modules/app';
|
|||||||
import { Rules, checkNumberRange } from '@/global/form-rules';
|
import { Rules, checkNumberRange } from '@/global/form-rules';
|
||||||
import { canEditPort } from '@/global/business';
|
import { canEditPort } from '@/global/business';
|
||||||
import { FormInstance, FormRules } from 'element-plus';
|
import { FormInstance, FormRules } from 'element-plus';
|
||||||
import { reactive, ref } from 'vue';
|
import { onMounted, reactive, ref } from 'vue';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
import Params from '../params/index.vue';
|
import Params from '../params/index.vue';
|
||||||
import Header from '@/components/drawer-header/index.vue';
|
import Header from '@/components/drawer-header/index.vue';
|
||||||
@ -113,6 +129,8 @@ import { javascript } from '@codemirror/lang-javascript';
|
|||||||
import { oneDark } from '@codemirror/theme-one-dark';
|
import { oneDark } from '@codemirror/theme-one-dark';
|
||||||
import i18n from '@/lang';
|
import i18n from '@/lang';
|
||||||
import { MsgError } from '@/utils/message';
|
import { MsgError } from '@/utils/message';
|
||||||
|
import { Container } from '@/api/interface/container';
|
||||||
|
import { loadResourceLimit } from '@/api/modules/container';
|
||||||
|
|
||||||
const extensions = [javascript(), oneDark];
|
const extensions = [javascript(), oneDark];
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@ -154,12 +172,25 @@ const initData = () => ({
|
|||||||
dockerCompose: '',
|
dockerCompose: '',
|
||||||
});
|
});
|
||||||
const req = reactive(initData());
|
const req = reactive(initData());
|
||||||
|
const limits = ref<Container.ResourceLimit>({
|
||||||
|
cpu: null as number,
|
||||||
|
memory: null as number,
|
||||||
|
});
|
||||||
|
const oldMemory = ref<number>(0);
|
||||||
|
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
open.value = false;
|
open.value = false;
|
||||||
resetForm();
|
resetForm();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const changeUnit = () => {
|
||||||
|
if (req.memoryUnit == 'M') {
|
||||||
|
limits.value.memory = oldMemory.value;
|
||||||
|
} else {
|
||||||
|
limits.value.memory = oldMemory.value / 1024;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
if (paramForm.value) {
|
if (paramForm.value) {
|
||||||
paramForm.value.clearValidate();
|
paramForm.value.clearValidate();
|
||||||
@ -193,10 +224,20 @@ const submit = async (formEl: FormInstance | undefined) => {
|
|||||||
if (req.memoryLimit < 0) {
|
if (req.memoryLimit < 0) {
|
||||||
req.memoryLimit = 0;
|
req.memoryLimit = 0;
|
||||||
}
|
}
|
||||||
|
if (req.advanced && !req.allowPort) {
|
||||||
ElMessageBox.confirm(i18n.global.t('app.installWarn'), i18n.global.t('app.checkTitle'), {
|
ElMessageBox.confirm(i18n.global.t('app.installWarn'), i18n.global.t('app.checkTitle'), {
|
||||||
confirmButtonText: i18n.global.t('commons.button.confirm'),
|
confirmButtonText: i18n.global.t('commons.button.confirm'),
|
||||||
cancelButtonText: i18n.global.t('commons.button.cancel'),
|
cancelButtonText: i18n.global.t('commons.button.cancel'),
|
||||||
}).then(async () => {
|
}).then(async () => {
|
||||||
|
install();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
install();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const install = () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
InstallApp(req)
|
InstallApp(req)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
@ -206,11 +247,20 @@ const submit = async (formEl: FormInstance | undefined) => {
|
|||||||
.finally(() => {
|
.finally(() => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
});
|
});
|
||||||
});
|
};
|
||||||
});
|
|
||||||
|
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;
|
||||||
};
|
};
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
acceptParams,
|
acceptParams,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadLimit();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user