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

62 lines
1.6 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
},
2019-11-15 04:23:47 +00:00
setupController(controller, model) {
controller.set('flagAsDraining', model.isDraining);
return this._super(...arguments);
},
resetController(controller) {
controller.setProperties({
eligibilityError: null,
stopDrainError: null,
drainError: null,
flagAsDraining: false,
showDrainNotification: false,
showDrainUpdateNotification: false,
showDrainStoppedNotification: false,
});
},
startWatchers(controller, model) {
2018-11-06 00:33:33 +00:00
if (model) {
2019-03-26 07:46:44 +00:00
controller.set('watchModel', this.watch.perform(model));
controller.set('watchAllocations', this.watchAllocations.perform(model));
2018-11-06 00:33:33 +00:00
}
},
watch: watchRecord('node'),
watchAllocations: watchRelationship('allocations'),
watchers: collect('watch', 'watchAllocations'),
2017-09-19 14:47:10 +00:00
});