mirror of
https://github.com/jumpserver/lina.git
synced 2025-08-28 11:24:25 +00:00
feat: 重构操作日志 (#2088)
* feat: 操作日志重构-支持查看变更资源信息 * feat: 修改界面 * feat: 优化操作日志详情界面 * feat: 修改显示样式
This commit is contained in:
parent
784bd16e87
commit
9d6ac3907a
61
src/components/TableFormatters/TwoTabFormatter.vue
Normal file
61
src/components/TableFormatters/TwoTabFormatter.vue
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<template>
|
||||||
|
<el-row :gutter="10">
|
||||||
|
<div v-if="isAllEmpty()" style="text-align: center">
|
||||||
|
{{ this.$t('common.NoContent') }}
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<el-col :span="rightEmpty() ? 24 : 12">
|
||||||
|
<div v-if="!leftEmpty()">
|
||||||
|
<el-alert type="info" effect="dark" :closable="false" style="width: 100%;">{{ row.leftTitle }}</el-alert>
|
||||||
|
<div v-for="(value, key, index) in row.left" :key="index" class="text item">
|
||||||
|
<el-tag type="info" :hit="true"><strong>{{ key }}: </strong>>{{ value }}</el-tag>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="leftEmpty() ? 24 : 12">
|
||||||
|
<div v-if="!rightEmpty()">
|
||||||
|
<el-alert type="success" effect="dark" :closable="false" style="width: 100%;">{{ row.rightTitle }}</el-alert>
|
||||||
|
<div v-for="(value, key, index) in row.right" :key="index">
|
||||||
|
<el-tag type="info" :hit="true"><strong>{{ key }}: </strong>{{ value }}</el-tag>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-col>
|
||||||
|
</div>
|
||||||
|
</el-row>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'TwoTabFormatter',
|
||||||
|
props: {
|
||||||
|
row: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
isEmpty(content) {
|
||||||
|
return !content || JSON.stringify(content) === '{}'
|
||||||
|
},
|
||||||
|
leftEmpty() {
|
||||||
|
return this.isEmpty(this.row.left)
|
||||||
|
},
|
||||||
|
rightEmpty() {
|
||||||
|
return this.isEmpty(this.row.right)
|
||||||
|
},
|
||||||
|
isAllEmpty() {
|
||||||
|
return this.leftEmpty() && this.rightEmpty()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.el-tag{
|
||||||
|
width: 100%;
|
||||||
|
white-space: normal;
|
||||||
|
height:auto;
|
||||||
|
}
|
||||||
|
</style>
|
@ -12,6 +12,7 @@ import DialogDetailFormatter from './DialogDetailFormatter'
|
|||||||
import EditableInputFormatter from './EditableInputFormatter'
|
import EditableInputFormatter from './EditableInputFormatter'
|
||||||
import StatusFormatter from './StatusFormatter'
|
import StatusFormatter from './StatusFormatter'
|
||||||
import TagsFormatter from './TagsFormatter'
|
import TagsFormatter from './TagsFormatter'
|
||||||
|
import TwoTabFormatter from './TwoTabFormatter'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
DetailFormatter,
|
DetailFormatter,
|
||||||
@ -27,7 +28,8 @@ export default {
|
|||||||
ArrayFormatter,
|
ArrayFormatter,
|
||||||
EditableInputFormatter,
|
EditableInputFormatter,
|
||||||
StatusFormatter,
|
StatusFormatter,
|
||||||
TagsFormatter
|
TagsFormatter,
|
||||||
|
TwoTabFormatter
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
@ -44,5 +46,6 @@ export {
|
|||||||
ArrayFormatter,
|
ArrayFormatter,
|
||||||
EditableInputFormatter,
|
EditableInputFormatter,
|
||||||
StatusFormatter,
|
StatusFormatter,
|
||||||
TagsFormatter
|
TagsFormatter,
|
||||||
|
TwoTabFormatter
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,9 @@
|
|||||||
"View": "View",
|
"View": "View",
|
||||||
"LoginIP": "Login IP",
|
"LoginIP": "Login IP",
|
||||||
"LoginCity": "Login city",
|
"LoginCity": "Login city",
|
||||||
"LoginDate": "Login date"
|
"LoginDate": "Login date",
|
||||||
|
"BeforeChange": "Before change",
|
||||||
|
"AfterChange": "After change"
|
||||||
},
|
},
|
||||||
"auth": {
|
"auth": {
|
||||||
"LoginRequiredMsg": "You account has logout, Please login again",
|
"LoginRequiredMsg": "You account has logout, Please login again",
|
||||||
@ -255,6 +257,7 @@
|
|||||||
"ReLoginErr": "Login time has exceeded 5 minutes, please login again"
|
"ReLoginErr": "Login time has exceeded 5 minutes, please login again"
|
||||||
},
|
},
|
||||||
"common": {
|
"common": {
|
||||||
|
"NoContent": "No content",
|
||||||
"NeedAddAppsOrSystemUserErrMsg": "Please add apps or system user",
|
"NeedAddAppsOrSystemUserErrMsg": "Please add apps or system user",
|
||||||
"VerificationCodeSent": "The verification code has been sent",
|
"VerificationCodeSent": "The verification code has been sent",
|
||||||
"SendVerificationCode": "Send verification code",
|
"SendVerificationCode": "Send verification code",
|
||||||
|
@ -250,7 +250,9 @@
|
|||||||
"SystemUserName": "システムユーザー名",
|
"SystemUserName": "システムユーザー名",
|
||||||
"LoginIP": "ログインIP",
|
"LoginIP": "ログインIP",
|
||||||
"LoginCity": "ログイン都市",
|
"LoginCity": "ログイン都市",
|
||||||
"LoginDate": "ログイン日"
|
"LoginDate": "ログイン日",
|
||||||
|
"BeforeChange": "変更前",
|
||||||
|
"AfterChange": "変更後"
|
||||||
},
|
},
|
||||||
"auth": {
|
"auth": {
|
||||||
"LoginRequiredMsg": "アカウントが終了しました。ログインし直してください",
|
"LoginRequiredMsg": "アカウントが終了しました。ログインし直してください",
|
||||||
@ -260,6 +262,7 @@
|
|||||||
"ReLoginErr": "ログイン時間が 5 分を超えました。もう一度ログインしてください"
|
"ReLoginErr": "ログイン時間が 5 分を超えました。もう一度ログインしてください"
|
||||||
},
|
},
|
||||||
"common": {
|
"common": {
|
||||||
|
"NoContent": "まだ内容がない",
|
||||||
"NeedAddAppsOrSystemUserErrMsg": "アプリケーションまたはシステムユーザーを追加してください",
|
"NeedAddAppsOrSystemUserErrMsg": "アプリケーションまたはシステムユーザーを追加してください",
|
||||||
"VerificationCodeSent": "検証コードが送信されました",
|
"VerificationCodeSent": "検証コードが送信されました",
|
||||||
"SendVerificationCode": "認証コードの送信",
|
"SendVerificationCode": "認証コードの送信",
|
||||||
|
@ -250,7 +250,9 @@
|
|||||||
"SystemUserName": "系统用户名",
|
"SystemUserName": "系统用户名",
|
||||||
"LoginIP": "登录IP",
|
"LoginIP": "登录IP",
|
||||||
"LoginCity": "登录城市",
|
"LoginCity": "登录城市",
|
||||||
"LoginDate": "登录日期"
|
"LoginDate": "登录日期",
|
||||||
|
"BeforeChange": "变更前",
|
||||||
|
"AfterChange": "变更后"
|
||||||
},
|
},
|
||||||
"auth": {
|
"auth": {
|
||||||
"LoginRequiredMsg": "账号已退出,请重新登录",
|
"LoginRequiredMsg": "账号已退出,请重新登录",
|
||||||
@ -260,6 +262,7 @@
|
|||||||
"ReLoginErr": "登录时长已超过 5 分钟,请重新登录"
|
"ReLoginErr": "登录时长已超过 5 分钟,请重新登录"
|
||||||
},
|
},
|
||||||
"common": {
|
"common": {
|
||||||
|
"NoContent": "暂无内容",
|
||||||
"NeedAddAppsOrSystemUserErrMsg": "需要添加应用或系统用户",
|
"NeedAddAppsOrSystemUserErrMsg": "需要添加应用或系统用户",
|
||||||
"VerificationCodeSent": "验证码已发送",
|
"VerificationCodeSent": "验证码已发送",
|
||||||
"SendVerificationCode": "发送验证码",
|
"SendVerificationCode": "发送验证码",
|
||||||
|
@ -1,23 +1,43 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<div>
|
||||||
<GenericListPage :table-config="tableConfig" :header-actions="headerActions" />
|
<GenericListPage :table-config="tableConfig" :header-actions="headerActions" />
|
||||||
|
<el-dialog
|
||||||
|
:title="this.$t('route.OperateLog')"
|
||||||
|
:visible.sync="logDetailVisible"
|
||||||
|
width="70%"
|
||||||
|
>
|
||||||
|
<TwoTabFormatter :row="rowObj" />
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import GenericListPage from '@/layout/components/GenericListPage'
|
import GenericListPage from '@/layout/components/GenericListPage'
|
||||||
import { getDaysAgo, getDaysFuture } from '@/utils/common'
|
import { getDaysAgo, getDaysFuture } from '@/utils/common'
|
||||||
|
import TwoTabFormatter from '@/components/TableFormatters/TwoTabFormatter'
|
||||||
|
import { ActionsFormatter } from '@/components/TableFormatters'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
GenericListPage
|
GenericListPage,
|
||||||
|
TwoTabFormatter
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
const vm = this
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
const dateFrom = getDaysAgo(7, now).toISOString()
|
const dateFrom = getDaysAgo(7, now).toISOString()
|
||||||
const dateTo = getDaysFuture(1, now).toISOString()
|
const dateTo = getDaysFuture(1, now).toISOString()
|
||||||
return {
|
return {
|
||||||
|
rowObj: {
|
||||||
|
left: '',
|
||||||
|
rigth: '',
|
||||||
|
leftTitle: vm.$t('audits.BeforeChange'),
|
||||||
|
rightTitle: vm.$t('audits.AfterChange')
|
||||||
|
},
|
||||||
|
logDetailVisible: false,
|
||||||
tableConfig: {
|
tableConfig: {
|
||||||
url: '/api/v1/audits/operate-logs/',
|
url: '/api/v1/audits/operate-logs/',
|
||||||
columns: ['user', 'action_display', 'resource_type_display', 'resource', 'remote_addr', 'datetime'],
|
columns: ['user', 'action_display', 'resource_type_display', 'resource', 'remote_addr', 'datetime', 'actions'],
|
||||||
columnsMeta: {
|
columnsMeta: {
|
||||||
user: {
|
user: {
|
||||||
showOverflowTooltip: true
|
showOverflowTooltip: true
|
||||||
@ -36,7 +56,35 @@ export default {
|
|||||||
width: '140px'
|
width: '140px'
|
||||||
},
|
},
|
||||||
action_display: {
|
action_display: {
|
||||||
width: '90px'
|
width: '70px'
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
width: '70px',
|
||||||
|
formatter: ActionsFormatter,
|
||||||
|
formatterArgs: {
|
||||||
|
hasUpdate: false,
|
||||||
|
canUpdate: false,
|
||||||
|
hasDelete: false,
|
||||||
|
canDelete: false,
|
||||||
|
hasClone: false,
|
||||||
|
canClone: false,
|
||||||
|
extraActions: [
|
||||||
|
{
|
||||||
|
name: 'View',
|
||||||
|
title: this.$t('common.View'),
|
||||||
|
type: 'primary',
|
||||||
|
callback: ({ row }) => {
|
||||||
|
vm.$axios.get(
|
||||||
|
`/api/v1/audits/operate-logs/${row.id}/?type=action_detail`,
|
||||||
|
).then(res => {
|
||||||
|
vm.rowObj.left = res.before
|
||||||
|
vm.rowObj.right = res.after
|
||||||
|
vm.logDetailVisible = true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
extraQuery: {
|
extraQuery: {
|
||||||
|
Loading…
Reference in New Issue
Block a user