aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-08-07 16:29:30 +0200
committerChocobozzz <me@florianbigard.com>2020-08-10 09:43:44 +0200
commit82f443de1aba70ce75c72a4a7f669385600ab3c6 (patch)
tree198ab1db910b44ad9844c3365d0ec2dec7325778 /client/src/app/+my-account/my-account-video-playlists/my-account-video-playlist-elements.component.ts
parent10846ef656585ee857ec43fc22b490409ddd0d44 (diff)
downloadPeerTube-82f443de1aba70ce75c72a4a7f669385600ab3c6.tar.gz
PeerTube-82f443de1aba70ce75c72a4a7f669385600ab3c6.tar.zst
PeerTube-82f443de1aba70ce75c72a4a7f669385600ab3c6.zip
Add buttons in playlist page
To delete/edit/share the playlist
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.ts64
1 files changed, 61 insertions, 3 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 0add81c38..e278d9ed2 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,9 +1,13 @@
1import { Subject, Subscription } from 'rxjs' 1import { Subject, Subscription } from 'rxjs'
2import { CdkDragDrop } from '@angular/cdk/drag-drop' 2import { CdkDragDrop } from '@angular/cdk/drag-drop'
3import { Component, OnDestroy, OnInit } from '@angular/core' 3import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core'
4import { ActivatedRoute } from '@angular/router' 4import { ActivatedRoute, Router } from '@angular/router'
5import { ComponentPagination, Notifier, ScreenService } from '@app/core' 5import { ComponentPagination, ConfirmService, Notifier, ScreenService } from '@app/core'
6import { DropdownAction } from '@app/shared/shared-main'
7import { VideoShareComponent } from '@app/shared/shared-share-modal'
6import { VideoPlaylist, VideoPlaylistElement, VideoPlaylistService } from '@app/shared/shared-video-playlist' 8import { VideoPlaylist, VideoPlaylistElement, VideoPlaylistService } from '@app/shared/shared-video-playlist'
9import { I18n } from '@ngx-translate/i18n-polyfill'
10import { VideoPlaylistType } from '@shared/models'
7 11
8@Component({ 12@Component({
9 selector: 'my-account-video-playlist-elements', 13 selector: 'my-account-video-playlist-elements',
@@ -11,9 +15,13 @@ import { VideoPlaylist, VideoPlaylistElement, VideoPlaylistService } from '@app/
11 styleUrls: [ './my-account-video-playlist-elements.component.scss' ] 15 styleUrls: [ './my-account-video-playlist-elements.component.scss' ]
12}) 16})
13export class MyAccountVideoPlaylistElementsComponent implements OnInit, OnDestroy { 17export class MyAccountVideoPlaylistElementsComponent implements OnInit, OnDestroy {
18 @ViewChild('videoShareModal') videoShareModal: VideoShareComponent
19
14 playlistElements: VideoPlaylistElement[] = [] 20 playlistElements: VideoPlaylistElement[] = []
15 playlist: VideoPlaylist 21 playlist: VideoPlaylist
16 22
23 playlistActions: DropdownAction<VideoPlaylist>[][] = []
24
17 pagination: ComponentPagination = { 25 pagination: ComponentPagination = {
18 currentPage: 1, 26 currentPage: 1,
19 itemsPerPage: 10, 27 itemsPerPage: 10,
@@ -27,12 +35,30 @@ export class MyAccountVideoPlaylistElementsComponent implements OnInit, OnDestro
27 35
28 constructor ( 36 constructor (
29 private notifier: Notifier, 37 private notifier: Notifier,
38 private i18n: I18n,
39 private router: Router,
40 private confirmService: ConfirmService,
30 private route: ActivatedRoute, 41 private route: ActivatedRoute,
31 private screenService: ScreenService, 42 private screenService: ScreenService,
32 private videoPlaylistService: VideoPlaylistService 43 private videoPlaylistService: VideoPlaylistService
33 ) {} 44 ) {}
34 45
35 ngOnInit () { 46 ngOnInit () {
47 this.playlistActions = [
48 [
49 {
50 label: this.i18n('Update playlist'),
51 iconName: 'edit',
52 linkBuilder: playlist => [ '/my-account', 'video-playlists', 'update', playlist.uuid ]
53 },
54 {
55 label: this.i18n('Delete playlist'),
56 iconName: 'delete',
57 handler: playlist => this.deleteVideoPlaylist(playlist)
58 }
59 ]
60 ]
61
36 this.paramsSub = this.route.params.subscribe(routeParams => { 62 this.paramsSub = this.route.params.subscribe(routeParams => {
37 this.videoPlaylistId = routeParams[ 'videoPlaylistId' ] 63 this.videoPlaylistId = routeParams[ 'videoPlaylistId' ]
38 this.loadElements() 64 this.loadElements()
@@ -90,6 +116,38 @@ export class MyAccountVideoPlaylistElementsComponent implements OnInit, OnDestro
90 return elem.id 116 return elem.id
91 } 117 }
92 118
119 isRegularPlaylist (playlist: VideoPlaylist) {
120 return playlist?.type.id === VideoPlaylistType.REGULAR
121 }
122
123 showShareModal () {
124 this.videoShareModal.show()
125 }
126
127 async deleteVideoPlaylist (videoPlaylist: VideoPlaylist) {
128 const res = await this.confirmService.confirm(
129 this.i18n(
130 'Do you really want to delete {{playlistDisplayName}}?',
131 { playlistDisplayName: videoPlaylist.displayName }
132 ),
133 this.i18n('Delete')
134 )
135 if (res === false) return
136
137 this.videoPlaylistService.removeVideoPlaylist(videoPlaylist)
138 .subscribe(
139 () => {
140 this.router.navigate([ '/my-account', 'video-playlists' ])
141
142 this.notifier.success(
143 this.i18n('Playlist {{playlistDisplayName}} deleted.', { playlistDisplayName: videoPlaylist.displayName })
144 )
145 },
146
147 error => this.notifier.error(error.message)
148 )
149 }
150
93 /** 151 /**
94 * Returns null to not have drag and drop delay. 152 * Returns null to not have drag and drop delay.
95 * In small views, where elements are about 100% wide, 153 * In small views, where elements are about 100% wide,