open-nomad/ui/app/controllers/jobs/job/task-group.js

63 lines
1.4 KiB
JavaScript
Raw Normal View History

import { inject as service } from '@ember/service';
import { alias, readOnly } from '@ember/object/computed';
import Controller from '@ember/controller';
import { action, 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';
import WithNamespaceResetting from 'nomad-ui/mixins/with-namespace-resetting';
import classic from 'ember-classic-decorator';
2017-09-19 14:47:10 +00:00
@classic
export default class TaskGroupController extends Controller.extend(
Sortable,
Searchable,
WithNamespaceResetting
) {
@service userSettings;
queryParams = [
{
currentPage: 'page',
},
{
searchTerm: 'search',
},
{
sortProperty: 'sort',
},
{
sortDescending: 'desc',
},
];
2017-09-19 14:47:10 +00:00
currentPage = 1;
@readOnly('userSettings.pageSize') pageSize;
2017-09-19 14:47:10 +00:00
sortProperty = 'modifyIndex';
sortDescending = true;
2017-09-19 14:47:10 +00:00
@computed
get searchProps() {
return ['shortId', 'name'];
}
2017-09-19 14:47:10 +00:00
@computed('model.allocations.[]')
get allocations() {
2017-09-19 14:47:10 +00:00
return this.get('model.allocations') || [];
}
@alias('allocations') listToSort;
@alias('listSorted') listToSearch;
@alias('listSearched') sortedAllocations;
@action
gotoAllocation(allocation) {
this.transitionToRoute('allocations.allocation', allocation);
}
@action
scaleTaskGroup(count) {
return this.model.scale(count);
}
}