From b99290b1d5d736083513fb8f66e91f61bfe07e0b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 23 Jan 2017 22:32:43 +0100 Subject: Client: lazy load admin area --- .../friends/friend-list/friend-list.component.ts | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 client/src/app/+admin/friends/friend-list/friend-list.component.ts (limited to 'client/src/app/+admin/friends/friend-list/friend-list.component.ts') 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..bec10162c --- /dev/null +++ b/client/src/app/+admin/friends/friend-list/friend-list.component.ts @@ -0,0 +1,38 @@ +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) + ); + } +} -- cgit v1.2.3