diff options
Diffstat (limited to 'client/src/app/+my-library/my-videos')
3 files changed, 26 insertions, 10 deletions
diff --git a/client/src/app/+my-library/my-videos/modals/video-change-ownership.component.ts b/client/src/app/+my-library/my-videos/modals/video-change-ownership.component.ts index 960c9a4f7..72187e893 100644 --- a/client/src/app/+my-library/my-videos/modals/video-change-ownership.component.ts +++ b/client/src/app/+my-library/my-videos/modals/video-change-ownership.component.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' | 1 | import { Component, ElementRef, OnInit, ViewChild } from '@angular/core' |
2 | import { Notifier, UserService } from '@app/core' | 2 | import { Notifier, UserService } from '@app/core' |
3 | import { OWNERSHIP_CHANGE_USERNAME_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators' | 3 | import { OWNERSHIP_CHANGE_USERNAME_VALIDATOR } from '@app/shared/form-validators/video-ownership-change-validators' |
4 | import { FormReactive, FormValidatorService } from '@app/shared/shared-forms' | 4 | import { FormReactive, FormReactiveService } from '@app/shared/shared-forms' |
5 | import { Video, VideoOwnershipService } from '@app/shared/shared-main' | 5 | import { Video, VideoOwnershipService } from '@app/shared/shared-main' |
6 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' | 6 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
7 | 7 | ||
@@ -20,7 +20,7 @@ export class VideoChangeOwnershipComponent extends FormReactive implements OnIni | |||
20 | private video: Video | undefined = undefined | 20 | private video: Video | undefined = undefined |
21 | 21 | ||
22 | constructor ( | 22 | constructor ( |
23 | protected formValidatorService: FormValidatorService, | 23 | protected formReactiveService: FormReactiveService, |
24 | private videoOwnershipService: VideoOwnershipService, | 24 | private videoOwnershipService: VideoOwnershipService, |
25 | private notifier: Notifier, | 25 | private notifier: Notifier, |
26 | private userService: UserService, | 26 | private userService: UserService, |
diff --git a/client/src/app/+my-library/my-videos/my-videos.component.html b/client/src/app/+my-library/my-videos/my-videos.component.html index 146dcf41e..995f6b75b 100644 --- a/client/src/app/+my-library/my-videos/my-videos.component.html +++ b/client/src/app/+my-library/my-videos/my-videos.component.html | |||
@@ -34,6 +34,7 @@ | |||
34 | </div> | 34 | </div> |
35 | 35 | ||
36 | <my-videos-selection | 36 | <my-videos-selection |
37 | [videosContainedInPlaylists]="videosContainedInPlaylists" | ||
37 | [pagination]="pagination" | 38 | [pagination]="pagination" |
38 | [(selection)]="selection" | 39 | [(selection)]="selection" |
39 | [(videosModel)]="videos" | 40 | [(videosModel)]="videos" |
diff --git a/client/src/app/+my-library/my-videos/my-videos.component.ts b/client/src/app/+my-library/my-videos/my-videos.component.ts index 2f1eb84ba..bcfc66099 100644 --- a/client/src/app/+my-library/my-videos/my-videos.component.ts +++ b/client/src/app/+my-library/my-videos/my-videos.component.ts | |||
@@ -1,10 +1,11 @@ | |||
1 | import { uniqBy } from 'lodash-es' | ||
1 | import { concat, Observable } from 'rxjs' | 2 | import { concat, Observable } from 'rxjs' |
2 | import { tap, toArray } from 'rxjs/operators' | 3 | import { tap, toArray } from 'rxjs/operators' |
3 | import { Component, OnInit, ViewChild } from '@angular/core' | 4 | import { Component, OnInit, ViewChild } from '@angular/core' |
4 | import { ActivatedRoute, Router } from '@angular/router' | 5 | import { ActivatedRoute, Router } from '@angular/router' |
5 | import { AuthService, ComponentPagination, ConfirmService, Notifier, ScreenService, ServerService, User } from '@app/core' | 6 | import { AuthService, ComponentPagination, ConfirmService, Notifier, ScreenService, ServerService, User } from '@app/core' |
6 | import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook' | 7 | import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook' |
7 | import { prepareIcu, immutableAssign } from '@app/helpers' | 8 | import { immutableAssign, prepareIcu } from '@app/helpers' |
8 | import { AdvancedInputFilter } from '@app/shared/shared-forms' | 9 | import { AdvancedInputFilter } from '@app/shared/shared-forms' |
9 | import { DropdownAction, Video, VideoService } from '@app/shared/shared-main' | 10 | import { DropdownAction, Video, VideoService } from '@app/shared/shared-main' |
10 | import { LiveStreamInformationComponent } from '@app/shared/shared-video-live' | 11 | import { LiveStreamInformationComponent } from '@app/shared/shared-video-live' |
@@ -14,7 +15,8 @@ import { | |||
14 | VideoActionsDisplayType, | 15 | VideoActionsDisplayType, |
15 | VideosSelectionComponent | 16 | VideosSelectionComponent |
16 | } from '@app/shared/shared-video-miniature' | 17 | } from '@app/shared/shared-video-miniature' |
17 | import { VideoChannel, VideoSortField } from '@shared/models' | 18 | import { VideoPlaylistService } from '@app/shared/shared-video-playlist' |
19 | import { VideoChannel, VideoExistInPlaylist, VideosExistInPlaylists, VideoSortField } from '@shared/models' | ||
18 | import { VideoChangeOwnershipComponent } from './modals/video-change-ownership.component' | 20 | import { VideoChangeOwnershipComponent } from './modals/video-change-ownership.component' |
19 | 21 | ||
20 | @Component({ | 22 | @Component({ |
@@ -26,6 +28,7 @@ export class MyVideosComponent implements OnInit, DisableForReuseHook { | |||
26 | @ViewChild('videoChangeOwnershipModal', { static: true }) videoChangeOwnershipModal: VideoChangeOwnershipComponent | 28 | @ViewChild('videoChangeOwnershipModal', { static: true }) videoChangeOwnershipModal: VideoChangeOwnershipComponent |
27 | @ViewChild('liveStreamInformationModal', { static: true }) liveStreamInformationModal: LiveStreamInformationComponent | 29 | @ViewChild('liveStreamInformationModal', { static: true }) liveStreamInformationModal: LiveStreamInformationComponent |
28 | 30 | ||
31 | videosContainedInPlaylists: VideosExistInPlaylists = {} | ||
29 | titlePage: string | 32 | titlePage: string |
30 | selection: SelectionType = {} | 33 | selection: SelectionType = {} |
31 | pagination: ComponentPagination = { | 34 | pagination: ComponentPagination = { |
@@ -40,7 +43,8 @@ export class MyVideosComponent implements OnInit, DisableForReuseHook { | |||
40 | privacyLabel: false, | 43 | privacyLabel: false, |
41 | privacyText: true, | 44 | privacyText: true, |
42 | state: true, | 45 | state: true, |
43 | blacklistInfo: true | 46 | blacklistInfo: true, |
47 | forceChannelInBy: true | ||
44 | } | 48 | } |
45 | videoDropdownDisplayOptions: VideoActionsDisplayType = { | 49 | videoDropdownDisplayOptions: VideoActionsDisplayType = { |
46 | playlist: false, | 50 | playlist: false, |
@@ -82,7 +86,8 @@ export class MyVideosComponent implements OnInit, DisableForReuseHook { | |||
82 | protected notifier: Notifier, | 86 | protected notifier: Notifier, |
83 | protected screenService: ScreenService, | 87 | protected screenService: ScreenService, |
84 | private confirmService: ConfirmService, | 88 | private confirmService: ConfirmService, |
85 | private videoService: VideoService | 89 | private videoService: VideoService, |
90 | private playlistService: VideoPlaylistService | ||
86 | ) { | 91 | ) { |
87 | this.titlePage = $localize`My videos` | 92 | this.titlePage = $localize`My videos` |
88 | } | 93 | } |
@@ -155,10 +160,20 @@ export class MyVideosComponent implements OnInit, DisableForReuseHook { | |||
155 | sort: this.sort, | 160 | sort: this.sort, |
156 | userChannels: this.userChannels, | 161 | userChannels: this.userChannels, |
157 | search: this.search | 162 | search: this.search |
158 | }) | 163 | }).pipe( |
159 | .pipe( | 164 | tap(res => this.pagination.totalItems = res.total), |
160 | tap(res => this.pagination.totalItems = res.total) | 165 | tap(({ data }) => this.fetchVideosContainedInPlaylists(data)) |
161 | ) | 166 | ) |
167 | } | ||
168 | |||
169 | private fetchVideosContainedInPlaylists (videos: Video[]) { | ||
170 | this.playlistService.doVideosExistInPlaylist(videos.map(v => v.id)) | ||
171 | .subscribe(result => { | ||
172 | this.videosContainedInPlaylists = Object.keys(result).reduce((acc, videoId) => ({ | ||
173 | ...acc, | ||
174 | [videoId]: uniqBy(result[videoId], (p: VideoExistInPlaylist) => p.playlistId) | ||
175 | }), this.videosContainedInPlaylists) | ||
176 | }) | ||
162 | } | 177 | } |
163 | 178 | ||
164 | async deleteSelectedVideos () { | 179 | async deleteSelectedVideos () { |