github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/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) =>
     7          all.concat(node.allocations.filterBy('allocation.isScheduled')),
     8        []
     9      );
    10    }
    11  
    12    get aggregatedAllocationResources() {
    13      return this.scheduledAllocations.reduce(
    14        (totals, allocation) => {
    15          totals.cpu += allocation.cpu;
    16          totals.memory += allocation.memory;
    17          return totals;
    18        },
    19        { cpu: 0, memory: 0 }
    20      );
    21    }
    22  
    23    get aggregatedNodeResources() {
    24      return this.args.datacenter.nodes.reduce(
    25        (totals, node) => {
    26          totals.cpu += node.cpu;
    27          totals.memory += node.memory;
    28          return totals;
    29        },
    30        { cpu: 0, memory: 0 }
    31      );
    32    }
    33  }