aboutsummaryrefslogblamecommitdiffhomepage
path: root/client/src/app/admin/friends/friend-list/friend-list.component.ts
blob: c76fc4df2e2e6b09acb725decc70cbc9f1bf094c (plain) (tree)
1
2
3
4
5
6
7
8






                                                    
                                                     






                                                        
                      

   





                                               
                          



                           







                                              
 
import { Component, OnInit } from '@angular/core';

import { Friend, FriendService } from '../shared';

@Component({
  selector: 'my-friend-list',
  template: require('./friend-list.component.html'),
  styles: [ require('./friend-list.component.scss') ]
})
export class FriendListComponent implements OnInit {
  friends: Friend[];

  constructor(private friendService: FriendService) {  }

  ngOnInit() {
    this.getFriends();
  }

  quitFriends() {
    if (!confirm('Are you sure?')) return;

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

  private getFriends() {
    this.friendService.getFriends().subscribe(
      friends => this.friends = friends,

      err => alert(err)
    );
  }
}