mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-12 05:15:59 +08:00
feat: 应用增加内存需求展示 (#6224)
Some checks failed
sync2gitee / repo-sync (push) Failing after -8m11s
Some checks failed
sync2gitee / repo-sync (push) Failing after -8m11s
This commit is contained in:
parent
034645f50c
commit
3c19a07226
17 changed files with 58 additions and 31 deletions
|
|
@ -95,7 +95,7 @@ type AppProperty struct {
|
||||||
Github string `json:"github"`
|
Github string `json:"github"`
|
||||||
Document string `json:"document"`
|
Document string `json:"document"`
|
||||||
Architectures []string `json:"architectures"`
|
Architectures []string `json:"architectures"`
|
||||||
MemoryLimit int `json:"memoryLimit"`
|
MemoryRequired int `json:"memoryRequired"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type AppConfigVersion struct {
|
type AppConfigVersion struct {
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ type AppDetailDTO struct {
|
||||||
Image string `json:"image"`
|
Image string `json:"image"`
|
||||||
HostMode bool `json:"hostMode"`
|
HostMode bool `json:"hostMode"`
|
||||||
Architectures string `json:"architectures"`
|
Architectures string `json:"architectures"`
|
||||||
MemoryLimit int `json:"memoryLimit"`
|
MemoryRequired int `json:"memoryRequired"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type IgnoredApp struct {
|
type IgnoredApp struct {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ type App struct {
|
||||||
ReadMe string `json:"readMe"`
|
ReadMe string `json:"readMe"`
|
||||||
LastModified int `json:"lastModified"`
|
LastModified int `json:"lastModified"`
|
||||||
Architectures string `json:"architectures"`
|
Architectures string `json:"architectures"`
|
||||||
MemoryLimit int `json:"memoryLimit"`
|
MemoryRequired int `json:"memoryRequired"`
|
||||||
|
|
||||||
Details []AppDetail `json:"-" gorm:"-:migration"`
|
Details []AppDetail `json:"-" gorm:"-:migration"`
|
||||||
TagsKey []string `json:"tags" yaml:"tags" gorm:"-"`
|
TagsKey []string `json:"tags" yaml:"tags" gorm:"-"`
|
||||||
|
|
|
||||||
|
|
@ -1118,7 +1118,7 @@ func getApps(oldApps []model.App, items []dto.AppDefine) map[string]model.App {
|
||||||
app.Status = constant.AppNormal
|
app.Status = constant.AppNormal
|
||||||
app.LastModified = item.LastModified
|
app.LastModified = item.LastModified
|
||||||
app.ReadMe = item.ReadMe
|
app.ReadMe = item.ReadMe
|
||||||
app.MemoryLimit = config.MemoryLimit
|
app.MemoryRequired = config.MemoryRequired
|
||||||
app.Architectures = strings.Join(config.Architectures, ",")
|
app.Architectures = strings.Join(config.Architectures, ",")
|
||||||
apps[key] = app
|
apps[key] = app
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,10 @@ func (t *Task) AddSubTaskWithIgnoreErr(name string, action ActionFunc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SubTask) Execute() error {
|
func (s *SubTask) Execute() error {
|
||||||
s.RootTask.Log(s.Name)
|
subTaskName := s.Name
|
||||||
|
if s.Name == "" {
|
||||||
|
subTaskName = i18n.GetMsgByKey("SubTask")
|
||||||
|
}
|
||||||
var err error
|
var err error
|
||||||
for i := 0; i < s.Retry+1; i++ {
|
for i := 0; i < s.Retry+1; i++ {
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
|
|
@ -136,12 +139,12 @@ func (s *SubTask) Execute() error {
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
s.RootTask.Log(i18n.GetWithName("TaskTimeout", s.Name))
|
s.RootTask.Log(i18n.GetWithName("TaskTimeout", subTaskName))
|
||||||
case err = <-done:
|
case err = <-done:
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.RootTask.Log(i18n.GetWithNameAndErr("SubTaskFailed", s.Name, err))
|
s.RootTask.Log(i18n.GetWithNameAndErr("SubTaskFailed", subTaskName, err))
|
||||||
} else {
|
} else {
|
||||||
s.RootTask.Log(i18n.GetWithName("SubTaskSuccess", s.Name))
|
s.RootTask.Log(i18n.GetWithName("SubTaskSuccess", subTaskName))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,12 @@
|
||||||
system:
|
system:
|
||||||
db_agent_file: agent.db
|
db_agent_file: agent.db
|
||||||
|
db_core_file: core.db
|
||||||
base_dir: /opt
|
base_dir: /opt
|
||||||
mode: dev
|
mode: dev
|
||||||
repo_url: https://resource.fit2cloud.com/1panel/package
|
repo_url: https://resource.fit2cloud.com/1panel/package
|
||||||
app_repo: https://apps-assets.fit2cloud.com
|
app_repo: https://apps-assets.fit2cloud.com
|
||||||
|
username: admin
|
||||||
|
password: admin
|
||||||
|
|
||||||
log:
|
log:
|
||||||
level: debug
|
level: debug
|
||||||
|
|
|
||||||
|
|
@ -236,4 +236,5 @@ EnableSSL: "Enable HTTPS"
|
||||||
AppStore: "App Store"
|
AppStore: "App Store"
|
||||||
TaskSync: "Sync"
|
TaskSync: "Sync"
|
||||||
LocalApp: "Local App"
|
LocalApp: "Local App"
|
||||||
|
SubTask: "Subtask"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -238,4 +238,5 @@ EnableSSL: "開啟 HTTPS"
|
||||||
AppStore: "應用商店"
|
AppStore: "應用商店"
|
||||||
TaskSync: "同步"
|
TaskSync: "同步"
|
||||||
LocalApp: "本地應用"
|
LocalApp: "本地應用"
|
||||||
|
SubTask: "子任務"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -239,3 +239,4 @@ EnableSSL: "开启 HTTPS"
|
||||||
AppStore: "应用商店"
|
AppStore: "应用商店"
|
||||||
TaskSync: "同步"
|
TaskSync: "同步"
|
||||||
LocalApp: "本地应用"
|
LocalApp: "本地应用"
|
||||||
|
SubTask: "子任务"
|
||||||
|
|
@ -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{
|
var AddTaskDB = &gormigrate.Migration{
|
||||||
ID: "20240822-add-task-table",
|
ID: "20240822-add-task-table",
|
||||||
Migrate: func(tx *gorm.DB) error {
|
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{})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ export namespace App {
|
||||||
dockerCompose: string;
|
dockerCompose: string;
|
||||||
image: string;
|
image: string;
|
||||||
hostMode?: boolean;
|
hostMode?: boolean;
|
||||||
memoryLimit: number;
|
memoryRequired: number;
|
||||||
architectures: string;
|
architectures: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1879,6 +1879,7 @@ const message = {
|
||||||
link: 'Link',
|
link: 'Link',
|
||||||
showCurrentArch: 'Architecture',
|
showCurrentArch: 'Architecture',
|
||||||
syncLocalApp: 'Sync Local App',
|
syncLocalApp: 'Sync Local App',
|
||||||
|
memoryRequiredHelper: 'Current application memory requirement {0}',
|
||||||
},
|
},
|
||||||
website: {
|
website: {
|
||||||
website: 'Website',
|
website: 'Website',
|
||||||
|
|
|
||||||
|
|
@ -1745,6 +1745,7 @@ const message = {
|
||||||
link: '鏈接',
|
link: '鏈接',
|
||||||
showCurrentArch: '僅顯示當前架構',
|
showCurrentArch: '僅顯示當前架構',
|
||||||
syncLocalApp: '同步本地應用',
|
syncLocalApp: '同步本地應用',
|
||||||
|
memoryRequiredHelper: '目前應用記憶體需求 {0}',
|
||||||
},
|
},
|
||||||
website: {
|
website: {
|
||||||
website: '網站',
|
website: '網站',
|
||||||
|
|
|
||||||
|
|
@ -1746,6 +1746,7 @@ const message = {
|
||||||
link: '链接',
|
link: '链接',
|
||||||
showCurrentArch: '仅显示当前服务器架构应用',
|
showCurrentArch: '仅显示当前服务器架构应用',
|
||||||
syncLocalApp: '同步本地应用',
|
syncLocalApp: '同步本地应用',
|
||||||
|
memoryRequiredHelper: '当前应用内存需求 {0}',
|
||||||
},
|
},
|
||||||
website: {
|
website: {
|
||||||
website: '网站',
|
website: '网站',
|
||||||
|
|
|
||||||
|
|
@ -58,8 +58,8 @@
|
||||||
<el-icon class="ml-1.5"><Promotion /></el-icon>
|
<el-icon class="ml-1.5"><Promotion /></el-icon>
|
||||||
</el-link>
|
</el-link>
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item :label="$t('app.requireMemory')" v-if="appDetail.memoryLimit > 0">
|
<el-descriptions-item :label="$t('app.requireMemory')" v-if="appDetail.memoryRequired > 0">
|
||||||
<span>{{ appDetail.memoryLimit }} MB</span>
|
<span>{{ computeSizeFromMB(appDetail.memoryRequired) }}</span>
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item :label="$t('app.supportedArchitectures')" v-if="architectures.length > 0">
|
<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">
|
<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 Install from './install/index.vue';
|
||||||
import router from '@/routers';
|
import router from '@/routers';
|
||||||
import { GlobalStore } from '@/store';
|
import { GlobalStore } from '@/store';
|
||||||
import { getLanguage } from '@/utils/util';
|
import { getLanguage, computeSizeFromMB } from '@/utils/util';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
|
|
||||||
const globalStore = GlobalStore();
|
const globalStore = GlobalStore();
|
||||||
const { isDarkTheme } = storeToRefs(globalStore);
|
const { isDarkTheme } = storeToRefs(globalStore);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,19 @@
|
||||||
<template>
|
<template>
|
||||||
<DrawerPro v-model="open" :header="$t('app.install')" :back="handleClose" size="large">
|
<DrawerPro v-model="open" :header="$t('app.install')" :back="handleClose" size="large">
|
||||||
<el-alert
|
<el-alert
|
||||||
:title="$t('app.appInstallWarn')"
|
:title="$t('app.hostModeHelper')"
|
||||||
class="common-prompt"
|
class="common-prompt"
|
||||||
:closable="false"
|
:closable="false"
|
||||||
type="error"
|
type="warning"
|
||||||
v-if="!isHostMode"
|
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
|
<el-form
|
||||||
v-loading="loading"
|
v-loading="loading"
|
||||||
@submit.prevent
|
@submit.prevent
|
||||||
|
|
@ -124,6 +130,7 @@ import { loadResourceLimit } from '@/api/modules/container';
|
||||||
import CodemirrorPro from '@/components/codemirror-pro/index.vue';
|
import CodemirrorPro from '@/components/codemirror-pro/index.vue';
|
||||||
import TaskLog from '@/components/task-log/index.vue';
|
import TaskLog from '@/components/task-log/index.vue';
|
||||||
import { newUUID } from '@/utils/util';
|
import { newUUID } from '@/utils/util';
|
||||||
|
import { computeSizeFromMB } from '@/utils/util';
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
|
@ -181,6 +188,7 @@ const handleClose = () => {
|
||||||
const paramKey = ref(1);
|
const paramKey = ref(1);
|
||||||
const isHostMode = ref(false);
|
const isHostMode = ref(false);
|
||||||
const taskLogRef = ref();
|
const taskLogRef = ref();
|
||||||
|
const memoryRequired = ref(0);
|
||||||
|
|
||||||
const changeUnit = () => {
|
const changeUnit = () => {
|
||||||
if (req.memoryUnit == 'M') {
|
if (req.memoryUnit == 'M') {
|
||||||
|
|
@ -228,6 +236,7 @@ const getAppDetail = async (version: string) => {
|
||||||
isHostMode.value = res.data.hostMode;
|
isHostMode.value = res.data.hostMode;
|
||||||
installData.value.params = res.data.params;
|
installData.value.params = res.data.params;
|
||||||
paramKey.value++;
|
paramKey.value++;
|
||||||
|
memoryRequired.value = res.data.memoryRequired;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,12 @@
|
||||||
<el-form-item :label="$t('app.app')" prop="appinstall.appId">
|
<el-form-item :label="$t('app.app')" prop="appinstall.appId">
|
||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col :span="12">
|
<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
|
<el-option
|
||||||
v-for="(app, index) in apps"
|
v-for="(app, index) in apps"
|
||||||
:key="index"
|
:key="index"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue