1 import { Component, ElementRef } from 'angular2/core';
2 import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, Router } from 'angular2/router';
3 import { HTTP_PROVIDERS } from 'angular2/http';
5 import { VideosAddComponent } from '../videos/components/add/videos-add.component';
6 import { VideosListComponent } from '../videos/components/list/videos-list.component';
7 import { VideosWatchComponent } from '../videos/components/watch/videos-watch.component';
8 import { VideosService } from '../videos/services/videos.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';
18 component: UserLoginComponent
23 component: VideosListComponent,
27 path: '/videos/watch/:id',
29 component: VideosWatchComponent
34 component: VideosAddComponent
40 templateUrl: 'app/angular/app/app.component.html',
41 styleUrls: [ 'app/angular/app/app.component.css' ],
42 directives: [ ROUTER_DIRECTIVES ],
43 providers: [ ROUTER_PROVIDERS, HTTP_PROVIDERS,
44 ElementRef, VideosService, FriendsService,
49 export class AppComponent {
52 constructor(private _friendsService: FriendsService,
53 private _authService: AuthService,
54 private _router: Router
56 if (localStorage.getItem('access_token')) this.isLoggedIn = true;
57 else this.isLoggedIn = false;
59 this._authService.loginChanged$.subscribe(
61 if (status === AuthStatus.LoggedIn) {
62 this.isLoggedIn = true;
68 doSearch(search: string) {
70 this._router.navigate(['VideosList', { search: search }]);
72 this._router.navigate(['VideosList']);
77 // this._authService.logout();
81 this._friendsService.makeFriends().subscribe(
84 alert('Already made friends!');
86 alert('Made friends!');
94 this._friendsService.quitFriends().subscribe(
96 alert('Quit friends!');