From d55c3ca809e8879fcc2e8b014487211246f7ba83 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Mon, 24 Aug 2020 09:27:43 -0700 Subject: [PATCH] Derive allocation Resources property from TaskResources --- ui/mirage/serializers/allocation.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ui/mirage/serializers/allocation.js b/ui/mirage/serializers/allocation.js index 9f5801a6f..eeaaf28f6 100644 --- a/ui/mirage/serializers/allocation.js +++ b/ui/mirage/serializers/allocation.js @@ -18,5 +18,14 @@ export default ApplicationSerializer.extend({ function serializeAllocation(allocation) { allocation.TaskStates = allocation.TaskStates.reduce(arrToObj('Name'), {}); + allocation.Resources = allocation.TaskResources.mapBy('Resources').reduce( + (hash, resources) => { + ['CPU', 'DiskMB', 'IOPS', 'MemoryMB'].forEach(key => (hash[key] += resources[key])); + hash.Networks = resources.Networks; + hash.Ports = resources.Ports; + return hash; + }, + { CPU: 0, DiskMB: 0, IOPS: 0, MemoryMB: 0 } + ); allocation.TaskResources = allocation.TaskResources.reduce(arrToObj('Name', 'Resources'), {}); }