Skip to content

Commit 2e2d328

Browse files
Add toggle button on the UI for list including elements in projects. (#5790)
* Allow to use projectid=-1 and list all resources (e.g. VMs) regardless of their project.
1 parent c08592c commit 2e2d328

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

ui/src/store/getters.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const getters = {
3030
userInfo: state => state.user.info,
3131
addRouters: state => state.permission.addRouters,
3232
multiTab: state => state.app.multiTab,
33+
listAllProjects: state => state.app.listAllProjects,
3334
headerNotices: state => state.user.headerNotices,
3435
isLdapEnabled: state => state.user.isLdapEnabled,
3536
cloudian: state => state.user.cloudian,

ui/src/store/modules/app.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ const app = {
4646
inverted: true,
4747
multiTab: true,
4848
metrics: false,
49+
listAllProjects: false,
4950
server: ''
5051
},
5152
mutations: {
@@ -99,6 +100,9 @@ const app = {
99100
SET_METRICS: (state, bool) => {
100101
state.metrics = bool
101102
},
103+
SET_LIST_ALL_PROJECTS: (state, bool) => {
104+
state.listAllProjects = bool
105+
},
102106
SET_USE_BROWSER_TIMEZONE: (state, bool) => {
103107
Vue.ls.set(USE_BROWSER_TIMEZONE, bool)
104108
state.usebrowsertimezone = bool
@@ -151,6 +155,9 @@ const app = {
151155
SetMetrics ({ commit }, bool) {
152156
commit('SET_METRICS', bool)
153157
},
158+
SetListAllProjects ({ commit }, bool) {
159+
commit('SET_LIST_ALL_PROJECTS', bool)
160+
},
154161
SetUseBrowserTimezone ({ commit }, bool) {
155162
commit('SET_USE_BROWSER_TIMEZONE', bool)
156163
},

ui/src/views/AutogenView.vue

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@
3939
:un-checked-children="$t('label.metrics')"
4040
:checked="$store.getters.metrics"
4141
@change="(checked, event) => { $store.dispatch('SetMetrics', checked) }"/>
42+
<a-switch
43+
v-if="!projectView && hasProjectId"
44+
style="margin-left: 8px"
45+
:checked-children="$t('label.projects')"
46+
:un-checked-children="$t('label.projects')"
47+
:checked="$store.getters.listAllProjects"
48+
@change="(checked, event) => { $store.dispatch('SetListAllProjects', checked) }"/>
4249
<a-tooltip placement="right">
4350
<template slot="title">
4451
{{ $t('label.filterby') }}
@@ -504,6 +511,7 @@ export default {
504511
showAction: false,
505512
dataView: false,
506513
projectView: false,
514+
hasProjectId: false,
507515
selectedFilter: '',
508516
filters: [],
509517
searchFilters: [],
@@ -634,6 +642,9 @@ export default {
634642
},
635643
'$store.getters.metrics' (oldVal, newVal) {
636644
this.fetchData()
645+
},
646+
'$store.getters.listAllProjects' (oldVal, newVal) {
647+
this.fetchData()
637648
}
638649
},
639650
computed: {
@@ -740,6 +751,7 @@ export default {
740751
}
741752
742753
this.projectView = Boolean(store.getters.project && store.getters.project.id)
754+
this.hasProjectId = ['vm', 'vmgroup', 'ssh', 'affinitygroup', 'volume', 'snapshot', 'vmsnapshot', 'guestnetwork', 'vpc', 'securitygroups', 'publicip', 'vpncustomergateway', 'template', 'iso', 'event'].includes(this.$route.name)
743755
744756
if ((this.$route && this.$route.params && this.$route.params.id) || this.$route.query.dataView) {
745757
this.dataView = true
@@ -831,6 +843,10 @@ export default {
831843
}
832844
}
833845
846+
if (this.$store.getters.listAllProjects && !this.projectView) {
847+
params.projectid = '-1'
848+
}
849+
834850
params.page = this.page
835851
params.pagesize = this.pageSize
836852

0 commit comments

Comments
 (0)