github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/ui/app/components/topo-viz/datacenter.js (about)

     1  import Component from '@glimmer/component';
     2  
     3  export default class TopoVizDatacenter extends Component {
     4    get scheduledAllocations() {
     5      return this.args.datacenter.nodes.reduce(
     6        (all, node) => all.concat(node.allocations.filterBy('allocation.isScheduled')),
     7        []
     8      );
     9    }
    10  
    11    get aggregatedAllocationResources() {
    12      return this.scheduledAllocations.reduce(
    13        (totals, allocation) => {
    14          totals.cpu += allocation.cpu;
    15          totals.memory += allocation.memory;
    16          return totals;
    17        },
    18        { cpu: 0, memory: 0 }
    19      );
    20    }
    21  
    22    get aggregatedNodeResources() {
    23      return this.args.datacenter.nodes.reduce(
    24        (totals, node) => {
    25          totals.cpu += node.cpu;
    26          totals.memory += node.memory;
    27          return totals;
    28        },
    29        { cpu: 0, memory: 0 }
    30      );
    31    }
    32  }