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
|
|
|
|
2018-03-01 00:27:15 +00:00
|
|
|
export default Route.extend(WithWatchers, {
|
2017-12-15 21:39:18 +00:00
|
|
|
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));
|
|
|
|
},
|
|
|
|
|
2018-06-20 01:15:46 +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');
|
2017-09-19 14:47:10 +00:00
|
|
|
},
|
2018-02-28 20:15:39 +00:00
|
|
|
|
2019-11-15 04:23:47 +00:00
|
|
|
setupController(controller, model) {
|
|
|
|
controller.set('flagAsDraining', model.isDraining);
|
|
|
|
|
|
|
|
return this._super(...arguments);
|
|
|
|
},
|
|
|
|
|
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
|
|
|
});
|
|
|
|
},
|
|
|
|
|
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
|
|
|
}
|
2018-02-28 20:15:39 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
watch: watchRecord('node'),
|
|
|
|
watchAllocations: watchRelationship('allocations'),
|
2018-03-01 00:27:15 +00:00
|
|
|
|
|
|
|
watchers: collect('watch', 'watchAllocations'),
|
2017-09-19 14:47:10 +00:00
|
|
|
});
|