Skip to content

Commit 6ab7123

Browse files
committed
template type filter
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 8e1786f commit 6ab7123

File tree

5 files changed

+27
-31
lines changed

5 files changed

+27
-31
lines changed

ui/src/components/view/SearchView.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ export default {
312312
'clusterid', 'podid', 'groupid', 'entitytype', 'accounttype', 'systemvmtype', 'scope', 'provider',
313313
'type', 'scope', 'managementserverid', 'serviceofferingid',
314314
'diskofferingid', 'networkid', 'usagetype', 'restartrequired',
315-
'displaynetwork', 'arch', 'oscategoryid'].includes(item)
315+
'displaynetwork', 'arch', 'oscategoryid', 'templatetype'].includes(item)
316316
) {
317317
type = 'list'
318318
} else if (item === 'tags') {
@@ -454,6 +454,13 @@ export default {
454454
this.fields[typeIndex].opts = this.$fetchCpuArchitectureTypes()
455455
this.fields[typeIndex].loading = false
456456
}
457+
458+
if (arrayField.includes('templatetype')) {
459+
const typeIndex = this.fields.findIndex(item => item.name === 'templatetype')
460+
this.fields[typeIndex].loading = true
461+
this.fields[typeIndex].opts = this.$fetchTemplateTypes()
462+
this.fields[typeIndex].loading = false
463+
}
457464
},
458465
async fetchDynamicFieldData (arrayField, searchKeyword) {
459466
const promises = []

ui/src/config/section/image.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default {
6767
return fields
6868
},
6969
searchFilters: () => {
70-
var filters = ['name', 'zoneid', 'tags', 'arch', 'oscategoryid']
70+
var filters = ['name', 'zoneid', 'tags', 'arch', 'oscategoryid', 'templatetype']
7171
if (['Admin', 'DomainAdmin'].includes(store.getters.userInfo.roletype)) {
7272
filters.push('storageid')
7373
filters.push('imagestoreid')

ui/src/main.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ import {
3737
genericUtilPlugin,
3838
localesPlugin,
3939
dialogUtilPlugin,
40-
cpuArchitectureUtilPlugin
40+
cpuArchitectureUtilPlugin,
41+
imagesUtilPlugin
4142
} from './utils/plugins'
4243
import { VueAxios } from './utils/request'
4344
import directives from './utils/directives'
@@ -55,6 +56,7 @@ vueApp.use(localesPlugin)
5556
vueApp.use(genericUtilPlugin)
5657
vueApp.use(dialogUtilPlugin)
5758
vueApp.use(cpuArchitectureUtilPlugin)
59+
vueApp.use(imagesUtilPlugin)
5860
vueApp.use(extensions)
5961
vueApp.use(directives)
6062

ui/src/utils/plugins.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,3 +550,17 @@ export const cpuArchitectureUtilPlugin = {
550550
}
551551
}
552552
}
553+
554+
export const imagesUtilPlugin = {
555+
install (app) {
556+
app.config.globalProperties.$fetchTemplateTypes = function () {
557+
const baseTypes = ['USER', 'VNF']
558+
const adminTypes = ['SYSTEM', 'BUILTIN', 'ROUTING']
559+
const types = [...baseTypes]
560+
if (store.getters.userInfo?.roletype === 'Admin') {
561+
types.push(...adminTypes)
562+
}
563+
return types.map(type => ({ id: type, name: type, description: type }))
564+
}
565+
}
566+
}

ui/src/views/image/RegisterOrUploadTemplate.vue

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ export default {
582582
this.fetchCustomHypervisorName()
583583
this.fetchZone()
584584
this.fetchOsTypes()
585-
this.fetchTemplateTypes()
585+
this.templateTypes.opts = this.$fetchTemplateTypes()
586586
this.architectureTypes.opts = this.$fetchCpuArchitectureTypes()
587587
this.fetchUserData()
588588
this.fetchUserdataPolicy()
@@ -726,33 +726,6 @@ export default {
726726
this.osTypes.loading = false
727727
})
728728
},
729-
fetchTemplateTypes () {
730-
this.templateTypes.opts = []
731-
const templatetypes = []
732-
templatetypes.push({
733-
id: 'USER',
734-
description: 'USER'
735-
})
736-
templatetypes.push({
737-
id: 'VNF',
738-
description: 'VNF'
739-
})
740-
if (this.isAdminRole) {
741-
templatetypes.push({
742-
id: 'SYSTEM',
743-
description: 'SYSTEM'
744-
})
745-
templatetypes.push({
746-
id: 'BUILTIN',
747-
description: 'BUILTIN'
748-
})
749-
templatetypes.push({
750-
id: 'ROUTING',
751-
description: 'ROUTING'
752-
})
753-
}
754-
this.templateTypes.opts = templatetypes
755-
},
756729
fetchUserData () {
757730
const params = {}
758731
params.listAll = true

0 commit comments

Comments
 (0)