Merge pull request #986 from jumpserver/dev

v2.13.0
This commit is contained in:
Jiangjie.Bai 2021-08-19 18:53:13 +08:00 committed by GitHub
commit f85d3567a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 84 additions and 23 deletions

View File

@ -57,7 +57,7 @@ export default {
formatter: DetailFormatter, formatter: DetailFormatter,
formatterArgs: { formatterArgs: {
getRoute({ row }) { getRoute({ row }) {
switch (row['app_category']) { switch (row['category']) {
case 'remote_app': case 'remote_app':
return { return {
name: 'RemoteAppDetail', name: 'RemoteAppDetail',

View File

@ -60,8 +60,8 @@ export default {
}, },
performExport: { performExport: {
type: Function, type: Function,
default(selectedRows, exportOptions, query) { default(selectedRows, exportOptions, query, exportType) {
return this.defaultPerformExport(selectedRows, exportOptions, query) return this.defaultPerformExport(selectedRows, exportOptions, query, exportType)
} }
}, },
canExportAll: { canExportAll: {
@ -143,7 +143,7 @@ export default {
mounted() { mounted() {
this.$eventBus.$on('showExportDialog', ({ selectedRows, url, name }) => { this.$eventBus.$on('showExportDialog', ({ selectedRows, url, name }) => {
// Todo: // Todo:
if (url === this.url || url.indexOf('account') > -1) { if (url === this.url || url.indexOf(this.url) > -1 || url.indexOf('account') > -1) {
this.showExportDialog() this.showExportDialog()
} }
}) })
@ -167,7 +167,7 @@ export default {
a.click() a.click()
window.URL.revokeObjectURL(url) window.URL.revokeObjectURL(url)
}, },
async defaultPerformExport(selectRows, exportOption, q) { async defaultPerformExport(selectRows, exportOption, q, exportTypeOption) {
const url = (process.env.VUE_APP_ENV === 'production') ? (`${this.url}`) : (`${process.env.VUE_APP_BASE_API}${this.url}`) const url = (process.env.VUE_APP_ENV === 'production') ? (`${this.url}`) : (`${process.env.VUE_APP_BASE_API}${this.url}`)
const query = Object.assign({}, q) const query = Object.assign({}, q)
if (exportOption === 'selected') { if (exportOption === 'selected') {
@ -179,7 +179,7 @@ export default {
const spm = await createSourceIdCache(resources) const spm = await createSourceIdCache(resources)
query['spm'] = spm.spm query['spm'] = spm.spm
} }
query['format'] = this.exportTypeOption query['format'] = exportTypeOption
const queryStr = const queryStr =
(url.indexOf('?') > -1 ? '&' : '?') + (url.indexOf('?') > -1 ? '&' : '?') +
queryUtil.stringify(query, '=', '&') queryUtil.stringify(query, '=', '&')
@ -187,11 +187,11 @@ export default {
}, },
async handleExport() { async handleExport() {
const listTableRef = this.$parent.$parent.$parent.$parent const listTableRef = this.$parent.$parent.$parent.$parent
const query = listTableRef.dataTable.getQuery() const query = listTableRef['dataTable'].getQuery()
delete query['limit'] delete query['limit']
delete query['offset'] delete query['offset']
await this.beforeExport() await this.beforeExport()
return this.performExport(this.selectedRows, this.exportOption, query) return this.performExport(this.selectedRows, this.exportOption, query, this.exportTypeOption)
}, },
async handleExportConfirm() { async handleExportConfirm() {
await this.handleExport() await this.handleExport()

View File

@ -1,8 +1,21 @@
<template> <template>
<div> <div>
<TableAction :table-url="iTableConfig.url" :search-table="search" :date-pick="handleDateChange" v-bind="headerActions" :selected-rows="selectedRows" :reload-table="reloadTable" /> <TableAction
:table-url="tableUrl"
:search-table="search"
:date-pick="handleDateChange"
:selected-rows="selectedRows"
:reload-table="reloadTable"
v-bind="headerActions"
/>
<IBox class="table-content"> <IBox class="table-content">
<AutoDataTable ref="dataTable" :filter-table="filter" :config="iTableConfig" @selection-change="handleSelectionChange" v-on="$listeners" /> <AutoDataTable
ref="dataTable"
:filter-table="filter"
:config="iTableConfig"
@selection-change="handleSelectionChange"
v-on="$listeners"
/>
</IBox> </IBox>
</div> </div>
</template> </template>
@ -50,6 +63,9 @@ export default {
this.$log.debug('Header actions', this.headerActions) this.$log.debug('Header actions', this.headerActions)
this.$log.debug('ListTable: iTableConfig change', config) this.$log.debug('ListTable: iTableConfig change', config)
return config return config
},
tableUrl() {
return this.iTableConfig.url
} }
}, },
watch: { watch: {

View File

@ -77,9 +77,9 @@ export default {
} }
}, },
methods: { methods: {
handleUrlChange(_url) { handleUrlChange(url) {
this.$set(this.iTableConfig, 'url', _url) this.$set(this.iTableConfig, 'url', url)
this.$emit('urlChange', _url) this.$emit('urlChange', url)
this.forceRerender() this.forceRerender()
}, },
forceRerender() { forceRerender() {

View File

@ -175,8 +175,12 @@ export default {
}, },
defaultUpdate() { defaultUpdate() {
const id = this.$route.params.id const id = this.$route.params.id
const routeName = this.validActions.updateRoute let route = this.validActions.updateRoute
this.$router.push({ name: routeName, params: { id: id }}) if (typeof route === 'string') {
route = { name: route, params: {}}
}
route.params.id = id
this.$router.push(route)
}, },
getObject() { getObject() {
const url = this.validActions.detailApiUrl const url = this.validActions.detailApiUrl

View File

@ -1,7 +1,7 @@
<template> <template>
<GenericDetailPage :object.sync="RemoteAppPermission" :active-menu.sync="config.activeMenu" v-bind="config" v-on="$listeners" @tab-click="TabClick"> <GenericDetailPage :object.sync="app" :active-menu.sync="config.activeMenu" v-bind="config" v-on="$listeners" @tab-click="TabClick">
<keep-alive> <keep-alive>
<component :is="config.activeMenu" :object="RemoteAppPermission" /> <component :is="config.activeMenu" :object="app" />
</keep-alive> </keep-alive>
</GenericDetailPage> </GenericDetailPage>
</template> </template>
@ -22,7 +22,7 @@ export default {
}, },
data() { data() {
return { return {
RemoteAppPermission: {}, app: { type: '', category: '', id: '' },
config: { config: {
activeMenu: 'ApplicationPermissionDetail', activeMenu: 'ApplicationPermissionDetail',
submenu: [ submenu: [
@ -41,7 +41,20 @@ export default {
], ],
actions: { actions: {
detailApiUrl: `/api/v1/perms/application-permissions/${this.$route.params.id}/`, detailApiUrl: `/api/v1/perms/application-permissions/${this.$route.params.id}/`,
deleteApiUrl: `/api/v1/perms/application-permissions/${this.$route.params.id}/` deleteApiUrl: `/api/v1/perms/application-permissions/${this.$route.params.id}/`,
updateCallback: () => {
const route = {
name: 'ApplicationPermissionUpdate',
query: {
type: this.app.type,
category: this.app.category
},
params: {
id: this.app.id
}
}
this.$router.push(route)
}
} }
} }
} }

View File

@ -21,6 +21,7 @@ import { DetailFormatter } from '@/components/TableFormatters'
import isFalsey from '@/components/DataTable/compenents/el-data-table/utils/is-falsey' import isFalsey from '@/components/DataTable/compenents/el-data-table/utils/is-falsey'
import deepmerge from 'deepmerge' import deepmerge from 'deepmerge'
import * as queryUtil from '@/components/DataTable/compenents/el-data-table/utils/query' import * as queryUtil from '@/components/DataTable/compenents/el-data-table/utils/query'
import { createSourceIdCache } from '@/api/common'
export default { export default {
components: { components: {
@ -66,7 +67,7 @@ export default {
label: this.$t('sessions.riskLevel'), label: this.$t('sessions.riskLevel'),
width: '105px', width: '105px',
formatter: (row, col, cellValue) => { formatter: (row, col, cellValue) => {
const display = row.risk_level_display const display = row['risk_level_display']
if (cellValue === 0) { if (cellValue === 0) {
return display return display
} else { } else {
@ -117,6 +118,33 @@ export default {
hasImport: false, hasImport: false,
hasDatePicker: true, hasDatePicker: true,
canExportSelected: true, canExportSelected: true,
exportOptions: {
// Todo:
performExport: async(selectRows, exportOption, q, exportTypeOption) => {
let url = this.tableConfig.url
url = (process.env.VUE_APP_ENV === 'production') ? (`${url}`) : (`${process.env.VUE_APP_BASE_API}${url}`)
const query = Object.assign({}, q)
if (exportOption === 'selected') {
const resources = []
const data = selectRows
for (let index = 0; index < data.length; index++) {
resources.push(data[index].id)
}
const spm = await createSourceIdCache(resources)
query['spm'] = spm.spm
}
query['format'] = exportTypeOption
const queryStr =
(url.indexOf('?') > -1 ? '&' : '?') +
queryUtil.stringify(query, '=', '&')
url = url + queryStr
this.$log.debug('Export url: ', this.url, '=>', url)
const a = document.createElement('a')
a.href = url
a.click()
window.URL.revokeObjectURL(url + queryStr)
}
},
datePicker: { datePicker: {
dateStart: dateFrom, dateStart: dateFrom,
dateEnd: dateTo dateEnd: dateTo
@ -138,7 +166,7 @@ export default {
} }
}, },
callback: { callback: {
onSelected: function(event, treeNode) { onSelected: (event, treeNode) => {
// //
if (treeNode.id === 'root') { if (treeNode.id === 'root') {
return return
@ -147,8 +175,8 @@ export default {
this.$message.error(this.$t('sessions.EsDisabled')) this.$message.error(this.$t('sessions.EsDisabled'))
return return
} }
this.tableConfig.url = `/api/v1/terminal/commands/?command_storage_id=${treeNode.id}` this.tableConfig.url = `/api/v1/terminal/commands/?command_storage_id=${treeNode.id}&order=-timestamp`
}.bind(this) }
} }
} }
} }