diff options
Diffstat (limited to 'client/angular/app')
-rw-r--r-- | client/angular/app/app.component.html | 10 | ||||
-rw-r--r-- | client/angular/app/app.component.ts | 35 |
2 files changed, 42 insertions, 3 deletions
diff --git a/client/angular/app/app.component.html b/client/angular/app/app.component.html index 25911731e..647697a0a 100644 --- a/client/angular/app/app.component.html +++ b/client/angular/app/app.component.html | |||
@@ -18,6 +18,14 @@ | |||
18 | 18 | ||
19 | <menu class="col-md-2"> | 19 | <menu class="col-md-2"> |
20 | <div class="panel_block"> | 20 | <div class="panel_block"> |
21 | <div id="panel_user_login" class="panel_button"> | ||
22 | <span class="glyphicon glyphicon-user"></span> | ||
23 | <a *ngIf="!isLoggedIn" [routerLink]="['UserLogin']">Login</a> | ||
24 | <a *ngIf="isLoggedIn" (click)="logout()">Logout</a> | ||
25 | </div> | ||
26 | </div> | ||
27 | |||
28 | <div class="panel_block"> | ||
21 | <div id="panel_get_videos" class="panel_button"> | 29 | <div id="panel_get_videos" class="panel_button"> |
22 | <span class="glyphicon glyphicon-list"></span> | 30 | <span class="glyphicon glyphicon-list"></span> |
23 | <a [routerLink]="['VideosList']">Get videos</a> | 31 | <a [routerLink]="['VideosList']">Get videos</a> |
@@ -31,7 +39,7 @@ | |||
31 | 39 | ||
32 | <div class="panel_block"> | 40 | <div class="panel_block"> |
33 | <div id="panel_make_friends" class="panel_button"> | 41 | <div id="panel_make_friends" class="panel_button"> |
34 | <span class="glyphicon glyphicon-user"></span> | 42 | <span class="glyphicon glyphicon-cloud"></span> |
35 | <a (click)='makeFriends()'>Make friends</a> | 43 | <a (click)='makeFriends()'>Make friends</a> |
36 | </div> | 44 | </div> |
37 | 45 | ||
diff --git a/client/angular/app/app.component.ts b/client/angular/app/app.component.ts index cb961a3c8..1648b8870 100644 --- a/client/angular/app/app.component.ts +++ b/client/angular/app/app.component.ts | |||
@@ -7,9 +7,17 @@ import { VideosListComponent } from '../videos/components/list/videos-list.compo | |||
7 | import { VideosWatchComponent } from '../videos/components/watch/videos-watch.component'; | 7 | import { VideosWatchComponent } from '../videos/components/watch/videos-watch.component'; |
8 | import { VideosService } from '../videos/services/videos.service'; | 8 | import { VideosService } from '../videos/services/videos.service'; |
9 | import { FriendsService } from '../friends/services/friends.service'; | 9 | import { FriendsService } from '../friends/services/friends.service'; |
10 | import { UserLoginComponent } from '../users/components/login/login.component'; | ||
11 | import { AuthService } from '../users/services/auth.service'; | ||
12 | import { AuthStatus } from '../users/models/authStatus'; | ||
10 | 13 | ||
11 | @RouteConfig([ | 14 | @RouteConfig([ |
12 | { | 15 | { |
16 | path: '/users/login', | ||
17 | name: 'UserLogin', | ||
18 | component: UserLoginComponent | ||
19 | }, | ||
20 | { | ||
13 | path: '/videos/list', | 21 | path: '/videos/list', |
14 | name: 'VideosList', | 22 | name: 'VideosList', |
15 | component: VideosListComponent, | 23 | component: VideosListComponent, |
@@ -32,11 +40,30 @@ import { FriendsService } from '../friends/services/friends.service'; | |||
32 | templateUrl: 'app/angular/app/app.component.html', | 40 | templateUrl: 'app/angular/app/app.component.html', |
33 | styleUrls: [ 'app/angular/app/app.component.css' ], | 41 | styleUrls: [ 'app/angular/app/app.component.css' ], |
34 | directives: [ ROUTER_DIRECTIVES ], | 42 | directives: [ ROUTER_DIRECTIVES ], |
35 | providers: [ ROUTER_PROVIDERS, HTTP_PROVIDERS, ElementRef, VideosService, FriendsService ] | 43 | providers: [ ROUTER_PROVIDERS, HTTP_PROVIDERS, |
44 | ElementRef, VideosService, FriendsService, | ||
45 | AuthService | ||
46 | ] | ||
36 | }) | 47 | }) |
37 | 48 | ||
38 | export class AppComponent { | 49 | export class AppComponent { |
39 | constructor(private _friendsService: FriendsService, private _router: Router) {} | 50 | isLoggedIn: boolean; |
51 | |||
52 | constructor(private _friendsService: FriendsService, | ||
53 | private _authService: AuthService, | ||
54 | private _router: Router | ||
55 | ) { | ||
56 | if (localStorage.getItem('access_token')) this.isLoggedIn = true; | ||
57 | else this.isLoggedIn = false; | ||
58 | |||
59 | this._authService.loginChanged$.subscribe( | ||
60 | status => { | ||
61 | if (status === AuthStatus.LoggedIn) { | ||
62 | this.isLoggedIn = true; | ||
63 | } | ||
64 | } | ||
65 | ); | ||
66 | } | ||
40 | 67 | ||
41 | doSearch(search: string) { | 68 | doSearch(search: string) { |
42 | if (search !== '') { | 69 | if (search !== '') { |
@@ -46,6 +73,10 @@ export class AppComponent { | |||
46 | } | 73 | } |
47 | } | 74 | } |
48 | 75 | ||
76 | logout() { | ||
77 | // this._authService.logout(); | ||
78 | } | ||
79 | |||
49 | makeFriends() { | 80 | makeFriends() { |
50 | this._friendsService.makeFriends().subscribe( | 81 | this._friendsService.makeFriends().subscribe( |
51 | status => { | 82 | status => { |