open-nomad/ui/app/controllers/evaluations/index.js

71 lines
1.6 KiB
JavaScript
Raw Normal View History

2021-12-20 20:11:01 +00:00
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
import { inject as service } from '@ember/service';
2021-12-20 20:11:01 +00:00
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;
}
2021-12-20 20:11:01 +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;
@tracked nextToken = null;
@tracked previousTokens = [];
@tracked status = null;
2021-12-20 20:11:01 +00:00
@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 = [];
}
2021-12-20 20:11:01 +00:00
}