X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fangular%2Fapp%2Fapp.component.ts;h=68c9ba0090510fd8d9e3c1c3446e74dec5a4283c;hb=44124980c55d5a5ec7dfb8e71bf14d10f0fe975d;hp=cb961a3c8157052b0c3f16abb10cebeecc235ec0;hpb=98b01bac2c2c4536aa97d826b61516657f4d15f5;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/angular/app/app.component.ts b/client/angular/app/app.component.ts index cb961a3c8..68c9ba009 100644 --- a/client/angular/app/app.component.ts +++ b/client/angular/app/app.component.ts @@ -7,8 +7,16 @@ import { VideosListComponent } from '../videos/components/list/videos-list.compo import { VideosWatchComponent } from '../videos/components/watch/videos-watch.component'; import { VideosService } from '../videos/services/videos.service'; import { FriendsService } from '../friends/services/friends.service'; +import { UserLoginComponent } from '../users/components/login/login.component'; +import { AuthService } from '../users/services/auth.service'; +import { AuthStatus } from '../users/models/authStatus'; @RouteConfig([ + { + path: '/users/login', + name: 'UserLogin', + component: UserLoginComponent + }, { path: '/videos/list', name: 'VideosList', @@ -32,11 +40,33 @@ import { FriendsService } from '../friends/services/friends.service'; templateUrl: 'app/angular/app/app.component.html', styleUrls: [ 'app/angular/app/app.component.css' ], directives: [ ROUTER_DIRECTIVES ], - providers: [ ROUTER_PROVIDERS, HTTP_PROVIDERS, ElementRef, VideosService, FriendsService ] + providers: [ ROUTER_PROVIDERS, HTTP_PROVIDERS, + ElementRef, VideosService, FriendsService, + AuthService + ] }) export class AppComponent { - constructor(private _friendsService: FriendsService, private _router: Router) {} + isLoggedIn: boolean; + + constructor(private _friendsService: FriendsService, + private _authService: AuthService, + private _router: Router + ) { + if (localStorage.getItem('access_token')) { + this.isLoggedIn = true; + } else { + this.isLoggedIn = false; + } + + this._authService.loginChanged$.subscribe( + status => { + if (status === AuthStatus.LoggedIn) { + this.isLoggedIn = true; + } + } + ); + } doSearch(search: string) { if (search !== '') { @@ -46,6 +76,10 @@ export class AppComponent { } } + logout() { + // this._authService.logout(); + } + makeFriends() { this._friendsService.makeFriends().subscribe( status => { @@ -56,7 +90,7 @@ export class AppComponent { } }, error => alert(error) - ) + ); } quitFriends() { @@ -65,6 +99,6 @@ export class AppComponent { alert('Quit friends!'); }, error => alert(error) - ) + ); } }