github.com/hspak/nomad@v0.7.2-0.20180309000617-bc4ae22a39a5/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 29 /** 30 Filtered jobs are those that match the selected namespace and aren't children 31 of periodic or parameterized jobs. 32 */ 33 filteredJobs: computed( 34 'model.[]', 35 'model.@each.parent', 36 'system.activeNamespace', 37 'system.namespaces.length', 38 function() { 39 const hasNamespaces = this.get('system.namespaces.length'); 40 const activeNamespace = this.get('system.activeNamespace.id') || 'default'; 41 42 return this.get('model') 43 .filter(job => !hasNamespaces || job.get('namespace.id') === activeNamespace) 44 .filter(job => !job.get('parent.content')); 45 } 46 ), 47 48 listToSort: alias('filteredJobs'), 49 listToSearch: alias('listSorted'), 50 sortedJobs: alias('listSearched'), 51 52 isShowingDeploymentDetails: false, 53 54 actions: { 55 gotoJob(job) { 56 this.transitionToRoute('jobs.job', job); 57 }, 58 59 refresh() { 60 this.send('refreshRoute'); 61 }, 62 }, 63 });