diff options
Diffstat (limited to 'client/src/app/admin/friends/friend-list/friend-list.component.ts')
-rw-r--r-- | client/src/app/admin/friends/friend-list/friend-list.component.ts | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/client/src/app/admin/friends/friend-list/friend-list.component.ts b/client/src/app/admin/friends/friend-list/friend-list.component.ts new file mode 100644 index 000000000..bf66d3ff1 --- /dev/null +++ b/client/src/app/admin/friends/friend-list/friend-list.component.ts | |||
@@ -0,0 +1,46 @@ | |||
1 | import { Component, OnInit } from '@angular/core'; | ||
2 | |||
3 | import { Friend, FriendService } from '../shared'; | ||
4 | |||
5 | @Component({ | ||
6 | selector: 'my-friend-list', | ||
7 | template: require('./friend-list.component.html'), | ||
8 | styles: [ require('./friend-list.component.scss') ] | ||
9 | }) | ||
10 | export class FriendListComponent implements OnInit { | ||
11 | friends: Friend[]; | ||
12 | |||
13 | constructor(private friendService: FriendService) { } | ||
14 | |||
15 | ngOnInit() { | ||
16 | this.friendService.getFriends().subscribe( | ||
17 | friends => this.friends = friends, | ||
18 | |||
19 | err => alert(err) | ||
20 | ); | ||
21 | } | ||
22 | |||
23 | makeFriends() { | ||
24 | this.friendService.makeFriends().subscribe( | ||
25 | status => { | ||
26 | if (status === 409) { | ||
27 | alert('Already made friends!'); | ||
28 | } else { | ||
29 | alert('Made friends!'); | ||
30 | } | ||
31 | }, | ||
32 | error => alert(error) | ||
33 | ); | ||
34 | } | ||
35 | |||
36 | quitFriends() { | ||
37 | if (!confirm('Are you sure?')) return; | ||
38 | |||
39 | this.friendService.quitFriends().subscribe( | ||
40 | status => { | ||
41 | alert('Quit friends!'); | ||
42 | }, | ||
43 | error => alert(error) | ||
44 | ); | ||
45 | } | ||
46 | } | ||