2020-11-09 09:25:35 +00:00
|
|
|
import { action } from '@ember/object';
|
2020-04-08 09:56:36 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
2020-11-09 09:25:35 +00:00
|
|
|
import Route from 'consul-ui/routing/route';
|
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';
|
|
|
|
|
2020-11-09 09:25:35 +00:00
|
|
|
export default class SessionsRoute extends Route.extend(WithBlockingActions) {
|
|
|
|
@service('data-source/service')
|
|
|
|
data;
|
|
|
|
|
|
|
|
@service('repository/session')
|
|
|
|
sessionRepo;
|
|
|
|
|
|
|
|
@service('feedback')
|
|
|
|
feedback;
|
|
|
|
|
|
|
|
model() {
|
2020-04-08 09:56:36 +00:00
|
|
|
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-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
setupController(controller, model) {
|
|
|
|
super.setupController(...arguments);
|
2020-04-08 09:56:36 +00:00
|
|
|
controller.setProperties(model);
|
2020-11-09 09:25:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
invalidateSession(item) {
|
|
|
|
const route = this;
|
|
|
|
return this.feedback.execute(() => {
|
|
|
|
return this.sessionRepo.remove(item).then(() => {
|
|
|
|
route.refresh();
|
|
|
|
});
|
|
|
|
}, 'delete');
|
|
|
|
}
|
|
|
|
}
|