diff options
Diffstat (limited to 'client/src/app/core')
-rw-r--r-- | client/src/app/core/core.module.ts | 8 | ||||
-rw-r--r-- | client/src/app/core/index.ts | 1 | ||||
-rw-r--r-- | client/src/app/core/menu/index.ts | 2 | ||||
-rw-r--r-- | client/src/app/core/menu/menu-admin.component.html | 35 | ||||
-rw-r--r-- | client/src/app/core/menu/menu-admin.component.ts | 33 | ||||
-rw-r--r-- | client/src/app/core/menu/menu.component.html | 55 | ||||
-rw-r--r-- | client/src/app/core/menu/menu.component.scss | 51 | ||||
-rw-r--r-- | client/src/app/core/menu/menu.component.ts | 92 |
8 files changed, 2 insertions, 275 deletions
diff --git a/client/src/app/core/core.module.ts b/client/src/app/core/core.module.ts index c4ce2b637..75262e6cf 100644 --- a/client/src/app/core/core.module.ts +++ b/client/src/app/core/core.module.ts | |||
@@ -26,17 +26,13 @@ import { throwIfAlreadyLoaded } from './module-import-guard' | |||
26 | ], | 26 | ], |
27 | 27 | ||
28 | declarations: [ | 28 | declarations: [ |
29 | ConfirmComponent, | 29 | ConfirmComponent |
30 | MenuComponent, | ||
31 | MenuAdminComponent | ||
32 | ], | 30 | ], |
33 | 31 | ||
34 | exports: [ | 32 | exports: [ |
35 | SimpleNotificationsModule, | 33 | SimpleNotificationsModule, |
36 | 34 | ||
37 | ConfirmComponent, | 35 | ConfirmComponent |
38 | MenuComponent, | ||
39 | MenuAdminComponent | ||
40 | ], | 36 | ], |
41 | 37 | ||
42 | providers: [ | 38 | providers: [ |
diff --git a/client/src/app/core/index.ts b/client/src/app/core/index.ts index 8358261ae..3c01e05aa 100644 --- a/client/src/app/core/index.ts +++ b/client/src/app/core/index.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | export * from './auth' | 1 | export * from './auth' |
2 | export * from './server' | 2 | export * from './server' |
3 | export * from './confirm' | 3 | export * from './confirm' |
4 | export * from './menu' | ||
5 | export * from './routing' | 4 | export * from './routing' |
6 | export * from './core.module' | 5 | export * from './core.module' |
diff --git a/client/src/app/core/menu/index.ts b/client/src/app/core/menu/index.ts deleted file mode 100644 index c905ed20a..000000000 --- a/client/src/app/core/menu/index.ts +++ /dev/null | |||
@@ -1,2 +0,0 @@ | |||
1 | export * from './menu.component' | ||
2 | export * from './menu-admin.component' | ||
diff --git a/client/src/app/core/menu/menu-admin.component.html b/client/src/app/core/menu/menu-admin.component.html deleted file mode 100644 index 9857b2e3e..000000000 --- a/client/src/app/core/menu/menu-admin.component.html +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | <menu> | ||
2 | <div class="panel-block"> | ||
3 | <a *ngIf="hasUsersRight()" routerLink="/admin/users" routerLinkActive="active"> | ||
4 | <span class="hidden-xs glyphicon glyphicon-user"></span> | ||
5 | List users | ||
6 | </a> | ||
7 | |||
8 | <a *ngIf="hasServerFollowRight()" routerLink="/admin/follows" routerLinkActive="active"> | ||
9 | <span class="hidden-xs glyphicon glyphicon-cloud"></span> | ||
10 | Manage follows | ||
11 | </a> | ||
12 | |||
13 | <a *ngIf="hasVideoAbusesRight()" routerLink="/admin/video-abuses" routerLinkActive="active"> | ||
14 | <span class="hidden-xs glyphicon glyphicon-alert"></span> | ||
15 | Video abuses | ||
16 | </a> | ||
17 | |||
18 | <a *ngIf="hasVideoBlacklistRight()" routerLink="/admin/video-blacklist" routerLinkActive="active"> | ||
19 | <span class="hidden-xs glyphicon glyphicon-eye-close"></span> | ||
20 | Video blacklist | ||
21 | </a> | ||
22 | |||
23 | <a *ngIf="hasJobsRight()" routerLink="/admin/jobs" routerLinkActive="active"> | ||
24 | <span class="hidden-xs glyphicon glyphicon-tasks"></span> | ||
25 | Jobs | ||
26 | </a> | ||
27 | </div> | ||
28 | |||
29 | <div class="panel-block"> | ||
30 | <a routerLink="/videos/list" routerLinkActive="active"> | ||
31 | <span class="hidden-xs glyphicon glyphicon-cog"></span> | ||
32 | Quit admin. | ||
33 | </a> | ||
34 | </div> | ||
35 | </menu> | ||
diff --git a/client/src/app/core/menu/menu-admin.component.ts b/client/src/app/core/menu/menu-admin.component.ts deleted file mode 100644 index ea8d5f57c..000000000 --- a/client/src/app/core/menu/menu-admin.component.ts +++ /dev/null | |||
@@ -1,33 +0,0 @@ | |||
1 | import { Component } from '@angular/core' | ||
2 | |||
3 | import { AuthService } from '../auth/auth.service' | ||
4 | import { UserRight } from '../../../../../shared' | ||
5 | |||
6 | @Component({ | ||
7 | selector: 'my-menu-admin', | ||
8 | templateUrl: './menu-admin.component.html', | ||
9 | styleUrls: [ './menu.component.scss' ] | ||
10 | }) | ||
11 | export class MenuAdminComponent { | ||
12 | constructor (private auth: AuthService) {} | ||
13 | |||
14 | hasUsersRight () { | ||
15 | return this.auth.getUser().hasRight(UserRight.MANAGE_USERS) | ||
16 | } | ||
17 | |||
18 | hasServerFollowRight () { | ||
19 | return this.auth.getUser().hasRight(UserRight.MANAGE_SERVER_FOLLOW) | ||
20 | } | ||
21 | |||
22 | hasVideoAbusesRight () { | ||
23 | return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_ABUSES) | ||
24 | } | ||
25 | |||
26 | hasVideoBlacklistRight () { | ||
27 | return this.auth.getUser().hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) | ||
28 | } | ||
29 | |||
30 | hasJobsRight () { | ||
31 | return this.auth.getUser().hasRight(UserRight.MANAGE_JOBS) | ||
32 | } | ||
33 | } | ||
diff --git a/client/src/app/core/menu/menu.component.html b/client/src/app/core/menu/menu.component.html deleted file mode 100644 index fcde23fdd..000000000 --- a/client/src/app/core/menu/menu.component.html +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | <menu> | ||
2 | <div class="panel-block"> | ||
3 | <div class="block-title">Account</div> | ||
4 | |||
5 | <div id="panel-user-login" class="panel-button"> | ||
6 | <a *ngIf="!isLoggedIn" routerLink="/login" routerLinkActive="active"> | ||
7 | <span class="hidden-xs glyphicon glyphicon-log-in"></span> | ||
8 | Login | ||
9 | </a> | ||
10 | |||
11 | <a *ngIf="isLoggedIn" (click)="logout()"> | ||
12 | <span class="hidden-xs glyphicon glyphicon-log-out"></span> | ||
13 | Logout | ||
14 | </a> | ||
15 | </div> | ||
16 | |||
17 | <a *ngIf="!isLoggedIn && isRegistrationAllowed()" routerLink="/signup" routerLinkActive="active"> | ||
18 | <span class="hidden-xs glyphicon glyphicon-user"></span> | ||
19 | Signup | ||
20 | </a> | ||
21 | |||
22 | <a *ngIf="isLoggedIn" routerLink="/account" routerLinkActive="active"> | ||
23 | <span class="hidden-xs glyphicon glyphicon-user"></span> | ||
24 | My account | ||
25 | </a> | ||
26 | |||
27 | <a *ngIf="isLoggedIn" routerLink="/videos/mine" routerLinkActive="active"> | ||
28 | <span class="hidden-xs glyphicon glyphicon-folder-open"></span> | ||
29 | My videos | ||
30 | </a> | ||
31 | </div> | ||
32 | |||
33 | <div class="panel-block"> | ||
34 | <div class="block-title">Videos</div> | ||
35 | |||
36 | <a routerLink="/videos/list" routerLinkActive="active"> | ||
37 | <span class="hidden-xs glyphicon glyphicon-list"></span> | ||
38 | See videos | ||
39 | </a> | ||
40 | |||
41 | <a *ngIf="isLoggedIn" routerLink="/videos/upload" routerLinkActive="active"> | ||
42 | <span class="hidden-xs glyphicon glyphicon-cloud-upload"></span> | ||
43 | Upload a video | ||
44 | </a> | ||
45 | </div> | ||
46 | |||
47 | <div *ngIf="userHasAdminAccess" class="panel-block"> | ||
48 | <div class="block-title">Other</div> | ||
49 | |||
50 | <a [routerLink]="getFirstAdminRouteAvailable()" routerLinkActive="active"> | ||
51 | <span class="hidden-xs glyphicon glyphicon-cog"></span> | ||
52 | Administration | ||
53 | </a> | ||
54 | </div> | ||
55 | </menu> | ||
diff --git a/client/src/app/core/menu/menu.component.scss b/client/src/app/core/menu/menu.component.scss deleted file mode 100644 index 45679c310..000000000 --- a/client/src/app/core/menu/menu.component.scss +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | menu { | ||
2 | background-color: $black-background; | ||
3 | padding: 15px; | ||
4 | margin: 0; | ||
5 | height: 100%; | ||
6 | white-space: nowrap; | ||
7 | text-overflow: ellipsis; | ||
8 | overflow: hidden; | ||
9 | z-index: 1000; | ||
10 | |||
11 | @media screen and (max-width: 550px) { | ||
12 | font-size: 90%; | ||
13 | } | ||
14 | |||
15 | @media screen and (min-width: 1200px) { | ||
16 | padding: 25px; | ||
17 | } | ||
18 | |||
19 | .panel-block { | ||
20 | margin-bottom: 15px; | ||
21 | } | ||
22 | |||
23 | .block-title { | ||
24 | text-transform: uppercase; | ||
25 | font-weight: bold; | ||
26 | color: $menu-color-block; | ||
27 | margin-bottom: 10px; | ||
28 | } | ||
29 | |||
30 | a { | ||
31 | display: block; | ||
32 | margin-left: 5px; | ||
33 | height: 30px; | ||
34 | color: $menu-color-link; | ||
35 | cursor: pointer; | ||
36 | transition: color 0.3s; | ||
37 | |||
38 | &:hover, &:focus { | ||
39 | text-decoration: none !important; | ||
40 | outline: none !important; | ||
41 | } | ||
42 | |||
43 | .glyphicon { | ||
44 | margin-right: 15px; | ||
45 | } | ||
46 | |||
47 | &:hover, &.active { | ||
48 | color: #fff; | ||
49 | } | ||
50 | } | ||
51 | } | ||
diff --git a/client/src/app/core/menu/menu.component.ts b/client/src/app/core/menu/menu.component.ts deleted file mode 100644 index d2bd71534..000000000 --- a/client/src/app/core/menu/menu.component.ts +++ /dev/null | |||
@@ -1,92 +0,0 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | ||
2 | import { Router } from '@angular/router' | ||
3 | |||
4 | import { AuthService, AuthStatus } from '../auth' | ||
5 | import { ServerService } from '../server' | ||
6 | import { UserRight } from '../../../../../shared/models/users/user-right.enum' | ||
7 | |||
8 | @Component({ | ||
9 | selector: 'my-menu', | ||
10 | templateUrl: './menu.component.html', | ||
11 | styleUrls: [ './menu.component.scss' ] | ||
12 | }) | ||
13 | export class MenuComponent implements OnInit { | ||
14 | isLoggedIn: boolean | ||
15 | userHasAdminAccess = false | ||
16 | |||
17 | private routesPerRight = { | ||
18 | [UserRight.MANAGE_USERS]: '/admin/users', | ||
19 | [UserRight.MANAGE_SERVER_FOLLOW]: '/admin/friends', | ||
20 | [UserRight.MANAGE_VIDEO_ABUSES]: '/admin/video-abuses', | ||
21 | [UserRight.MANAGE_VIDEO_BLACKLIST]: '/admin/video-blacklist' | ||
22 | } | ||
23 | |||
24 | constructor ( | ||
25 | private authService: AuthService, | ||
26 | private serverService: ServerService, | ||
27 | private router: Router | ||
28 | ) {} | ||
29 | |||
30 | ngOnInit () { | ||
31 | this.isLoggedIn = this.authService.isLoggedIn() | ||
32 | this.computeIsUserHasAdminAccess() | ||
33 | |||
34 | this.authService.loginChangedSource.subscribe( | ||
35 | status => { | ||
36 | if (status === AuthStatus.LoggedIn) { | ||
37 | this.isLoggedIn = true | ||
38 | this.computeIsUserHasAdminAccess() | ||
39 | console.log('Logged in.') | ||
40 | } else if (status === AuthStatus.LoggedOut) { | ||
41 | this.isLoggedIn = false | ||
42 | this.computeIsUserHasAdminAccess() | ||
43 | console.log('Logged out.') | ||
44 | } else { | ||
45 | console.error('Unknown auth status: ' + status) | ||
46 | } | ||
47 | } | ||
48 | ) | ||
49 | } | ||
50 | |||
51 | isRegistrationAllowed () { | ||
52 | return this.serverService.getConfig().signup.allowed | ||
53 | } | ||
54 | |||
55 | getFirstAdminRightAvailable () { | ||
56 | const user = this.authService.getUser() | ||
57 | if (!user) return undefined | ||
58 | |||
59 | const adminRights = [ | ||
60 | UserRight.MANAGE_USERS, | ||
61 | UserRight.MANAGE_SERVER_FOLLOW, | ||
62 | UserRight.MANAGE_VIDEO_ABUSES, | ||
63 | UserRight.MANAGE_VIDEO_BLACKLIST | ||
64 | ] | ||
65 | |||
66 | for (const adminRight of adminRights) { | ||
67 | if (user.hasRight(adminRight)) { | ||
68 | return adminRight | ||
69 | } | ||
70 | } | ||
71 | |||
72 | return undefined | ||
73 | } | ||
74 | |||
75 | getFirstAdminRouteAvailable () { | ||
76 | const right = this.getFirstAdminRightAvailable() | ||
77 | |||
78 | return this.routesPerRight[right] | ||
79 | } | ||
80 | |||
81 | logout () { | ||
82 | this.authService.logout() | ||
83 | // Redirect to home page | ||
84 | this.router.navigate(['/videos/list']) | ||
85 | } | ||
86 | |||
87 | private computeIsUserHasAdminAccess () { | ||
88 | const right = this.getFirstAdminRightAvailable() | ||
89 | |||
90 | this.userHasAdminAccess = right !== undefined | ||
91 | } | ||
92 | } | ||