github.com/iqoqo/nomad@v0.11.3-0.20200911112621-d7021c74d101/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 import Searchable from 'nomad-ui/mixins/searchable'; 7 import { lazyClick } from 'nomad-ui/helpers/lazy-click'; 8 9 export default Controller.extend( 10 SortableFactory([ 11 'id', 12 'schedulable', 13 'controllersHealthyProportion', 14 'nodesHealthyProportion', 15 'provider', 16 ]), 17 Searchable, 18 { 19 system: service(), 20 userSettings: service(), 21 volumesController: controller('csi/volumes'), 22 23 isForbidden: alias('volumesController.isForbidden'), 24 25 queryParams: { 26 currentPage: 'page', 27 searchTerm: 'search', 28 sortProperty: 'sort', 29 sortDescending: 'desc', 30 }, 31 32 currentPage: 1, 33 pageSize: readOnly('userSettings.pageSize'), 34 35 sortProperty: 'id', 36 sortDescending: false, 37 38 searchProps: computed(() => ['name']), 39 fuzzySearchProps: computed(() => ['name']), 40 fuzzySearchEnabled: true, 41 42 /** 43 Visible volumes are those that match the selected namespace 44 */ 45 visibleVolumes: computed('model.[]', 'model.@each.parent', function() { 46 if (!this.model) return []; 47 48 // Namespace related properties are ommitted from the dependent keys 49 // due to a prop invalidation bug caused by region switching. 50 const hasNamespaces = this.get('system.namespaces.length'); 51 const activeNamespace = this.get('system.activeNamespace.id') || 'default'; 52 53 return this.model 54 .compact() 55 .filter(volume => !hasNamespaces || volume.get('namespace.id') === activeNamespace); 56 }), 57 58 listToSort: alias('visibleVolumes'), 59 listToSearch: alias('listSorted'), 60 sortedVolumes: alias('listSearched'), 61 62 actions: { 63 gotoVolume(volume, event) { 64 lazyClick([ 65 () => this.transitionToRoute('csi.volumes.volume', volume.get('plainId')), 66 event, 67 ]); 68 }, 69 }, 70 } 71 );