1 import { Component } from '@angular/core';
2 import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, Router } from '@angular/router-deprecated';
3 import { HTTP_PROVIDERS } from '@angular/http';
5 import { DROPDOWN_DIRECTIVES} from 'ng2-bootstrap/components/dropdown';
7 import { VideosAddComponent } from '../videos/components/add/videos-add.component';
8 import { VideosListComponent } from '../videos/components/list/videos-list.component';
9 import { VideosWatchComponent } from '../videos/components/watch/videos-watch.component';
10 import { VideosService } from '../videos/videos.service';
11 import { FriendsService } from '../friends/services/friends.service';
12 import { UserLoginComponent } from '../users/components/login/login.component';
13 import { AuthService } from '../users/services/auth.service';
14 import { AuthStatus } from '../users/models/authStatus';
15 import { SearchComponent } from './search.component';
16 import { Search } from './search';
22 component: UserLoginComponent
27 component: VideosListComponent,
31 path: '/videos/watch/:id',
33 component: VideosWatchComponent
38 component: VideosAddComponent
44 templateUrl: 'app/angular/app/app.component.html',
45 styleUrls: [ 'app/angular/app/app.component.css' ],
46 directives: [ ROUTER_DIRECTIVES, SearchComponent ],
47 providers: [ ROUTER_PROVIDERS, HTTP_PROVIDERS, VideosService, FriendsService, AuthService ]
50 export class AppComponent {
52 search_field: string = name;
55 constructor(private _friendsService: FriendsService,
56 private _authService: AuthService,
57 private _router: Router
59 this.isLoggedIn = this._authService.isLoggedIn();
61 this._authService.loginChanged$.subscribe(
63 if (status === AuthStatus.LoggedIn) {
64 this.isLoggedIn = true;
70 onSearch(search: Search) {
72 if (search.value !== '') {
73 this._router.navigate(['VideosList', { search: search.value, field: search.field }]);
75 this._router.navigate(['VideosList']);
80 // this._authService.logout();
84 this._friendsService.makeFriends().subscribe(
87 alert('Already made friends!');
89 alert('Made friends!');
97 this._friendsService.quitFriends().subscribe(
99 alert('Quit friends!');
101 error => alert(error)