github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/app/routes/jobs/index.js (about) 1 import { inject as service } from '@ember/service'; 2 import Route from '@ember/routing/route'; 3 import RSVP from 'rsvp'; 4 import { collect } from '@ember/object/computed'; 5 import { watchAll, watchQuery } 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 jobs: this.store 25 .query('job', { namespace: params.qpNamespace, meta: true }) 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.watchJobs.perform({ namespace: controller.qpNamespace, meta: true }) 36 ); 37 } 38 39 @watchQuery('job') watchJobs; 40 @watchAll('namespace') watchNamespaces; 41 @collect('watchJobs', 'watchNamespaces') watchers; 42 }