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;
|
|
|
|
|
2021-05-26 16:43:46 +00:00
|
|
|
model(params) {
|
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;
|
2021-05-26 16:43:46 +00:00
|
|
|
const nspace = this.optionalParams().nspace;
|
2020-10-01 08:33:22 +00:00
|
|
|
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');
|
|
|
|
}
|
|
|
|
}
|