diff options
Diffstat (limited to 'client/src/app/admin/menu-admin.component.ts')
-rw-r--r-- | client/src/app/admin/menu-admin.component.ts | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/client/src/app/admin/menu-admin.component.ts b/client/src/app/admin/menu-admin.component.ts new file mode 100644 index 000000000..eb27c1e58 --- /dev/null +++ b/client/src/app/admin/menu-admin.component.ts | |||
@@ -0,0 +1,42 @@ | |||
1 | import { Component, Output, EventEmitter } from '@angular/core'; | ||
2 | import { ROUTER_DIRECTIVES } from '@angular/router'; | ||
3 | |||
4 | import { FriendService } from './friends'; | ||
5 | |||
6 | @Component({ | ||
7 | selector: 'my-menu-admin', | ||
8 | template: require('./menu-admin.component.html'), | ||
9 | directives: [ ROUTER_DIRECTIVES ], | ||
10 | providers: [ FriendService ] | ||
11 | }) | ||
12 | export class MenuAdminComponent { | ||
13 | @Output() quittedAdmin = new EventEmitter<boolean>(); | ||
14 | |||
15 | constructor(private friendService: FriendService) {} | ||
16 | |||
17 | makeFriends() { | ||
18 | this.friendService.makeFriends().subscribe( | ||
19 | status => { | ||
20 | if (status === 409) { | ||
21 | alert('Already made friends!'); | ||
22 | } else { | ||
23 | alert('Made friends!'); | ||
24 | } | ||
25 | }, | ||
26 | error => alert(error) | ||
27 | ); | ||
28 | } | ||
29 | |||
30 | quitAdmin() { | ||
31 | this.quittedAdmin.emit(true); | ||
32 | } | ||
33 | |||
34 | quitFriends() { | ||
35 | this.friendService.quitFriends().subscribe( | ||
36 | status => { | ||
37 | alert('Quit friends!'); | ||
38 | }, | ||
39 | error => alert(error) | ||
40 | ); | ||
41 | } | ||
42 | } | ||