github.com/manicqin/nomad@v0.9.5/ui/app/controllers/clients/client.js (about)

     1  import { alias } from '@ember/object/computed';
     2  import Controller from '@ember/controller';
     3  import { computed } from '@ember/object';
     4  import Sortable from 'nomad-ui/mixins/sortable';
     5  import Searchable from 'nomad-ui/mixins/searchable';
     6  
     7  export default Controller.extend(Sortable, Searchable, {
     8    queryParams: {
     9      currentPage: 'page',
    10      searchTerm: 'search',
    11      sortProperty: 'sort',
    12      sortDescending: 'desc',
    13      onlyPreemptions: 'preemptions',
    14    },
    15  
    16    currentPage: 1,
    17    pageSize: 8,
    18  
    19    sortProperty: 'modifyIndex',
    20    sortDescending: true,
    21  
    22    searchProps: computed(() => ['shortId', 'name']),
    23  
    24    onlyPreemptions: false,
    25  
    26    visibleAllocations: computed(
    27      'model.allocations.[]',
    28      'preemptions.[]',
    29      'onlyPreemptions',
    30      function() {
    31        return this.onlyPreemptions ? this.preemptions : this.model.allocations;
    32      }
    33    ),
    34  
    35    listToSort: alias('visibleAllocations'),
    36    listToSearch: alias('listSorted'),
    37    sortedAllocations: alias('listSearched'),
    38  
    39    preemptions: computed('model.allocations.@each.wasPreempted', function() {
    40      return this.model.allocations.filterBy('wasPreempted');
    41    }),
    42  
    43    sortedEvents: computed('model.events.@each.time', function() {
    44      return this.get('model.events')
    45        .sortBy('time')
    46        .reverse();
    47    }),
    48  
    49    sortedDrivers: computed('model.drivers.@each.name', function() {
    50      return this.get('model.drivers').sortBy('name');
    51    }),
    52  
    53    actions: {
    54      gotoAllocation(allocation) {
    55        this.transitionToRoute('allocations.allocation', allocation);
    56      },
    57  
    58      setPreemptionFilter(value) {
    59        this.set('onlyPreemptions', value);
    60      },
    61    },
    62  });