diff options
Diffstat (limited to 'client/src/app/+videos/+video-watch/shared/action-buttons/action-buttons.component.ts')
-rw-r--r-- | client/src/app/+videos/+video-watch/shared/action-buttons/action-buttons.component.ts | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/client/src/app/+videos/+video-watch/shared/action-buttons/action-buttons.component.ts b/client/src/app/+videos/+video-watch/shared/action-buttons/action-buttons.component.ts new file mode 100644 index 000000000..e59238ffe --- /dev/null +++ b/client/src/app/+videos/+video-watch/shared/action-buttons/action-buttons.component.ts | |||
@@ -0,0 +1,93 @@ | |||
1 | import { Component, Input, OnChanges, OnInit, ViewChild } from '@angular/core' | ||
2 | import { RedirectService, ScreenService } from '@app/core' | ||
3 | import { VideoDetails } from '@app/shared/shared-main' | ||
4 | import { VideoShareComponent } from '@app/shared/shared-share-modal' | ||
5 | import { SupportModalComponent } from '@app/shared/shared-support-modal' | ||
6 | import { VideoActionsDisplayType, VideoDownloadComponent } from '@app/shared/shared-video-miniature' | ||
7 | import { VideoPlaylist } from '@app/shared/shared-video-playlist' | ||
8 | import { UserVideoRateType, VideoCaption } from '@shared/models/videos' | ||
9 | |||
10 | @Component({ | ||
11 | selector: 'my-action-buttons', | ||
12 | templateUrl: './action-buttons.component.html', | ||
13 | styleUrls: [ './action-buttons.component.scss' ] | ||
14 | }) | ||
15 | export class ActionButtonsComponent implements OnInit, OnChanges { | ||
16 | @ViewChild('videoShareModal') videoShareModal: VideoShareComponent | ||
17 | @ViewChild('supportModal') supportModal: SupportModalComponent | ||
18 | @ViewChild('videoDownloadModal') videoDownloadModal: VideoDownloadComponent | ||
19 | |||
20 | @Input() video: VideoDetails | ||
21 | @Input() videoCaptions: VideoCaption[] | ||
22 | @Input() playlist: VideoPlaylist | ||
23 | |||
24 | @Input() isUserLoggedIn: boolean | ||
25 | |||
26 | @Input() currentTime: number | ||
27 | @Input() currentPlaylistPosition: number | ||
28 | |||
29 | likesBarTooltipText = '' | ||
30 | |||
31 | tooltipSupport = '' | ||
32 | tooltipSaveToPlaylist = '' | ||
33 | |||
34 | videoActionsOptions: VideoActionsDisplayType = { | ||
35 | playlist: false, | ||
36 | download: true, | ||
37 | update: true, | ||
38 | blacklist: true, | ||
39 | delete: true, | ||
40 | report: true, | ||
41 | duplicate: true, | ||
42 | mute: true, | ||
43 | liveInfo: true | ||
44 | } | ||
45 | |||
46 | userRating: UserVideoRateType | ||
47 | |||
48 | constructor ( | ||
49 | private screenService: ScreenService, | ||
50 | private redirectService: RedirectService | ||
51 | ) { } | ||
52 | |||
53 | ngOnInit () { | ||
54 | // Hide the tooltips for unlogged users in mobile view, this adds confusion with the popover | ||
55 | if (this.isUserLoggedIn || !this.screenService.isInMobileView()) { | ||
56 | this.tooltipSupport = $localize`Support options for this video` | ||
57 | this.tooltipSaveToPlaylist = $localize`Save to playlist` | ||
58 | } | ||
59 | } | ||
60 | |||
61 | ngOnChanges () { | ||
62 | this.setVideoLikesBarTooltipText() | ||
63 | } | ||
64 | |||
65 | showDownloadModal () { | ||
66 | this.videoDownloadModal.show(this.video, this.videoCaptions) | ||
67 | } | ||
68 | |||
69 | isVideoDownloadable () { | ||
70 | return this.video && this.video instanceof VideoDetails && this.video.downloadEnabled && !this.video.isLive | ||
71 | } | ||
72 | |||
73 | showSupportModal () { | ||
74 | this.supportModal.show() | ||
75 | } | ||
76 | |||
77 | showShareModal () { | ||
78 | this.videoShareModal.show(this.currentTime, this.currentPlaylistPosition) | ||
79 | } | ||
80 | |||
81 | onRateUpdated (userRating: UserVideoRateType) { | ||
82 | this.userRating = userRating | ||
83 | this.setVideoLikesBarTooltipText() | ||
84 | } | ||
85 | |||
86 | onVideoRemoved () { | ||
87 | this.redirectService.redirectToHomepage() | ||
88 | } | ||
89 | |||
90 | private setVideoLikesBarTooltipText () { | ||
91 | this.likesBarTooltipText = `${this.video.likes} likes / ${this.video.dislikes} dislikes` | ||
92 | } | ||
93 | } | ||