2020-11-04 18:22:24 +00:00
|
|
|
import Route from '@ember/routing/route';
|
|
|
|
import notifyError from 'nomad-ui/utils/notify-error';
|
|
|
|
|
|
|
|
export default class OptimizeSummaryRoute extends Route {
|
|
|
|
async model({ jobNamespace, slug }) {
|
2021-04-29 20:00:59 +00:00
|
|
|
const model = this.modelFor('optimize').summaries.find(
|
2021-12-28 16:08:12 +00:00
|
|
|
(summary) =>
|
|
|
|
summary.slug === slug && summary.jobNamespace === jobNamespace
|
2020-11-04 18:22:24 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
if (!model) {
|
2021-12-28 16:08:12 +00:00
|
|
|
const error = new Error(
|
|
|
|
`Unable to find summary for ${slug} in namespace ${jobNamespace}`
|
|
|
|
);
|
2020-11-04 18:22:24 +00:00
|
|
|
error.code = 404;
|
|
|
|
notifyError(this)(error);
|
|
|
|
} else {
|
|
|
|
return model;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|