diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-05 10:52:27 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-05 10:53:09 +0200 |
commit | 3a0fb65c61f80b510bce979a45d59d17948745e8 (patch) | |
tree | c1be0b2158a008fea826835c8d2fd4e8d648bae9 /client/src/app/shared/video/video-miniature.component.ts | |
parent | 693263e936763a851e3c8c020e3739def8bd4eca (diff) | |
download | PeerTube-3a0fb65c61f80b510bce979a45d59d17948745e8.tar.gz PeerTube-3a0fb65c61f80b510bce979a45d59d17948745e8.tar.zst PeerTube-3a0fb65c61f80b510bce979a45d59d17948745e8.zip |
Add video miniature dropdown
Diffstat (limited to 'client/src/app/shared/video/video-miniature.component.ts')
-rw-r--r-- | client/src/app/shared/video/video-miniature.component.ts | 70 |
1 files changed, 56 insertions, 14 deletions
diff --git a/client/src/app/shared/video/video-miniature.component.ts b/client/src/app/shared/video/video-miniature.component.ts index 800417a79..e3552abba 100644 --- a/client/src/app/shared/video/video-miniature.component.ts +++ b/client/src/app/shared/video/video-miniature.component.ts | |||
@@ -1,9 +1,11 @@ | |||
1 | import { ChangeDetectionStrategy, Component, Inject, Input, LOCALE_ID, OnInit } from '@angular/core' | 1 | import { ChangeDetectionStrategy, Component, EventEmitter, Inject, Input, LOCALE_ID, OnInit, Output } 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 | import { ServerService } from '@app/core' |
5 | import { VideoPrivacy, VideoState } from '../../../../../shared' | 5 | import { VideoPrivacy, VideoState } from '../../../../../shared' |
6 | import { I18n } from '@ngx-translate/i18n-polyfill' | 6 | import { I18n } from '@ngx-translate/i18n-polyfill' |
7 | import { VideoActionsDisplayType } from '@app/shared/video/video-actions-dropdown.component' | ||
8 | import { ScreenService } from '@app/shared/misc/screen.service' | ||
7 | 9 | ||
8 | export type OwnerDisplayType = 'account' | 'videoChannel' | 'auto' | 10 | export type OwnerDisplayType = 'account' | 'videoChannel' | 'auto' |
9 | export type MiniatureDisplayOptions = { | 11 | export type MiniatureDisplayOptions = { |
@@ -38,10 +40,26 @@ export class VideoMiniatureComponent implements OnInit { | |||
38 | blacklistInfo: false | 40 | blacklistInfo: false |
39 | } | 41 | } |
40 | @Input() displayAsRow = false | 42 | @Input() displayAsRow = false |
43 | @Input() displayVideoActions = true | ||
44 | |||
45 | @Output() videoBlacklisted = new EventEmitter() | ||
46 | @Output() videoUnblacklisted = new EventEmitter() | ||
47 | @Output() videoRemoved = new EventEmitter() | ||
48 | |||
49 | videoActionsDisplayOptions: VideoActionsDisplayType = { | ||
50 | playlist: true, | ||
51 | download: false, | ||
52 | update: true, | ||
53 | blacklist: true, | ||
54 | delete: true, | ||
55 | report: true | ||
56 | } | ||
57 | showActions = false | ||
41 | 58 | ||
42 | private ownerDisplayTypeChosen: 'account' | 'videoChannel' | 59 | private ownerDisplayTypeChosen: 'account' | 'videoChannel' |
43 | 60 | ||
44 | constructor ( | 61 | constructor ( |
62 | private screenService: ScreenService, | ||
45 | private serverService: ServerService, | 63 | private serverService: ServerService, |
46 | private i18n: I18n, | 64 | private i18n: I18n, |
47 | @Inject(LOCALE_ID) private localeId: string | 65 | @Inject(LOCALE_ID) private localeId: string |
@@ -52,20 +70,10 @@ export class VideoMiniatureComponent implements OnInit { | |||
52 | } | 70 | } |
53 | 71 | ||
54 | ngOnInit () { | 72 | ngOnInit () { |
55 | if (this.ownerDisplayType === 'account' || this.ownerDisplayType === 'videoChannel') { | 73 | this.setUpBy() |
56 | this.ownerDisplayTypeChosen = this.ownerDisplayType | ||
57 | return | ||
58 | } | ||
59 | 74 | ||
60 | // If the video channel name an UUID (not really displayable, we changed this behaviour in v1.0.0-beta.12) | 75 | if (this.screenService.isInSmallView()) { |
61 | // -> Use the account name | 76 | this.showActions = true |
62 | if ( | ||
63 | this.video.channel.name === `${this.video.account.name}_channel` || | ||
64 | this.video.channel.name.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/) | ||
65 | ) { | ||
66 | this.ownerDisplayTypeChosen = 'account' | ||
67 | } else { | ||
68 | this.ownerDisplayTypeChosen = 'videoChannel' | ||
69 | } | 77 | } |
70 | } | 78 | } |
71 | 79 | ||
@@ -109,4 +117,38 @@ export class VideoMiniatureComponent implements OnInit { | |||
109 | 117 | ||
110 | return '' | 118 | return '' |
111 | } | 119 | } |
120 | |||
121 | loadActions () { | ||
122 | if (this.displayVideoActions) this.showActions = true | ||
123 | } | ||
124 | |||
125 | onVideoBlacklisted () { | ||
126 | this.videoBlacklisted.emit() | ||
127 | } | ||
128 | |||
129 | onVideoUnblacklisted () { | ||
130 | this.videoUnblacklisted.emit() | ||
131 | } | ||
132 | |||
133 | onVideoRemoved () { | ||
134 | this.videoRemoved.emit() | ||
135 | } | ||
136 | |||
137 | private setUpBy () { | ||
138 | if (this.ownerDisplayType === 'account' || this.ownerDisplayType === 'videoChannel') { | ||
139 | this.ownerDisplayTypeChosen = this.ownerDisplayType | ||
140 | return | ||
141 | } | ||
142 | |||
143 | // If the video channel name an UUID (not really displayable, we changed this behaviour in v1.0.0-beta.12) | ||
144 | // -> Use the account name | ||
145 | if ( | ||
146 | this.video.channel.name === `${this.video.account.name}_channel` || | ||
147 | this.video.channel.name.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/) | ||
148 | ) { | ||
149 | this.ownerDisplayTypeChosen = 'account' | ||
150 | } else { | ||
151 | this.ownerDisplayTypeChosen = 'videoChannel' | ||
152 | } | ||
153 | } | ||
112 | } | 154 | } |