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 class ClientRoute extends Route.extend(WithWatchers) {
@service store;
2017-09-19 14:47:10 +00:00
2017-09-28 17:06:24 +00:00
model() {
return super.model(...arguments).catch(notifyError(this));
}
2017-09-28 17:06:24 +00:00
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');
}
2019-11-15 04:23:47 +00:00
setupController(controller, model) {
2019-12-05 00:54:36 +00:00
controller.set('flagAsDraining', model && model.isDraining);
2019-11-15 04:23:47 +00:00
return super.setupController(...arguments);
}
2019-11-15 04:23:47 +00:00
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
}
}
@watchRecord('node') watch;
@watchRelationship('allocations') watchAllocations;
@collect('watch', 'watchAllocations') watchers;
}