fix(settings): 修复ldap提交时,json报错 (#836)

* perf: 修改命令存储创建

* fix(settings): 修复ldap提交时,json报错

Co-authored-by: ibuler <ibuler@qq.com>
This commit is contained in:
fit2bot
2021-06-10 19:05:08 +08:00
committed by GitHub
parent c15f22e05b
commit ee53941fb0
4 changed files with 21 additions and 4 deletions

View File

@@ -19,3 +19,16 @@ export default {
RequiredChange,
EmailCheck
}
export const JsonRequired = {
required: true,
trigger: 'change',
validator: (rule, value, callback) => {
try {
JSON.parse(value)
callback()
} catch (e) {
callback(new Error(i18n.t('common.InvalidJson')))
}
}
}

View File

@@ -385,7 +385,8 @@
"SPECIAL_CHAR_REQUIRED": "须包含特殊字符",
"MIN_LENGTH_ERROR": "密码最小长度 {0} 位"
},
"lastCannotBeDeleteMsg": "最后一项,不能被删除"
"lastCannotBeDeleteMsg": "最后一项,不能被删除",
"InvalidJson": "不是合法 JSON"
},
"dashboard": {
"ActiveAsset": "近期被登录过",

View File

@@ -383,7 +383,8 @@
"SPECIAL_CHAR_REQUIRED": "Special char required",
"MIN_LENGTH_ERROR": "Password minimum length {}"
},
"lastCannotBeDeleteMsg": "The last one can't be delete"
"lastCannotBeDeleteMsg": "The last one can't be delete",
"InvalidJson": "Not a valid json format"
},
"dashboard": {
"ActiveAsset": "Asset active",

View File

@@ -20,6 +20,7 @@ import { testLdapSetting } from '@/api/settings'
import ImportDialog from './ImportDialog'
import TestLoginDialog from './TestLoginDialog'
import { IBox } from '@/components'
import { JsonRequired } from '@/components/DataForm/rules'
export default {
name: 'Ldap',
@@ -61,7 +62,8 @@ export default {
el: {
type: 'textarea'
},
label: this.$t('setting.authLdapUserAttrMap')
label: this.$t('setting.authLdapUserAttrMap'),
rules: [JsonRequired]
}
},
url: '/api/v1/settings/setting/?category=ldap',
@@ -121,7 +123,7 @@ export default {
<style scoped>
.listTable ::v-deep .table-action-right-side{
padding-top: 0px !important;
padding-top: 0 !important;
}
</style>