2021-12-20 20:11:01 +00:00
|
|
|
import Controller from '@ember/controller';
|
|
|
|
import { action } from '@ember/object';
|
|
|
|
import { tracked } from '@glimmer/tracking';
|
2021-12-23 16:54:47 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
2021-12-20 20:11:01 +00:00
|
|
|
|
|
|
|
export default class EvaluationsController extends Controller {
|
2021-12-23 16:54:47 +00:00
|
|
|
@service userSettings;
|
|
|
|
|
|
|
|
queryParams = ['nextToken', 'pageSize', 'status'];
|
2021-12-21 18:31:28 +00:00
|
|
|
|
|
|
|
get shouldDisableNext() {
|
|
|
|
return !this.model.meta?.nextToken;
|
|
|
|
}
|
|
|
|
|
|
|
|
get shouldDisablePrev() {
|
|
|
|
return !this.previousTokens.length;
|
|
|
|
}
|
2021-12-20 20:11:01 +00:00
|
|
|
|
2021-12-23 16:54:47 +00:00
|
|
|
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;
|
2021-12-21 18:31:28 +00:00
|
|
|
@tracked nextToken = null;
|
|
|
|
@tracked previousTokens = [];
|
2021-12-23 16:54:47 +00:00
|
|
|
@tracked status = null;
|
2021-12-20 20:11:01 +00:00
|
|
|
|
|
|
|
@action
|
|
|
|
onChange(newPageSize) {
|
|
|
|
this.pageSize = newPageSize;
|
|
|
|
}
|
2021-12-21 18:31:28 +00:00
|
|
|
|
|
|
|
@action
|
|
|
|
onNext(nextToken) {
|
|
|
|
this.previousTokens = [...this.previousTokens, this.nextToken];
|
|
|
|
this.nextToken = nextToken;
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
2021-12-23 16:54:47 +00:00
|
|
|
onPrev() {
|
|
|
|
const lastToken = this.previousTokens.pop();
|
2021-12-21 18:31:28 +00:00
|
|
|
this.previousTokens = [...this.previousTokens];
|
|
|
|
this.nextToken = lastToken;
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
refresh() {
|
2021-12-23 16:54:47 +00:00
|
|
|
this._resetTokens();
|
|
|
|
this.status = null;
|
|
|
|
this.pageSize = this.userSettings.pageSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
setStatus(selection) {
|
|
|
|
this._resetTokens();
|
|
|
|
this.status = selection;
|
|
|
|
}
|
|
|
|
|
|
|
|
_resetTokens() {
|
2021-12-21 18:31:28 +00:00
|
|
|
this.nextToken = null;
|
|
|
|
this.previousTokens = [];
|
|
|
|
}
|
2021-12-20 20:11:01 +00:00
|
|
|
}
|