aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/admin
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-08-12 16:52:10 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-08-12 16:53:32 +0200
commit602eb142bebb62f1774d6e17c211eef99ace584b (patch)
tree9410d3b225f5a904a41d7c8f3c3035375dc4268a /client/src/app/admin
parent7da18e4420c4b71a8ecfda07f39324fbfec081c3 (diff)
downloadPeerTube-602eb142bebb62f1774d6e17c211eef99ace584b.tar.gz
PeerTube-602eb142bebb62f1774d6e17c211eef99ace584b.tar.zst
PeerTube-602eb142bebb62f1774d6e17c211eef99ace584b.zip
Client: make an admin menu and a classic menu component
Diffstat (limited to 'client/src/app/admin')
-rw-r--r--client/src/app/admin/friends/friend.service.ts29
-rw-r--r--client/src/app/admin/friends/index.ts1
-rw-r--r--client/src/app/admin/index.ts1
-rw-r--r--client/src/app/admin/menu-admin.component.html26
-rw-r--r--client/src/app/admin/menu-admin.component.ts42
5 files changed, 99 insertions, 0 deletions
diff --git a/client/src/app/admin/friends/friend.service.ts b/client/src/app/admin/friends/friend.service.ts
new file mode 100644
index 000000000..d4ab5e60f
--- /dev/null
+++ b/client/src/app/admin/friends/friend.service.ts
@@ -0,0 +1,29 @@
1import { Injectable } from '@angular/core';
2import { Response } from '@angular/http';
3import { Observable } from 'rxjs/Observable';
4
5import { AuthHttp, AuthService } from '../../shared';
6
7@Injectable()
8export class FriendService {
9 private static BASE_FRIEND_URL: string = '/api/v1/pods/';
10
11 constructor (private authHttp: AuthHttp, private authService: AuthService) {}
12
13 makeFriends() {
14 return this.authHttp.get(FriendService.BASE_FRIEND_URL + 'makefriends')
15 .map(res => res.status)
16 .catch(this.handleError);
17 }
18
19 quitFriends() {
20 return this.authHttp.get(FriendService.BASE_FRIEND_URL + 'quitfriends')
21 .map(res => res.status)
22 .catch(this.handleError);
23 }
24
25 private handleError (error: Response): Observable<number> {
26 console.error(error);
27 return Observable.throw(error.json().error || 'Server error');
28 }
29}
diff --git a/client/src/app/admin/friends/index.ts b/client/src/app/admin/friends/index.ts
new file mode 100644
index 000000000..0adc256c4
--- /dev/null
+++ b/client/src/app/admin/friends/index.ts
@@ -0,0 +1 @@
export * from './friend.service';
diff --git a/client/src/app/admin/index.ts b/client/src/app/admin/index.ts
index 3b0540818..292973681 100644
--- a/client/src/app/admin/index.ts
+++ b/client/src/app/admin/index.ts
@@ -1,3 +1,4 @@
1export * from './users'; 1export * from './users';
2export * from './admin.component'; 2export * from './admin.component';
3export * from './admin.routes'; 3export * from './admin.routes';
4export * from './menu-admin.component';
diff --git a/client/src/app/admin/menu-admin.component.html b/client/src/app/admin/menu-admin.component.html
new file mode 100644
index 000000000..15a3c764e
--- /dev/null
+++ b/client/src/app/admin/menu-admin.component.html
@@ -0,0 +1,26 @@
1<menu class="col-md-2 col-sm-3 col-xs-3">
2
3 <div class="panel-block">
4 <div id="panel-users" class="panel-button">
5 <span class="hidden-xs glyphicon glyphicon-user"></span>
6 <a [routerLink]="['/admin/users/list']">List users</a>
7 </div>
8
9 <div id="panel-make-friends" class="panel-button">
10 <span class="hidden-xs glyphicon glyphicon-cloud"></span>
11 <a (click)='makeFriends()'>Make friends</a>
12 </div>
13
14 <div id="panel-quit-friends" class="panel-button">
15 <span class="hidden-xs glyphicon glyphicon-plane"></span>
16 <a (click)='quitFriends()'>Quit friends</a>
17 </div>
18 </div>
19
20 <div class="panel-block">
21 <div id="panel-quit-administration" class="panel-button">
22 <span class="hidden-xs glyphicon glyphicon-cog"></span>
23 <a (click)="quitAdmin()">Quit admin.</a>
24 </div>
25 </div>
26</menu>
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 @@
1import { Component, Output, EventEmitter } from '@angular/core';
2import { ROUTER_DIRECTIVES } from '@angular/router';
3
4import { 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})
12export 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}