aboutsummaryrefslogblamecommitdiffhomepage
path: root/client/src/app/admin/friends/friend-list/friend-list.component.ts
blob: bec10162cd1e7443f5b1df30cafe2a5efcac8c13 (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',
  templateUrl: './friend-list.component.html',
  styleUrls: [ './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.text)
    );
  }

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

      err => alert(err.text)
    );
  }
}