github.com/hernad/nomad@v1.6.112/ui/app/routes/topology.js (about)

     1  /**
     2   * Copyright (c) HashiCorp, Inc.
     3   * SPDX-License-Identifier: MPL-2.0
     4   */
     5  
     6  import { inject as service } from '@ember/service';
     7  import Route from '@ember/routing/route';
     8  import WithForbiddenState from 'nomad-ui/mixins/with-forbidden-state';
     9  import notifyForbidden from 'nomad-ui/utils/notify-forbidden';
    10  import classic from 'ember-classic-decorator';
    11  import RSVP from 'rsvp';
    12  
    13  @classic
    14  export default class TopologyRoute extends Route.extend(WithForbiddenState) {
    15    @service store;
    16    @service system;
    17  
    18    model() {
    19      return RSVP.hash({
    20        allocations: this.store.query('allocation', {
    21          resources: true,
    22          task_states: false,
    23          namespace: '*',
    24        }),
    25        nodes: this.store.query('node', { resources: true }),
    26        // Nodes are not allowed to be in the 'all' node pool, so filter it out.
    27        nodePools: this.store
    28          .findAll('node-pool')
    29          .then((pools) => pools.filter((p) => p.name !== 'all')),
    30      }).catch(notifyForbidden(this));
    31    }
    32  
    33    setupController(controller, model) {
    34      // When the model throws, make sure the interface expected by the controller is consistent.
    35      if (!model) {
    36        controller.model = {
    37          allocations: [],
    38          nodes: [],
    39          nodePools: [],
    40        };
    41      }
    42  
    43      return super.setupController(...arguments);
    44    }
    45  }