aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-08-21 11:27:24 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-08-21 11:27:24 +0200
commitbeacf6993c93f93bf5ea86665827154eb291d1fd (patch)
tree5aa8b69bbf4891c8d34798b052236f0ebfb94963 /client/src
parent9aa46b0c7bade696a477626ad7590ffdd281e03c (diff)
downloadPeerTube-beacf6993c93f93bf5ea86665827154eb291d1fd.tar.gz
PeerTube-beacf6993c93f93bf5ea86665827154eb291d1fd.tar.zst
PeerTube-beacf6993c93f93bf5ea86665827154eb291d1fd.zip
Client: simplify simple menu/admin menu displaying logic
Diffstat (limited to 'client/src')
-rw-r--r--client/src/app/admin/menu-admin.component.html2
-rw-r--r--client/src/app/admin/menu-admin.component.ts10
-rw-r--r--client/src/app/app.component.html7
-rw-r--r--client/src/app/app.component.ts12
-rw-r--r--client/src/app/menu.component.html2
-rw-r--r--client/src/app/menu.component.ts7
6 files changed, 11 insertions, 29 deletions
diff --git a/client/src/app/admin/menu-admin.component.html b/client/src/app/admin/menu-admin.component.html
index 26a3f3492..f821974bd 100644
--- a/client/src/app/admin/menu-admin.component.html
+++ b/client/src/app/admin/menu-admin.component.html
@@ -15,7 +15,7 @@
15 <div class="panel-block"> 15 <div class="panel-block">
16 <div id="panel-quit-administration" class="panel-button"> 16 <div id="panel-quit-administration" class="panel-button">
17 <span class="hidden-xs glyphicon glyphicon-cog"></span> 17 <span class="hidden-xs glyphicon glyphicon-cog"></span>
18 <a [routerLink]="['/videos/list']" (click)="quitAdmin()">Quit admin.</a> 18 <a [routerLink]="['/videos/list']">Quit admin.</a>
19 </div> 19 </div>
20 </div> 20 </div>
21</menu> 21</menu>
diff --git a/client/src/app/admin/menu-admin.component.ts b/client/src/app/admin/menu-admin.component.ts
index b23f7409e..788592872 100644
--- a/client/src/app/admin/menu-admin.component.ts
+++ b/client/src/app/admin/menu-admin.component.ts
@@ -1,4 +1,4 @@
1import { Component, Output, EventEmitter } from '@angular/core'; 1import { Component } from '@angular/core';
2import { ROUTER_DIRECTIVES } from '@angular/router'; 2import { ROUTER_DIRECTIVES } from '@angular/router';
3 3
4@Component({ 4@Component({
@@ -6,10 +6,4 @@ import { ROUTER_DIRECTIVES } from '@angular/router';
6 template: require('./menu-admin.component.html'), 6 template: require('./menu-admin.component.html'),
7 directives: [ ROUTER_DIRECTIVES ] 7 directives: [ ROUTER_DIRECTIVES ]
8}) 8})
9export class MenuAdminComponent { 9export class MenuAdminComponent { }
10 @Output() quittedAdmin = new EventEmitter<boolean>();
11
12 quitAdmin() {
13 this.quittedAdmin.emit(true);
14 }
15}
diff --git a/client/src/app/app.component.html b/client/src/app/app.component.html
index a7538ee7a..ead491968 100644
--- a/client/src/app/app.component.html
+++ b/client/src/app/app.component.html
@@ -14,14 +14,11 @@
14 14
15 15
16 <div class="row"> 16 <div class="row">
17 <my-menu *ngIf="isInAdmin === false" (enteredInAdmin)="onEnteredInAdmin()"></my-menu> 17 <my-menu *ngIf="isInAdmin() === false"></my-menu>
18 <my-menu-admin *ngIf="isInAdmin === true" (quittedAdmin)="onQuittedAdmin()"></my-menu-admin> 18 <my-menu-admin *ngIf="isInAdmin() === true"></my-menu-admin>
19 19
20 <div class="col-md-9 col-sm-8 col-xs-8 router-outlet-container"> 20 <div class="col-md-9 col-sm-8 col-xs-8 router-outlet-container">
21 <router-outlet></router-outlet> 21 <router-outlet></router-outlet>
22 </div>
23 </div>
24
25 22
26 <footer> 23 <footer>
27 PeerTube, CopyLeft 2015-2016 24 PeerTube, CopyLeft 2015-2016
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts
index d9549ad5b..2e0fd13f1 100644
--- a/client/src/app/app.component.ts
+++ b/client/src/app/app.component.ts
@@ -1,5 +1,5 @@
1import { Component } from '@angular/core'; 1import { Component } from '@angular/core';
2import { ROUTER_DIRECTIVES } from '@angular/router'; 2import { Router, ROUTER_DIRECTIVES } from '@angular/router';
3 3
4import { MenuAdminComponent } from './admin'; 4import { MenuAdminComponent } from './admin';
5import { MenuComponent } from './menu.component'; 5import { MenuComponent } from './menu.component';
@@ -15,13 +15,9 @@ import { VideoService } from './videos';
15}) 15})
16 16
17export class AppComponent { 17export class AppComponent {
18 isInAdmin = false; 18 constructor(private router: Router) {}
19 19
20 onEnteredInAdmin() { 20 isInAdmin() {
21 this.isInAdmin = true; 21 return this.router.url.indexOf('/admin/') !== -1;
22 }
23
24 onQuittedAdmin() {
25 this.isInAdmin = false;
26 } 22 }
27} 23}
diff --git a/client/src/app/menu.component.html b/client/src/app/menu.component.html
index 8ea99138d..29ef7f9cf 100644
--- a/client/src/app/menu.component.html
+++ b/client/src/app/menu.component.html
@@ -33,7 +33,7 @@
33 <div class="panel-block" *ngIf="isUserAdmin()"> 33 <div class="panel-block" *ngIf="isUserAdmin()">
34 <div id="panel-get-videos" class="panel-button"> 34 <div id="panel-get-videos" class="panel-button">
35 <span class="hidden-xs glyphicon glyphicon-cog"></span> 35 <span class="hidden-xs glyphicon glyphicon-cog"></span>
36 <a [routerLink]="['/admin']" (click)="enterInAdmin()">Administration</a> 36 <a [routerLink]="['/admin']">Administration</a>
37 </div> 37 </div>
38 </div> 38 </div>
39</menu> 39</menu>
diff --git a/client/src/app/menu.component.ts b/client/src/app/menu.component.ts
index 594cd996e..6b08301df 100644
--- a/client/src/app/menu.component.ts
+++ b/client/src/app/menu.component.ts
@@ -1,4 +1,4 @@
1import { Component, EventEmitter, OnInit, Output } from '@angular/core'; 1import { Component, OnInit } from '@angular/core';
2import { Router, ROUTER_DIRECTIVES } from '@angular/router'; 2import { Router, ROUTER_DIRECTIVES } from '@angular/router';
3 3
4import { AuthService, AuthStatus } from './shared'; 4import { AuthService, AuthStatus } from './shared';
@@ -9,7 +9,6 @@ import { AuthService, AuthStatus } from './shared';
9 directives: [ ROUTER_DIRECTIVES ] 9 directives: [ ROUTER_DIRECTIVES ]
10}) 10})
11export class MenuComponent implements OnInit { 11export class MenuComponent implements OnInit {
12 @Output() enteredInAdmin = new EventEmitter<boolean>();
13 isLoggedIn: boolean; 12 isLoggedIn: boolean;
14 13
15 constructor ( 14 constructor (
@@ -35,10 +34,6 @@ export class MenuComponent implements OnInit {
35 ); 34 );
36 } 35 }
37 36
38 enterInAdmin() {
39 this.enteredInAdmin.emit(true);
40 }
41
42 isUserAdmin() { 37 isUserAdmin() {
43 return this.authService.isAdmin(); 38 return this.authService.isAdmin();
44 } 39 }