header.component.ts 1.43 KB
Newer Older
1
2
3
4
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { AuthenticationService } from '../../services/authentication.service';
import { SessionService } from '../../services/session.service';
5
import { GHCIService } from '../../services/ghci.service';
6
import { Usuario } from '../../objects/usuario';
7
import { TranslateService } from '@ngx-translate/core';
8
9
10
11
12
13
14
15

@Component({
    selector: 'app-header',
    templateUrl: './header.component.html',
    styleUrls: ['./header.component.scss']
})
export class HeaderComponent implements OnInit {
    usuario: Usuario;
16
    translateService: any;
17
18
19
20
    constructor(
        private authService: AuthenticationService, 
        private router : Router, 
        private sessionService : SessionService,
21
22
23
        private ghciService : GHCIService,
        public translate: TranslateService) {
        this.translateService = translate;
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
        this.usuario = authService.getUser();
    }
    ngOnInit() {}

    toggleSidebar(event) {
        event.stopPropagation();
        const dom: any = document.querySelector('body');
        dom.classList.toggle('push-right');
    }
    rltAndLtr() {
        const dom: any = document.querySelector('body');
        dom.classList.toggle('rtl');
    }

    logout(){
        this.sessionService.reset();
40
        this.ghciService.desconectarWS();
41
        this.router.navigate(['/'+this.translateService.get('i18n.code').value+'/login']);
42
43
    }
}