From e2f01c47e08d26a30ad47068d195b3d21d0df8a1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 13 Mar 2019 14:18:58 +0100 Subject: Playlist support in watch page --- ...my-account-video-playlist-elements.component.ts | 102 +-------------------- 1 file changed, 4 insertions(+), 98 deletions(-) (limited to 'client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component.ts') 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 @@ -import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core' +import { Component, OnDestroy, OnInit } from '@angular/core' import { Notifier, ServerService } from '@app/core' import { AuthService } from '../../core/auth' import { ConfirmService } from '../../core/confirm' @@ -10,9 +10,6 @@ import { VideoService } from '@app/shared/video/video.service' import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service' import { VideoPlaylist } from '@app/shared/video-playlist/video-playlist.model' import { I18n } from '@ngx-translate/i18n-polyfill' -import { secondsToTime } from '../../../assets/player/utils' -import { VideoPlaylistElementUpdate } from '@shared/models' -import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap' import { CdkDragDrop, CdkDragMove } from '@angular/cdk/drag-drop' import { throttleTime } from 'rxjs/operators' @@ -22,8 +19,6 @@ import { throttleTime } from 'rxjs/operators' styleUrls: [ './my-account-video-playlist-elements.component.scss' ] }) export class MyAccountVideoPlaylistElementsComponent implements OnInit, OnDestroy { - @ViewChild('moreDropdown') moreDropdown: NgbDropdown - videos: Video[] = [] playlist: VideoPlaylist @@ -33,15 +28,6 @@ export class MyAccountVideoPlaylistElementsComponent implements OnInit, OnDestro totalItems: null } - displayTimestampOptions = false - - timestampOptions: { - startTimestampEnabled: boolean - startTimestamp: number - stopTimestampEnabled: boolean - stopTimestamp: number - } = {} as any - private videoPlaylistId: string | number private paramsSub: Subscription private dragMoveSubject = new Subject() @@ -124,45 +110,9 @@ export class MyAccountVideoPlaylistElementsComponent implements OnInit, OnDestro // } } - isVideoBlur (video: Video) { - return video.isVideoNSFWForUser(this.authService.getUser(), this.serverService.getConfig()) - } - - removeFromPlaylist (video: Video) { - this.videoPlaylistService.removeVideoFromPlaylist(this.playlist.id, video.id) - .subscribe( - () => { - this.notifier.success(this.i18n('Video removed from {{name}}', { name: this.playlist.displayName })) - - this.videos = this.videos.filter(v => v.id !== video.id) - this.reorderClientPositions() - }, - - err => this.notifier.error(err.message) - ) - - this.moreDropdown.close() - } - - updateTimestamps (video: Video) { - const body: VideoPlaylistElementUpdate = {} - - body.startTimestamp = this.timestampOptions.startTimestampEnabled ? this.timestampOptions.startTimestamp : null - body.stopTimestamp = this.timestampOptions.stopTimestampEnabled ? this.timestampOptions.stopTimestamp : null - - this.videoPlaylistService.updateVideoOfPlaylist(this.playlist.id, video.id, body) - .subscribe( - () => { - this.notifier.success(this.i18n('Timestamps updated')) - - video.playlistElement.startTimestamp = body.startTimestamp - video.playlistElement.stopTimestamp = body.stopTimestamp - }, - - err => this.notifier.error(err.message) - ) - - this.moreDropdown.close() + onElementRemoved (video: Video) { + this.videos = this.videos.filter(v => v.id !== video.id) + this.reorderClientPositions() } onNearOfBottom () { @@ -173,50 +123,6 @@ export class MyAccountVideoPlaylistElementsComponent implements OnInit, OnDestro this.loadElements() } - formatTimestamp (video: Video) { - const start = video.playlistElement.startTimestamp - const stop = video.playlistElement.stopTimestamp - - const startFormatted = secondsToTime(start, true, ':') - const stopFormatted = secondsToTime(stop, true, ':') - - if (start === null && stop === null) return '' - - if (start !== null && stop === null) return this.i18n('Starts at ') + startFormatted - if (start === null && stop !== null) return this.i18n('Stops at ') + stopFormatted - - return this.i18n('Starts at ') + startFormatted + this.i18n(' and stops at ') + stopFormatted - } - - onDropdownOpenChange () { - this.displayTimestampOptions = false - } - - toggleDisplayTimestampsOptions (event: Event, video: Video) { - event.preventDefault() - - this.displayTimestampOptions = !this.displayTimestampOptions - - if (this.displayTimestampOptions === true) { - this.timestampOptions = { - startTimestampEnabled: false, - stopTimestampEnabled: false, - startTimestamp: 0, - stopTimestamp: video.duration - } - - if (video.playlistElement.startTimestamp) { - this.timestampOptions.startTimestampEnabled = true - this.timestampOptions.startTimestamp = video.playlistElement.startTimestamp - } - - if (video.playlistElement.stopTimestamp) { - this.timestampOptions.stopTimestampEnabled = true - this.timestampOptions.stopTimestamp = video.playlistElement.stopTimestamp - } - } - } - private loadElements () { this.videoService.getPlaylistVideos(this.videoPlaylistId, this.pagination) .subscribe(({ totalVideos, videos }) => { -- cgit v1.2.3