mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
Example usage of the NodeStatsTracker
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { alias } from '@ember/object/computed';
|
||||
import Controller from '@ember/controller';
|
||||
import { computed } from '@ember/object';
|
||||
import { task, timeout } from 'ember-concurrency';
|
||||
import Sortable from 'nomad-ui/mixins/sortable';
|
||||
import Searchable from 'nomad-ui/mixins/searchable';
|
||||
import { stats } from 'nomad-ui/utils/classes/node-stats-tracker';
|
||||
|
||||
export default Controller.extend(Sortable, Searchable, {
|
||||
queryParams: {
|
||||
@@ -34,6 +36,17 @@ export default Controller.extend(Sortable, Searchable, {
|
||||
return this.get('model.drivers').sortBy('name');
|
||||
}),
|
||||
|
||||
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: {
|
||||
gotoAllocation(allocation) {
|
||||
this.transitionToRoute('allocations.allocation', allocation);
|
||||
|
||||
@@ -38,4 +38,13 @@ export default Route.extend(WithWatchers, {
|
||||
watchAllocations: watchRelationship('allocations'),
|
||||
|
||||
watchers: collect('watch', 'watchAllocations'),
|
||||
|
||||
setupController(controller) {
|
||||
this._super(...arguments);
|
||||
controller.get('pollStats').perform();
|
||||
},
|
||||
|
||||
resetController(controller) {
|
||||
controller.get('pollStats').cancelAll();
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user