diff options
Diffstat (limited to 'client/app/app.component.ts')
-rw-r--r-- | client/app/app.component.ts | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/client/app/app.component.ts b/client/app/app.component.ts deleted file mode 100644 index 94924a47a..000000000 --- a/client/app/app.component.ts +++ /dev/null | |||
@@ -1,109 +0,0 @@ | |||
1 | import { Component } from '@angular/core'; | ||
2 | import { HTTP_PROVIDERS } from '@angular/http'; | ||
3 | import { RouteConfig, Router, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from '@angular/router-deprecated'; | ||
4 | |||
5 | import { FriendService } from './friends/index'; | ||
6 | import { LoginComponent } from './login/index'; | ||
7 | import { | ||
8 | AuthService, | ||
9 | AuthStatus, | ||
10 | Search, | ||
11 | SearchComponent | ||
12 | } from './shared/index'; | ||
13 | import { | ||
14 | VideoAddComponent, | ||
15 | VideoListComponent, | ||
16 | VideoWatchComponent, | ||
17 | VideoService | ||
18 | } from './videos/index'; | ||
19 | |||
20 | @RouteConfig([ | ||
21 | { | ||
22 | path: '/users/login', | ||
23 | name: 'UserLogin', | ||
24 | component: LoginComponent | ||
25 | }, | ||
26 | { | ||
27 | path: '/videos/list', | ||
28 | name: 'VideosList', | ||
29 | component: VideoListComponent, | ||
30 | useAsDefault: true | ||
31 | }, | ||
32 | { | ||
33 | path: '/videos/watch/:id', | ||
34 | name: 'VideosWatch', | ||
35 | component: VideoWatchComponent | ||
36 | }, | ||
37 | { | ||
38 | path: '/videos/add', | ||
39 | name: 'VideosAdd', | ||
40 | component: VideoAddComponent | ||
41 | } | ||
42 | ]) | ||
43 | |||
44 | @Component({ | ||
45 | selector: 'my-app', | ||
46 | templateUrl: 'client/app/app.component.html', | ||
47 | styleUrls: [ 'client/app/app.component.css' ], | ||
48 | directives: [ ROUTER_DIRECTIVES, SearchComponent ], | ||
49 | providers: [ AuthService, FriendService, HTTP_PROVIDERS, ROUTER_PROVIDERS, VideoService ] | ||
50 | }) | ||
51 | |||
52 | export class AppComponent { | ||
53 | choices = []; | ||
54 | isLoggedIn: boolean; | ||
55 | |||
56 | constructor( | ||
57 | private authService: AuthService, | ||
58 | private friendService: FriendService, | ||
59 | private router: Router | ||
60 | ) { | ||
61 | this.isLoggedIn = this.authService.isLoggedIn(); | ||
62 | |||
63 | this.authService.loginChangedSource.subscribe( | ||
64 | status => { | ||
65 | if (status === AuthStatus.LoggedIn) { | ||
66 | this.isLoggedIn = true; | ||
67 | } | ||
68 | } | ||
69 | ); | ||
70 | } | ||
71 | |||
72 | onSearch(search: Search) { | ||
73 | if (search.value !== '') { | ||
74 | const params = { | ||
75 | field: search.field, | ||
76 | search: search.value | ||
77 | }; | ||
78 | this.router.navigate(['VideosList', params]); | ||
79 | } else { | ||
80 | this.router.navigate(['VideosList']); | ||
81 | } | ||
82 | } | ||
83 | |||
84 | logout() { | ||
85 | // this._authService.logout(); | ||
86 | } | ||
87 | |||
88 | makeFriends() { | ||
89 | this.friendService.makeFriends().subscribe( | ||
90 | status => { | ||
91 | if (status === 409) { | ||
92 | alert('Already made friends!'); | ||
93 | } else { | ||
94 | alert('Made friends!'); | ||
95 | } | ||
96 | }, | ||
97 | error => alert(error) | ||
98 | ); | ||
99 | } | ||
100 | |||
101 | quitFriends() { | ||
102 | this.friendService.quitFriends().subscribe( | ||
103 | status => { | ||
104 | alert('Quit friends!'); | ||
105 | }, | ||
106 | error => alert(error) | ||
107 | ); | ||
108 | } | ||
109 | } | ||