From fcbcddbcb96f18a5f4dc2d464ec1d91cb53360ea Mon Sep 17 00:00:00 2001 From: kishankavala Date: Wed, 19 Apr 2023 12:12:29 +0530 Subject: [PATCH] ui: Allow admin/user to filter by state for Pods, Clusters and Hosts (#7373) This PR allows admin/user to filter by state for Pods, Clusters and Hosts. This is part of #7366 . --- ui/public/locales/en.json | 4 ++++ ui/src/config/section/infra/clusters.js | 4 ++++ ui/src/config/section/infra/hosts.js | 4 ++++ ui/src/config/section/infra/pods.js | 4 ++++ ui/src/views/AutogenView.vue | 23 +++++++++++++++++++++-- 5 files changed, 37 insertions(+), 2 deletions(-) diff --git a/ui/public/locales/en.json b/ui/public/locales/en.json index 5bc585fa3f2..dd94644c6f8 100644 --- a/ui/public/locales/en.json +++ b/ui/public/locales/en.json @@ -722,6 +722,7 @@ "label.domainrouter": "Virtual Router", "label.domains": "Domains", "label.done": "Done", +"label.down": "Down", "label.download": "Download", "label.download.kubeconfig.cluster": "Download kubeconfig for the cluster

The kubectl command-line tool uses kubeconfig files to find the information it needs to choose a cluster and communicate with the API server of a cluster.", "label.download.kubectl": "Download kubectl tool for cluster's Kubernetes version", @@ -762,6 +763,7 @@ "label.egressdefaultpolicy": "Default egress policy", "label.elastic": "Elastic", "label.email": "Email", +"label.enabled": "Enabled", "label.enable.autoscale.vmgroup": "Enable AutoScale VM Group", "label.enable.host": "Enable Host", "label.enable.network.offering": "Enable network offering", @@ -1158,6 +1160,7 @@ "label.macaddresschanges": "MAC address changes", "label.maclearning": "MAC learning", "label.macos": "MacOS", +"label.maintenance": "Maintenance", "label.majorsequence": "Major Sequence", "label.make": "Make", "label.make.project.owner": "Make account project owner", @@ -2002,6 +2005,7 @@ "label.unmanaged.instance": "Unmanaged instance", "label.unmanaged.instances": "Unmanaged instances", "label.untagged": "Untagged", +"label.up": "Up", "label.updateinsequence": "Update in sequence", "label.update.autoscale.vmgroup": "Update AutoScale VM group", "label.update.condition": "Update condition", diff --git a/ui/src/config/section/infra/clusters.js b/ui/src/config/section/infra/clusters.js index 743c782a7a0..904938ca528 100644 --- a/ui/src/config/section/infra/clusters.js +++ b/ui/src/config/section/infra/clusters.js @@ -40,6 +40,10 @@ export default { param: 'clusterid' }], resourceType: 'Cluster', + filters: () => { + const filters = ['enabled', 'disabled'] + return filters + }, tabs: [{ name: 'details', component: shallowRef(defineAsyncComponent(() => import('@/components/view/DetailsTab.vue'))) diff --git a/ui/src/config/section/infra/hosts.js b/ui/src/config/section/infra/hosts.js index 1ca0a99e617..9f2c6292052 100644 --- a/ui/src/config/section/infra/hosts.js +++ b/ui/src/config/section/infra/hosts.js @@ -24,6 +24,10 @@ export default { icon: 'desktop-outlined', permission: ['listHostsMetrics'], resourceType: 'Host', + filters: () => { + const filters = ['enabled', 'disabled', 'maintenance', 'up', 'down', 'alert'] + return filters + }, params: { type: 'routing' }, columns: () => { const fields = ['name', 'state', 'resourcestate', 'ipaddress', 'hypervisor', 'instances', 'powerstate'] diff --git a/ui/src/config/section/infra/pods.js b/ui/src/config/section/infra/pods.js index 70674ac7fbb..a462478f979 100644 --- a/ui/src/config/section/infra/pods.js +++ b/ui/src/config/section/infra/pods.js @@ -35,6 +35,10 @@ export default { param: 'podid' }], resourceType: 'Pod', + filters: () => { + const filters = ['enabled', 'disabled'] + return filters + }, tabs: [{ name: 'details', component: shallowRef(defineAsyncComponent(() => import('@/components/view/DetailsTab.vue'))) diff --git a/ui/src/views/AutogenView.vue b/ui/src/views/AutogenView.vue index 16cf14e04cb..4a8a909e794 100644 --- a/ui/src/views/AutogenView.vue +++ b/ui/src/views/AutogenView.vue @@ -54,7 +54,8 @@ v-if="!dataView && filters && filters.length > 0" :placeholder="$t('label.filterby')" :value="$route.query.filter || (projectView && $route.name === 'vm' || - ['Admin', 'DomainAdmin'].includes($store.getters.userInfo.roletype) && ['vm', 'iso', 'template'].includes($route.name) + ['Admin', 'DomainAdmin'].includes($store.getters.userInfo.roletype) && + ['vm', 'iso', 'template', 'pod', 'cluster', 'host'].includes($route.name) ? 'all' : ['publicip'].includes($route.name) ? 'allocated' : ['guestnetwork', 'guestvlans'].includes($route.name) ? 'all' : ['volume'].includes($route.name) @@ -68,7 +69,8 @@ }" > {{ $t('label.all') }} @@ -1573,6 +1575,23 @@ export default { } } else if (this.$route.name === 'publicip') { query.state = filter + } else if (['pod', 'cluster'].includes(this.$route.name)) { + if (filter === 'all') { + delete query.allocationstate + } else { + query.allocationstate = filter + } + } else if (['host'].includes(this.$route.name)) { + if (filter === 'all') { + delete query.resourcestate + delete query.state + } else if (['up', 'down', 'alert'].includes(filter)) { + delete query.resourcestate + query.state = filter + } else { + delete query.state + query.resourcestate = filter + } } else if (this.$route.name === 'vm') { if (filter === 'self') { query.account = this.$store.getters.userInfo.account