aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-11-17 16:04:53 +0100
committerChocobozzz <me@florianbigard.com>2021-11-18 09:04:30 +0100
commitb46cf4b920984492df598c1b61179acfc7f6f22e (patch)
tree21fda049c85be48ab3d37b537aafa98e94649ad7 /client/src/app/+admin
parent3cfa817672657df18260ece5b354efa0f3b6e317 (diff)
downloadPeerTube-b46cf4b920984492df598c1b61179acfc7f6f22e.tar.gz
PeerTube-b46cf4b920984492df598c1b61179acfc7f6f22e.tar.zst
PeerTube-b46cf4b920984492df598c1b61179acfc7f6f22e.zip
Add ability to remove hls/webtorrent files
Diffstat (limited to 'client/src/app/+admin')
-rw-r--r--client/src/app/+admin/overview/videos/video-list.component.html4
-rw-r--r--client/src/app/+admin/overview/videos/video-list.component.ts55
2 files changed, 44 insertions, 15 deletions
diff --git a/client/src/app/+admin/overview/videos/video-list.component.html b/client/src/app/+admin/overview/videos/video-list.component.html
index 9b536ec11..6e4fb4c6f 100644
--- a/client/src/app/+admin/overview/videos/video-list.component.html
+++ b/client/src/app/+admin/overview/videos/video-list.component.html
@@ -57,7 +57,7 @@
57 <td class="action-cell"> 57 <td class="action-cell">
58 <my-video-actions-dropdown 58 <my-video-actions-dropdown
59 placement="bottom auto" buttonDirection="horizontal" [buttonStyled]="true" [video]="video" 59 placement="bottom auto" buttonDirection="horizontal" [buttonStyled]="true" [video]="video"
60 [displayOptions]="videoActionsOptions" (videoRemoved)="onVideoRemoved()" 60 [displayOptions]="videoActionsOptions" (videoRemoved)="reloadData()" (videoFilesRemoved)="reloadData()"
61 ></my-video-actions-dropdown> 61 ></my-video-actions-dropdown>
62 </td> 62 </td>
63 63
@@ -127,4 +127,4 @@
127 </ng-template> 127 </ng-template>
128</p-table> 128</p-table>
129 129
130<my-video-block #videoBlockModal (videoBlocked)="onVideoBlocked()"></my-video-block> 130<my-video-block #videoBlockModal (videoBlocked)="reloadData()"></my-video-block>
diff --git a/client/src/app/+admin/overview/videos/video-list.component.ts b/client/src/app/+admin/overview/videos/video-list.component.ts
index 7f268bb23..3c21adb44 100644
--- a/client/src/app/+admin/overview/videos/video-list.component.ts
+++ b/client/src/app/+admin/overview/videos/video-list.component.ts
@@ -39,7 +39,8 @@ export class VideoListComponent extends RestTable implements OnInit {
39 report: false, 39 report: false,
40 duplicate: true, 40 duplicate: true,
41 mute: true, 41 mute: true,
42 liveInfo: false 42 liveInfo: false,
43 removeFiles: true
43 } 44 }
44 45
45 loading = true 46 loading = true
@@ -71,17 +72,34 @@ export class VideoListComponent extends RestTable implements OnInit {
71 { 72 {
72 label: $localize`Delete`, 73 label: $localize`Delete`,
73 handler: videos => this.removeVideos(videos), 74 handler: videos => this.removeVideos(videos),
74 isDisplayed: () => this.authUser.hasRight(UserRight.REMOVE_ANY_VIDEO) 75 isDisplayed: () => this.authUser.hasRight(UserRight.REMOVE_ANY_VIDEO),
76 iconName: 'delete'
75 }, 77 },
76 { 78 {
77 label: $localize`Block`, 79 label: $localize`Block`,
78 handler: videos => this.videoBlockModal.show(videos), 80 handler: videos => this.videoBlockModal.show(videos),
79 isDisplayed: videos => this.authUser.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) && videos.every(v => !v.blacklisted) 81 isDisplayed: videos => this.authUser.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) && videos.every(v => !v.blacklisted),
82 iconName: 'no'
80 }, 83 },
81 { 84 {
82 label: $localize`Unblock`, 85 label: $localize`Unblock`,
83 handler: videos => this.unblockVideos(videos), 86 handler: videos => this.unblockVideos(videos),
84 isDisplayed: videos => this.authUser.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) && videos.every(v => v.blacklisted) 87 isDisplayed: videos => this.authUser.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) && videos.every(v => v.blacklisted),
88 iconName: 'undo'
89 }
90 ],
91 [
92 {
93 label: $localize`Delete HLS files`,
94 handler: videos => this.removeVideoFiles(videos, 'hls'),
95 isDisplayed: videos => this.authUser.hasRight(UserRight.MANAGE_VIDEO_FILES) && videos.every(v => v.hasHLS() && v.hasWebTorrent()),
96 iconName: 'delete'
97 },
98 {
99 label: $localize`Delete WebTorrent files`,
100 handler: videos => this.removeVideoFiles(videos, 'webtorrent'),
101 isDisplayed: videos => this.authUser.hasRight(UserRight.MANAGE_VIDEO_FILES) && videos.every(v => v.hasHLS() && v.hasWebTorrent()),
102 iconName: 'delete'
85 } 103 }
86 ] 104 ]
87 ] 105 ]
@@ -95,10 +113,6 @@ export class VideoListComponent extends RestTable implements OnInit {
95 return this.selectedVideos.length !== 0 113 return this.selectedVideos.length !== 0
96 } 114 }
97 115
98 onVideoRemoved () {
99 this.reloadData()
100 }
101
102 getPrivacyBadgeClass (video: Video) { 116 getPrivacyBadgeClass (video: Video) {
103 if (video.privacy.id === VideoPrivacy.PUBLIC) return 'badge-green' 117 if (video.privacy.id === VideoPrivacy.PUBLIC) return 'badge-green'
104 118
@@ -146,11 +160,7 @@ export class VideoListComponent extends RestTable implements OnInit {
146 return files.reduce((p, f) => p += f.size, 0) 160 return files.reduce((p, f) => p += f.size, 0)
147 } 161 }
148 162
149 onVideoBlocked () { 163 reloadData () {
150 this.reloadData()
151 }
152
153 protected reloadData () {
154 this.selectedVideos = [] 164 this.selectedVideos = []
155 165
156 this.loading = true 166 this.loading = true
@@ -197,4 +207,23 @@ export class VideoListComponent extends RestTable implements OnInit {
197 error: err => this.notifier.error(err.message) 207 error: err => this.notifier.error(err.message)
198 }) 208 })
199 } 209 }
210
211 private async removeVideoFiles (videos: Video[], type: 'hls' | 'webtorrent') {
212 const message = type === 'hls'
213 ? $localize`Are you sure you want to delete ${videos.length} HLS streaming playlists?`
214 : $localize`Are you sure you want to delete WebTorrent files of ${videos.length} videos?`
215
216 const res = await this.confirmService.confirm(message, $localize`Delete`)
217 if (res === false) return
218
219 this.videoService.removeVideoFiles(videos.map(v => v.id), type)
220 .subscribe({
221 next: () => {
222 this.notifier.success($localize`Files were removed.`)
223 this.reloadData()
224 },
225
226 error: err => this.notifier.error(err.message)
227 })
228 }
200} 229}