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'
10 selector: 'my-account-videos',
11 templateUrl: './account-videos.component.html',
12 styleUrls: [ './account-videos.component.scss' ]
14 export class AccountVideosComponent extends AbstractVideoList implements OnInit {
15 titlePage = 'My videos'
16 currentRoute = '/account/videos'
18 constructor (protected router: Router,
19 protected route: ActivatedRoute,
20 protected notificationsService: NotificationsService,
21 protected confirmService: ConfirmService,
22 private videoService: VideoService) {
30 getVideosObservable () {
31 return this.videoService.getMyVideos(this.pagination, this.sort)
34 deleteVideo (video: Video) {
35 this.confirmService.confirm(`Do you really want to delete ${video.name}?`, 'Delete').subscribe(
37 if (res === false) return
39 this.videoService.removeVideo(video.id)
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)
47 error => this.notificationsService.error('Error', error.text)