2017-12-15 21:39:18 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import Route from '@ember/routing/route';
|
2018-03-01 00:27:15 +00:00
|
|
|
import { collect } from '@ember/object/computed';
|
2017-09-28 17:06:24 +00:00
|
|
|
import notifyError from 'nomad-ui/utils/notify-error';
|
2018-02-28 20:15:39 +00:00
|
|
|
import { watchRecord, watchRelationship } from 'nomad-ui/utils/properties/watch';
|
2018-03-01 00:27:15 +00:00
|
|
|
import WithWatchers from 'nomad-ui/mixins/with-watchers';
|
2017-09-19 14:47:10 +00:00
|
|
|
|
2020-06-10 13:49:16 +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() {
|
2020-06-10 13:49:16 +00:00
|
|
|
return super.model(...arguments).catch(notifyError(this));
|
|
|
|
}
|
2017-09-28 17:06:24 +00:00
|
|
|
|
2018-06-20 01:15:46 +00:00
|
|
|
breadcrumbs(model) {
|
|
|
|
if (!model) return [];
|
|
|
|
return [
|
|
|
|
{
|
|
|
|
label: model.get('shortId'),
|
|
|
|
args: ['clients.client', model.get('id')],
|
|
|
|
},
|
|
|
|
];
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2018-06-20 01:15:46 +00:00
|
|
|
|
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');
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2018-02-28 20:15:39 +00:00
|
|
|
|
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
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
return super.setupController(...arguments);
|
|
|
|
}
|
2019-11-15 04:23:47 +00:00
|
|
|
|
2019-11-19 06:36:07 +00:00
|
|
|
resetController(controller) {
|
|
|
|
controller.setProperties({
|
|
|
|
eligibilityError: null,
|
|
|
|
stopDrainError: null,
|
2019-11-22 00:51:04 +00:00
|
|
|
drainError: null,
|
|
|
|
flagAsDraining: false,
|
|
|
|
showDrainNotification: false,
|
|
|
|
showDrainUpdateNotification: false,
|
|
|
|
showDrainStoppedNotification: false,
|
2019-11-19 06:36:07 +00:00
|
|
|
});
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2019-11-19 06:36:07 +00:00
|
|
|
|
2018-03-06 22:27:01 +00:00
|
|
|
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
|
|
|
}
|
2020-06-10 13:49:16 +00:00
|
|
|
}
|
2018-02-28 20:15:39 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@watchRecord('node') watch;
|
|
|
|
@watchRelationship('allocations') watchAllocations;
|
2018-03-01 00:27:15 +00:00
|
|
|
|
2020-06-10 13:49:16 +00:00
|
|
|
@collect('watch', 'watchAllocations') watchers;
|
|
|
|
}
|