Skip to content

Commit a6bdd52

Browse files
committed
refactor fetch arch types
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 5d696f0 commit a6bdd52

File tree

9 files changed

+23
-93
lines changed

9 files changed

+23
-93
lines changed

ui/src/components/view/SearchView.vue

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ export default {
451451
if (arrayField.includes('arch')) {
452452
const typeIndex = this.fields.findIndex(item => item.name === 'arch')
453453
this.fields[typeIndex].loading = true
454-
this.fields[typeIndex].opts = this.fetchArchitectureTypes()
454+
this.fields[typeIndex].opts = this.$fetchCpuArchitectureTypes()
455455
this.fields[typeIndex].loading = false
456456
}
457457
},
@@ -1324,12 +1324,6 @@ export default {
13241324
})
13251325
})
13261326
},
1327-
fetchArchitectureTypes () {
1328-
return [
1329-
{ id: 'x86_64', name: 'AMD 64 bits (x86_64)' },
1330-
{ id: 'aarch64', name: 'ARM 64 bits (aarch64)' }
1331-
]
1332-
},
13331327
onSearch (value) {
13341328
this.paramsFilter = {}
13351329
this.searchQuery = value

ui/src/main.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ import {
3535
resourceTypePlugin,
3636
fileSizeUtilPlugin,
3737
genericUtilPlugin,
38-
localesPlugin
38+
localesPlugin,
39+
cpuArchitectureUtilPlugin
3940
} from './utils/plugins'
4041
import { VueAxios } from './utils/request'
4142
import directives from './utils/directives'
@@ -51,6 +52,7 @@ vueApp.use(resourceTypePlugin)
5152
vueApp.use(fileSizeUtilPlugin)
5253
vueApp.use(localesPlugin)
5354
vueApp.use(genericUtilPlugin)
55+
vueApp.use(cpuArchitectureUtilPlugin)
5456
vueApp.use(extensions)
5557
vueApp.use(directives)
5658

ui/src/utils/plugins.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,3 +523,15 @@ export function createPathBasedOnVmType (vmtype, virtualmachineid) {
523523

524524
return path + virtualmachineid
525525
}
526+
527+
export const cpuArchitectureUtilPlugin = {
528+
install (app) {
529+
app.config.globalProperties.$fetchCpuArchitectureTypes = function () {
530+
const architectures = [
531+
{ id: 'x86_64', name: 'AMD 64 bits (x86_64)' },
532+
{ id: 'aarch64', name: 'ARM 64 bits (aarch64)' }
533+
]
534+
return architectures.map(item => ({ ...item, description: item.name }))
535+
}
536+
}
537+
}

ui/src/views/image/AddKubernetesSupportedVersion.vue

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export default {
216216
})
217217
},
218218
fetchData () {
219-
this.fetchArchitectureTypes()
219+
this.architectureTypes.opts = this.$fetchCpuArchitectureTypes()
220220
this.fetchZoneData()
221221
},
222222
isValidValueForKey (obj, key) {
@@ -225,19 +225,6 @@ export default {
225225
arrayHasItems (array) {
226226
return array !== null && array !== undefined && Array.isArray(array) && array.length > 0
227227
},
228-
fetchArchitectureTypes () {
229-
this.architectureTypes.opts = []
230-
const typesList = []
231-
typesList.push({
232-
id: 'x86_64',
233-
description: 'AMD 64 bits (x86_64)'
234-
})
235-
typesList.push({
236-
id: 'aarch64',
237-
description: 'ARM 64 bits (aarch64)'
238-
})
239-
this.architectureTypes.opts = typesList
240-
},
241228
fetchZoneData () {
242229
const params = {}
243230
params.showicon = true

ui/src/views/image/RegisterOrUploadIso.vue

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ export default {
384384
fetchData () {
385385
this.fetchZoneData()
386386
this.fetchOsType()
387-
this.fetchArchitectureTypes()
387+
this.architectureTypes.opts = this.$fetchCpuArchitectureTypes()
388388
this.fetchUserData()
389389
this.fetchUserdataPolicy()
390390
if ('listDomains' in this.$store.getters.apis) {
@@ -410,19 +410,6 @@ export default {
410410
this.form.zoneid = (this.zones[0].id ? this.zones[0].id : '')
411411
})
412412
},
413-
fetchArchitectureTypes () {
414-
this.architectureTypes.opts = []
415-
const typesList = []
416-
typesList.push({
417-
id: 'x86_64',
418-
description: 'AMD 64 bits (x86_64)'
419-
})
420-
typesList.push({
421-
id: 'aarch64',
422-
description: 'ARM 64 bits (aarch64)'
423-
})
424-
this.architectureTypes.opts = typesList
425-
},
426413
fetchOsType () {
427414
this.osTypeLoading = true
428415

ui/src/views/image/RegisterOrUploadTemplate.vue

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ export default {
583583
this.fetchZone()
584584
this.fetchOsTypes()
585585
this.fetchTemplateTypes()
586-
this.fetchArchitectureTypes()
586+
this.architectureTypes.opts = this.$fetchCpuArchitectureTypes()
587587
this.fetchUserData()
588588
this.fetchUserdataPolicy()
589589
if ('listDomains' in this.$store.getters.apis) {
@@ -753,19 +753,6 @@ export default {
753753
}
754754
this.templateTypes.opts = templatetypes
755755
},
756-
fetchArchitectureTypes () {
757-
this.architectureTypes.opts = []
758-
const typesList = []
759-
typesList.push({
760-
id: 'x86_64',
761-
description: 'AMD 64 bits (x86_64)'
762-
})
763-
typesList.push({
764-
id: 'aarch64',
765-
description: 'ARM 64 bits (aarch64)'
766-
})
767-
this.architectureTypes.opts = typesList
768-
},
769756
fetchUserData () {
770757
const params = {}
771758
params.listAll = true

ui/src/views/image/UpdateISO.vue

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export default {
216216
},
217217
fetchData () {
218218
this.fetchOsTypes()
219-
this.fetchArchitectureTypes()
219+
this.architectureTypes.opts = this.$fetchCpuArchitectureTypes()
220220
this.fetchUserdata()
221221
this.fetchUserdataPolicy()
222222
},
@@ -235,19 +235,6 @@ export default {
235235
this.osTypes.loading = false
236236
})
237237
},
238-
fetchArchitectureTypes () {
239-
this.architectureTypes.opts = []
240-
const typesList = []
241-
typesList.push({
242-
id: 'x86_64',
243-
description: 'AMD 64 bits (x86_64)'
244-
})
245-
typesList.push({
246-
id: 'aarch64',
247-
description: 'ARM 64 bits (aarch64)'
248-
})
249-
this.architectureTypes.opts = typesList
250-
},
251238
fetchUserdataPolicy () {
252239
const userdataPolicy = []
253240
userdataPolicy.push({

ui/src/views/image/UpdateTemplate.vue

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ export default {
310310
},
311311
fetchData () {
312312
this.fetchOsTypes()
313-
this.fetchArchitectureTypes()
313+
this.architectureTypes.opts = this.$fetchCpuArchitectureTypes()
314314
this.fetchRootDiskControllerTypes(this.resource.hypervisor)
315315
this.fetchNicAdapterTypes()
316316
this.fetchKeyboardTypes()
@@ -335,19 +335,6 @@ export default {
335335
this.osTypes.loading = false
336336
})
337337
},
338-
fetchArchitectureTypes () {
339-
this.architectureTypes.opts = []
340-
const typesList = []
341-
typesList.push({
342-
id: 'x86_64',
343-
description: 'AMD 64 bits (x86_64)'
344-
})
345-
typesList.push({
346-
id: 'aarch64',
347-
description: 'ARM 64 bits (aarch64)'
348-
})
349-
this.architectureTypes.opts = typesList
350-
},
351338
fetchRootDiskControllerTypes (hyperVisor) {
352339
const controller = []
353340
this.rootDisk.opts = []

ui/src/views/infra/ClusterAdd.vue

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ export default {
213213
fetchData () {
214214
this.fetchZones()
215215
this.fetchHypervisors()
216-
this.fetchArchitectureTypes()
216+
this.architectureTypes.opts = this.$fetchCpuArchitectureTypes()
217+
this.selectedArchitecture = this.architectureTypes?.opts?.[0]?.id || null
217218
this.params = this.$store.getters.apis.addCluster.params
218219
Object.keys(this.placeholder).forEach(item => { this.returnPlaceholder(item) })
219220
},
@@ -240,20 +241,6 @@ export default {
240241
this.loading = false
241242
})
242243
},
243-
fetchArchitectureTypes () {
244-
this.architectureTypes.opts = []
245-
const typesList = []
246-
typesList.push({
247-
id: 'x86_64',
248-
description: 'AMD 64 bits (x86_64)'
249-
})
250-
typesList.push({
251-
id: 'aarch64',
252-
description: 'ARM 64 bits (aarch64)'
253-
})
254-
this.architectureTypes.opts = typesList
255-
this.selectedArchitecture = this.architectureTypes.opts[0].id
256-
},
257244
fetchPods () {
258245
this.loading = true
259246
api('listPods', {

0 commit comments

Comments
 (0)