import ngModule from '../module';
import Section from 'salix/components/section';

export default class Controller extends Section {
    constructor(...args) {
        super(...args);
        this.filter = {
            fields: ['id', 'created', 'userId'],
            include: {
                relation: 'user',
                scope: {
                    fields: ['username']
                }
            },
            order: 'created DESC'
        };
    }

    onDisconnect(row) {
        return this.$http.delete(`AccessTokens/${row.id}`)
            .then(() => this.$.model.refresh())
            .then(() => this.vnApp.showSuccess(this.$t('Session killed')));
    }
}

ngModule.component('vnConnections', {
    template: require('./index.html'),
    controller: Controller
});