This is an automated email from the ASF dual-hosted git repository.
sureshanaparti pushed a commit to branch 4.16
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.16 by this push:
new 2e2d328 Add toggle button on the UI for list including elements in
projects. (#5790)
2e2d328 is described below
commit 2e2d328cde82488f002c12ec4a62304a94a74596
Author: Gabriel Beims Bräscher <[email protected]>
AuthorDate: Tue Jan 11 17:00:30 2022 +0100
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.
---
ui/src/store/getters.js | 1 +
ui/src/store/modules/app.js | 7 +++++++
ui/src/views/AutogenView.vue | 16 ++++++++++++++++
3 files changed, 24 insertions(+)
diff --git a/ui/src/store/getters.js b/ui/src/store/getters.js
index b3734d6..f6489ee 100644
--- a/ui/src/store/getters.js
+++ b/ui/src/store/getters.js
@@ -30,6 +30,7 @@ const getters = {
userInfo: state => state.user.info,
addRouters: state => state.permission.addRouters,
multiTab: state => state.app.multiTab,
+ listAllProjects: state => state.app.listAllProjects,
headerNotices: state => state.user.headerNotices,
isLdapEnabled: state => state.user.isLdapEnabled,
cloudian: state => state.user.cloudian,
diff --git a/ui/src/store/modules/app.js b/ui/src/store/modules/app.js
index eff828d..90be53b 100644
--- a/ui/src/store/modules/app.js
+++ b/ui/src/store/modules/app.js
@@ -46,6 +46,7 @@ const app = {
inverted: true,
multiTab: true,
metrics: false,
+ listAllProjects: false,
server: ''
},
mutations: {
@@ -99,6 +100,9 @@ const app = {
SET_METRICS: (state, bool) => {
state.metrics = bool
},
+ SET_LIST_ALL_PROJECTS: (state, bool) => {
+ state.listAllProjects = bool
+ },
SET_USE_BROWSER_TIMEZONE: (state, bool) => {
Vue.ls.set(USE_BROWSER_TIMEZONE, bool)
state.usebrowsertimezone = bool
@@ -151,6 +155,9 @@ const app = {
SetMetrics ({ commit }, bool) {
commit('SET_METRICS', bool)
},
+ SetListAllProjects ({ commit }, bool) {
+ commit('SET_LIST_ALL_PROJECTS', bool)
+ },
SetUseBrowserTimezone ({ commit }, bool) {
commit('SET_USE_BROWSER_TIMEZONE', bool)
},
diff --git a/ui/src/views/AutogenView.vue b/ui/src/views/AutogenView.vue
index 4c128a7..5baf064 100644
--- a/ui/src/views/AutogenView.vue
+++ b/ui/src/views/AutogenView.vue
@@ -39,6 +39,13 @@
:un-checked-children="$t('label.metrics')"
:checked="$store.getters.metrics"
@change="(checked, event) => { $store.dispatch('SetMetrics',
checked) }"/>
+ <a-switch
+ v-if="!projectView && hasProjectId"
+ style="margin-left: 8px"
+ :checked-children="$t('label.projects')"
+ :un-checked-children="$t('label.projects')"
+ :checked="$store.getters.listAllProjects"
+ @change="(checked, event) => {
$store.dispatch('SetListAllProjects', checked) }"/>
<a-tooltip placement="right">
<template slot="title">
{{ $t('label.filterby') }}
@@ -504,6 +511,7 @@ export default {
showAction: false,
dataView: false,
projectView: false,
+ hasProjectId: false,
selectedFilter: '',
filters: [],
searchFilters: [],
@@ -634,6 +642,9 @@ export default {
},
'$store.getters.metrics' (oldVal, newVal) {
this.fetchData()
+ },
+ '$store.getters.listAllProjects' (oldVal, newVal) {
+ this.fetchData()
}
},
computed: {
@@ -740,6 +751,7 @@ export default {
}
this.projectView = Boolean(store.getters.project &&
store.getters.project.id)
+ this.hasProjectId = ['vm', 'vmgroup', 'ssh', 'affinitygroup', 'volume',
'snapshot', 'vmsnapshot', 'guestnetwork', 'vpc', 'securitygroups', 'publicip',
'vpncustomergateway', 'template', 'iso', 'event'].includes(this.$route.name)
if ((this.$route && this.$route.params && this.$route.params.id) ||
this.$route.query.dataView) {
this.dataView = true
@@ -831,6 +843,10 @@ export default {
}
}
+ if (this.$store.getters.listAllProjects && !this.projectView) {
+ params.projectid = '-1'
+ }
+
params.page = this.page
params.pagesize = this.pageSize