diff options
Diffstat (limited to 'client/src/app/shared')
-rw-r--r-- | client/src/app/shared/misc/help.component.html | 7 | ||||
-rw-r--r-- | client/src/app/shared/misc/help.component.scss | 22 | ||||
-rw-r--r-- | client/src/app/shared/misc/help.component.ts | 16 | ||||
-rw-r--r-- | client/src/app/shared/users/user.model.ts | 9 | ||||
-rw-r--r-- | client/src/app/shared/video/video-details.model.ts | 11 | ||||
-rw-r--r-- | client/src/app/shared/video/video-miniature.component.html | 4 | ||||
-rw-r--r-- | client/src/app/shared/video/video-miniature.component.ts | 7 | ||||
-rw-r--r-- | client/src/app/shared/video/video.model.ts | 17 |
8 files changed, 42 insertions, 51 deletions
diff --git a/client/src/app/shared/misc/help.component.html b/client/src/app/shared/misc/help.component.html index e37d93b62..3da5701a0 100644 --- a/client/src/app/shared/misc/help.component.html +++ b/client/src/app/shared/misc/help.component.html | |||
@@ -13,6 +13,9 @@ | |||
13 | </ng-template> | 13 | </ng-template> |
14 | 14 | ||
15 | <span | 15 | <span |
16 | class="help-tooltip-button" containerClass="help-tooltip" title="Click to get help" | 16 | class="help-tooltip-button" |
17 | #tooltipDirective="bs-tooltip" [tooltip]="tooltipTemplate" triggers="click" | 17 | title="Get help" |
18 | [popover]="tooltipTemplate" | ||
19 | [placement]="tooltipPlacement" | ||
20 | [outsideClick]="true" | ||
18 | ></span> | 21 | ></span> |
diff --git a/client/src/app/shared/misc/help.component.scss b/client/src/app/shared/misc/help.component.scss index b8bf3a7a5..0df8b86fa 100644 --- a/client/src/app/shared/misc/help.component.scss +++ b/client/src/app/shared/misc/help.component.scss | |||
@@ -12,20 +12,16 @@ | |||
12 | } | 12 | } |
13 | 13 | ||
14 | /deep/ { | 14 | /deep/ { |
15 | .help-tooltip { | 15 | .popover-body { |
16 | opacity: 1 !important; | 16 | text-align: left; |
17 | padding: 10px; | ||
18 | max-width: 300px; | ||
17 | 19 | ||
18 | .tooltip-inner { | 20 | font-size: 13px; |
19 | text-align: left; | 21 | font-family: $main-fonts; |
20 | padding: 10px; | 22 | background-color: #fff; |
21 | max-width: 300px; | 23 | color: #000; |
22 | 24 | box-shadow: 0 0 6px rgba(0, 0, 0, 0.5); | |
23 | font-size: 13px; | ||
24 | font-family: $main-fonts; | ||
25 | background-color: #fff; | ||
26 | color: #000; | ||
27 | box-shadow: 0 0 6px rgba(0, 0, 0, 0.5); | ||
28 | } | ||
29 | 25 | ||
30 | ul { | 26 | ul { |
31 | padding-left: 20px; | 27 | padding-left: 20px; |
diff --git a/client/src/app/shared/misc/help.component.ts b/client/src/app/shared/misc/help.component.ts index 89dd1dae5..0373a63de 100644 --- a/client/src/app/shared/misc/help.component.ts +++ b/client/src/app/shared/misc/help.component.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import { Component, ElementRef, HostListener, Input, OnInit, ViewChild, OnChanges } from '@angular/core' | 1 | import { Component, Input, OnChanges, OnInit } from '@angular/core' |
2 | import { MarkdownService } from '@app/videos/shared' | 2 | import { MarkdownService } from '@app/videos/shared' |
3 | import { TooltipDirective } from 'ngx-bootstrap/tooltip' | ||
4 | 3 | ||
5 | @Component({ | 4 | @Component({ |
6 | selector: 'my-help', | 5 | selector: 'my-help', |
@@ -9,16 +8,14 @@ import { TooltipDirective } from 'ngx-bootstrap/tooltip' | |||
9 | }) | 8 | }) |
10 | 9 | ||
11 | export class HelpComponent implements OnInit, OnChanges { | 10 | export class HelpComponent implements OnInit, OnChanges { |
12 | @ViewChild('tooltipDirective') tooltipDirective: TooltipDirective | ||
13 | @Input() preHtml = '' | 11 | @Input() preHtml = '' |
14 | @Input() postHtml = '' | 12 | @Input() postHtml = '' |
15 | @Input() customHtml = '' | 13 | @Input() customHtml = '' |
16 | @Input() helpType: 'custom' | 'markdownText' | 'markdownEnhanced' = 'custom' | 14 | @Input() helpType: 'custom' | 'markdownText' | 'markdownEnhanced' = 'custom' |
15 | @Input() tooltipPlacement = 'right' | ||
17 | 16 | ||
18 | mainHtml = '' | 17 | mainHtml = '' |
19 | 18 | ||
20 | constructor (private elementRef: ElementRef) { } | ||
21 | |||
22 | ngOnInit () { | 19 | ngOnInit () { |
23 | this.init() | 20 | this.init() |
24 | } | 21 | } |
@@ -27,15 +24,6 @@ export class HelpComponent implements OnInit, OnChanges { | |||
27 | this.init() | 24 | this.init() |
28 | } | 25 | } |
29 | 26 | ||
30 | @HostListener('document:click', ['$event.target']) | ||
31 | public onClick (targetElement) { | ||
32 | const clickedInside = this.elementRef.nativeElement.contains(targetElement) | ||
33 | |||
34 | if (this.tooltipDirective.isOpen && !clickedInside) { | ||
35 | this.tooltipDirective.hide() | ||
36 | } | ||
37 | } | ||
38 | |||
39 | private init () { | 27 | private init () { |
40 | if (this.helpType === 'custom') { | 28 | if (this.helpType === 'custom') { |
41 | this.mainHtml = this.customHtml | 29 | this.mainHtml = this.customHtml |
diff --git a/client/src/app/shared/users/user.model.ts b/client/src/app/shared/users/user.model.ts index 4a94b032d..2bdc48a1d 100644 --- a/client/src/app/shared/users/user.model.ts +++ b/client/src/app/shared/users/user.model.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import { hasUserRight, User as UserServerModel, UserRight, UserRole, VideoChannel } from '../../../../../shared' | 1 | import { hasUserRight, User as UserServerModel, UserRight, UserRole, VideoChannel } from '../../../../../shared' |
2 | import { Account } from '../account/account.model' | 2 | import { Account } from '../account/account.model' |
3 | import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type' | ||
3 | 4 | ||
4 | export type UserConstructorHash = { | 5 | export type UserConstructorHash = { |
5 | id: number, | 6 | id: number, |
@@ -7,7 +8,7 @@ export type UserConstructorHash = { | |||
7 | email: string, | 8 | email: string, |
8 | role: UserRole, | 9 | role: UserRole, |
9 | videoQuota?: number, | 10 | videoQuota?: number, |
10 | displayNSFW?: boolean, | 11 | nsfwPolicy?: NSFWPolicyType, |
11 | autoPlayVideo?: boolean, | 12 | autoPlayVideo?: boolean, |
12 | createdAt?: Date, | 13 | createdAt?: Date, |
13 | account?: Account, | 14 | account?: Account, |
@@ -18,7 +19,7 @@ export class User implements UserServerModel { | |||
18 | username: string | 19 | username: string |
19 | email: string | 20 | email: string |
20 | role: UserRole | 21 | role: UserRole |
21 | displayNSFW: boolean | 22 | nsfwPolicy: NSFWPolicyType |
22 | autoPlayVideo: boolean | 23 | autoPlayVideo: boolean |
23 | videoQuota: number | 24 | videoQuota: number |
24 | account: Account | 25 | account: Account |
@@ -40,8 +41,8 @@ export class User implements UserServerModel { | |||
40 | this.videoQuota = hash.videoQuota | 41 | this.videoQuota = hash.videoQuota |
41 | } | 42 | } |
42 | 43 | ||
43 | if (hash.displayNSFW !== undefined) { | 44 | if (hash.nsfwPolicy !== undefined) { |
44 | this.displayNSFW = hash.displayNSFW | 45 | this.nsfwPolicy = hash.nsfwPolicy |
45 | } | 46 | } |
46 | 47 | ||
47 | if (hash.autoPlayVideo !== undefined) { | 48 | if (hash.autoPlayVideo !== undefined) { |
diff --git a/client/src/app/shared/video/video-details.model.ts b/client/src/app/shared/video/video-details.model.ts index a1f7207a2..5397aa37f 100644 --- a/client/src/app/shared/video/video-details.model.ts +++ b/client/src/app/shared/video/video-details.model.ts | |||
@@ -1,17 +1,9 @@ | |||
1 | import { | 1 | import { UserRight, VideoChannel, VideoDetails as VideoDetailsServerModel, VideoFile } from '../../../../../shared' |
2 | UserRight, | ||
3 | VideoChannel, | ||
4 | VideoDetails as VideoDetailsServerModel, | ||
5 | VideoFile, | ||
6 | VideoPrivacy | ||
7 | } from '../../../../../shared' | ||
8 | import { Account } from '../../../../../shared/models/actors' | 2 | import { Account } from '../../../../../shared/models/actors' |
9 | import { VideoConstant } from '../../../../../shared/models/videos/video.model' | ||
10 | import { AuthUser } from '../../core' | 3 | import { AuthUser } from '../../core' |
11 | import { Video } from '../../shared/video/video.model' | 4 | import { Video } from '../../shared/video/video.model' |
12 | 5 | ||
13 | export class VideoDetails extends Video implements VideoDetailsServerModel { | 6 | export class VideoDetails extends Video implements VideoDetailsServerModel { |
14 | privacy: VideoConstant<VideoPrivacy> | ||
15 | descriptionPath: string | 7 | descriptionPath: string |
16 | support: string | 8 | support: string |
17 | channel: VideoChannel | 9 | channel: VideoChannel |
@@ -26,7 +18,6 @@ export class VideoDetails extends Video implements VideoDetailsServerModel { | |||
26 | constructor (hash: VideoDetailsServerModel) { | 18 | constructor (hash: VideoDetailsServerModel) { |
27 | super(hash) | 19 | super(hash) |
28 | 20 | ||
29 | this.privacy = hash.privacy | ||
30 | this.descriptionPath = hash.descriptionPath | 21 | this.descriptionPath = hash.descriptionPath |
31 | this.files = hash.files | 22 | this.files = hash.files |
32 | this.channel = hash.channel | 23 | this.channel = hash.channel |
diff --git a/client/src/app/shared/video/video-miniature.component.html b/client/src/app/shared/video/video-miniature.component.html index f28e9b8d9..233432142 100644 --- a/client/src/app/shared/video/video-miniature.component.html +++ b/client/src/app/shared/video/video-miniature.component.html | |||
@@ -1,11 +1,11 @@ | |||
1 | <div class="video-miniature"> | 1 | <div class="video-miniature"> |
2 | <my-video-thumbnail [video]="video" [nsfw]="isVideoNSFWForThisUser()"></my-video-thumbnail> | 2 | <my-video-thumbnail [video]="video" [nsfw]="isVideoBlur()"></my-video-thumbnail> |
3 | 3 | ||
4 | <div class="video-miniature-information"> | 4 | <div class="video-miniature-information"> |
5 | <span class="video-miniature-name"> | 5 | <span class="video-miniature-name"> |
6 | <a | 6 | <a |
7 | class="video-miniature-name" | 7 | class="video-miniature-name" |
8 | [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name" [ngClass]="{ 'blur-filter': isVideoNSFWForThisUser() }" | 8 | [routerLink]="['/videos/watch', video.uuid]" [attr.title]="video.name" [ngClass]="{ 'blur-filter': isVideoBlur() }" |
9 | > | 9 | > |
10 | {{ video.name }} | 10 | {{ video.name }} |
11 | </a> | 11 | </a> |
diff --git a/client/src/app/shared/video/video-miniature.component.ts b/client/src/app/shared/video/video-miniature.component.ts index 4d79a74bb..d3f6dc1f6 100644 --- a/client/src/app/shared/video/video-miniature.component.ts +++ b/client/src/app/shared/video/video-miniature.component.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | import { Component, Input } from '@angular/core' | 1 | import { Component, Input } from '@angular/core' |
2 | import { User } from '../users' | 2 | import { User } from '../users' |
3 | import { Video } from './video.model' | 3 | import { Video } from './video.model' |
4 | import { ServerService } from '@app/core' | ||
4 | 5 | ||
5 | @Component({ | 6 | @Component({ |
6 | selector: 'my-video-miniature', | 7 | selector: 'my-video-miniature', |
@@ -11,7 +12,9 @@ export class VideoMiniatureComponent { | |||
11 | @Input() user: User | 12 | @Input() user: User |
12 | @Input() video: Video | 13 | @Input() video: Video |
13 | 14 | ||
14 | isVideoNSFWForThisUser () { | 15 | constructor (private serverService: ServerService) { } |
15 | return this.video.isVideoNSFWForUser(this.user) | 16 | |
17 | isVideoBlur () { | ||
18 | return this.video.isVideoNSFWForUser(this.user, this.serverService.getConfig()) | ||
16 | } | 19 | } |
17 | } | 20 | } |
diff --git a/client/src/app/shared/video/video.model.ts b/client/src/app/shared/video/video.model.ts index 0c02cbcb9..e25c172e0 100644 --- a/client/src/app/shared/video/video.model.ts +++ b/client/src/app/shared/video/video.model.ts | |||
@@ -1,9 +1,10 @@ | |||
1 | import { Account } from '@app/shared/account/account.model' | 1 | import { Account } from '@app/shared/account/account.model' |
2 | import { User } from '../' | 2 | import { User } from '../' |
3 | import { Video as VideoServerModel } from '../../../../../shared' | 3 | import { Video as VideoServerModel, VideoPrivacy } from '../../../../../shared' |
4 | import { Avatar } from '../../../../../shared/models/avatars/avatar.model' | 4 | import { Avatar } from '../../../../../shared/models/avatars/avatar.model' |
5 | import { VideoConstant } from '../../../../../shared/models/videos/video.model' | 5 | import { VideoConstant } from '../../../../../shared/models/videos/video.model' |
6 | import { getAbsoluteAPIUrl } from '../misc/utils' | 6 | import { getAbsoluteAPIUrl } from '../misc/utils' |
7 | import { ServerConfig } from '../../../../../shared/models' | ||
7 | 8 | ||
8 | export class Video implements VideoServerModel { | 9 | export class Video implements VideoServerModel { |
9 | by: string | 10 | by: string |
@@ -13,6 +14,7 @@ export class Video implements VideoServerModel { | |||
13 | category: VideoConstant<number> | 14 | category: VideoConstant<number> |
14 | licence: VideoConstant<number> | 15 | licence: VideoConstant<number> |
15 | language: VideoConstant<number> | 16 | language: VideoConstant<number> |
17 | privacy: VideoConstant<VideoPrivacy> | ||
16 | description: string | 18 | description: string |
17 | duration: number | 19 | duration: number |
18 | durationLabel: string | 20 | durationLabel: string |
@@ -61,6 +63,7 @@ export class Video implements VideoServerModel { | |||
61 | this.category = hash.category | 63 | this.category = hash.category |
62 | this.licence = hash.licence | 64 | this.licence = hash.licence |
63 | this.language = hash.language | 65 | this.language = hash.language |
66 | this.privacy = hash.privacy | ||
64 | this.description = hash.description | 67 | this.description = hash.description |
65 | this.duration = hash.duration | 68 | this.duration = hash.duration |
66 | this.durationLabel = Video.createDurationString(hash.duration) | 69 | this.durationLabel = Video.createDurationString(hash.duration) |
@@ -83,8 +86,14 @@ export class Video implements VideoServerModel { | |||
83 | this.by = Account.CREATE_BY_STRING(hash.account.name, hash.account.host) | 86 | this.by = Account.CREATE_BY_STRING(hash.account.name, hash.account.host) |
84 | } | 87 | } |
85 | 88 | ||
86 | isVideoNSFWForUser (user: User) { | 89 | isVideoNSFWForUser (user: User, serverConfig: ServerConfig) { |
87 | // If the video is NSFW and the user is not logged in, or the user does not want to display NSFW videos... | 90 | // Video is not NSFW, skip |
88 | return (this.nsfw && (!user || user.displayNSFW === false)) | 91 | if (this.nsfw === false) return false |
92 | |||
93 | // Return user setting if logged in | ||
94 | if (user) return user.nsfwPolicy !== 'display' | ||
95 | |||
96 | // Return default instance config | ||
97 | return serverConfig.instance.defaultNSFWPolicy !== 'display' | ||
89 | } | 98 | } |
90 | } | 99 | } |