2017-12-15 21:39:18 +00:00
|
|
|
import Route from '@ember/routing/route';
|
2018-03-01 00:27:15 +00:00
|
|
|
import { collect } from '@ember/object/computed';
|
2018-02-28 19:48:06 +00:00
|
|
|
import { watchRecord } from 'nomad-ui/utils/properties/watch';
|
2018-03-01 00:27:15 +00:00
|
|
|
import WithWatchers from 'nomad-ui/mixins/with-watchers';
|
2018-03-13 21:58:22 +00:00
|
|
|
import notifyError from 'nomad-ui/utils/notify-error';
|
2020-06-10 13:49:16 +00:00
|
|
|
export default class AllocationRoute extends Route.extend(WithWatchers) {
|
2018-03-06 22:27:01 +00:00
|
|
|
startWatchers(controller, model) {
|
2018-11-06 00:33:33 +00:00
|
|
|
if (model) {
|
2019-03-26 07:46:44 +00:00
|
|
|
controller.set('watcher', this.watch.perform(model));
|
2018-11-06 00:33:33 +00:00
|
|
|
}
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2018-02-28 19:48:06 +00:00
|
|
|
|
2018-03-13 21:58:22 +00:00
|
|
|
model() {
|
|
|
|
// Preload the job for the allocation since it's required for the breadcrumb trail
|
2020-06-10 13:49:16 +00:00
|
|
|
return super
|
|
|
|
.model(...arguments)
|
2018-03-13 21:58:22 +00:00
|
|
|
.then(allocation => allocation.get('job').then(() => allocation))
|
|
|
|
.catch(notifyError(this));
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2018-03-13 21:58:22 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@watchRecord('allocation') watch;
|
2018-03-01 00:27:15 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@collect('watch') watchers;
|
|
|
|
}
|