mirror of
https://github.com/kemko/nomad.git
synced 2026-01-09 11:55:42 +03:00
Clean up the remaining routes
This commit is contained in:
@@ -8,7 +8,9 @@ import { jobCrumbs } from 'nomad-ui/utils/breadcrumb-utils';
|
||||
|
||||
export default Route.extend(WithWatchers, {
|
||||
startWatchers(controller, model) {
|
||||
controller.set('watcher', this.get('watch').perform(model));
|
||||
if (model) {
|
||||
controller.set('watcher', this.get('watch').perform(model));
|
||||
}
|
||||
},
|
||||
|
||||
// Allocation breadcrumbs extend from job / task group breadcrumbs
|
||||
|
||||
@@ -17,16 +17,19 @@ export default Route.extend({
|
||||
|
||||
model({ name }) {
|
||||
const allocation = this.modelFor('allocations.allocation');
|
||||
if (allocation) {
|
||||
const task = allocation.get('states').findBy('name', name);
|
||||
|
||||
if (task) {
|
||||
return task;
|
||||
}
|
||||
// If there is no allocation, then there is no task.
|
||||
// Let the allocation route handle the 404 error.
|
||||
if (!allocation) return;
|
||||
|
||||
const task = allocation.get('states').findBy('name', name);
|
||||
|
||||
if (!task) {
|
||||
const err = new EmberError(`Task ${name} not found for allocation ${allocation.get('id')}`);
|
||||
err.code = '404';
|
||||
this.controllerFor('application').set('error', err);
|
||||
}
|
||||
|
||||
return task;
|
||||
},
|
||||
});
|
||||
|
||||
@@ -3,6 +3,6 @@ import Route from '@ember/routing/route';
|
||||
export default Route.extend({
|
||||
model() {
|
||||
const task = this._super(...arguments);
|
||||
return task.get('allocation.node').then(() => task);
|
||||
return task && task.get('allocation.node').then(() => task);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -30,8 +30,10 @@ export default Route.extend(WithWatchers, {
|
||||
},
|
||||
|
||||
startWatchers(controller, model) {
|
||||
controller.set('watchModel', this.get('watch').perform(model));
|
||||
controller.set('watchAllocations', this.get('watchAllocations').perform(model));
|
||||
if (model) {
|
||||
controller.set('watchModel', this.get('watch').perform(model));
|
||||
controller.set('watchAllocations', this.get('watchAllocations').perform(model));
|
||||
}
|
||||
},
|
||||
|
||||
watch: watchRecord('node'),
|
||||
|
||||
Reference in New Issue
Block a user