github.com/zhizhiboom/nomad@v0.8.5-0.20180907175415-f28fd3a1a056/ui/app/components/job-page/parts/recent-allocations.js (about)

     1  import Component from '@ember/component';
     2  import { computed } from '@ember/object';
     3  import PromiseArray from 'nomad-ui/utils/classes/promise-array';
     4  
     5  export default Component.extend({
     6    sortProperty: 'modifyIndex',
     7    sortDescending: true,
     8    sortedAllocations: computed('job.allocations.@each.modifyIndex', function() {
     9      return new PromiseArray({
    10        promise: this.get('job.allocations').then(allocations =>
    11          allocations
    12            .sortBy('modifyIndex')
    13            .reverse()
    14            .slice(0, 5)
    15        ),
    16      });
    17    }),
    18  
    19    actions: {
    20      gotoAllocation(allocation) {
    21        this.transitionToRoute('allocations.allocation', allocation);
    22      },
    23    },
    24  });