import { Component } from '@angular/core';
-import { HTTP_PROVIDERS } from '@angular/http';
-import { Router, ROUTER_DIRECTIVES } from '@angular/router';
+import { ActivatedRoute, Router, ROUTER_DIRECTIVES } from '@angular/router';
import { FriendService } from './friends';
import {
AuthService,
AuthStatus,
- Search,
SearchComponent,
SearchService
} from './shared';
template: require('./app.component.html'),
styles: [ require('./app.component.scss') ],
directives: [ ROUTER_DIRECTIVES, SearchComponent ],
- providers: [ AuthService, FriendService, HTTP_PROVIDERS, VideoService, SearchService ]
+ providers: [ FriendService, VideoService, SearchService ]
})
export class AppComponent {
constructor(
private authService: AuthService,
private friendService: FriendService,
+ private route: ActivatedRoute,
private router: Router
) {
this.isLoggedIn = this.authService.isLoggedIn();
status => {
if (status === AuthStatus.LoggedIn) {
this.isLoggedIn = true;
+ console.log('Logged in.');
+ } else if (status === AuthStatus.LoggedOut) {
+ this.isLoggedIn = false;
+ console.log('Logged out.');
+ } else {
+ console.error('Unknown auth status: ' + status);
}
}
);
}
- onSearch(search: Search) {
- if (search.value !== '') {
- const params = {
- field: search.field,
- search: search.value
- };
-
- this.router.navigate(['/videos/list', params]);
- } else {
- this.router.navigate(['/videos/list']);
- }
- }
-
- // FIXME
logout() {
- // this._authService.logout();
+ this.authService.logout();
}
makeFriends() {