71 lines
1.6 KiB
JavaScript
71 lines
1.6 KiB
JavaScript
import Controller from '@ember/controller';
|
|
import { action } from '@ember/object';
|
|
import { tracked } from '@glimmer/tracking';
|
|
import { inject as service } from '@ember/service';
|
|
|
|
export default class EvaluationsController extends Controller {
|
|
@service userSettings;
|
|
|
|
queryParams = ['nextToken', 'pageSize', 'status'];
|
|
|
|
get shouldDisableNext() {
|
|
return !this.model.meta?.nextToken;
|
|
}
|
|
|
|
get shouldDisablePrev() {
|
|
return !this.previousTokens.length;
|
|
}
|
|
|
|
get optionsEvaluationsStatus() {
|
|
return [
|
|
{ key: null, label: 'All' },
|
|
{ key: 'blocked', label: 'Blocked' },
|
|
{ key: 'pending', label: 'Pending' },
|
|
{ key: 'complete', label: 'Complete' },
|
|
{ key: 'failed', label: 'Failed' },
|
|
{ key: 'canceled', label: 'Canceled' },
|
|
];
|
|
}
|
|
|
|
@tracked pageSize = this.userSettings.pageSize;
|
|
@tracked nextToken = null;
|
|
@tracked previousTokens = [];
|
|
@tracked status = null;
|
|
|
|
@action
|
|
onChange(newPageSize) {
|
|
this.pageSize = newPageSize;
|
|
}
|
|
|
|
@action
|
|
onNext(nextToken) {
|
|
this.previousTokens = [...this.previousTokens, this.nextToken];
|
|
this.nextToken = nextToken;
|
|
}
|
|
|
|
@action
|
|
onPrev() {
|
|
const lastToken = this.previousTokens.pop();
|
|
this.previousTokens = [...this.previousTokens];
|
|
this.nextToken = lastToken;
|
|
}
|
|
|
|
@action
|
|
refresh() {
|
|
this._resetTokens();
|
|
this.status = null;
|
|
this.pageSize = this.userSettings.pageSize;
|
|
}
|
|
|
|
@action
|
|
setStatus(selection) {
|
|
this._resetTokens();
|
|
this.status = selection;
|
|
}
|
|
|
|
_resetTokens() {
|
|
this.nextToken = null;
|
|
this.previousTokens = [];
|
|
}
|
|
}
|