Adjust topo viz controller to new resource code

This commit is contained in:
Michael Lange 2020-10-13 07:53:05 -07:00
parent f918987d51
commit 9fc33a1f9b
1 changed files with 10 additions and 7 deletions

View File

@ -38,17 +38,19 @@ export default class TopologyControllers extends Controller {
return reduceToLargestUnit(this.totalMemory)[1];
}
@computed('model.allocations.@each.resources')
@computed('model.allocations.@each.allocatedResources')
get totalReservedMemory() {
const mibs = this.model.allocations
.mapBy('resources.memory')
.mapBy('allocatedResources.memory')
.reduce((sum, memory) => sum + (memory || 0), 0);
return mibs * 1024 * 1024;
}
@computed('model.allocations.@each.resources')
@computed('model.allocations.@each.allocatedResources')
get totalReservedCPU() {
return this.model.allocations.mapBy('resources.cpu').reduce((sum, cpu) => sum + (cpu || 0), 0);
return this.model.allocations
.mapBy('allocatedResources.cpu')
.reduce((sum, cpu) => sum + (cpu || 0), 0);
}
@computed('totalMemory', 'totalReservedMemory')
@ -105,11 +107,12 @@ export default class TopologyControllers extends Controller {
}
@action
setAllocation(allocation) {
this.set('activeAllocation', allocation);
async setAllocation(allocation) {
if (allocation) {
allocation.reload();
await allocation.reload();
await allocation.job.reload();
}
this.set('activeAllocation', allocation);
}
@action