<commit_before>import { Component } from 'angular2/core';
import { ROUTER_DIRECTIVES, Router } from 'angular2/router';
import { URLSearchParams } from 'angular2/http';

import { Group } from '../../models/group';
import { GroupService } from '../../services/group';
import { ContactService } from '../../services/contact';
import { BaseHttpService } from '../../services/base-http';
import { OrderByPipe  } from '../../models/OrderBy';



@Component({    
    templateUrl: './components/group/group-list.html',    
    providers: [GroupService, BaseHttpService, ContactService],
    directives: [ROUTER_DIRECTIVES],
    pipes: [OrderByPipe]
})

export class GroupListCmp {
    public groups: Group[] = [];
    shadowImage: string = 'https://image.freepik.com/free-icon/male-user-shadow_318-34042.png';

    constructor(private groupService: GroupService, private router: Router) {        
        var token = localStorage.getItem('session_token');
        if (token === '' || token === null) {
            this.logout();
        } else {
            
        }
    }
    
ngAfterViewInit() {
  setTimeout(() => {
    this.getList();
  }, 1);
}
    logout() {
        localStorage.setItem('session_token', '');
        this.router.navigate(['Login']);
    }
    getList() {
        let self = this;
        let params = new URLSearchParams();
        params.set('order', 'name+ASC');
        this.groupService.query(params)
            .subscribe((groups: Group[]) => {
                self.groups = groups;
            });
    }

    remove(groupId) {
    	var token = localStorage.getItem('session_token');
        if (token ==='' || token === null) {
            this.logout(); 
        }
        var self = this;
        this.groupService.remove(groupId)
            .subscribe(() => {<commit_msg>Adding session-token/content-type for API calls<commit_after>import { Component } from 'angular2/core';
import { ROUTER_DIRECTIVES, Router } from 'angular2/router';
import { URLSearchParams } from 'angular2/http';

import { Group } from '../../models/group';
import { GroupService } from '../../services/group';
import { ContactService } from '../../services/contact';
import { BaseHttpService } from '../../services/base-http';
import { OrderByPipe  } from '../../models/OrderBy';



@Component({    
    templateUrl: './components/group/group-list.html',    
    providers: [GroupService, BaseHttpService, ContactService],
    directives: [ROUTER_DIRECTIVES],
    pipes: [OrderByPipe]
})

export class GroupListCmp {
    public groups: Group[] = [];
    shadowImage: string = 'https://image.freepik.com/free-icon/male-user-shadow_318-34042.png';

    constructor(private groupService: GroupService, private router: Router) {        
        var token = localStorage.getItem('session_token');
        if (token === '' || token === null) {
            this.logout();
        } else {
           this.getList(); 
        }
    }    

    logout() {
        localStorage.setItem('session_token', '');
        this.router.navigate(['Login']);
    }
    getList() {
        let self = this;
        let params = new URLSearchParams();
        params.set('order', 'name+ASC');
        this.groupService.query(params)
            .subscribe((groups: Group[]) => {
                self.groups = groups;
            });
    }

    remove(groupId) {
    	var token = localStorage.getItem('session_token');
        if (token ==='' || token === null) {
            this.logout(); 
        }
        var self = this;
        this.groupService.remove(groupId)
            .subscribe(() => {
{'fraction_non_alphanumeric': 0.1596309756779424, 'fraction_numerical': 0.006429969247973162, 'mean_word_length': 2.4108674928503335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7639630', 'n_tokens_mistral': 1040, 'n_tokens_neox': 1026, 'n_words': 209}