hopefully fix server metrics refresh bug

This commit is contained in:
Matt Hill
2021-06-15 11:09:48 -06:00
committed by Aiden McClelland
parent 1b0173197f
commit e5de786cf1
3 changed files with 82 additions and 35 deletions

View File

@@ -43,16 +43,19 @@ export class ServerMetricsPage {
async getMetrics (): Promise<void> { async getMetrics (): Promise<void> {
try { try {
const metrics = await this.apiService.getServerMetrics({ }) this.metrics = await this.apiService.getServerMetrics({ })
Object.keys(metrics).forEach(outerKey => {
if (!this.metrics[outerKey]) { // @TODO keeping code in case naive approach (above) has issues
this.metrics[outerKey] = metrics[outerKey] // Object.keys(metrics).forEach(outerKey => {
} else { // if (!this.metrics[outerKey]) {
Object.entries(metrics[outerKey]).forEach(([key, value]) => { // console.log('outer keys')
this.metrics[outerKey][key] = value // this.metrics[outerKey] = metrics[outerKey]
}) // } else {
} // Object.entries(metrics[outerKey]).forEach(([key, value]) => {
}) // this.metrics[outerKey][key] = value
// })
// }
// })
} catch (e) { } catch (e) {
console.error(e) console.error(e)
this.error = e.message this.error = e.message

View File

@@ -93,7 +93,7 @@ export class MockApiService extends ApiService {
async getServerMetrics (params: RR.GetServerMetricsReq): Promise<RR.GetServerMetricsRes> { async getServerMetrics (params: RR.GetServerMetricsReq): Promise<RR.GetServerMetricsRes> {
await pauseFor(2000) await pauseFor(2000)
return Mock.ServerMetrics return Mock.getServerMetrics()
} }
async updateServerRaw (params: RR.UpdateServerReq): Promise<RR.UpdateServerRes> { async updateServerRaw (params: RR.UpdateServerReq): Promise<RR.UpdateServerRes> {

View File

@@ -783,35 +783,79 @@ export module Mock {
}, },
] ]
export const ServerMetrics: RR.GetServerMetricsRes = { export function getServerMetrics () {
'Group1': { return {
'Metric1': { 'Group1': {
value: 22.2, 'Metric1': {
unit: 'mi/b', value: Math.random(),
unit: 'mi/b',
},
'Metric2': {
value: Math.random(),
unit: '%',
},
'Metric3': {
value: 10.1,
unit: '%',
},
}, },
'Metric2': { 'Group2': {
value: 50, 'Hmmmm1': {
unit: '%', value: 22.2,
unit: 'mi/b',
},
'Hmmmm2': {
value: 50,
unit: '%',
},
'Hmmmm3': {
value: 10.1,
unit: '%',
},
}, },
'Metric3': { 'Group3': {
value: 10.1, 'Hmmmm1': {
unit: '%', value: Math.random(),
unit: 'mi/b',
},
'Hmmmm2': {
value: 50,
unit: '%',
},
'Hmmmm3': {
value: 10.1,
unit: '%',
},
}, },
}, 'Group4': {
'Group2': { 'Hmmmm1': {
'Hmmmm1': { value: Math.random(),
value: 22.2, unit: 'mi/b',
unit: 'mi/b', },
'Hmmmm2': {
value: 50,
unit: '%',
},
'Hmmmm3': {
value: 10.1,
unit: '%',
},
}, },
'Hmmmm2': { 'Group5': {
value: 50, 'Hmmmm1': {
unit: '%', value: Math.random(),
unit: 'mi/b',
},
'Hmmmm2': {
value: 50,
unit: '%',
},
'Hmmmm3': {
value: 10.1,
unit: '%',
},
}, },
'Hmmmm3': { }
value: 10.1,
unit: '%',
},
},
} }
export const ServerLogs: RR.GetServerLogsRes = [ export const ServerLogs: RR.GetServerLogsRes = [