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 .
This commit is contained in:
kishankavala 2023-04-19 12:12:29 +05:30 committed by GitHub
parent dabefca2b6
commit fcbcddbcb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 2 deletions

View File

@ -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 <br><br> The <code><b>kubectl</b></code> 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 <code><b>kubectl</b></code> 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",

View File

@ -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')))

View File

@ -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']

View File

@ -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')))

View File

@ -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 @@
}" >
<template #suffixIcon><filter-outlined class="ant-select-suffix" /></template>
<a-select-option
v-if="['Admin', 'DomainAdmin'].includes($store.getters.userInfo.roletype) && ['vm', 'iso', 'template'].includes($route.name)"
v-if="['Admin', 'DomainAdmin'].includes($store.getters.userInfo.roletype) &&
['vm', 'iso', 'template', 'pod', 'cluster', 'host'].includes($route.name)"
key="all"
:label="$t('label.all')">
{{ $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