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