github.com/aminovpavel/nomad@v0.11.8/ui/app/components/fs/browser.js (about)

     1  import Component from '@ember/component';
     2  import { computed } from '@ember/object';
     3  import { filterBy } from '@ember/object/computed';
     4  
     5  export default Component.extend({
     6    tagName: '',
     7  
     8    model: null,
     9  
    10    allocation: computed('model', function() {
    11      if (this.model.allocation) {
    12        return this.model.allocation;
    13      } else {
    14        return this.model;
    15      }
    16    }),
    17  
    18    task: computed('model', function() {
    19      if (this.model.allocation) {
    20        return this.model;
    21      }
    22    }),
    23  
    24    type: computed('task', function() {
    25      if (this.task) {
    26        return 'task';
    27      } else {
    28        return 'allocation';
    29      }
    30    }),
    31  
    32    directories: filterBy('directoryEntries', 'IsDir'),
    33    files: filterBy('directoryEntries', 'IsDir', false),
    34  
    35    sortedDirectoryEntries: computed(
    36      'directoryEntries.[]',
    37      'sortProperty',
    38      'sortDescending',
    39      function() {
    40        const sortProperty = this.sortProperty;
    41  
    42        const directorySortProperty = sortProperty === 'Size' ? 'Name' : sortProperty;
    43  
    44        const sortedDirectories = this.directories.sortBy(directorySortProperty);
    45        const sortedFiles = this.files.sortBy(sortProperty);
    46  
    47        const sortedDirectoryEntries = sortedDirectories.concat(sortedFiles);
    48  
    49        if (this.sortDescending) {
    50          return sortedDirectoryEntries.reverse();
    51        } else {
    52          return sortedDirectoryEntries;
    53        }
    54      }
    55    ),
    56  
    57  });