mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-11-22 08:46:54 -06:00
Client: simplify simple menu/admin menu displaying logic
This commit is contained in:
parent
9aa46b0c7b
commit
beacf6993c
@ -15,7 +15,7 @@
|
||||
<div class="panel-block">
|
||||
<div id="panel-quit-administration" class="panel-button">
|
||||
<span class="hidden-xs glyphicon glyphicon-cog"></span>
|
||||
<a [routerLink]="['/videos/list']" (click)="quitAdmin()">Quit admin.</a>
|
||||
<a [routerLink]="['/videos/list']">Quit admin.</a>
|
||||
</div>
|
||||
</div>
|
||||
</menu>
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Component, Output, EventEmitter } from '@angular/core';
|
||||
import { Component } from '@angular/core';
|
||||
import { ROUTER_DIRECTIVES } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
@ -6,10 +6,4 @@ import { ROUTER_DIRECTIVES } from '@angular/router';
|
||||
template: require('./menu-admin.component.html'),
|
||||
directives: [ ROUTER_DIRECTIVES ]
|
||||
})
|
||||
export class MenuAdminComponent {
|
||||
@Output() quittedAdmin = new EventEmitter<boolean>();
|
||||
|
||||
quitAdmin() {
|
||||
this.quittedAdmin.emit(true);
|
||||
}
|
||||
}
|
||||
export class MenuAdminComponent { }
|
||||
|
@ -14,14 +14,11 @@
|
||||
|
||||
|
||||
<div class="row">
|
||||
<my-menu *ngIf="isInAdmin === false" (enteredInAdmin)="onEnteredInAdmin()"></my-menu>
|
||||
<my-menu-admin *ngIf="isInAdmin === true" (quittedAdmin)="onQuittedAdmin()"></my-menu-admin>
|
||||
<my-menu *ngIf="isInAdmin() === false"></my-menu>
|
||||
<my-menu-admin *ngIf="isInAdmin() === true"></my-menu-admin>
|
||||
|
||||
<div class="col-md-9 col-sm-8 col-xs-8 router-outlet-container">
|
||||
<router-outlet></router-outlet>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<footer>
|
||||
PeerTube, CopyLeft 2015-2016
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { ROUTER_DIRECTIVES } from '@angular/router';
|
||||
import { Router, ROUTER_DIRECTIVES } from '@angular/router';
|
||||
|
||||
import { MenuAdminComponent } from './admin';
|
||||
import { MenuComponent } from './menu.component';
|
||||
@ -15,13 +15,9 @@ import { VideoService } from './videos';
|
||||
})
|
||||
|
||||
export class AppComponent {
|
||||
isInAdmin = false;
|
||||
constructor(private router: Router) {}
|
||||
|
||||
onEnteredInAdmin() {
|
||||
this.isInAdmin = true;
|
||||
}
|
||||
|
||||
onQuittedAdmin() {
|
||||
this.isInAdmin = false;
|
||||
isInAdmin() {
|
||||
return this.router.url.indexOf('/admin/') !== -1;
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
<div class="panel-block" *ngIf="isUserAdmin()">
|
||||
<div id="panel-get-videos" class="panel-button">
|
||||
<span class="hidden-xs glyphicon glyphicon-cog"></span>
|
||||
<a [routerLink]="['/admin']" (click)="enterInAdmin()">Administration</a>
|
||||
<a [routerLink]="['/admin']">Administration</a>
|
||||
</div>
|
||||
</div>
|
||||
</menu>
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router, ROUTER_DIRECTIVES } from '@angular/router';
|
||||
|
||||
import { AuthService, AuthStatus } from './shared';
|
||||
@ -9,7 +9,6 @@ import { AuthService, AuthStatus } from './shared';
|
||||
directives: [ ROUTER_DIRECTIVES ]
|
||||
})
|
||||
export class MenuComponent implements OnInit {
|
||||
@Output() enteredInAdmin = new EventEmitter<boolean>();
|
||||
isLoggedIn: boolean;
|
||||
|
||||
constructor (
|
||||
@ -35,10 +34,6 @@ export class MenuComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
enterInAdmin() {
|
||||
this.enteredInAdmin.emit(true);
|
||||
}
|
||||
|
||||
isUserAdmin() {
|
||||
return this.authService.isAdmin();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user