github.com/anuvu/nomad@v0.8.7-atom1/ui/app/controllers/jobs/index.js (about) 1 import { inject as service } from '@ember/service'; 2 import { alias } from '@ember/object/computed'; 3 import Controller, { inject as controller } from '@ember/controller'; 4 import { computed } from '@ember/object'; 5 import Sortable from 'nomad-ui/mixins/sortable'; 6 import Searchable from 'nomad-ui/mixins/searchable'; 7 8 export default Controller.extend(Sortable, Searchable, { 9 system: service(), 10 jobsController: controller('jobs'), 11 12 isForbidden: alias('jobsController.isForbidden'), 13 14 queryParams: { 15 currentPage: 'page', 16 searchTerm: 'search', 17 sortProperty: 'sort', 18 sortDescending: 'desc', 19 }, 20 21 currentPage: 1, 22 pageSize: 10, 23 24 sortProperty: 'modifyIndex', 25 sortDescending: true, 26 27 searchProps: computed(() => ['id', 'name']), 28 fuzzySearchProps: computed(() => ['name']), 29 fuzzySearchEnabled: true, 30 31 /** 32 Filtered jobs are those that match the selected namespace and aren't children 33 of periodic or parameterized jobs. 34 */ 35 filteredJobs: computed( 36 'model.[]', 37 'model.@each.parent', 38 'system.activeNamespace', 39 'system.namespaces.length', 40 function() { 41 const hasNamespaces = this.get('system.namespaces.length'); 42 const activeNamespace = this.get('system.activeNamespace.id') || 'default'; 43 44 return this.get('model') 45 .compact() 46 .filter(job => !hasNamespaces || job.get('namespace.id') === activeNamespace) 47 .filter(job => !job.get('parent.content')); 48 } 49 ), 50 51 listToSort: alias('filteredJobs'), 52 listToSearch: alias('listSorted'), 53 sortedJobs: alias('listSearched'), 54 55 isShowingDeploymentDetails: false, 56 57 actions: { 58 gotoJob(job) { 59 this.transitionToRoute('jobs.job', job.get('plainId')); 60 }, 61 62 refresh() { 63 this.send('refreshRoute'); 64 }, 65 }, 66 });