aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-library
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-04-05 14:03:52 +0200
committerChocobozzz <chocobozzz@cpy.re>2022-04-15 09:49:35 +0200
commit384ba8b77a8e4805c099f5ea12b41c2ca5776e26 (patch)
tree6b517033d9265d283677b85e0f57486e0e7fd8cf /client/src/app/+my-library
parentb211106695bb82f6c32e53306081b5262c3d109d (diff)
downloadPeerTube-384ba8b77a8e4805c099f5ea12b41c2ca5776e26.tar.gz
PeerTube-384ba8b77a8e4805c099f5ea12b41c2ca5776e26.tar.zst
PeerTube-384ba8b77a8e4805c099f5ea12b41c2ca5776e26.zip
Support videos stats in client
Diffstat (limited to 'client/src/app/+my-library')
-rw-r--r--client/src/app/+my-library/my-videos/my-videos.component.html6
-rw-r--r--client/src/app/+my-library/my-videos/my-videos.component.ts77
2 files changed, 36 insertions, 47 deletions
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 9f81f0ad7..7f12e2c71 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
@@ -55,10 +55,12 @@
55 <div class="action-button"> 55 <div class="action-button">
56 <my-edit-button label [routerLink]="[ '/videos', 'update', video.uuid ]"></my-edit-button> 56 <my-edit-button label [routerLink]="[ '/videos', 'update', video.uuid ]"></my-edit-button>
57 57
58 <my-action-dropdown [actions]="videoActions" [entry]="{ video: video }"></my-action-dropdown> 58 <my-video-actions-dropdown
59 [video]="video" [displayOptions]="videoDropdownDisplayOptions" [moreActions]="moreVideoActions"
60 [buttonStyled]="true" buttonDirection="horizontal" (videoRemoved)="onVideoRemoved(video)"
61 ></my-video-actions-dropdown>
59 </div> 62 </div>
60 </ng-template> 63 </ng-template>
61</my-videos-selection> 64</my-videos-selection>
62 65
63<my-video-change-ownership #videoChangeOwnershipModal></my-video-change-ownership> 66<my-video-change-ownership #videoChangeOwnershipModal></my-video-change-ownership>
64<my-live-stream-information #liveStreamInformationModal></my-live-stream-information>
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 a364b9b6a..8da2bc890 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
@@ -8,7 +8,12 @@ import { immutableAssign } from '@app/helpers'
8import { AdvancedInputFilter } from '@app/shared/shared-forms' 8import { AdvancedInputFilter } from '@app/shared/shared-forms'
9import { DropdownAction, Video, VideoService } from '@app/shared/shared-main' 9import { DropdownAction, Video, VideoService } from '@app/shared/shared-main'
10import { LiveStreamInformationComponent } from '@app/shared/shared-video-live' 10import { LiveStreamInformationComponent } from '@app/shared/shared-video-live'
11import { MiniatureDisplayOptions, SelectionType, VideosSelectionComponent } from '@app/shared/shared-video-miniature' 11import {
12 MiniatureDisplayOptions,
13 SelectionType,
14 VideoActionsDisplayType,
15 VideosSelectionComponent
16} from '@app/shared/shared-video-miniature'
12import { VideoChannel, VideoSortField } from '@shared/models' 17import { VideoChannel, VideoSortField } from '@shared/models'
13import { VideoChangeOwnershipComponent } from './modals/video-change-ownership.component' 18import { VideoChangeOwnershipComponent } from './modals/video-change-ownership.component'
14 19
@@ -37,8 +42,23 @@ export class MyVideosComponent implements OnInit, DisableForReuseHook {
37 state: true, 42 state: true,
38 blacklistInfo: true 43 blacklistInfo: true
39 } 44 }
45 videoDropdownDisplayOptions: VideoActionsDisplayType = {
46 playlist: false,
47 download: false,
48 update: false,
49 blacklist: false,
50 delete: true,
51 report: false,
52 duplicate: false,
53 mute: false,
54 liveInfo: false,
55 removeFiles: false,
56 transcoding: false,
57 studio: true,
58 stats: true
59 }
40 60
41 videoActions: DropdownAction<{ video: Video }>[] = [] 61 moreVideoActions: DropdownAction<{ video: Video }>[][] = []
42 62
43 videos: Video[] = [] 63 videos: Video[] = []
44 getVideosObservableFunction = this.getVideosObservable.bind(this) 64 getVideosObservableFunction = this.getVideosObservable.bind(this)
@@ -172,60 +192,27 @@ export class MyVideosComponent implements OnInit, DisableForReuseHook {
172 }) 192 })
173 } 193 }
174 194
175 async deleteVideo (video: Video) { 195 onVideoRemoved (video: Video) {
176 const res = await this.confirmService.confirm( 196 this.removeVideoFromArray(video.id)
177 $localize`Do you really want to delete ${video.name}?`,
178 $localize`Delete`
179 )
180 if (res === false) return
181
182 this.videoService.removeVideo(video.id)
183 .subscribe({
184 next: () => {
185 this.notifier.success($localize`Video ${video.name} deleted.`)
186 this.removeVideoFromArray(video.id)
187 },
188
189 error: err => this.notifier.error(err.message)
190 })
191 } 197 }
192 198
193 changeOwnership (video: Video) { 199 changeOwnership (video: Video) {
194 this.videoChangeOwnershipModal.show(video) 200 this.videoChangeOwnershipModal.show(video)
195 } 201 }
196 202
197 displayLiveInformation (video: Video) {
198 this.liveStreamInformationModal.show(video)
199 }
200
201 private removeVideoFromArray (id: number) { 203 private removeVideoFromArray (id: number) {
202 this.videos = this.videos.filter(v => v.id !== id) 204 this.videos = this.videos.filter(v => v.id !== id)
203 } 205 }
204 206
205 private buildActions () { 207 private buildActions () {
206 this.videoActions = [ 208 this.moreVideoActions = [
207 { 209 [
208 label: $localize`Studio`, 210 {
209 linkBuilder: ({ video }) => [ '/studio/edit', video.uuid ], 211 label: $localize`Change ownership`,
210 isDisplayed: ({ video }) => video.isEditableBy(this.authService.getUser(), this.serverService.getHTMLConfig().videoStudio.enabled), 212 handler: ({ video }) => this.changeOwnership(video),
211 iconName: 'film' 213 iconName: 'ownership-change'
212 }, 214 }
213 { 215 ]
214 label: $localize`Display live information`,
215 handler: ({ video }) => this.displayLiveInformation(video),
216 isDisplayed: ({ video }) => video.isLive,
217 iconName: 'live'
218 },
219 {
220 label: $localize`Change ownership`,
221 handler: ({ video }) => this.changeOwnership(video),
222 iconName: 'ownership-change'
223 },
224 {
225 label: $localize`Delete`,
226 handler: ({ video }) => this.deleteVideo(video),
227 iconName: 'delete'
228 }
229 ] 216 ]
230 } 217 }
231} 218}