aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/+videos/+video-watch/video-watch.component.html8
-rw-r--r--client/src/app/+videos/+video-watch/video-watch.component.ts6
-rw-r--r--client/src/app/app.component.ts2
-rw-r--r--client/src/app/app.module.ts3
-rw-r--r--client/src/app/core/routing/redirect.service.ts9
-rw-r--r--client/src/app/menu/menu.component.html6
-rw-r--r--client/src/app/menu/menu.component.ts65
-rw-r--r--client/src/app/shared/shared-main/date/date-toggle.component.html5
-rw-r--r--client/src/app/shared/shared-main/date/date-toggle.component.ts16
-rw-r--r--client/src/app/shared/shared-main/video/video.model.ts10
-rw-r--r--client/src/app/shared/shared-video-miniature/video-miniature.component.html2
-rw-r--r--client/src/app/shared/shared-video-miniature/video-miniature.component.ts6
12 files changed, 72 insertions, 66 deletions
diff --git a/client/src/app/+videos/+video-watch/video-watch.component.html b/client/src/app/+videos/+video-watch/video-watch.component.html
index d74334b13..602214ac5 100644
--- a/client/src/app/+videos/+video-watch/video-watch.component.html
+++ b/client/src/app/+videos/+video-watch/video-watch.component.html
@@ -54,9 +54,7 @@
54 <div class="video-info-date-views"> 54 <div class="video-info-date-views">
55 <ng-container i18n>Published <my-date-toggle [date]="video.publishedAt"></my-date-toggle></ng-container> 55 <ng-container i18n>Published <my-date-toggle [date]="video.publishedAt"></my-date-toggle></ng-container>
56 56
57 <span i18n 57 <span i18n [title]="video.getExactNumberOfViews()" class="views">
58 title="{{ getExactNumberOfViews() }}"
59 class="views">
60 • {{ video.views | myNumberFormatter }} 58 • {{ video.views | myNumberFormatter }}
61 <ng-container *ngIf="!video.isLive">views</ng-container> 59 <ng-container *ngIf="!video.isLive">views</ng-container>
62 <ng-container *ngIf="video.isLive">viewers</ng-container> 60 <ng-container *ngIf="video.isLive">viewers</ng-container>
@@ -73,9 +71,7 @@
73 <div class="d-none d-md-block video-info-date-views"> 71 <div class="d-none d-md-block video-info-date-views">
74 <ng-container i18n>Published <my-date-toggle [date]="video.publishedAt"></my-date-toggle></ng-container> 72 <ng-container i18n>Published <my-date-toggle [date]="video.publishedAt"></my-date-toggle></ng-container>
75 73
76 <span i18n 74 <span i18n [title]="video.getExactNumberOfViews()" class="views">
77 title="{{ getExactNumberOfViews() }}"
78 class="views">
79 • {{ video.views | myNumberFormatter }} 75 • {{ video.views | myNumberFormatter }}
80 <ng-container *ngIf="!video.isLive">views</ng-container> 76 <ng-container *ngIf="!video.isLive">views</ng-container>
81 <ng-container *ngIf="video.isLive">viewers</ng-container> 77 <ng-container *ngIf="video.isLive">viewers</ng-container>
diff --git a/client/src/app/+videos/+video-watch/video-watch.component.ts b/client/src/app/+videos/+video-watch/video-watch.component.ts
index bc047489e..66af9709d 100644
--- a/client/src/app/+videos/+video-watch/video-watch.component.ts
+++ b/client/src/app/+videos/+video-watch/video-watch.component.ts
@@ -219,12 +219,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
219 return $localize`You need to be <a href="/login">logged in</a> to rate this video.` 219 return $localize`You need to be <a href="/login">logged in</a> to rate this video.`
220 } 220 }
221 221
222 getExactNumberOfViews () {
223 return (this.video.views >= 1000)
224 ? `${this.video.views} ${this.video.isLive ? $localize`viewers` : $localize`views`}`
225 : ''
226 }
227
228 showMoreDescription () { 222 showMoreDescription () {
229 if (this.completeVideoDescription === undefined) { 223 if (this.completeVideoDescription === undefined) {
230 return this.loadCompleteDescription() 224 return this.loadCompleteDescription()
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts
index 75f4bdfe6..c5cb54ddd 100644
--- a/client/src/app/app.component.ts
+++ b/client/src/app/app.component.ts
@@ -1,6 +1,6 @@
1import { Hotkey, HotkeysService } from 'angular2-hotkeys' 1import { Hotkey, HotkeysService } from 'angular2-hotkeys'
2import { concat } from 'rxjs' 2import { concat } from 'rxjs'
3import { filter, first, map, pairwise } from 'rxjs/operators' 3import { filter, first, map, pairwise, tap } from 'rxjs/operators'
4import { DOCUMENT, PlatformLocation, ViewportScroller } from '@angular/common' 4import { DOCUMENT, PlatformLocation, ViewportScroller } from '@angular/common'
5import { AfterViewInit, Component, Inject, LOCALE_ID, OnInit, ViewChild } from '@angular/core' 5import { AfterViewInit, Component, Inject, LOCALE_ID, OnInit, ViewChild } from '@angular/core'
6import { DomSanitizer, SafeHtml } from '@angular/platform-browser' 6import { DomSanitizer, SafeHtml } from '@angular/platform-browser'
diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts
index 5c4616153..3f874856d 100644
--- a/client/src/app/app.module.ts
+++ b/client/src/app/app.module.ts
@@ -1,11 +1,10 @@
1import 'focus-visible' 1import 'focus-visible'
2import { APP_BASE_HREF, registerLocaleData } from '@angular/common' 2import { APP_BASE_HREF, registerLocaleData } from '@angular/common'
3import { LOCALE_ID, NgModule, TRANSLATIONS, TRANSLATIONS_FORMAT } from '@angular/core' 3import { NgModule } from '@angular/core'
4import { BrowserModule } from '@angular/platform-browser' 4import { BrowserModule } from '@angular/platform-browser'
5import { ServerService } from '@app/core' 5import { ServerService } from '@app/core'
6import localeOc from '@app/helpers/locales/oc' 6import localeOc from '@app/helpers/locales/oc'
7import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core' 7import { MetaLoader, MetaModule, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core'
8import { buildFileLocale, getCompleteLocale, isDefaultLocale } from '@shared/core-utils/i18n'
9import { AppRoutingModule } from './app-routing.module' 8import { AppRoutingModule } from './app-routing.module'
10import { AppComponent } from './app.component' 9import { AppComponent } from './app.component'
11import { CoreModule } from './core' 10import { CoreModule } from './core'
diff --git a/client/src/app/core/routing/redirect.service.ts b/client/src/app/core/routing/redirect.service.ts
index 3982cf36f..4f4b346e2 100644
--- a/client/src/app/core/routing/redirect.service.ts
+++ b/client/src/app/core/routing/redirect.service.ts
@@ -11,6 +11,8 @@ export class RedirectService {
11 private previousUrl: string 11 private previousUrl: string
12 private currentUrl: string 12 private currentUrl: string
13 13
14 private redirectingToHomepage = false
15
14 constructor ( 16 constructor (
15 private router: Router, 17 private router: Router,
16 private serverService: ServerService 18 private serverService: ServerService
@@ -56,10 +58,17 @@ export class RedirectService {
56 } 58 }
57 59
58 redirectToHomepage (skipLocationChange = false) { 60 redirectToHomepage (skipLocationChange = false) {
61 if (this.redirectingToHomepage) return
62
63 this.redirectingToHomepage = true
64
59 console.log('Redirecting to %s...', RedirectService.DEFAULT_ROUTE) 65 console.log('Redirecting to %s...', RedirectService.DEFAULT_ROUTE)
60 66
61 this.router.navigate([ RedirectService.DEFAULT_ROUTE ], { skipLocationChange }) 67 this.router.navigate([ RedirectService.DEFAULT_ROUTE ], { skipLocationChange })
68 .then(() => this.redirectingToHomepage = false)
62 .catch(() => { 69 .catch(() => {
70 this.redirectingToHomepage = false
71
63 console.error( 72 console.error(
64 'Cannot navigate to %s, resetting default route to %s.', 73 'Cannot navigate to %s, resetting default route to %s.',
65 RedirectService.DEFAULT_ROUTE, 74 RedirectService.DEFAULT_ROUTE,
diff --git a/client/src/app/menu/menu.component.html b/client/src/app/menu/menu.component.html
index 810466a72..bba5fdadf 100644
--- a/client/src/app/menu/menu.component.html
+++ b/client/src/app/menu/menu.component.html
@@ -12,7 +12,7 @@
12 <div class="logged-in-username">@{{ user.username }}</div> 12 <div class="logged-in-username">@{{ user.username }}</div>
13 </div> 13 </div>
14 14
15 <div class="logged-in-more" ngbDropdown [placement]="placement" container="body" autoClose="outside"> 15 <div class="logged-in-more" ngbDropdown [placement]="loggedInMorePlacement" container="body" autoClose="outside">
16 <my-global-icon iconName="more-vertical" ngbDropdownToggle role="button"></my-global-icon> 16 <my-global-icon iconName="more-vertical" ngbDropdownToggle role="button"></my-global-icon>
17 17
18 <div ngbDropdownMenu> 18 <div ngbDropdownMenu>
@@ -32,7 +32,7 @@
32 <a ngbDropdownItem ngbDropdownToggle class="dropdown-item" (click)="openLanguageChooser()"> 32 <a ngbDropdownItem ngbDropdownToggle class="dropdown-item" (click)="openLanguageChooser()">
33 <my-global-icon iconName="language" aria-hidden="true"></my-global-icon> 33 <my-global-icon iconName="language" aria-hidden="true"></my-global-icon>
34 <span i18n>Interface:</span> 34 <span i18n>Interface:</span>
35 <span class="ml-auto text-muted">{{ language }}</span> 35 <span class="ml-auto text-muted">{{ currentInterfaceLanguage }}</span>
36 </a> 36 </a>
37 37
38 <a ngbDropdownItem ngbDropdownToggle class="dropdown-item" routerLink="/my-account/settings" fragment="video-languages-subtitles" 38 <a ngbDropdownItem ngbDropdownToggle class="dropdown-item" routerLink="/my-account/settings" fragment="video-languages-subtitles"
@@ -168,7 +168,7 @@
168 168
169 <div class="footer-links"> 169 <div class="footer-links">
170 <div *ngIf="isLoggedIn === false"> 170 <div *ngIf="isLoggedIn === false">
171 <span role="button" (click)="openLanguageChooser()" class="c-hand" i18n>Interface: {{ language }}</span> 171 <span role="button" (click)="openLanguageChooser()" class="c-hand" i18n>Interface: {{ currentInterfaceLanguage }}</span>
172 </div> 172 </div>
173 173
174 <div> 174 <div>
diff --git a/client/src/app/menu/menu.component.ts b/client/src/app/menu/menu.component.ts
index 97a3b6d24..bdc95127b 100644
--- a/client/src/app/menu/menu.component.ts
+++ b/client/src/app/menu/menu.component.ts
@@ -28,6 +28,11 @@ export class MenuComponent implements OnInit {
28 helpVisible = false 28 helpVisible = false
29 29
30 videoLanguages: string[] = [] 30 videoLanguages: string[] = []
31 nsfwPolicy: string
32
33 loggedInMorePlacement: string
34
35 currentInterfaceLanguage: string
31 36
32 private languages: VideoConstant<string>[] = [] 37 private languages: VideoConstant<string>[] = []
33 private serverConfig: ServerConfig 38 private serverConfig: ServerConfig
@@ -52,37 +57,6 @@ export class MenuComponent implements OnInit {
52 private router: Router 57 private router: Router
53 ) { } 58 ) { }
54 59
55 get isInMobileView () {
56 return this.screenService.isInMobileView()
57 }
58
59 get placement () {
60 if (this.isInMobileView) {
61 return 'left-top auto'
62 } else {
63 return 'right-top auto'
64 }
65 }
66
67 get language () {
68 return this.languageChooserModal.getCurrentLanguage()
69 }
70
71 get nsfwPolicy () {
72 if (!this.user) return
73
74 switch (this.user.nsfwPolicy) {
75 case 'do_not_list':
76 return $localize`hide`
77
78 case 'blur':
79 return $localize`blur`
80
81 case 'display':
82 return $localize`display`
83 }
84 }
85
86 get instanceName () { 60 get instanceName () {
87 return this.serverConfig.instance.name 61 return this.serverConfig.instance.name
88 } 62 }
@@ -95,11 +69,19 @@ export class MenuComponent implements OnInit {
95 this.isLoggedIn = this.authService.isLoggedIn() 69 this.isLoggedIn = this.authService.isLoggedIn()
96 if (this.isLoggedIn === true) { 70 if (this.isLoggedIn === true) {
97 this.user = this.authService.getUser() 71 this.user = this.authService.getUser()
72
73 this.computeNSFWPolicy()
98 this.computeVideosLink() 74 this.computeVideosLink()
99 } 75 }
100 76
101 this.computeAdminAccess() 77 this.computeAdminAccess()
102 78
79 this.loggedInMorePlacement = this.screenService.isInMobileView()
80 ? 'left-top auto'
81 : 'right-top auto'
82
83 this.currentInterfaceLanguage = this.languageChooserModal.getCurrentLanguage()
84
103 this.authService.loginChangedSource.subscribe( 85 this.authService.loginChangedSource.subscribe(
104 status => { 86 status => {
105 if (status === AuthStatus.LoggedIn) { 87 if (status === AuthStatus.LoggedIn) {
@@ -252,4 +234,25 @@ export class MenuComponent implements OnInit {
252 else logger('User cannot see videos link.') 234 else logger('User cannot see videos link.')
253 }) 235 })
254 } 236 }
237
238 private computeNSFWPolicy () {
239 if (!this.user) {
240 this.nsfwPolicy = null
241 return
242 }
243
244 switch (this.user.nsfwPolicy) {
245 case 'do_not_list':
246 this.nsfwPolicy = $localize`hide`
247 break
248
249 case 'blur':
250 this.nsfwPolicy = $localize`blur`
251 break
252
253 case 'display':
254 this.nsfwPolicy = $localize`display`
255 break
256 }
257 }
255} 258}
diff --git a/client/src/app/shared/shared-main/date/date-toggle.component.html b/client/src/app/shared/shared-main/date/date-toggle.component.html
index ebd4ce442..14b6e7d7a 100644
--- a/client/src/app/shared/shared-main/date/date-toggle.component.html
+++ b/client/src/app/shared/shared-main/date/date-toggle.component.html
@@ -1,6 +1,7 @@
1<span 1<span
2 class="date-toggle" 2 class="date-toggle"
3 [title]="getTitle()" 3 [title]="getTitle()"
4 [innerHtml]="getContent()"
5 (click)="toggle()" 4 (click)="toggle()"
6></span> 5>
6 {{ getContent() }}
7</span>
diff --git a/client/src/app/shared/shared-main/date/date-toggle.component.ts b/client/src/app/shared/shared-main/date/date-toggle.component.ts
index bedf0ba4e..53f25f0ad 100644
--- a/client/src/app/shared/shared-main/date/date-toggle.component.ts
+++ b/client/src/app/shared/shared-main/date/date-toggle.component.ts
@@ -7,7 +7,7 @@ import { FromNowPipe } from '../angular/from-now.pipe'
7 templateUrl: './date-toggle.component.html', 7 templateUrl: './date-toggle.component.html',
8 styleUrls: [ './date-toggle.component.scss' ] 8 styleUrls: [ './date-toggle.component.scss' ]
9}) 9})
10export class DateToggleComponent implements OnInit, OnChanges { 10export class DateToggleComponent implements OnChanges {
11 @Input() date: Date 11 @Input() date: Date
12 @Input() toggled = false 12 @Input() toggled = false
13 13
@@ -19,10 +19,6 @@ export class DateToggleComponent implements OnInit, OnChanges {
19 private fromNowPipe: FromNowPipe 19 private fromNowPipe: FromNowPipe
20 ) { } 20 ) { }
21 21
22 ngOnInit () {
23 this.updateDates()
24 }
25
26 ngOnChanges () { 22 ngOnChanges () {
27 this.updateDates() 23 this.updateDates()
28 } 24 }
@@ -32,15 +28,19 @@ export class DateToggleComponent implements OnInit, OnChanges {
32 } 28 }
33 29
34 getTitle () { 30 getTitle () {
35 return this.toggled ? this.dateRelative : this.dateAbsolute 31 return this.toggled
32 ? this.dateRelative
33 : this.dateAbsolute
36 } 34 }
37 35
38 getContent () { 36 getContent () {
39 return this.toggled ? this.dateAbsolute : this.dateRelative 37 return this.toggled
38 ? this.dateAbsolute
39 : this.dateRelative
40 } 40 }
41 41
42 private updateDates () { 42 private updateDates () {
43 this.dateRelative = this.fromNowPipe.transform(this.date) 43 this.dateRelative = this.fromNowPipe.transform(this.date)
44 this.dateAbsolute = this.datePipe.transform(this.date, 'long') 44 this.dateAbsolute = this.date.toLocaleDateString()
45 } 45 }
46} 46}
diff --git a/client/src/app/shared/shared-main/video/video.model.ts b/client/src/app/shared/shared-main/video/video.model.ts
index 04e7bd717..adb6e884f 100644
--- a/client/src/app/shared/shared-main/video/video.model.ts
+++ b/client/src/app/shared/shared-main/video/video.model.ts
@@ -203,4 +203,14 @@ export class Video implements VideoServerModel {
203 canBeDuplicatedBy (user: AuthUser) { 203 canBeDuplicatedBy (user: AuthUser) {
204 return user && this.isLocal === false && user.hasRight(UserRight.MANAGE_VIDEOS_REDUNDANCIES) 204 return user && this.isLocal === false && user.hasRight(UserRight.MANAGE_VIDEOS_REDUNDANCIES)
205 } 205 }
206
207 getExactNumberOfViews () {
208 if (this.views < 1000) return ''
209
210 if (this.isLive) {
211 return $localize`${this.views} viewers`
212 }
213
214 return $localize`${this.views} views`
215 }
206} 216}
diff --git a/client/src/app/shared/shared-video-miniature/video-miniature.component.html b/client/src/app/shared/shared-video-miniature/video-miniature.component.html
index b323002e3..395a4df97 100644
--- a/client/src/app/shared/shared-video-miniature/video-miniature.component.html
+++ b/client/src/app/shared/shared-video-miniature/video-miniature.component.html
@@ -26,7 +26,7 @@
26 <span class="video-miniature-created-at-views"> 26 <span class="video-miniature-created-at-views">
27 <my-date-toggle *ngIf="displayOptions.date" [date]="video.publishedAt"></my-date-toggle> 27 <my-date-toggle *ngIf="displayOptions.date" [date]="video.publishedAt"></my-date-toggle>
28 28
29 <span class="views" title="{{ getExactNumberOfViews() }}"> 29 <span class="views" [title]="video.getExactNumberOfViews()">
30 <ng-container *ngIf="displayOptions.date && displayOptions.views"> • </ng-container> 30 <ng-container *ngIf="displayOptions.date && displayOptions.views"> • </ng-container>
31 <ng-container i18n *ngIf="displayOptions.views"> 31 <ng-container i18n *ngIf="displayOptions.views">
32 {video.views, plural, =1 {1 view} other {{{ video.views | myNumberFormatter }} views}} 32 {video.views, plural, =1 {1 view} other {{{ video.views | myNumberFormatter }} views}}
diff --git a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts
index e59255cf8..cc5665ab1 100644
--- a/client/src/app/shared/shared-video-miniature/video-miniature.component.ts
+++ b/client/src/app/shared/shared-video-miniature/video-miniature.component.ts
@@ -190,12 +190,6 @@ export class VideoMiniatureComponent implements OnInit {
190 return this.video.videoChannelAvatarUrl 190 return this.video.videoChannelAvatarUrl
191 } 191 }
192 192
193 getExactNumberOfViews () {
194 return (this.video.views >= 1000 && this.displayOptions.views)
195 ? `${this.video.views} ${this.video.isLive ? $localize`viewers` : $localize`views`}`
196 : ''
197 }
198
199 loadActions () { 193 loadActions () {
200 if (this.displayVideoActions) this.showActions = true 194 if (this.displayVideoActions) this.showActions = true
201 195