]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.ts
Fix my-video-imports display when a video gets deleted
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-video-imports / my-account-video-imports.component.ts
1 import { Component, OnInit } from '@angular/core'
2 import { RestPagination, RestTable } from '@app/shared'
3 import { SortMeta } from 'primeng/api'
4 import { Notifier } from '@app/core'
5 import { I18n } from '@ngx-translate/i18n-polyfill'
6 import { VideoImport, VideoImportState } from '../../../../../shared/models/videos'
7 import { VideoImportService } from '@app/shared/video-import'
8
9 @Component({
10 selector: 'my-account-video-imports',
11 templateUrl: './my-account-video-imports.component.html',
12 styleUrls: [ './my-account-video-imports.component.scss' ]
13 })
14 export class MyAccountVideoImportsComponent extends RestTable implements OnInit {
15 videoImports: VideoImport[] = []
16 totalRecords = 0
17 rowsPerPage = 10
18 sort: SortMeta = { field: 'createdAt', order: 1 }
19 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
20
21 constructor (
22 private notifier: Notifier,
23 private videoImportService: VideoImportService
24 ) {
25 super()
26 }
27
28 ngOnInit () {
29 this.initialize()
30 }
31
32 getIdentifier () {
33 return 'MyAccountVideoImportsComponent'
34 }
35
36 isVideoImportSuccess (videoImport: VideoImport) {
37 return videoImport.state.id === VideoImportState.SUCCESS
38 }
39
40 isVideoImportPending (videoImport: VideoImport) {
41 return videoImport.state.id === VideoImportState.PENDING
42 }
43
44 isVideoImportFailed (videoImport: VideoImport) {
45 return videoImport.state.id === VideoImportState.FAILED
46 }
47
48 getVideoUrl (video: { uuid: string }) {
49 return '/videos/watch/' + video.uuid
50 }
51
52 getEditVideoUrl (video: { uuid: string }) {
53 return '/videos/update/' + video.uuid
54 }
55
56 protected loadData () {
57 this.videoImportService.getMyVideoImports(this.pagination, this.sort)
58 .subscribe(
59 resultList => {
60 this.videoImports = resultList.data
61 this.totalRecords = resultList.total
62 },
63
64 err => this.notifier.error(err.message)
65 )
66 }
67 }