open-nomad/ui/app/routes/jobs/job/clients.js
2022-01-24 11:07:17 -05:00

43 lines
1,002 B
JavaScript

import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
import WithWatchers from 'nomad-ui/mixins/with-watchers';
import {
watchRecord,
watchRelationship,
watchAll,
} from 'nomad-ui/utils/properties/watch';
import { collect } from '@ember/object/computed';
export default class ClientsRoute extends Route.extend(WithWatchers) {
@service can;
beforeModel() {
if (this.can.cannot('read client')) {
this.transitionTo('jobs.job');
}
}
async model() {
return this.modelFor('jobs.job');
}
startWatchers(controller, model) {
if (!model) {
return;
}
controller.set('watchers', {
model: this.watch.perform(model),
allocations: this.watchAllocations.perform(model),
nodes: this.watchNodes.perform(),
});
}
@watchRecord('job') watch;
@watchAll('node') watchNodes;
@watchRelationship('allocations') watchAllocations;
@collect('watch', 'watchNodes', 'watchAllocations')
watchers;
}