fix: 修复资产详情中的权限判断 (#1437)

* fix: 修复资产详情中的权限判断

* fix: change

Co-authored-by: ibuler <ibuler@qq.com>
This commit is contained in:
fit2bot
2022-03-10 18:25:39 +08:00
committed by GitHub
parent 5482d6cf83
commit 3c75ab58e4
3 changed files with 32 additions and 9 deletions

View File

@@ -10,13 +10,19 @@ export default [
component: () => import('@/views/ops/CeleryTaskLog'),
name: 'CeleryTaskLog',
hidden: true,
meta: { title: i18n.t('route.CeleryTaskLog'), roles: ['SuperAdmin', 'Admin', 'Auditor', 'User'] }
meta: {
title: i18n.t('route.CeleryTaskLog'),
permissions: []
}
},
{
path: '/ops/task/task/:id/log/',
component: () => import('@/views/ops/CeleryTaskLog'),
name: 'TaskLog',
hidden: true,
meta: { title: i18n.t('route.CeleryTaskLog'), roles: ['SuperAdmin', 'Admin', 'Auditor', 'User'] }
meta: {
title: i18n.t('route.CeleryTaskLog'),
permissions: []
}
}
]

View File

@@ -1,5 +1,6 @@
import store from '@/store'
import Vue from 'vue'
import { constantRoutes } from '@/router'
export function openTaskPage(taskId) {
window.open(`/#/ops/celery/task/${taskId}/log/`, '', 'width=900,height=600')
@@ -134,3 +135,18 @@ export function hasRouteViewPerm(route) {
const perms = getViewRequirePerms(viewName)
return hasPermission(perms)
}
export function getConstRouteName() {
const names = []
const constRoutes = constantRoutes
const addRoutes = (all, routes) => {
for (const route of routes) {
names.push(route.name)
if (route.children) {
addRoutes(all, route.children)
}
}
}
addRoutes(names, constRoutes)
return names
}

View File

@@ -5,7 +5,7 @@
</el-col>
<el-col :span="10">
<QuickActions type="primary" :actions="quickActions" />
<RelationCard ref="NodeRelation" type="info" style="margin-top: 15px" v-bind="nodeRelationConfig" />
<RelationCard ref="NodeRelation" v-perms="'assets.change_asset'" type="info" style="margin-top: 15px" v-bind="nodeRelationConfig" />
<LabelCard type="warning" style="margin-top: 15px" v-bind="labelConfig" />
</el-col>
</el-row>
@@ -34,6 +34,7 @@ export default {
}
},
data() {
const vm = this
return {
quickActions: [
{
@@ -41,7 +42,8 @@ export default {
type: 'switcher',
attrs: {
label: this.$t('common.Test'),
model: this.object.is_active
model: this.object.is_active,
disabled: !vm.$hasPerm('assets.change_asset')
},
callbacks: {
change: function(val) {
@@ -60,7 +62,8 @@ export default {
title: this.$t('assets.RefreshHardware'),
attrs: {
type: 'primary',
label: this.$t('assets.Refresh')
label: this.$t('assets.Refresh'),
disabled: !vm.$hasPerm('assets.refresh_assethardwareinfo')
},
callbacks: {
click: function() {
@@ -78,7 +81,8 @@ export default {
title: this.$t('assets.TestAssetsConnective'),
attrs: {
type: 'primary',
label: this.$t('assets.Test')
label: this.$t('assets.Test'),
disabled: !vm.$hasPerm('assets.test_assetconnectivity')
},
callbacks: {
click: function() {
@@ -215,13 +219,10 @@ export default {
}
]
}
},
mounted() {
},
methods: {
}
}
</script>