Example of usage of the AllocationsStatsTracker
This commit is contained in:
parent
da4852a6cd
commit
f5fa5101b4
|
@ -1,9 +1,14 @@
|
|||
import { alias } from '@ember/object/computed';
|
||||
import Controller from '@ember/controller';
|
||||
import { inject as service } from '@ember/service';
|
||||
import { task, timeout } from 'ember-concurrency';
|
||||
import Sortable from 'nomad-ui/mixins/sortable';
|
||||
import { lazyClick } from 'nomad-ui/helpers/lazy-click';
|
||||
import { stats } from 'nomad-ui/utils/classes/allocation-stats-tracker';
|
||||
|
||||
export default Controller.extend(Sortable, {
|
||||
token: service(),
|
||||
|
||||
queryParams: {
|
||||
sortProperty: 'sort',
|
||||
sortDescending: 'desc',
|
||||
|
@ -15,6 +20,17 @@ export default Controller.extend(Sortable, {
|
|||
listToSort: alias('model.states'),
|
||||
sortedStates: alias('listSorted'),
|
||||
|
||||
stats: stats('model', function statsFetch() {
|
||||
return url => this.get('token').authorizedRequest(url);
|
||||
}),
|
||||
|
||||
pollStats: task(function*() {
|
||||
while (true) {
|
||||
yield this.get('stats').poll();
|
||||
yield timeout(1000);
|
||||
}
|
||||
}),
|
||||
|
||||
actions: {
|
||||
gotoTask(allocation, task) {
|
||||
this.transitionToRoute('allocations.allocation.task', task);
|
||||
|
|
12
ui/app/routes/allocations/allocation/index.js
Normal file
12
ui/app/routes/allocations/allocation/index.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
import Route from '@ember/routing/route';
|
||||
|
||||
export default Route.extend({
|
||||
setupController(controller) {
|
||||
this._super(...arguments);
|
||||
controller.get('pollStats').perform();
|
||||
},
|
||||
|
||||
resetController(controller) {
|
||||
controller.get('pollStats').cancelAll();
|
||||
},
|
||||
});
|
Loading…
Reference in a new issue