github.com/thomasobenaus/nomad@v0.11.1/ui/app/controllers/csi/volumes/index.js (about)

     1  import { inject as service } from '@ember/service';
     2  import { computed } from '@ember/object';
     3  import { alias, readOnly } from '@ember/object/computed';
     4  import Controller, { inject as controller } from '@ember/controller';
     5  import SortableFactory from 'nomad-ui/mixins/sortable-factory';
     6  
     7  export default Controller.extend(
     8    SortableFactory([
     9      'id',
    10      'schedulable',
    11      'controllersHealthyProportion',
    12      'nodesHealthyProportion',
    13      'provider',
    14    ]),
    15    {
    16      system: service(),
    17      userSettings: service(),
    18      volumesController: controller('csi/volumes'),
    19  
    20      isForbidden: alias('volumesController.isForbidden'),
    21  
    22      queryParams: {
    23        currentPage: 'page',
    24        sortProperty: 'sort',
    25        sortDescending: 'desc',
    26      },
    27  
    28      currentPage: 1,
    29      pageSize: readOnly('userSettings.pageSize'),
    30  
    31      sortProperty: 'id',
    32      sortDescending: false,
    33  
    34      /**
    35        Visible volumes are those that match the selected namespace
    36      */
    37      visibleVolumes: computed('model.[]', 'model.@each.parent', function() {
    38        if (!this.model) return [];
    39  
    40        // Namespace related properties are ommitted from the dependent keys
    41        // due to a prop invalidation bug caused by region switching.
    42        const hasNamespaces = this.get('system.namespaces.length');
    43        const activeNamespace = this.get('system.activeNamespace.id') || 'default';
    44  
    45        return this.model
    46          .compact()
    47          .filter(volume => !hasNamespaces || volume.get('namespace.id') === activeNamespace);
    48      }),
    49  
    50      listToSort: alias('visibleVolumes'),
    51      sortedVolumes: alias('listSorted'),
    52  
    53      // TODO: Remove once this page gets search capability
    54      resetPagination() {
    55        if (this.currentPage != null) {
    56          this.set('currentPage', 1);
    57        }
    58      },
    59  
    60      actions: {
    61        gotoVolume(volume) {
    62          this.transitionToRoute('csi.volumes.volume', volume.get('plainId'));
    63        },
    64      },
    65    }
    66  );