Merge pull request #815 from jumpserver/dev

v2.10.0 rc4
This commit is contained in:
Jiangjie.Bai
2021-05-19 19:29:38 +08:00
committed by GitHub
14 changed files with 76 additions and 42 deletions

View File

@@ -58,6 +58,10 @@ export default {
minColumns: {
type: Array,
default: () => []
},
url: {
type: String,
default: ''
}
},
data() {
@@ -67,15 +71,17 @@ export default {
}
},
mounted() {
this.$eventBus.$on('showColumnSettingPopover', () => {
this.showColumnSettingPopover = true
this.iCurrentColumns = this.currentColumns
this.$eventBus.$on('showColumnSettingPopover', ({ url }) => {
if (url === this.url) {
this.showColumnSettingPopover = true
this.iCurrentColumns = this.currentColumns
}
})
},
methods: {
handleColumnConfirm() {
this.showColumnSettingPopover = false
this.$emit('columnsUpdate', this.iCurrentColumns)
this.$emit('columnsUpdate', { columns: this.iCurrentColumns, url: this.url })
}
}
}

View File

@@ -5,6 +5,7 @@
:current-columns="popoverColumns.currentCols"
:total-columns-list="popoverColumns.totalColumnsList"
:min-columns="popoverColumns.minCols"
:url="config.url"
@columnsUpdate="handlePopoverColumnsChange"
/>
</div>
@@ -15,6 +16,7 @@ import DataTable from '../DataTable'
import { DateFormatter, DetailFormatter, DisplayFormatter, BooleanFormatter, ActionsFormatter } from '@/components/TableFormatters'
import i18n from '@/i18n/i18n'
import ColumnSettingPopover from './components/ColumnSettingPopover'
import { newURL } from '@/utils/common'
export default {
name: 'AutoDataTable',
components: {
@@ -228,7 +230,7 @@ export default {
const _tableConfig = localStorage.getItem('tableConfig')
? JSON.parse(localStorage.getItem('tableConfig'))
: {}
const tableName = this.config.name || this.$route.name
const tableName = this.config.name || this.$route.name + '_' + newURL(this.iConfig.url).pathname
const configShowColumnsNames = _.get(_tableConfig[tableName], 'showColumns', null)
let showColumnsNames = configShowColumnsNames || defaultColumnsNames
if (showColumnsNames.length === 0) {
@@ -249,7 +251,7 @@ export default {
min: minColumnsNames,
configShow: configShowColumnsNames
}
this.$log.debug('Cleaned colums show: ', this.cleanedColumnsShow)
this.$log.debug('Cleaned columns show: ', this.cleanedColumnsShow)
},
filterShowColumns() {
this.cleanColumnsShow()
@@ -265,13 +267,13 @@ export default {
this.popoverColumns.minCols = this.cleanedColumnsShow.min
this.$log.debug('Popover cols: ', this.popoverColumns)
},
handlePopoverColumnsChange(columns) {
// this.$log.debug('Columns change: ', columns)
handlePopoverColumnsChange({ columns, url }) {
this.$log.debug('Columns change: ', columns)
this.popoverColumns.currentCols = columns
const _tableConfig = localStorage.getItem('tableConfig')
? JSON.parse(localStorage.getItem('tableConfig'))
: {}
const tableName = this.config.name || this.$route.name
const tableName = this.config.name || this.$route.name + '_' + newURL(url).pathname
_tableConfig[tableName] = {
'showColumns': columns
}

View File

@@ -115,8 +115,10 @@ export default {
}
},
mounted() {
this.$eventBus.$on('showExportDialog', (row) => {
this.showExportDialog = true
this.$eventBus.$on('showExportDialog', ({ selectedRows, url }) => {
if (url === this.url) {
this.showExportDialog = true
}
})
},
methods: {

View File

@@ -7,7 +7,6 @@
:loading-status="loadStatus"
width="80%"
class="importDialog"
:confirm-title="confirmTitle"
:show-cancel="false"
:show-confirm="false"
@close="handleImportCancel"
@@ -118,9 +117,6 @@ export default {
} else {
return this.$t('common.Import') + this.$t('common.Update')
}
},
confirmTitle() {
return '导入'
}
},
watch: {
@@ -129,8 +125,10 @@ export default {
}
},
mounted() {
this.$eventBus.$on('showImportDialog', (row) => {
this.showImportDialog = true
this.$eventBus.$on('showImportDialog', ({ url }) => {
if (url === this.url) {
this.showImportDialog = true
}
})
},
methods: {

View File

@@ -1,6 +1,6 @@
<template>
<div>
<ActionsGroup :is-fa="true" :actions="rightSideActions" class="right-side-actions right-side-item" />
<ActionsGroup :is-fa="true" :actions="rightSideActions" :url="tableUrl" class="right-side-actions right-side-item" />
<ImExportDialog :selected-rows="selectedRows" :url="tableUrl" v-bind="$attrs" />
</div>
</template>
@@ -27,21 +27,21 @@ export default {
handleExport: {
type: Function,
default: function({ selectedRows }) {
this.$eventBus.$emit('showExportDialog', { selectedRows })
this.$eventBus.$emit('showExportDialog', { selectedRows, url: this.tableUrl })
}
},
hasImport: defaultTrue,
handleImport: {
type: Function,
default: function({ selectedRows }) {
this.$eventBus.$emit('showImportDialog', { selectedRows })
this.$eventBus.$emit('showImportDialog', { selectedRows, url: this.tableUrl })
}
},
hasColumnSetting: defaultTrue,
handleColumnConfig: {
type: Function,
default: function() {
this.$eventBus.$emit('showColumnSettingPopover')
default: function({ selectedRows }) {
this.$eventBus.$emit('showColumnSettingPopover', { url: this.tableUrl })
}
},
hasRefresh: defaultTrue,

View File

@@ -16,6 +16,7 @@
import GenericCreateUpdateForm from '@/layout/components/GenericCreateUpdateForm'
import UserPassword from '@/components/FormFields/UserPassword'
import { IBox } from '@/components'
import rules from '@/components/DataForm/rules'
export default {
name: 'PasswordUpdate',
@@ -42,8 +43,8 @@ export default {
},
new_password: {
label: this.$t('users.NewPassword'),
component: UserPassword,
rules: []
rules: [rules.RequiredChange],
component: UserPassword
},
new_password_again: {
label: this.$t('users.ConfirmPassword'),

View File

@@ -206,6 +206,16 @@ function customizer(objValue, srcValue) {
return _.isUndefined(objValue) ? srcValue : objValue
}
export function newURL(url) {
let obj
if (url.indexOf('//') > -1) {
obj = new URL(url)
} else {
obj = new URL(url, 'http://localhost')
}
return obj
}
export const assignIfNot = _.partialRight(_.assignInWith, customizer)
const scheme = document.location.protocol

View File

@@ -36,6 +36,8 @@ function getFields() {
if (form.username_same_with_user) {
this.fieldsMeta.username.el.disabled = true
form.username = ''
} else {
this.fieldsMeta.username.el.disabled = false
}
}
}

View File

@@ -53,21 +53,23 @@ export default {
return `${url}?type=${commandType}`
},
url: '/api/v1/terminal/command-storages/'
}
},
computed: {
},
methods: {
afterGetFormValue(validValues) {
if (!validValues?.meta?.HOSTS) {
return validValues
}
validValues.meta.HOSTS = validValues.meta.HOSTS.toString()
return validValues
},
performSubmit(validValues) {
const method = this.getMethod()
validValues.meta.HOSTS = validValues.meta.HOSTS.split(',').map(item => (item.trim()))
return this.$axios[method](`${this.getUrl()}`, validValues)
const url = this.getUrl()
return this.$axios[method](url, validValues)
},
getMethod() {
const params = this.$route.params

View File

@@ -7,6 +7,7 @@
:fields-meta="fieldsMeta"
:more-buttons="moreButtons"
:has-detail-in-msg="false"
:clean-form-value="cleanFormValue"
/>
</IBox>
</template>
@@ -56,6 +57,13 @@ export default {
methods: {
getMethod() {
return 'put'
},
// 不清理的话编辑secret在删除提交会报错
cleanFormValue(data) {
if (!data['DINGTALK_APPSECRET']) {
delete data['DINGTALK_APPSECRET']
}
return data
}
}
}

View File

@@ -3,7 +3,7 @@
<GenericCreateUpdateForm
:fields="fields"
:url="url"
:perform-submit="performSubmit"
:clean-form-value="cleanFormValue"
:get-method="getMethod"
:fields-meta="fieldsMeta"
:more-buttons="moreButtons"
@@ -94,18 +94,13 @@ export default {
getMethod() {
return 'put'
},
performSubmit(validValues) {
Object.keys(validValues).forEach(
function(key) {
if (validValues[key] === null) {
delete validValues[key]
}
}
)
return this.$axios['put'](`/api/v1/settings/setting/?category=email`, validValues)
// 不清理的话编辑secret在删除提交会报错
cleanFormValue(data) {
if (!data['EMAIL_HOST_PASSWORD']) {
delete data['EMAIL_HOST_PASSWORD']
}
return data
}
}
}

View File

@@ -108,7 +108,7 @@ export default {
}
},
hiddenDialog() {
this.$emit('update:show', false)
this.$emit('update:visible', false)
}
}
}

View File

@@ -7,6 +7,7 @@
:fields-meta="fieldsMeta"
:more-buttons="moreButtons"
:has-detail-in-msg="false"
:clean-form-value="cleanFormValue"
/>
</IBox>
</template>
@@ -56,6 +57,13 @@ export default {
methods: {
getMethod() {
return 'put'
},
// 不清理的话编辑secret在删除提交会报错
cleanFormValue(data) {
if (!data['WECOM_SECRET']) {
delete data['WECOM_SECRET']
}
return data
}
}
}

View File

@@ -40,8 +40,8 @@ export default {
}
}
},
updateSuccessNextRoute: { name: 'AccountList' },
createSuccessNextRoute: { name: 'AccountList' },
updateSuccessNextRoute: { name: 'CloudCenter', params: { activeMenu: 'AccountList' }},
createSuccessNextRoute: { name: 'CloudCenter', params: { activeMenu: 'AccountList' }},
getUrl() {
const params = this.$route.params
let url = `/api/v1/xpack/cloud/accounts/`