github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/ui/app/components/job-page/parts/recent-allocations.js (about) 1 import Component from '@ember/component'; 2 import { action, computed } from '@ember/object'; 3 import { inject as service } from '@ember/service'; 4 import PromiseArray from 'nomad-ui/utils/classes/promise-array'; 5 import { classNames } from '@ember-decorators/component'; 6 import classic from 'ember-classic-decorator'; 7 8 @classic 9 @classNames('boxed-section') 10 export default class RecentAllocations extends Component { 11 @service router; 12 13 sortProperty = 'modifyIndex'; 14 sortDescending = true; 15 16 @computed('job.allocations.@each.modifyIndex') 17 get sortedAllocations() { 18 return PromiseArray.create({ 19 promise: this.get('job.allocations').then(allocations => 20 allocations 21 .sortBy('modifyIndex') 22 .reverse() 23 .slice(0, 5) 24 ), 25 }); 26 } 27 28 @action 29 gotoAllocation(allocation) { 30 this.router.transitionTo('allocations.allocation', allocation.id); 31 } 32 }