Skip to content

Commit fcbcddb

Browse files
authored
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 .
1 parent dabefca commit fcbcddb

5 files changed

Lines changed: 37 additions & 2 deletions

File tree

ui/public/locales/en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,7 @@
722722
"label.domainrouter": "Virtual Router",
723723
"label.domains": "Domains",
724724
"label.done": "Done",
725+
"label.down": "Down",
725726
"label.download": "Download",
726727
"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.",
727728
"label.download.kubectl": "Download <code><b>kubectl</b></code> tool for cluster's Kubernetes version",
@@ -762,6 +763,7 @@
762763
"label.egressdefaultpolicy": "Default egress policy",
763764
"label.elastic": "Elastic",
764765
"label.email": "Email",
766+
"label.enabled": "Enabled",
765767
"label.enable.autoscale.vmgroup": "Enable AutoScale VM Group",
766768
"label.enable.host": "Enable Host",
767769
"label.enable.network.offering": "Enable network offering",
@@ -1158,6 +1160,7 @@
11581160
"label.macaddresschanges": "MAC address changes",
11591161
"label.maclearning": "MAC learning",
11601162
"label.macos": "MacOS",
1163+
"label.maintenance": "Maintenance",
11611164
"label.majorsequence": "Major Sequence",
11621165
"label.make": "Make",
11631166
"label.make.project.owner": "Make account project owner",
@@ -2002,6 +2005,7 @@
20022005
"label.unmanaged.instance": "Unmanaged instance",
20032006
"label.unmanaged.instances": "Unmanaged instances",
20042007
"label.untagged": "Untagged",
2008+
"label.up": "Up",
20052009
"label.updateinsequence": "Update in sequence",
20062010
"label.update.autoscale.vmgroup": "Update AutoScale VM group",
20072011
"label.update.condition": "Update condition",

ui/src/config/section/infra/clusters.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ export default {
4040
param: 'clusterid'
4141
}],
4242
resourceType: 'Cluster',
43+
filters: () => {
44+
const filters = ['enabled', 'disabled']
45+
return filters
46+
},
4347
tabs: [{
4448
name: 'details',
4549
component: shallowRef(defineAsyncComponent(() => import('@/components/view/DetailsTab.vue')))

ui/src/config/section/infra/hosts.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ export default {
2424
icon: 'desktop-outlined',
2525
permission: ['listHostsMetrics'],
2626
resourceType: 'Host',
27+
filters: () => {
28+
const filters = ['enabled', 'disabled', 'maintenance', 'up', 'down', 'alert']
29+
return filters
30+
},
2731
params: { type: 'routing' },
2832
columns: () => {
2933
const fields = ['name', 'state', 'resourcestate', 'ipaddress', 'hypervisor', 'instances', 'powerstate']

ui/src/config/section/infra/pods.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ export default {
3535
param: 'podid'
3636
}],
3737
resourceType: 'Pod',
38+
filters: () => {
39+
const filters = ['enabled', 'disabled']
40+
return filters
41+
},
3842
tabs: [{
3943
name: 'details',
4044
component: shallowRef(defineAsyncComponent(() => import('@/components/view/DetailsTab.vue')))

ui/src/views/AutogenView.vue

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454
v-if="!dataView && filters && filters.length > 0"
5555
:placeholder="$t('label.filterby')"
5656
:value="$route.query.filter || (projectView && $route.name === 'vm' ||
57-
['Admin', 'DomainAdmin'].includes($store.getters.userInfo.roletype) && ['vm', 'iso', 'template'].includes($route.name)
57+
['Admin', 'DomainAdmin'].includes($store.getters.userInfo.roletype) &&
58+
['vm', 'iso', 'template', 'pod', 'cluster', 'host'].includes($route.name)
5859
? 'all' : ['publicip'].includes($route.name)
5960
? 'allocated' : ['guestnetwork', 'guestvlans'].includes($route.name)
6061
? 'all' : ['volume'].includes($route.name)
@@ -68,7 +69,8 @@
6869
}" >
6970
<template #suffixIcon><filter-outlined class="ant-select-suffix" /></template>
7071
<a-select-option
71-
v-if="['Admin', 'DomainAdmin'].includes($store.getters.userInfo.roletype) && ['vm', 'iso', 'template'].includes($route.name)"
72+
v-if="['Admin', 'DomainAdmin'].includes($store.getters.userInfo.roletype) &&
73+
['vm', 'iso', 'template', 'pod', 'cluster', 'host'].includes($route.name)"
7274
key="all"
7375
:label="$t('label.all')">
7476
{{ $t('label.all') }}
@@ -1573,6 +1575,23 @@ export default {
15731575
}
15741576
} else if (this.$route.name === 'publicip') {
15751577
query.state = filter
1578+
} else if (['pod', 'cluster'].includes(this.$route.name)) {
1579+
if (filter === 'all') {
1580+
delete query.allocationstate
1581+
} else {
1582+
query.allocationstate = filter
1583+
}
1584+
} else if (['host'].includes(this.$route.name)) {
1585+
if (filter === 'all') {
1586+
delete query.resourcestate
1587+
delete query.state
1588+
} else if (['up', 'down', 'alert'].includes(filter)) {
1589+
delete query.resourcestate
1590+
query.state = filter
1591+
} else {
1592+
delete query.state
1593+
query.resourcestate = filter
1594+
}
15761595
} else if (this.$route.name === 'vm') {
15771596
if (filter === 'self') {
15781597
query.account = this.$store.getters.userInfo.account

0 commit comments

Comments
 (0)