open-nomad/ui/app/routes/optimize/summary.js

19 lines
563 B
JavaScript
Raw Normal View History

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