github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/app/routes/csi/volumes/index.js (about)

     1  import { inject as service } from '@ember/service';
     2  import RSVP from 'rsvp';
     3  import Route from '@ember/routing/route';
     4  import { collect } from '@ember/object/computed';
     5  import { watchQuery, watchAll } from 'nomad-ui/utils/properties/watch';
     6  import WithWatchers from 'nomad-ui/mixins/with-watchers';
     7  import notifyForbidden from 'nomad-ui/utils/notify-forbidden';
     8  import WithForbiddenState from 'nomad-ui/mixins/with-forbidden-state';
     9  
    10  export default class IndexRoute extends Route.extend(
    11    WithWatchers,
    12    WithForbiddenState
    13  ) {
    14    @service store;
    15  
    16    queryParams = {
    17      qpNamespace: {
    18        refreshModel: true,
    19      },
    20    };
    21  
    22    model(params) {
    23      return RSVP.hash({
    24        volumes: this.store
    25          .query('volume', { type: 'csi', namespace: params.qpNamespace })
    26          .catch(notifyForbidden(this)),
    27        namespaces: this.store.findAll('namespace'),
    28      });
    29    }
    30  
    31    startWatchers(controller) {
    32      controller.set('namespacesWatch', this.watchNamespaces.perform());
    33      controller.set(
    34        'modelWatch',
    35        this.watchVolumes.perform({
    36          type: 'csi',
    37          namespace: controller.qpNamespace,
    38        })
    39      );
    40    }
    41  
    42    @watchQuery('volume') watchVolumes;
    43    @watchAll('namespace') watchNamespaces;
    44    @collect('watchVolumes', 'watchNamespaces') watchers;
    45  }