Skip to content

Commit

Permalink
perf: update account risk list
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuler committed Nov 4, 2024
1 parent 322d12f commit fd745f0
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/views/pam/AccountCheck/AccountCheckEngine.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default {
}
},
headerActions: {
hasLeftActions: false,
hasRefresh: true,
hasExport: false,
hasImport: false
Expand Down
65 changes: 65 additions & 0 deletions src/views/pam/AccountCheck/AccountRiskSummary.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<template>
<GenericListTable ref="listTable" :header-actions="headerActions" :table-config="tableConfig" />
</template>

<script>
import { DetailFormatter } from '@/components/Table/TableFormatters'
import { GenericListTable } from '@/layout/components'
import RiskSummaryFormatter from './RiskSummaryFormatter.vue'
export default {
name: 'AccountPushList',
components: {
GenericListTable
},
data() {
return {
tableConfig: {
url: '/api/v1/accounts/account-risks/assets/',
columns: [
'name', 'address', 'platform', 'risk_total', 'risk_summary'
],
columnsShow: {
min: ['name', 'actions'],
default: [
'name', 'address', 'platform', 'risk_total',
'risk_summary', 'actions'
]
},
columnsMeta: {
name: {
formatter: DetailFormatter,
formatterArgs: {
route: 'AccountPushDetail'
}
},
risk_summary: {
formatter: RiskSummaryFormatter
},
risk_total: {
width: '80px'
},
platform: {
width: '80px'
},
address: {
width: '160px'
},
actions: {
formatterArgs: {
hasUpdate: false,
hasDelete: false,
hasClone: false
}
}
}
},
headerActions: {
hasRefresh: true,
hasExport: false,
hasImport: false
}
}
}
}
</script>
76 changes: 76 additions & 0 deletions src/views/pam/AccountCheck/RiskSummaryFormatter.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<template>
<span class="risk">
<span v-for="[k, v] of Object.entries(cellValue) " :key="k">
<span v-if="v !== 0" size="mini" type="getRiskType(k)">
{{ getRiskLabel(k) }}: {{ v }};
</span>
</span>
</span>
</template>
<script>
import BaseFormatter from '@/components/Table/TableFormatters/base.vue'
export default {
name: 'RiskSummaryFormatter',
extends: BaseFormatter,
props: {
formatterArgsDefault: {
type: Object,
default: () => ({})
}
},
data() {
return {
formatterArgs: Object.assign(this.formatterArgsDefault, this.col.formatterArgs),
riskLabel: {
zombie: '长时间未使用',
ghost: '未托管',
long_time_password: '长时间未修改密码',
weak_password: '弱密码',
password_error: '密码错误',
password_expired: '密码过期',
group_changed: '组变更',
sudo_changed: 'sudo提权',
account_deleted: '账号删除',
no_admin_account: '无管理账号',
no_user_account: '无用户账号',
other: '其它'
},
riskType: {
zombie: 'warning',
ghost: 'danger',
long_time_password: 'warning',
weak_password: 'warning',
password_error: 'danger',
password_expired: 'danger',
group_changed: 'warning',
sudo_changed: 'warning',
account_deleted: 'danger',
no_admin_account: 'danger',
no_user_account: 'danger',
other: 'warning'
}
}
},
methods: {
getRiskLabel(key) {
return this.riskLabel[key.replace('_count', '')] || key
},
getRiskType(key) {
return this.riskType[key.replace('_count', '')] || 'info'
}
}
}
</script>

<style lang='scss' scoped>
.risk {
font-size: 12px;
color: #1c84c6;
.el-tag {
margin-right: 2px;
}
}
</style>
6 changes: 3 additions & 3 deletions src/views/pam/AccountCheck/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export default {
submenu: [
{
title: this.$t('检查结果'),
name: 'AccountPushList',
hidden: !this.$hasPerm('accounts.view_pushaccountautomation'),
component: () => import('@/views/accounts/AccountPush/AccountPushList.vue')
name: 'AccountRisks',
hidden: !this.$hasPerm('accounts.view_accountrisk'),
component: () => import('@/views/pam/AccountCheck/AccountRiskSummary.vue')
},
{
title: this.$t('检查任务'),
Expand Down

0 comments on commit fd745f0

Please sign in to comment.