diff options
Diffstat (limited to 'client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component.ts')
-rw-r--r-- | client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component.ts | 102 |
1 files changed, 4 insertions, 98 deletions
diff --git a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component.ts b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component.ts index 4076a3721..dcf470be3 100644 --- a/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component.ts +++ b/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core' | 1 | import { Component, OnDestroy, OnInit } from '@angular/core' |
2 | import { Notifier, ServerService } from '@app/core' | 2 | import { Notifier, ServerService } from '@app/core' |
3 | import { AuthService } from '../../core/auth' | 3 | import { AuthService } from '../../core/auth' |
4 | import { ConfirmService } from '../../core/confirm' | 4 | import { ConfirmService } from '../../core/confirm' |
@@ -10,9 +10,6 @@ import { VideoService } from '@app/shared/video/video.service' | |||
10 | import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service' | 10 | import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service' |
11 | import { VideoPlaylist } from '@app/shared/video-playlist/video-playlist.model' | 11 | import { VideoPlaylist } from '@app/shared/video-playlist/video-playlist.model' |
12 | import { I18n } from '@ngx-translate/i18n-polyfill' | 12 | import { I18n } from '@ngx-translate/i18n-polyfill' |
13 | import { secondsToTime } from '../../../assets/player/utils' | ||
14 | import { VideoPlaylistElementUpdate } from '@shared/models' | ||
15 | import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap' | ||
16 | import { CdkDragDrop, CdkDragMove } from '@angular/cdk/drag-drop' | 13 | import { CdkDragDrop, CdkDragMove } from '@angular/cdk/drag-drop' |
17 | import { throttleTime } from 'rxjs/operators' | 14 | import { throttleTime } from 'rxjs/operators' |
18 | 15 | ||
@@ -22,8 +19,6 @@ import { throttleTime } from 'rxjs/operators' | |||
22 | styleUrls: [ './my-account-video-playlist-elements.component.scss' ] | 19 | styleUrls: [ './my-account-video-playlist-elements.component.scss' ] |
23 | }) | 20 | }) |
24 | export class MyAccountVideoPlaylistElementsComponent implements OnInit, OnDestroy { | 21 | export class MyAccountVideoPlaylistElementsComponent implements OnInit, OnDestroy { |
25 | @ViewChild('moreDropdown') moreDropdown: NgbDropdown | ||
26 | |||
27 | videos: Video[] = [] | 22 | videos: Video[] = [] |
28 | playlist: VideoPlaylist | 23 | playlist: VideoPlaylist |
29 | 24 | ||
@@ -33,15 +28,6 @@ export class MyAccountVideoPlaylistElementsComponent implements OnInit, OnDestro | |||
33 | totalItems: null | 28 | totalItems: null |
34 | } | 29 | } |
35 | 30 | ||
36 | displayTimestampOptions = false | ||
37 | |||
38 | timestampOptions: { | ||
39 | startTimestampEnabled: boolean | ||
40 | startTimestamp: number | ||
41 | stopTimestampEnabled: boolean | ||
42 | stopTimestamp: number | ||
43 | } = {} as any | ||
44 | |||
45 | private videoPlaylistId: string | number | 31 | private videoPlaylistId: string | number |
46 | private paramsSub: Subscription | 32 | private paramsSub: Subscription |
47 | private dragMoveSubject = new Subject<number>() | 33 | private dragMoveSubject = new Subject<number>() |
@@ -124,45 +110,9 @@ export class MyAccountVideoPlaylistElementsComponent implements OnInit, OnDestro | |||
124 | // } | 110 | // } |
125 | } | 111 | } |
126 | 112 | ||
127 | isVideoBlur (video: Video) { | 113 | onElementRemoved (video: Video) { |
128 | return video.isVideoNSFWForUser(this.authService.getUser(), this.serverService.getConfig()) | 114 | this.videos = this.videos.filter(v => v.id !== video.id) |
129 | } | 115 | this.reorderClientPositions() |
130 | |||
131 | removeFromPlaylist (video: Video) { | ||
132 | this.videoPlaylistService.removeVideoFromPlaylist(this.playlist.id, video.id) | ||
133 | .subscribe( | ||
134 | () => { | ||
135 | this.notifier.success(this.i18n('Video removed from {{name}}', { name: this.playlist.displayName })) | ||
136 | |||
137 | this.videos = this.videos.filter(v => v.id !== video.id) | ||
138 | this.reorderClientPositions() | ||
139 | }, | ||
140 | |||
141 | err => this.notifier.error(err.message) | ||
142 | ) | ||
143 | |||
144 | this.moreDropdown.close() | ||
145 | } | ||
146 | |||
147 | updateTimestamps (video: Video) { | ||
148 | const body: VideoPlaylistElementUpdate = {} | ||
149 | |||
150 | body.startTimestamp = this.timestampOptions.startTimestampEnabled ? this.timestampOptions.startTimestamp : null | ||
151 | body.stopTimestamp = this.timestampOptions.stopTimestampEnabled ? this.timestampOptions.stopTimestamp : null | ||
152 | |||
153 | this.videoPlaylistService.updateVideoOfPlaylist(this.playlist.id, video.id, body) | ||
154 | .subscribe( | ||
155 | () => { | ||
156 | this.notifier.success(this.i18n('Timestamps updated')) | ||
157 | |||
158 | video.playlistElement.startTimestamp = body.startTimestamp | ||
159 | video.playlistElement.stopTimestamp = body.stopTimestamp | ||
160 | }, | ||
161 | |||
162 | err => this.notifier.error(err.message) | ||
163 | ) | ||
164 | |||
165 | this.moreDropdown.close() | ||
166 | } | 116 | } |
167 | 117 | ||
168 | onNearOfBottom () { | 118 | onNearOfBottom () { |
@@ -173,50 +123,6 @@ export class MyAccountVideoPlaylistElementsComponent implements OnInit, OnDestro | |||
173 | this.loadElements() | 123 | this.loadElements() |
174 | } | 124 | } |
175 | 125 | ||
176 | formatTimestamp (video: Video) { | ||
177 | const start = video.playlistElement.startTimestamp | ||
178 | const stop = video.playlistElement.stopTimestamp | ||
179 | |||
180 | const startFormatted = secondsToTime(start, true, ':') | ||
181 | const stopFormatted = secondsToTime(stop, true, ':') | ||
182 | |||
183 | if (start === null && stop === null) return '' | ||
184 | |||
185 | if (start !== null && stop === null) return this.i18n('Starts at ') + startFormatted | ||
186 | if (start === null && stop !== null) return this.i18n('Stops at ') + stopFormatted | ||
187 | |||
188 | return this.i18n('Starts at ') + startFormatted + this.i18n(' and stops at ') + stopFormatted | ||
189 | } | ||
190 | |||
191 | onDropdownOpenChange () { | ||
192 | this.displayTimestampOptions = false | ||
193 | } | ||
194 | |||
195 | toggleDisplayTimestampsOptions (event: Event, video: Video) { | ||
196 | event.preventDefault() | ||
197 | |||
198 | this.displayTimestampOptions = !this.displayTimestampOptions | ||
199 | |||
200 | if (this.displayTimestampOptions === true) { | ||
201 | this.timestampOptions = { | ||
202 | startTimestampEnabled: false, | ||
203 | stopTimestampEnabled: false, | ||
204 | startTimestamp: 0, | ||
205 | stopTimestamp: video.duration | ||
206 | } | ||
207 | |||
208 | if (video.playlistElement.startTimestamp) { | ||
209 | this.timestampOptions.startTimestampEnabled = true | ||
210 | this.timestampOptions.startTimestamp = video.playlistElement.startTimestamp | ||
211 | } | ||
212 | |||
213 | if (video.playlistElement.stopTimestamp) { | ||
214 | this.timestampOptions.stopTimestampEnabled = true | ||
215 | this.timestampOptions.stopTimestamp = video.playlistElement.stopTimestamp | ||
216 | } | ||
217 | } | ||
218 | } | ||
219 | |||
220 | private loadElements () { | 126 | private loadElements () { |
221 | this.videoService.getPlaylistVideos(this.videoPlaylistId, this.pagination) | 127 | this.videoService.getPlaylistVideos(this.videoPlaylistId, this.pagination) |
222 | .subscribe(({ totalVideos, videos }) => { | 128 | .subscribe(({ totalVideos, videos }) => { |