open-nomad/ui/app/routes/clients/client.js

44 lines
1.2 KiB
JavaScript
Raw Normal View History

import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
import { collect } from '@ember/object/computed';
2017-09-28 17:06:24 +00:00
import notifyError from 'nomad-ui/utils/notify-error';
import { watchRecord, watchRelationship } from 'nomad-ui/utils/properties/watch';
import WithWatchers from 'nomad-ui/mixins/with-watchers';
2017-09-19 14:47:10 +00:00
export default Route.extend(WithWatchers, {
store: service(),
2017-09-19 14:47:10 +00:00
2017-09-28 17:06:24 +00:00
model() {
return this._super(...arguments).catch(notifyError(this));
},
breadcrumbs(model) {
if (!model) return [];
return [
{
label: model.get('shortId'),
args: ['clients.client', model.get('id')],
},
];
},
2017-09-19 14:47:10 +00:00
afterModel(model) {
2017-09-28 17:06:24 +00:00
if (model && model.get('isPartial')) {
2017-09-19 14:47:10 +00:00
return model.reload().then(node => node.get('allocations'));
}
2017-09-28 17:06:24 +00:00
return model && model.get('allocations');
2017-09-19 14:47:10 +00:00
},
startWatchers(controller, model) {
2018-11-06 00:33:33 +00:00
if (model) {
controller.set('watchModel', this.get('watch').perform(model));
controller.set('watchAllocations', this.get('watchAllocations').perform(model));
}
},
watch: watchRecord('node'),
watchAllocations: watchRelationship('allocations'),
watchers: collect('watch', 'watchAllocations'),
2017-09-19 14:47:10 +00:00
});