aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/admin/menu-admin.component.ts
blob: eb27c1e58ca421afc0a7994bdd8560723f4f15df (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { Component, Output, EventEmitter } from '@angular/core';
import { ROUTER_DIRECTIVES } from '@angular/router';

import { FriendService } from './friends';

@Component({
  selector: 'my-menu-admin',
  template: require('./menu-admin.component.html'),
  directives: [ ROUTER_DIRECTIVES ],
  providers: [ FriendService ]
})
export class MenuAdminComponent {
  @Output() quittedAdmin = new EventEmitter<boolean>();

  constructor(private friendService: FriendService) {}

  makeFriends() {
    this.friendService.makeFriends().subscribe(
      status => {
        if (status === 409) {
          alert('Already made friends!');
        } else {
          alert('Made friends!');
        }
      },
      error => alert(error)
    );
  }

  quitAdmin() {
    this.quittedAdmin.emit(true);
  }

  quitFriends() {
    this.friendService.quitFriends().subscribe(
      status => {
        alert('Quit friends!');
      },
      error => alert(error)
    );
  }
}