github.com/hernad/nomad@v1.6.112/ui/app/components/topo-viz/datacenter.js (about)

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