2017-12-15 21:39:18 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
2018-01-23 21:23:16 +00:00
|
|
|
import { alias } from '@ember/object/computed';
|
2017-12-15 21:39:18 +00:00
|
|
|
import Controller, { inject as controller } from '@ember/controller';
|
|
|
|
import { computed } from '@ember/object';
|
2017-09-19 14:47:10 +00:00
|
|
|
import Sortable from 'nomad-ui/mixins/sortable';
|
|
|
|
import Searchable from 'nomad-ui/mixins/searchable';
|
|
|
|
|
|
|
|
export default Controller.extend(Sortable, Searchable, {
|
2017-12-15 21:39:18 +00:00
|
|
|
system: service(),
|
|
|
|
jobsController: controller('jobs'),
|
2017-10-24 23:07:43 +00:00
|
|
|
|
2017-12-15 21:39:18 +00:00
|
|
|
isForbidden: alias('jobsController.isForbidden'),
|
2017-10-11 20:44:27 +00:00
|
|
|
|
2017-09-19 14:47:10 +00:00
|
|
|
queryParams: {
|
|
|
|
currentPage: 'page',
|
|
|
|
searchTerm: 'search',
|
|
|
|
sortProperty: 'sort',
|
|
|
|
sortDescending: 'desc',
|
|
|
|
},
|
|
|
|
|
|
|
|
currentPage: 1,
|
|
|
|
pageSize: 10,
|
|
|
|
|
|
|
|
sortProperty: 'modifyIndex',
|
|
|
|
sortDescending: true,
|
|
|
|
|
|
|
|
searchProps: computed(() => ['id', 'name']),
|
2018-04-12 16:20:47 +00:00
|
|
|
fuzzySearchProps: computed(() => ['name']),
|
|
|
|
fuzzySearchEnabled: true,
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2018-01-23 21:23:16 +00:00
|
|
|
/**
|
|
|
|
Filtered jobs are those that match the selected namespace and aren't children
|
|
|
|
of periodic or parameterized jobs.
|
|
|
|
*/
|
2018-08-09 18:02:50 +00:00
|
|
|
filteredJobs: computed('model.[]', 'model.@each.parent', function() {
|
|
|
|
// Namespace related properties are ommitted from the dependent keys
|
|
|
|
// due to a prop invalidation bug caused by region switching.
|
|
|
|
const hasNamespaces = this.get('system.namespaces.length');
|
|
|
|
const activeNamespace = this.get('system.activeNamespace.id') || 'default';
|
|
|
|
|
|
|
|
return this.get('model')
|
|
|
|
.compact()
|
|
|
|
.filter(job => !hasNamespaces || job.get('namespace.id') === activeNamespace)
|
|
|
|
.filter(job => !job.get('parent.content'));
|
|
|
|
}),
|
2017-10-11 20:44:27 +00:00
|
|
|
|
2017-12-15 21:39:18 +00:00
|
|
|
listToSort: alias('filteredJobs'),
|
|
|
|
listToSearch: alias('listSorted'),
|
|
|
|
sortedJobs: alias('listSearched'),
|
2017-09-19 14:47:10 +00:00
|
|
|
|
|
|
|
isShowingDeploymentDetails: false,
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
gotoJob(job) {
|
2018-03-20 20:40:48 +00:00
|
|
|
this.transitionToRoute('jobs.job', job.get('plainId'));
|
2017-09-19 14:47:10 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|