feat: ldap一键导入及设置用户组织

This commit is contained in:
feng626
2022-04-01 15:34:07 +08:00
committed by Jiangjie.Bai
parent 357b67ffe0
commit 31bb679a8e
4 changed files with 34 additions and 1 deletions

View File

@@ -320,6 +320,7 @@
"Export": "Export",
"Import": "Import",
"ContinueImport": "ContinueImport",
"ImportAll": "Import All",
"Continue": "Continue",
"Stop": "Stop",
"Finished": "Finished",

View File

@@ -332,6 +332,7 @@
"Export": "エクスポート",
"Import": "インポート",
"ContinueImport": "インポートを続ける",
"ImportAll": "すべてインポート",
"Continue": "続ける",
"Stop": "停止",
"Finished": "完了",

View File

@@ -333,6 +333,7 @@
"Export": "导出",
"Import": "导入",
"ContinueImport": "继续导入",
"ImportAll": "导入全部",
"Continue": "继续",
"Stop": "停止",
"Finished": "完成",

View File

@@ -18,6 +18,7 @@
<div slot="footer">
<el-button @click="hiddenDialog">{{ $t('common.Cancel') }}</el-button>
<el-button type="primary" :loading="dialogLdapUserImportLoginStatus" @click="importUserClick">{{ $t('common.Import') }}</el-button>
<el-button type="primary" :loading="dialogLdapUserImportAllLoginStatus" @click="importAllUserClick">{{ $t('common.ImportAll') }}</el-button>
</div>
</Dialog>
<Dialog
@@ -41,8 +42,10 @@
import ListTable from '@/components/ListTable'
import { GenericCreateUpdateForm } from '@/layout/components'
import Dialog from '@/components/Dialog'
import Select2 from '@/components/FormFields/Select2'
import { importLdapUser, refreshLdapUserCache, startLdapUserCache } from '@/api/settings'
import { CronTab } from '@/components'
import { Required } from '@/components/DataForm/rules'
export default {
name: 'ImportDialog',
@@ -54,6 +57,7 @@ export default {
data() {
return {
dialogLdapUserImportLoginStatus: false,
dialogLdapUserImportAllLoginStatus: false,
refreshed: false,
headerActions: {
hasCreate: false,
@@ -105,8 +109,24 @@ export default {
settings: {
visible: false,
url: '/api/v1/settings/setting/?category=ldap',
fields: ['AUTH_LDAP_SYNC_IS_PERIODIC', 'AUTH_LDAP_SYNC_CRONTAB', 'AUTH_LDAP_SYNC_INTERVAL'],
fields: ['AUTH_LDAP_SYNC_ORG_ID', 'AUTH_LDAP_SYNC_IS_PERIODIC', 'AUTH_LDAP_SYNC_CRONTAB', 'AUTH_LDAP_SYNC_INTERVAL'],
fieldsMeta: {
AUTH_LDAP_SYNC_ORG_ID: {
component: Select2,
rules: [Required],
el: {
multiple: false,
ajax: {
url: '/api/v1/orgs/orgs/',
transformOption: (item) => {
return { label: item.name, value: item.id }
}
}
},
hidden: (formValue) => {
return !this.$hasLicense()
}
},
AUTH_LDAP_SYNC_IS_PERIODIC: {
type: 'switch'
},
@@ -142,6 +162,16 @@ export default {
}).finally(() => this.dialogLdapUserImportLoginStatus = false)
}
},
importAllUserClick() {
this.dialogLdapUserImportAllLoginStatus = true
const data = {
username_list: ['*']
}
importLdapUser(data).then(res => {
this.$message.success(res.msg)
// eslint-disable-next-line no-return-assign
}).finally(() => this.dialogLdapUserImportAllLoginStatus = false)
},
handlerListTableXHRError(errMsg) {
if (this.dialogLdapUserImport) {
setTimeout(this.$refs.listTable.reloadTable, 30000)