<commit_before>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) {
  async model() {
    await this.store.findAll('node');
    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;
}
<commit_msg>fix:  protect route if not auth<commit_after>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;
}

{'fraction_non_alphanumeric': 0.14352090862157976, 'fraction_numerical': 0.0, 'mean_word_length': 4.113456464379947, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7300123', 'n_tokens_mistral': 616, 'n_tokens_neox': 604, 'n_words': 120}