]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/account/account-videos/account-videos.component.ts
Add hover effect to buttons
[github/Chocobozzz/PeerTube.git] / client / src / app / account / account-videos / account-videos.component.ts
1 import { Component, OnInit } from '@angular/core'
2 import { ActivatedRoute, Router } from '@angular/router'
3 import { NotificationsService } from 'angular2-notifications'
4 import { ConfirmService } from '../../core/confirm'
5 import { AbstractVideoList } from '../../shared/video/abstract-video-list'
6 import { Video } from '../../shared/video/video.model'
7 import { VideoService } from '../../shared/video/video.service'
8
9 @Component({
10 selector: 'my-account-videos',
11 templateUrl: './account-videos.component.html',
12 styleUrls: [ './account-videos.component.scss' ]
13 })
14 export class AccountVideosComponent extends AbstractVideoList implements OnInit {
15 titlePage = 'My videos'
16 currentRoute = '/account/videos'
17
18 constructor (protected router: Router,
19 protected route: ActivatedRoute,
20 protected notificationsService: NotificationsService,
21 protected confirmService: ConfirmService,
22 private videoService: VideoService) {
23 super()
24 }
25
26 ngOnInit () {
27 super.ngOnInit()
28 }
29
30 getVideosObservable () {
31 return this.videoService.getMyVideos(this.pagination, this.sort)
32 }
33
34 deleteVideo (video: Video) {
35 this.confirmService.confirm(`Do you really want to delete ${video.name}?`, 'Delete').subscribe(
36 res => {
37 if (res === false) return
38
39 this.videoService.removeVideo(video.id)
40 .subscribe(
41 status => {
42 this.notificationsService.success('Success', `Video ${video.name} deleted.`)
43 const index = this.videos.findIndex(v => v.id === video.id)
44 this.videos.splice(index, 1)
45 },
46
47 error => this.notificationsService.error('Error', error.text)
48 )
49 }
50 )
51 }
52 }