github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/ui/app/routes/csi/volumes.js (about)

     1  import { inject as service } from '@ember/service';
     2  import Route from '@ember/routing/route';
     3  import WithForbiddenState from 'nomad-ui/mixins/with-forbidden-state';
     4  import notifyForbidden from 'nomad-ui/utils/notify-forbidden';
     5  import classic from 'ember-classic-decorator';
     6  
     7  @classic
     8  export default class VolumesRoute extends Route.extend(WithForbiddenState) {
     9    @service system;
    10    @service store;
    11  
    12    breadcrumbs = [
    13      {
    14        label: 'Storage',
    15        args: ['csi.index'],
    16      },
    17    ];
    18  
    19    queryParams = {
    20      volumeNamespace: {
    21        refreshModel: true,
    22      },
    23    };
    24  
    25    beforeModel(transition) {
    26      return this.get('system.namespaces').then(namespaces => {
    27        const queryParam = transition.to.queryParams.namespace;
    28        this.set('system.activeNamespace', queryParam || 'default');
    29  
    30        return namespaces;
    31      });
    32    }
    33  
    34    model() {
    35      return this.store
    36        .query('volume', { type: 'csi' })
    37        .then(volumes => {
    38          volumes.forEach(volume => volume.plugin);
    39          return volumes;
    40        })
    41        .catch(notifyForbidden(this));
    42    }
    43  }