Skip to content

Commit

Permalink
ui: use *metrics apis only when metrics enabled for list
Browse files Browse the repository at this point in the history
In UI for the list views it is regular API view by default and *Metrics
API response may not be needed. *Metrics APIs will take more time to
return response so this PR tries to improve the behaviour and enables
calling regular API without metrics when metrics toggle is not enabled.

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
  • Loading branch information
shwstppr committed Oct 18, 2024
1 parent 20901c7 commit 6af86a7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
1 change: 0 additions & 1 deletion ui/src/config/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ function generateRouterMap (section) {
icon: child.icon,
docHelp: vueProps.$applyDocHelpMappings(child.docHelp),
permission: child.permission,
getApiToCall: child.getApiToCall,
resourceType: child.resourceType,
filters: child.filters,
params: child.params ? child.params : {},
Expand Down
3 changes: 1 addition & 2 deletions ui/src/config/section/compute.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ export default {
title: 'label.instances',
icon: 'cloud-server-outlined',
docHelp: 'adminguide/virtual_machines.html',
permission: ['listVirtualMachines', 'listVirtualMachinesMetrics'],
getApiToCall: () => store.getters.metrics ? 'listVirtualMachinesMetrics' : 'listVirtualMachines',
permission: ['listVirtualMachinesMetrics'],
resourceType: 'UserVm',
params: () => {
var params = { details: 'group,nics,secgrp,tmpl,servoff,diskoff,iso,volume,affgrp,backoff' }
Expand Down
4 changes: 2 additions & 2 deletions ui/src/config/section/infra/clusters.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export default {
permission: ['listClustersMetrics'],
searchFilters: ['name', 'zoneid', 'podid', 'hypervisor'],
columns: () => {
const fields = ['name', 'state', 'allocationstate', 'clustertype', 'hypervisortype', 'hosts']
const metricsFields = ['cpuused', 'cpumaxdeviation', 'cpuallocated', 'cputotal', 'memoryused', 'memorymaxdeviation', 'memoryallocated', 'memorytotal', 'drsimbalance']
const fields = ['name', 'allocationstate', 'clustertype', 'hypervisortype', 'hosts']
const metricsFields = ['state', 'cpuused', 'cpumaxdeviation', 'cpuallocated', 'cputotal', 'memoryused', 'memorymaxdeviation', 'memoryallocated', 'memorytotal', 'drsimbalance']
if (store.getters.metrics) {
fields.push(...metricsFields)
}
Expand Down
7 changes: 6 additions & 1 deletion ui/src/views/AutogenView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,12 @@ export default {
}
if (this.$route && this.$route.meta && this.$route.meta.permission) {
this.apiName = (this.$route.meta.getApiToCall && this.$route.meta.getApiToCall()) || this.$route.meta.permission[0]
this.apiName = this.$route.meta.permission[0]
if (!store.getters.metrics && !this.dataView &&
this.apiName && this.apiName.endsWith('Metrics') &&
store.getters.apis[this.apiName.replace(/Metrics$/, '')]) {
this.apiName = this.apiName.replace(/Metrics$/, '')
}
if (this.$route.meta.columns) {
const columns = this.$route.meta.columns
if (columns && typeof columns === 'function') {
Expand Down

0 comments on commit 6af86a7

Please sign in to comment.