fix: 数据库获取时,忽略重名数据库 (#1906)

pull/1911/head v1.5.0
ssongliu 2023-08-10 14:06:13 +08:00 committed by GitHub
parent 278a562320
commit 39d8b0d98c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 11 additions and 11 deletions

View File

@ -6,8 +6,8 @@ type ImageRepoCreate struct {
Name string `json:"name" validate:"required"`
DownloadUrl string `json:"downloadUrl"`
Protocol string `json:"protocol"`
Username string `json:"username"`
Password string `json:"password"`
Username string `json:"username" validate:"max=256"`
Password string `json:"password" validate:"max=256"`
Auth bool `json:"auth"`
}

View File

@ -30,7 +30,7 @@ type RemoteDBOption struct {
}
type RemoteDBCreate struct {
Name string `json:"name" validate:"required"`
Name string `json:"name" validate:"required,max=256"`
Type string `json:"type" validate:"required,oneof=mysql"`
From string `json:"from" validate:"required,oneof=local remote"`
Version string `json:"version" validate:"required"`

View File

@ -163,7 +163,7 @@ func (u *MysqlService) LoadFromRemote(from string) error {
for _, data := range datas {
hasOld := false
for _, oldData := range databases {
if oldData.Name == data.Name {
if strings.EqualFold(oldData.Name, data.Name) {
hasOld = true
break
}

View File

@ -137,7 +137,7 @@ const checkDBName = (rule: any, value: any, callback: any) => {
if (value === '' || typeof value === 'undefined' || value == null) {
callback(new Error(i18n.global.t('commons.rule.dbName')));
} else {
const reg = /^[a-z0-9\u4e00-\u9fa5]{1}[a-z0-9_.\u4e00-\u9fa5-]{0,64}$/;
const reg = /^[a-zA-Z0-9\u4e00-\u9fa5]{1}[a-zA-Z0-9_.\u4e00-\u9fa5-]{0,64}$/;
if (!reg.test(value) && value !== '') {
callback(new Error(i18n.global.t('commons.rule.dbName')));
} else {

View File

@ -154,7 +154,7 @@ const message = {
commonName: 'Support English, Chinese, numbers, .-, and _ length 1-30',
userName: 'Support English, Chinese, numbers and _ length 3-30',
simpleName: 'Support English, numbers and _ length 1-30',
dbName: 'Support lowercase letters, Chinese, numbers, .-, and _ length 1-64',
dbName: 'Support English, Chinese, numbers, .-, and _ length 1-64',
imageName: 'Support English, numbers, :/.-_, length 1-150',
volumeName: 'Support English, numbers, .-_, length 2-30',
complexityPassword:

View File

@ -155,7 +155,7 @@ const message = {
commonName: '.-_,1-30',
userName: '_,3-30',
simpleName: '_,1-30',
dbName: '.-_,1-64',
dbName: '.-_,1-64',
imageName: ':/.-_,1-150',
volumeName: '.-_,2-30',
complexityPassword: ' 8 ',

View File

@ -155,7 +155,7 @@ const message = {
commonName: '.-_,1-30',
userName: '_,3-30',
simpleName: '_,1-30',
dbName: '.-_,1-64',
dbName: '.-_,1-64',
imageName: ':/.-_,1-150',
volumeName: '.-_,2-30',
complexityPassword: ' 8 ',

View File

@ -173,7 +173,7 @@ const buttons = [
{
label: i18n.global.t('commons.button.sync'),
disabled: (row: Container.RepoInfo) => {
return row.downloadUrl === 'docker.io';
return row.id === 1;
},
click: (row: Container.RepoInfo) => {
onCheckConn(row);
@ -182,7 +182,7 @@ const buttons = [
{
label: i18n.global.t('commons.button.edit'),
disabled: (row: Container.RepoInfo) => {
return row.downloadUrl === 'docker.io';
return row.id === 1;
},
click: (row: Container.RepoInfo) => {
onOpenDialog('edit', row);
@ -191,7 +191,7 @@ const buttons = [
{
label: i18n.global.t('commons.button.delete'),
disabled: (row: Container.RepoInfo) => {
return row.downloadUrl === 'docker.io';
return row.id === 1;
},
click: (row: Container.RepoInfo) => {
onDelete(row);