feat: 应用增加内存需求展示 (#6224)
Some checks failed
sync2gitee / repo-sync (push) Failing after -8m11s

This commit is contained in:
zhengkunwang 2024-08-23 17:38:58 +08:00 committed by GitHub
parent 034645f50c
commit 3c19a07226
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 58 additions and 31 deletions

View file

@ -95,7 +95,7 @@ type AppProperty struct {
Github string `json:"github"`
Document string `json:"document"`
Architectures []string `json:"architectures"`
MemoryLimit int `json:"memoryLimit"`
MemoryRequired int `json:"memoryRequired"`
}
type AppConfigVersion struct {

View file

@ -67,12 +67,12 @@ type AppInstalledCheck struct {
type AppDetailDTO struct {
model.AppDetail
Enable bool `json:"enable"`
Params interface{} `json:"params"`
Image string `json:"image"`
HostMode bool `json:"hostMode"`
Architectures string `json:"architectures"`
MemoryLimit int `json:"memoryLimit"`
Enable bool `json:"enable"`
Params interface{} `json:"params"`
Image string `json:"image"`
HostMode bool `json:"hostMode"`
Architectures string `json:"architectures"`
MemoryRequired int `json:"memoryRequired"`
}
type IgnoredApp struct {

View file

@ -27,7 +27,7 @@ type App struct {
ReadMe string `json:"readMe"`
LastModified int `json:"lastModified"`
Architectures string `json:"architectures"`
MemoryLimit int `json:"memoryLimit"`
MemoryRequired int `json:"memoryRequired"`
Details []AppDetail `json:"-" gorm:"-:migration"`
TagsKey []string `json:"tags" yaml:"tags" gorm:"-"`

View file

@ -1118,7 +1118,7 @@ func getApps(oldApps []model.App, items []dto.AppDefine) map[string]model.App {
app.Status = constant.AppNormal
app.LastModified = item.LastModified
app.ReadMe = item.ReadMe
app.MemoryLimit = config.MemoryLimit
app.MemoryRequired = config.MemoryRequired
app.Architectures = strings.Join(config.Architectures, ",")
apps[key] = app
}

View file

@ -120,7 +120,10 @@ func (t *Task) AddSubTaskWithIgnoreErr(name string, action ActionFunc) {
}
func (s *SubTask) Execute() error {
s.RootTask.Log(s.Name)
subTaskName := s.Name
if s.Name == "" {
subTaskName = i18n.GetMsgByKey("SubTask")
}
var err error
for i := 0; i < s.Retry+1; i++ {
if i > 0 {
@ -136,12 +139,12 @@ func (s *SubTask) Execute() error {
select {
case <-ctx.Done():
s.RootTask.Log(i18n.GetWithName("TaskTimeout", s.Name))
s.RootTask.Log(i18n.GetWithName("TaskTimeout", subTaskName))
case err = <-done:
if err != nil {
s.RootTask.Log(i18n.GetWithNameAndErr("SubTaskFailed", s.Name, err))
s.RootTask.Log(i18n.GetWithNameAndErr("SubTaskFailed", subTaskName, err))
} else {
s.RootTask.Log(i18n.GetWithName("SubTaskSuccess", s.Name))
s.RootTask.Log(i18n.GetWithName("SubTaskSuccess", subTaskName))
return nil
}
}

View file

@ -1,9 +1,12 @@
system:
db_agent_file: agent.db
db_core_file: core.db
base_dir: /opt
mode: dev
repo_url: https://resource.fit2cloud.com/1panel/package
app_repo: https://apps-assets.fit2cloud.com
username: admin
password: admin
log:
level: debug

View file

@ -236,4 +236,5 @@ EnableSSL: "Enable HTTPS"
AppStore: "App Store"
TaskSync: "Sync"
LocalApp: "Local App"
SubTask: "Subtask"

View file

@ -238,4 +238,5 @@ EnableSSL: "開啟 HTTPS"
AppStore: "應用商店"
TaskSync: "同步"
LocalApp: "本地應用"
SubTask: "子任務"

View file

@ -238,4 +238,5 @@ AppLink: "关联应用"
EnableSSL: "开启 HTTPS"
AppStore: "应用商店"
TaskSync: "同步"
LocalApp: "本地应用"
LocalApp: "本地应用"
SubTask: "子任务"

View file

@ -235,14 +235,6 @@ var UpdateWebsiteDomain = &gormigrate.Migration{
},
}
var UpdateApp = &gormigrate.Migration{
ID: "20240822-update-app",
Migrate: func(tx *gorm.DB) error {
return tx.AutoMigrate(
&model.App{})
},
}
var AddTaskDB = &gormigrate.Migration{
ID: "20240822-add-task-table",
Migrate: func(tx *gorm.DB) error {
@ -251,3 +243,11 @@ var AddTaskDB = &gormigrate.Migration{
)
},
}
var UpdateApp = &gormigrate.Migration{
ID: "20240823-update-app",
Migrate: func(tx *gorm.DB) error {
return tx.AutoMigrate(
&model.App{})
},
}

View file

@ -49,7 +49,7 @@ export namespace App {
dockerCompose: string;
image: string;
hostMode?: boolean;
memoryLimit: number;
memoryRequired: number;
architectures: string;
}

View file

@ -1879,6 +1879,7 @@ const message = {
link: 'Link',
showCurrentArch: 'Architecture',
syncLocalApp: 'Sync Local App',
memoryRequiredHelper: 'Current application memory requirement {0}',
},
website: {
website: 'Website',

View file

@ -1745,6 +1745,7 @@ const message = {
link: '鏈接',
showCurrentArch: '僅顯示當前架構',
syncLocalApp: '同步本地應用',
memoryRequiredHelper: '目前應用記憶體需求 {0}',
},
website: {
website: '網站',

View file

@ -1746,6 +1746,7 @@ const message = {
link: '链接',
showCurrentArch: '仅显示当前服务器架构应用',
syncLocalApp: '同步本地应用',
memoryRequiredHelper: '当前应用内存需求 {0}',
},
website: {
website: '网站',

View file

@ -58,8 +58,8 @@
<el-icon class="ml-1.5"><Promotion /></el-icon>
</el-link>
</el-descriptions-item>
<el-descriptions-item :label="$t('app.requireMemory')" v-if="appDetail.memoryLimit > 0">
<span>{{ appDetail.memoryLimit }} MB</span>
<el-descriptions-item :label="$t('app.requireMemory')" v-if="appDetail.memoryRequired > 0">
<span>{{ computeSizeFromMB(appDetail.memoryRequired) }}</span>
</el-descriptions-item>
<el-descriptions-item :label="$t('app.supportedArchitectures')" v-if="architectures.length > 0">
<el-tag v-for="(arch, index) in architectures" :key="index" class="mx-1">
@ -81,8 +81,9 @@ import { ref } from 'vue';
import Install from './install/index.vue';
import router from '@/routers';
import { GlobalStore } from '@/store';
import { getLanguage } from '@/utils/util';
import { getLanguage, computeSizeFromMB } from '@/utils/util';
import { storeToRefs } from 'pinia';
const globalStore = GlobalStore();
const { isDarkTheme } = storeToRefs(globalStore);

View file

@ -1,13 +1,19 @@
<template>
<DrawerPro v-model="open" :header="$t('app.install')" :back="handleClose" size="large">
<el-alert
:title="$t('app.appInstallWarn')"
:title="$t('app.hostModeHelper')"
class="common-prompt"
:closable="false"
type="error"
v-if="!isHostMode"
type="warning"
v-if="isHostMode"
/>
<el-alert
:title="$t('app.memoryRequiredHelper', [computeSizeFromMB(memoryRequired)])"
class="common-prompt"
:closable="false"
type="warning"
v-if="memoryRequired > 0"
/>
<el-alert :title="$t('app.hostModeHelper')" class="common-prompt" :closable="false" type="warning" v-else />
<el-form
v-loading="loading"
@submit.prevent
@ -124,6 +130,7 @@ import { loadResourceLimit } from '@/api/modules/container';
import CodemirrorPro from '@/components/codemirror-pro/index.vue';
import TaskLog from '@/components/task-log/index.vue';
import { newUUID } from '@/utils/util';
import { computeSizeFromMB } from '@/utils/util';
const router = useRouter();
@ -181,6 +188,7 @@ const handleClose = () => {
const paramKey = ref(1);
const isHostMode = ref(false);
const taskLogRef = ref();
const memoryRequired = ref(0);
const changeUnit = () => {
if (req.memoryUnit == 'M') {
@ -228,6 +236,7 @@ const getAppDetail = async (version: string) => {
isHostMode.value = res.data.hostMode;
installData.value.params = res.data.params;
paramKey.value++;
memoryRequired.value = res.data.memoryRequired;
} catch (error) {
} finally {
loading.value = false;

View file

@ -120,7 +120,12 @@
<el-form-item :label="$t('app.app')" prop="appinstall.appId">
<el-row :gutter="20">
<el-col :span="12">
<el-select v-model="website.appinstall.appId" @change="changeApp()" class="p-w-200">
<el-select
v-model="website.appinstall.appId"
@change="changeApp()"
class="p-w-200"
filterable
>
<el-option
v-for="(app, index) in apps"
:key="index"