github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/ui/app/components/job-page/parts/recent-allocations.js (about) 1 import Component from '@ember/component'; 2 import { computed } from '@ember/object'; 3 import { inject as service } from '@ember/service'; 4 import PromiseArray from 'nomad-ui/utils/classes/promise-array'; 5 6 export default Component.extend({ 7 classNames: ['boxed-section'], 8 9 router: service(), 10 11 sortProperty: 'modifyIndex', 12 sortDescending: true, 13 sortedAllocations: computed('job.allocations.@each.modifyIndex', function() { 14 return PromiseArray.create({ 15 promise: this.get('job.allocations').then(allocations => 16 allocations 17 .sortBy('modifyIndex') 18 .reverse() 19 .slice(0, 5) 20 ), 21 }); 22 }), 23 24 actions: { 25 gotoAllocation(allocation) { 26 this.router.transitionTo('allocations.allocation', allocation.id); 27 }, 28 }, 29 });