From 55582f941e5b788c8e1bfce8a95fc1dccf584dc2 Mon Sep 17 00:00:00 2001 From: Harikrishna Patnala Date: Mon, 20 Jan 2025 13:16:42 +0530 Subject: [PATCH 1/3] Added displaynetwork option in filters for listnetwork only for admin --- ui/public/locales/en.json | 2 ++ ui/src/components/view/SearchView.vue | 23 ++++++++++++++++++++++- ui/src/config/section/network.js | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ui/public/locales/en.json b/ui/public/locales/en.json index 8cc17bbb1286..cb113d41b2f5 100644 --- a/ui/public/locales/en.json +++ b/ui/public/locales/en.json @@ -2143,6 +2143,8 @@ "label.traffictype": "Traffic type", "label.transportzoneuuid": "Transport zone UUID", "label.trigger.shutdown": "Trigger Safe Shutdown", +"label.true": "True", +"label.false": "False", "label.try.again": "Try again", "label.tuesday": "Tuesday", "label.two.factor.authentication.secret.key": "Your Two factor authentication secret key", diff --git a/ui/src/components/view/SearchView.vue b/ui/src/components/view/SearchView.vue index a43dfabf8689..0d35e4fdad65 100644 --- a/ui/src/components/view/SearchView.vue +++ b/ui/src/components/view/SearchView.vue @@ -289,9 +289,12 @@ export default { if (item === 'groupid' && !('listInstanceGroups' in this.$store.getters.apis)) { return true } + if (item === 'displaynetwork' && this.$store.getters.userInfo.roletype !== 'Admin') { + return true + } if (['zoneid', 'domainid', 'imagestoreid', 'storageid', 'state', 'account', 'hypervisor', 'level', 'clusterid', 'podid', 'groupid', 'entitytype', 'accounttype', 'systemvmtype', 'scope', 'provider', - 'type', 'serviceofferingid', 'diskofferingid'].includes(item) + 'type', 'serviceofferingid', 'diskofferingid', 'displaynetwork'].includes(item) ) { type = 'list' } else if (item === 'tags') { @@ -311,6 +314,12 @@ export default { return arrayField }, fetchStaticFieldData (arrayField) { + if (arrayField.includes('displaynetwork')) { + const typeIndex = this.fields.findIndex(item => item.name === 'displaynetwork') + this.fields[typeIndex].loading = true + this.fields[typeIndex].opts = this.fetchBoolean() + this.fields[typeIndex].loading = false + } if (arrayField.includes('type')) { if (this.$route.path === '/guestnetwork' || this.$route.path.includes('/guestnetwork/')) { const typeIndex = this.fields.findIndex(item => item.name === 'type') @@ -856,6 +865,18 @@ export default { } return types }, + fetchBoolean () { + const types = [] + types.push({ + id: 'true', + name: 'label.true' + }) + types.push({ + id: 'false', + name: 'label.false' + }) + return types + }, fetchAccountTypes () { const types = [] if (this.apiName.indexOf('listAccounts') > -1) { diff --git a/ui/src/config/section/network.js b/ui/src/config/section/network.js index 5a3221810be8..6e677fa2647e 100644 --- a/ui/src/config/section/network.js +++ b/ui/src/config/section/network.js @@ -54,7 +54,7 @@ export default { return fields }, filters: ['all', 'account', 'domainpath', 'shared'], - searchFilters: ['keyword', 'zoneid', 'domainid', 'account', 'type', 'tags'], + searchFilters: ['keyword', 'zoneid', 'domainid', 'account', 'type', 'displaynetwork', 'tags'], related: [{ name: 'vm', title: 'label.instances', From 899b09dddbecde6049b6122f019d61b2ad92b33b Mon Sep 17 00:00:00 2001 From: Harikrishna Patnala Date: Mon, 20 Jan 2025 14:02:08 +0530 Subject: [PATCH 2/3] Indentation fix --- ui/src/components/view/SearchView.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ui/src/components/view/SearchView.vue b/ui/src/components/view/SearchView.vue index 0d35e4fdad65..9cbe1ef0fe69 100644 --- a/ui/src/components/view/SearchView.vue +++ b/ui/src/components/view/SearchView.vue @@ -315,10 +315,10 @@ export default { }, fetchStaticFieldData (arrayField) { if (arrayField.includes('displaynetwork')) { - const typeIndex = this.fields.findIndex(item => item.name === 'displaynetwork') - this.fields[typeIndex].loading = true - this.fields[typeIndex].opts = this.fetchBoolean() - this.fields[typeIndex].loading = false + const typeIndex = this.fields.findIndex(item => item.name === 'displaynetwork') + this.fields[typeIndex].loading = true + this.fields[typeIndex].opts = this.fetchBoolean() + this.fields[typeIndex].loading = false } if (arrayField.includes('type')) { if (this.$route.path === '/guestnetwork' || this.$route.path.includes('/guestnetwork/')) { From f4d3042ab9cff56dc5c21dcfa36eab452d7fd0b0 Mon Sep 17 00:00:00 2001 From: Harikrishna Patnala Date: Tue, 21 Jan 2025 12:33:59 +0530 Subject: [PATCH 3/3] Add displaynetwork parameter in listnetworks when id exists --- ui/src/components/view/ListView.vue | 3 +++ ui/src/views/AutogenView.vue | 3 +++ 2 files changed, 6 insertions(+) diff --git a/ui/src/components/view/ListView.vue b/ui/src/components/view/ListView.vue index 61b688dc75ae..4f5e32652368 100644 --- a/ui/src/components/view/ListView.vue +++ b/ui/src/components/view/ListView.vue @@ -86,6 +86,9 @@ {{ $t(text.toLowerCase()) }} {{ $t(text.toLowerCase()) }} + + {{ $t(text.toLowerCase()) }} + {{ text }} {{ text }} diff --git a/ui/src/views/AutogenView.vue b/ui/src/views/AutogenView.vue index 3471c02d2e4a..74fae8cada4d 100644 --- a/ui/src/views/AutogenView.vue +++ b/ui/src/views/AutogenView.vue @@ -915,6 +915,9 @@ export default { this.loading = true if (this.$route.params && this.$route.params.id) { params.id = this.$route.params.id + if (['listNetworks'].includes(this.apiName) && 'displaynetwork' in this.$route.query) { + params.displaynetwork = this.$route.query.displaynetwork + } if (['listSSHKeyPairs'].includes(this.apiName)) { if (!this.$isValidUuid(params.id)) { delete params.id