github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/ui/app/routes/optimize.js (about) 1 import Route from '@ember/routing/route'; 2 import classic from 'ember-classic-decorator'; 3 import { inject as service } from '@ember/service'; 4 import { action } from '@ember/object'; 5 import { next } from '@ember/runloop'; 6 import RSVP from 'rsvp'; 7 8 @classic 9 export default class OptimizeRoute extends Route { 10 @service can; 11 12 breadcrumbs = [ 13 { 14 label: 'Recommendations', 15 args: ['optimize'], 16 }, 17 ]; 18 19 beforeModel() { 20 if (this.can.cannot('accept recommendation')) { 21 this.transitionTo('jobs'); 22 } 23 } 24 25 async model() { 26 const summaries = await this.store.findAll('recommendation-summary'); 27 const jobs = await RSVP.all(summaries.mapBy('job')); 28 await RSVP.all( 29 jobs 30 .filter(job => job) 31 .filterBy('isPartial') 32 .map(j => j.reload()) 33 ); 34 35 return summaries.sortBy('submitTime').reverse(); 36 } 37 38 @action 39 reachedEnd() { 40 this.store.unloadAll('recommendation-summary'); 41 42 next(() => { 43 this.transitionTo('optimize'); 44 this.refresh(); 45 }); 46 } 47 }