aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-02-22 15:29:32 +0100
committerChocobozzz <me@florianbigard.com>2018-02-22 15:29:32 +0100
commit1f30a1853e38c20a45722dbd6d38aaaec63839e8 (patch)
treecdce8cc9fcc62d9b3343c9478b1dbcefedcea972 /client/src/app/videos
parent78967fca4cacbc247fa6fb62d64b2d6825a10804 (diff)
downloadPeerTube-1f30a1853e38c20a45722dbd6d38aaaec63839e8.tar.gz
PeerTube-1f30a1853e38c20a45722dbd6d38aaaec63839e8.tar.zst
PeerTube-1f30a1853e38c20a45722dbd6d38aaaec63839e8.zip
Add confirm when admin use custom js/css
Diffstat (limited to 'client/src/app/videos')
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comments.component.ts55
-rw-r--r--client/src/app/videos/+video-watch/video-watch.component.ts51
2 files changed, 48 insertions, 58 deletions
diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.ts b/client/src/app/videos/+video-watch/comment/video-comments.component.ts
index 16f1a0643..711a01ba0 100644
--- a/client/src/app/videos/+video-watch/comment/video-comments.component.ts
+++ b/client/src/app/videos/+video-watch/comment/video-comments.component.ts
@@ -109,38 +109,35 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
109 this.viewReplies(commentTree.comment.id) 109 this.viewReplies(commentTree.comment.id)
110 } 110 }
111 111
112 onWantedToDelete (commentToDelete: VideoComment) { 112 async onWantedToDelete (commentToDelete: VideoComment) {
113 let message = 'Do you really want to delete this comment?' 113 let message = 'Do you really want to delete this comment?'
114 if (commentToDelete.totalReplies !== 0) message += `${commentToDelete.totalReplies} would be deleted too.` 114 if (commentToDelete.totalReplies !== 0) message += `${commentToDelete.totalReplies} would be deleted too.`
115 115
116 this.confirmService.confirm(message, 'Delete').subscribe( 116 const res = await this.confirmService.confirm(message, 'Delete')
117 res => { 117 if (res === false) return
118 if (res === false) return 118
119 119 this.videoCommentService.deleteVideoComment(commentToDelete.videoId, commentToDelete.id)
120 this.videoCommentService.deleteVideoComment(commentToDelete.videoId, commentToDelete.id) 120 .subscribe(
121 .subscribe( 121 () => {
122 () => { 122 // Delete the comment in the tree
123 // Delete the comment in the tree 123 if (commentToDelete.inReplyToCommentId) {
124 if (commentToDelete.inReplyToCommentId) { 124 const thread = this.threadComments[commentToDelete.threadId]
125 const thread = this.threadComments[commentToDelete.threadId] 125 if (!thread) {
126 if (!thread) { 126 console.error(`Cannot find thread ${commentToDelete.threadId} of the comment to delete ${commentToDelete.id}`)
127 console.error(`Cannot find thread ${commentToDelete.threadId} of the comment to delete ${commentToDelete.id}`) 127 return
128 return 128 }
129 } 129
130 130 this.deleteLocalCommentThread(thread, commentToDelete)
131 this.deleteLocalCommentThread(thread, commentToDelete) 131 return
132 return 132 }
133 } 133
134 134 // Delete the thread
135 // Delete the thread 135 this.comments = this.comments.filter(c => c.id !== commentToDelete.id)
136 this.comments = this.comments.filter(c => c.id !== commentToDelete.id) 136 this.componentPagination.totalItems--
137 this.componentPagination.totalItems-- 137 },
138 }, 138
139 139 err => this.notificationsService.error('Error', err.message)
140 err => this.notificationsService.error('Error', err.message) 140 )
141 )
142 }
143 )
144 } 141 }
145 142
146 isUserLoggedIn () { 143 isUserLoggedIn () {
diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts
index 6b118b1de..d04d50310 100644
--- a/client/src/app/videos/+video-watch/video-watch.component.ts
+++ b/client/src/app/videos/+video-watch/video-watch.component.ts
@@ -130,24 +130,21 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
130 } 130 }
131 } 131 }
132 132
133 blacklistVideo (event: Event) { 133 async blacklistVideo (event: Event) {
134 event.preventDefault() 134 event.preventDefault()
135 135
136 this.confirmService.confirm('Do you really want to blacklist this video?', 'Blacklist').subscribe( 136 const res = await this.confirmService.confirm('Do you really want to blacklist this video?', 'Blacklist')
137 res => { 137 if (res === false) return
138 if (res === false) return
139 138
140 this.videoBlacklistService.blacklistVideo(this.video.id) 139 this.videoBlacklistService.blacklistVideo(this.video.id)
141 .subscribe( 140 .subscribe(
142 status => { 141 status => {
143 this.notificationsService.success('Success', `Video ${this.video.name} had been blacklisted.`) 142 this.notificationsService.success('Success', `Video ${this.video.name} had been blacklisted.`)
144 this.router.navigate(['/videos/list']) 143 this.router.navigate(['/videos/list'])
145 }, 144 },
146 145
147 error => this.notificationsService.error('Error', error.message) 146 error => this.notificationsService.error('Error', error.message)
148 ) 147 )
149 }
150 )
151 } 148 }
152 149
153 showMoreDescription () { 150 showMoreDescription () {
@@ -236,26 +233,22 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
236 return this.video.isRemovableBy(this.authService.getUser()) 233 return this.video.isRemovableBy(this.authService.getUser())
237 } 234 }
238 235
239 removeVideo (event: Event) { 236 async removeVideo (event: Event) {
240 event.preventDefault() 237 event.preventDefault()
241 238
242 this.confirmService.confirm('Do you really want to delete this video?', 'Delete') 239 const res = await this.confirmService.confirm('Do you really want to delete this video?', 'Delete')
243 .subscribe( 240 if (res === false) return
244 res => {
245 if (res === false) return
246 241
247 this.videoService.removeVideo(this.video.id) 242 this.videoService.removeVideo(this.video.id)
248 .subscribe( 243 .subscribe(
249 status => { 244 status => {
250 this.notificationsService.success('Success', `Video ${this.video.name} deleted.`) 245 this.notificationsService.success('Success', `Video ${this.video.name} deleted.`)
251 246
252 // Go back to the video-list. 247 // Go back to the video-list.
253 this.router.navigate([ '/videos/list' ]) 248 this.router.navigate([ '/videos/list' ])
254 }, 249 },
255 250
256 error => this.notificationsService.error('Error', error.message) 251 error => this.notificationsService.error('Error', error.message)
257 )
258 }
259 ) 252 )
260 } 253 }
261 254