2020-10-01 08:33:22 +00:00
|
|
|
import Route from 'consul-ui/routing/route';
|
2020-04-08 09:56:36 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
2020-10-01 08:33:22 +00:00
|
|
|
import { hash } from 'rsvp';
|
2020-04-08 09:56:36 +00:00
|
|
|
import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions';
|
|
|
|
|
|
|
|
export default Route.extend(WithBlockingActions, {
|
2020-10-01 08:33:22 +00:00
|
|
|
data: service('data-source/service'),
|
2020-04-08 09:56:36 +00:00
|
|
|
sessionRepo: service('repository/session'),
|
|
|
|
feedback: service('feedback'),
|
|
|
|
model: function() {
|
|
|
|
const parent = this.routeName
|
|
|
|
.split('.')
|
|
|
|
.slice(0, -1)
|
|
|
|
.join('.');
|
2020-10-01 08:33:22 +00:00
|
|
|
const dc = this.modelFor('dc').dc.Name;
|
|
|
|
const nspace = this.modelFor('nspace').nspace.substr(1);
|
|
|
|
const node = this.paramsFor(parent).name;
|
|
|
|
return hash({
|
|
|
|
dc: dc,
|
|
|
|
nspace: nspace,
|
|
|
|
node: node,
|
|
|
|
sessions: this.data.source(uri => uri`/${nspace}/${dc}/sessions/for-node/${node}`),
|
|
|
|
});
|
2020-04-08 09:56:36 +00:00
|
|
|
},
|
|
|
|
setupController: function(controller, model) {
|
2020-10-01 08:33:22 +00:00
|
|
|
this._super(...arguments);
|
2020-04-08 09:56:36 +00:00
|
|
|
controller.setProperties(model);
|
|
|
|
},
|
|
|
|
actions: {
|
|
|
|
invalidateSession: function(item) {
|
2020-10-01 08:33:22 +00:00
|
|
|
const route = this;
|
2020-04-08 09:56:36 +00:00
|
|
|
return this.feedback.execute(() => {
|
|
|
|
return this.sessionRepo.remove(item).then(() => {
|
2020-10-01 08:33:22 +00:00
|
|
|
route.refresh();
|
2020-04-08 09:56:36 +00:00
|
|
|
});
|
|
|
|
}, 'delete');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|