1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-19 08:19:15 +08:00

fix: 数据库、计划任务下拉框样式调整 (#2255)

This commit is contained in:
ssongliu 2023-09-11 18:28:19 +08:00 committed by GitHub
parent 9aaf3bf435
commit a364dbffbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 97 additions and 13 deletions

View File

@ -27,6 +27,7 @@ type MysqlDBInfo struct {
type MysqlOption struct { type MysqlOption struct {
ID uint `json:"id"` ID uint `json:"id"`
From string `json:"from"` From string `json:"from"`
Type string `json:"type"`
Database string `json:"database"` Database string `json:"database"`
Name string `json:"name"` Name string `json:"name"`
} }

View File

@ -75,6 +75,14 @@ func (u *MysqlService) SearchWithPage(search dto.MysqlDBSearch) (int64, interfac
func (u *MysqlService) ListDBOption() ([]dto.MysqlOption, error) { func (u *MysqlService) ListDBOption() ([]dto.MysqlOption, error) {
mysqls, err := mysqlRepo.List() mysqls, err := mysqlRepo.List()
if err != nil {
return nil, err
}
databases, err := databaseRepo.GetList(databaseRepo.WithTypeList("mysql,mariadb"))
if err != nil {
return nil, err
}
var dbs []dto.MysqlOption var dbs []dto.MysqlOption
for _, mysql := range mysqls { for _, mysql := range mysqls {
var item dto.MysqlOption var item dto.MysqlOption
@ -82,6 +90,11 @@ func (u *MysqlService) ListDBOption() ([]dto.MysqlOption, error) {
return nil, errors.WithMessage(constant.ErrStructTransform, err.Error()) return nil, errors.WithMessage(constant.ErrStructTransform, err.Error())
} }
item.Database = mysql.MysqlName item.Database = mysql.MysqlName
for _, database := range databases {
if database.Name == item.Database {
item.Type = database.Type
}
}
dbs = append(dbs, item) dbs = append(dbs, item)
} }
return dbs, err return dbs, err

View File

@ -12215,6 +12215,12 @@ const docTemplate = `{
"cpuShares": { "cpuShares": {
"type": "integer" "type": "integer"
}, },
"entrypoint": {
"type": "array",
"items": {
"type": "string"
}
},
"env": { "env": {
"type": "array", "type": "array",
"items": { "items": {
@ -13714,6 +13720,9 @@ const docTemplate = `{
}, },
"name": { "name": {
"type": "string" "type": "string"
},
"type": {
"type": "string"
} }
} }
}, },

View File

@ -12208,6 +12208,12 @@
"cpuShares": { "cpuShares": {
"type": "integer" "type": "integer"
}, },
"entrypoint": {
"type": "array",
"items": {
"type": "string"
}
},
"env": { "env": {
"type": "array", "type": "array",
"items": { "items": {
@ -13707,6 +13713,9 @@
}, },
"name": { "name": {
"type": "string" "type": "string"
},
"type": {
"type": "string"
} }
} }
}, },

View File

@ -347,6 +347,10 @@ definitions:
type: string type: string
cpuShares: cpuShares:
type: integer type: integer
entrypoint:
items:
type: string
type: array
env: env:
items: items:
type: string type: string
@ -1362,6 +1366,8 @@ definitions:
type: integer type: integer
name: name:
type: string type: string
type:
type: string
type: object type: object
dto.MysqlStatus: dto.MysqlStatus:
properties: properties:

View File

@ -134,6 +134,7 @@ export namespace Database {
export interface MysqlOption { export interface MysqlOption {
id: number; id: number;
from: string; from: string;
type: string;
database: string; database: string;
name: string; name: string;
} }

View File

@ -318,7 +318,8 @@ const message = {
deleteHelper: '" to delete this database', deleteHelper: '" to delete this database',
create: 'Create database', create: 'Create database',
noMysql: 'Database service (MySQL or MariaDB)', noMysql: 'Database service (MySQL or MariaDB)',
goInstall: 'Go to install', goUpgrade: 'Go for upgrade',
goInstall: 'Go for install',
source: 'Source', source: 'Source',
permission: 'Permission', permission: 'Permission',
permissionForIP: 'IP', permissionForIP: 'IP',

View File

@ -314,6 +314,7 @@ const message = {
deleteHelper: '" 刪除此數據庫', deleteHelper: '" 刪除此數據庫',
create: '創建數據庫', create: '創建數據庫',
noMysql: '數據庫服務 (MySQL MariaDB)', noMysql: '數據庫服務 (MySQL MariaDB)',
goUpgrade: '去應用商店升級',
goInstall: '去應用商店安裝', goInstall: '去應用商店安裝',
source: '來源', source: '來源',
permission: '權限', permission: '權限',

View File

@ -314,6 +314,7 @@ const message = {
deleteHelper: '" 删除此数据库', deleteHelper: '" 删除此数据库',
create: '创建数据库', create: '创建数据库',
noMysql: '数据库服务 (MySQL MariaDB)', noMysql: '数据库服务 (MySQL MariaDB)',
goUpgrade: '去应用列表升级',
goInstall: '去应用商店安装', goInstall: '去应用商店安装',
source: '来源', source: '来源',
permission: '权限', permission: '权限',

View File

@ -138,7 +138,7 @@
<el-tooltip :hide-after="20" :content="item.option" placement="top"> <el-tooltip :hide-after="20" :content="item.option" placement="top">
<el-option <el-option
:value="item.option" :value="item.option"
:label="item.option.substring(0, 12)" :label="item.option.substring(0, 30)"
/> />
</el-tooltip> </el-tooltip>
</div> </div>

View File

@ -125,7 +125,7 @@
<el-select class="selectClass" clearable v-model="dialogData.rowData!.appID"> <el-select class="selectClass" clearable v-model="dialogData.rowData!.appID">
<el-option :label="$t('commons.table.all')" value="all" /> <el-option :label="$t('commons.table.all')" value="all" />
<div v-for="item in appOptions" :key="item.id"> <div v-for="item in appOptions" :key="item.id">
<el-option :value="item.id + ''"> <el-option :value="item.id + ''" :label="item.name">
<span>{{ item.name }}</span> <span>{{ item.name }}</span>
<el-tag class="tagClass"> <el-tag class="tagClass">
{{ item.key }} {{ item.key }}
@ -140,13 +140,18 @@
<el-form-item :label="$t('cronjob.database')" prop="dbName"> <el-form-item :label="$t('cronjob.database')" prop="dbName">
<el-select class="selectClass" clearable v-model="dialogData.rowData!.dbName"> <el-select class="selectClass" clearable v-model="dialogData.rowData!.dbName">
<el-option :label="$t('commons.table.all')" value="all" /> <el-option :label="$t('commons.table.all')" value="all" />
<el-option v-for="item in mysqlInfo.dbs" :key="item.id" :value="item.id + ''"> <el-option
v-for="item in mysqlInfo.dbs"
:key="item.id"
:value="item.id + ''"
:label="item.name"
>
<span>{{ item.name }}</span> <span>{{ item.name }}</span>
<el-tag class="tagClass"> <el-tag class="tagClass">
{{ item.from === 'local' ? $t('database.local') : $t('database.remote') }} {{ item.from === 'local' ? $t('database.local') : $t('database.remote') }}
</el-tag> </el-tag>
<el-tag class="tagClass"> <el-tag class="tagClass">
{{ item.database }} {{ item.type === 'mysql' ? 'MySQL' : 'MariaDB' }}
</el-tag> </el-tag>
</el-option> </el-option>
</el-select> </el-select>

View File

@ -27,8 +27,11 @@
<template #prefix>{{ $t('commons.table.type') }}</template> <template #prefix>{{ $t('commons.table.type') }}</template>
<el-option-group :label="$t('database.local')"> <el-option-group :label="$t('database.local')">
<div v-for="(item, index) in dbOptionsLocal" :key="index"> <div v-for="(item, index) in dbOptionsLocal" :key="index">
<el-option v-if="item.from === 'local'" :value="item.database"> <el-option v-if="item.from === 'local'" :value="item.database" class="optionClass">
<span>{{ item.database }}</span> <span v-if="item.database.length < 25">{{ item.database }}</span>
<el-tooltip v-else :content="item.database" placement="top">
<span>{{ item.database.substring(0, 25) }}...</span>
</el-tooltip>
<el-tag class="tagClass"> <el-tag class="tagClass">
{{ item.type === 'mysql' ? 'MySQL' : 'MariaDB' }} {{ item.type === 'mysql' ? 'MySQL' : 'MariaDB' }}
</el-tag> </el-tag>
@ -40,8 +43,11 @@
</el-option-group> </el-option-group>
<el-option-group :label="$t('database.remote')"> <el-option-group :label="$t('database.remote')">
<div v-for="(item, index) in dbOptionsRemote" :key="index"> <div v-for="(item, index) in dbOptionsRemote" :key="index">
<el-option v-if="item.from === 'remote'" :value="item.database"> <el-option v-if="item.from === 'remote'" :value="item.database" class="optionClass">
<span>{{ item.database }}</span> <span v-if="item.database.length < 25">{{ item.database }}</span>
<el-tooltip v-else :content="item.database" placement="top">
<span>{{ item.database.substring(0, 25) }}...</span>
</el-tooltip>
<el-tag class="tagClass"> <el-tag class="tagClass">
{{ item.type === 'mysql' ? 'MySQL' : 'MariaDB' }} {{ item.type === 'mysql' ? 'MySQL' : 'MariaDB' }}
</el-tag> </el-tag>
@ -573,4 +579,7 @@ onMounted(() => {
font-size: 12px; font-size: 12px;
margin-top: 5px; margin-top: 5px;
} }
.optionClass {
min-width: 350px;
}
</style> </style>

View File

@ -116,6 +116,25 @@
</template> </template>
</LayoutContent> </LayoutContent>
<el-dialog
v-model="upgradeVisiable"
:title="$t('app.checkTitle')"
width="30%"
:close-on-click-modal="false"
:destroy-on-close="true"
>
<el-alert :closable="false" :title="$t('database.confNotFound')" type="info">
<el-link icon="Position" @click="goUpgrade()" type="primary">
{{ $t('database.goUpgrade') }}
</el-link>
</el-alert>
<template #footer>
<span class="dialog-footer">
<el-button @click="upgradeVisiable = false">{{ $t('commons.button.cancel') }}</el-button>
</span>
</template>
</el-dialog>
<ConfirmDialog ref="confirmPortRef" @confirm="onSubmitChangePort"></ConfirmDialog> <ConfirmDialog ref="confirmPortRef" @confirm="onSubmitChangePort"></ConfirmDialog>
<ConfirmDialog ref="confirmConfRef" @confirm="onSubmitChangeConf"></ConfirmDialog> <ConfirmDialog ref="confirmConfRef" @confirm="onSubmitChangeConf"></ConfirmDialog>
</div> </div>
@ -136,7 +155,8 @@ import { loadDatabaseFile, loadMysqlBaseInfo, loadMysqlVariables, updateMysqlCon
import { ChangePort, CheckAppInstalled, GetAppDefaultConfig } from '@/api/modules/app'; import { ChangePort, CheckAppInstalled, GetAppDefaultConfig } from '@/api/modules/app';
import { Rules } from '@/global/form-rules'; import { Rules } from '@/global/form-rules';
import i18n from '@/lang'; import i18n from '@/lang';
import { MsgError, MsgSuccess } from '@/utils/message'; import { MsgSuccess } from '@/utils/message';
import router from '@/routers';
const loading = ref(false); const loading = ref(false);
@ -152,6 +172,7 @@ const baseInfo = reactive({
}); });
const panelFormRef = ref<FormInstance>(); const panelFormRef = ref<FormInstance>();
const mysqlConf = ref(); const mysqlConf = ref();
const upgradeVisiable = ref();
const useOld = ref(false); const useOld = ref(false);
@ -312,11 +333,15 @@ const loadMysqlConf = async () => {
mysqlConf.value = res.data; mysqlConf.value = res.data;
}) })
.catch(() => { .catch(() => {
MsgError(i18n.global.t('database.confNotFound')); upgradeVisiable.value = true;
loading.value = false; loading.value = false;
}); });
}; };
const goUpgrade = () => {
router.push({ name: 'AppUpgrade' });
};
const onLoadInfo = async () => { const onLoadInfo = async () => {
await CheckAppInstalled(props.type, props.database).then((res) => { await CheckAppInstalled(props.type, props.database).then((res) => {
mysqlName.value = res.data.name; mysqlName.value = res.data.name;

View File

@ -62,7 +62,9 @@
</el-alert> </el-alert>
<el-alert :type="loadStatus(status.compress)" :closable="false"> <el-alert :type="loadStatus(status.compress)" :closable="false">
<template #title> <template #title>
<el-button :icon="loadIcon(status.compress)" link>{{ $t('setting.compress') }}</el-button> <el-button :icon="loadIcon(status.compress)" link>
{{ $t('setting.compress') }} {{ status.size }}
</el-button>
<div v-if="showErrorMsg(status.compress)" class="top-margin"> <div v-if="showErrorMsg(status.compress)" class="top-margin">
<span class="err-message">{{ status.compress }}</span> <span class="err-message">{{ status.compress }}</span>
</div> </div>
@ -71,7 +73,7 @@
<el-alert :type="loadStatus(status.upload)" :closable="false"> <el-alert :type="loadStatus(status.upload)" :closable="false">
<template #title> <template #title>
<el-button :icon="loadIcon(status.upload)" link> <el-button :icon="loadIcon(status.upload)" link>
{{ $t('setting.upload') }} {{ status.size }} {{ $t('setting.upload') }}
</el-button> </el-button>
<div v-if="showErrorMsg(status.upload)" class="top-margin"> <div v-if="showErrorMsg(status.upload)" class="top-margin">
<span class="err-message">{{ status.upload }}</span> <span class="err-message">{{ status.upload }}</span>
@ -187,6 +189,7 @@ const onWatch = () => {
status.backupData = res.data.backupData; status.backupData = res.data.backupData;
status.compress = res.data.compress; status.compress = res.data.compress;
status.size = res.data.size;
status.upload = res.data.upload; status.upload = res.data.upload;
} }
}, 1000 * 3); }, 1000 * 3);