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