]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+videos/+video-watch/shared/action-buttons/action-buttons.component.ts
Replace all glyphicon icons
[github/Chocobozzz/PeerTube.git] / client / src / app / +videos / +video-watch / shared / action-buttons / action-buttons.component.ts
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 studio: true,
39 blacklist: true,
40 delete: true,
41 report: true,
42 duplicate: true,
43 mute: true,
44 liveInfo: true,
45 stats: true
46 }
47
48 userRating: UserVideoRateType
49
50 constructor (
51 private screenService: ScreenService,
52 private redirectService: RedirectService
53 ) { }
54
55 ngOnInit () {
56 // Hide the tooltips for unlogged users in mobile view, this adds confusion with the popover
57 if (this.isUserLoggedIn || !this.screenService.isInMobileView()) {
58 this.tooltipSupport = $localize`Support options for this video`
59 this.tooltipSaveToPlaylist = $localize`Save to playlist`
60 }
61 }
62
63 ngOnChanges () {
64 this.setVideoLikesBarTooltipText()
65 }
66
67 showDownloadModal () {
68 this.videoDownloadModal.show(this.video, this.videoCaptions)
69 }
70
71 isVideoDownloadable () {
72 return this.video && this.video instanceof VideoDetails && this.video.downloadEnabled && !this.video.isLive
73 }
74
75 showSupportModal () {
76 this.supportModal.show()
77 }
78
79 showShareModal () {
80 this.videoShareModal.show(this.currentTime, this.currentPlaylistPosition)
81 }
82
83 onRateUpdated (userRating: UserVideoRateType) {
84 this.userRating = userRating
85 this.setVideoLikesBarTooltipText()
86 }
87
88 onVideoRemoved () {
89 this.redirectService.redirectToHomepage()
90 }
91
92 private setVideoLikesBarTooltipText () {
93 this.likesBarTooltipText = `${this.video.likes} likes / ${this.video.dislikes} dislikes`
94 }
95 }