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