Skip to content

Commit 19e9020

Browse files
authored
ui: fix dashboard retrievals based on permissions (#9237)
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent abbc61c commit 19e9020

1 file changed

Lines changed: 66 additions & 40 deletions

File tree

ui/src/views/dashboard/UsageDashboard.vue

Lines changed: 66 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
</template>
5252
<a-divider style="margin: 6px 0px; border-width: 0px"/>
5353
<a-row :gutter="[10, 10]">
54-
<a-col :span="12">
54+
<a-col :span="12" v-if="'listVirtualMachines' in $store.getters.apis">
5555
<router-link :to="{ path: '/vm' }">
5656
<a-statistic
5757
:title="$t('label.instances')"
@@ -63,7 +63,7 @@
6363
</a-statistic>
6464
</router-link>
6565
</a-col>
66-
<a-col :span="12">
66+
<a-col :span="12" v-if="'listKubernetesClusters' in $store.getters.apis">
6767
<router-link :to="{ path: '/kubernetes' }">
6868
<a-statistic
6969
:title="$t('label.kubernetes.cluster')"
@@ -75,7 +75,7 @@
7575
</a-statistic>
7676
</router-link>
7777
</a-col>
78-
<a-col :span="12">
78+
<a-col :span="12" v-if="'listVolumes' in $store.getters.apis">
7979
<router-link :to="{ path: '/volume' }">
8080
<a-statistic
8181
:title="$t('label.volumes')"
@@ -87,7 +87,7 @@
8787
</a-statistic>
8888
</router-link>
8989
</a-col>
90-
<a-col :span="12">
90+
<a-col :span="12" v-if="'listSnapshots' in $store.getters.apis">
9191
<router-link :to="{ path: '/snapshot' }">
9292
<a-statistic
9393
:title="$t('label.snapshots')"
@@ -99,7 +99,7 @@
9999
</a-statistic>
100100
</router-link>
101101
</a-col>
102-
<a-col :span="12">
102+
<a-col :span="12" v-if="'listNetworks' in $store.getters.apis">
103103
<router-link :to="{ path: '/guestnetwork' }">
104104
<a-statistic
105105
:title="$t('label.guest.networks')"
@@ -111,7 +111,7 @@
111111
</a-statistic>
112112
</router-link>
113113
</a-col>
114-
<a-col :span="12">
114+
<a-col :span="12" v-if="'listVPCs' in $store.getters.apis">
115115
<router-link :to="{ path: '/vpc' }">
116116
<a-statistic
117117
:title="$t('label.vpcs')"
@@ -123,7 +123,7 @@
123123
</a-statistic>
124124
</router-link>
125125
</a-col>
126-
<a-col :span="12">
126+
<a-col :span="12" v-if="'listPublicIpAddresses' in $store.getters.apis">
127127
<router-link :to="{ path: '/publicip' }">
128128
<a-statistic
129129
:title="$t('label.public.ips')"
@@ -135,7 +135,7 @@
135135
</a-statistic>
136136
</router-link>
137137
</a-col>
138-
<a-col :span="12">
138+
<a-col :span="12" v-if="'listTemplates' in $store.getters.apis">
139139
<router-link :to="{ path: '/template', query: { templatefilter: 'self', filter: 'self' } }">
140140
<a-statistic
141141
:title="$t('label.templates')"
@@ -150,7 +150,7 @@
150150
</a-row>
151151
</chart-card>
152152
</a-col>
153-
<a-col :xs="{ span: 24 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{ span: 8 }">
153+
<a-col :xs="{ span: 24 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{ span: 8 }" v-if="'listVirtualMachines' in $store.getters.apis">
154154
<chart-card :loading="loading" class="dashboard-card">
155155
<template #title>
156156
<div class="center">
@@ -315,7 +315,7 @@
315315
</a-list>
316316
</chart-card>
317317
</a-col>
318-
<a-col :xs="{ span: 24 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{ span: 8 }">
318+
<a-col :xs="{ span: 24 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{ span: 8 }" v-if="'listEvents' in $store.getters.apis">
319319
<chart-card :loading="loading" class="dashboard-card dashboard-event">
320320
<template #title>
321321
<div class="center">
@@ -482,37 +482,60 @@ export default {
482482
}
483483
this.listInstances()
484484
this.listEvents()
485-
this.loading = true
486-
api('listKubernetesClusters', { listall: true, page: 1, pagesize: 1 }).then(json => {
487-
this.loading = false
488-
this.data.kubernetes = json?.listkubernetesclustersresponse?.count
489-
})
490-
api('listVolumes', { listall: true, page: 1, pagesize: 1 }).then(json => {
491-
this.loading = false
492-
this.data.volumes = json?.listvolumesresponse?.count
493-
})
494-
api('listSnapshots', { listall: true, page: 1, pagesize: 1 }).then(json => {
495-
this.loading = false
496-
this.data.snapshots = json?.listsnapshotsresponse?.count
497-
})
498-
api('listNetworks', { listall: true, page: 1, pagesize: 1 }).then(json => {
499-
this.loading = false
500-
this.data.networks = json?.listnetworksresponse?.count
501-
})
502-
api('listVPCs', { listall: true, page: 1, pagesize: 1 }).then(json => {
503-
this.loading = false
504-
this.data.vpcs = json?.listvpcsresponse?.count
505-
})
506-
api('listPublicIpAddresses', { listall: true, page: 1, pagesize: 1 }).then(json => {
507-
this.loading = false
508-
this.data.ips = json?.listpublicipaddressesresponse?.count
509-
})
510-
api('listTemplates', { templatefilter: 'self', listall: true, page: 1, pagesize: 1 }).then(json => {
511-
this.loading = false
512-
this.data.templates = json?.listtemplatesresponse?.count
513-
})
485+
if ('listKubernetesClusters' in this.$store.getters.apis) {
486+
this.loading = true
487+
api('listKubernetesClusters', { listall: true, page: 1, pagesize: 1 }).then(json => {
488+
this.loading = false
489+
this.data.kubernetes = json?.listkubernetesclustersresponse?.count
490+
})
491+
}
492+
if ('listVolumes' in this.$store.getters.apis) {
493+
this.loading = true
494+
api('listVolumes', { listall: true, page: 1, pagesize: 1 }).then(json => {
495+
this.loading = false
496+
this.data.volumes = json?.listvolumesresponse?.count
497+
})
498+
}
499+
if ('listSnapshots' in this.$store.getters.apis) {
500+
this.loading = true
501+
api('listSnapshots', { listall: true, page: 1, pagesize: 1 }).then(json => {
502+
this.loading = false
503+
this.data.snapshots = json?.listsnapshotsresponse?.count
504+
})
505+
}
506+
if ('listNetworks' in this.$store.getters.apis) {
507+
this.loading = true
508+
api('listNetworks', { listall: true, page: 1, pagesize: 1 }).then(json => {
509+
this.loading = false
510+
this.data.networks = json?.listnetworksresponse?.count
511+
})
512+
}
513+
if ('listVPCs' in this.$store.getters.apis) {
514+
this.loading = true
515+
api('listVPCs', { listall: true, page: 1, pagesize: 1 }).then(json => {
516+
this.loading = false
517+
this.data.vpcs = json?.listvpcsresponse?.count
518+
})
519+
}
520+
if ('listPublicIpAddresses' in this.$store.getters.apis) {
521+
this.loading = true
522+
api('listPublicIpAddresses', { listall: true, page: 1, pagesize: 1 }).then(json => {
523+
this.loading = false
524+
this.data.ips = json?.listpublicipaddressesresponse?.count
525+
})
526+
}
527+
if ('listTemplates' in this.$store.getters.apis) {
528+
this.loading = true
529+
api('listTemplates', { templatefilter: 'self', listall: true, page: 1, pagesize: 1 }).then(json => {
530+
this.loading = false
531+
this.data.templates = json?.listtemplatesresponse?.count
532+
})
533+
}
514534
},
515-
listInstances (zone) {
535+
listInstances () {
536+
if (!('listVirtualMachines' in this.$store.getters.apis)) {
537+
return
538+
}
516539
this.loading = true
517540
api('listVirtualMachines', { listall: true, details: 'min', page: 1, pagesize: 1 }).then(json => {
518541
this.loading = false
@@ -528,6 +551,9 @@ export default {
528551
})
529552
},
530553
listEvents () {
554+
if (!('listEvents' in this.$store.getters.apis)) {
555+
return
556+
}
531557
const params = {
532558
page: 1,
533559
pagesize: 8,

0 commit comments

Comments
 (0)