]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.ts
Factorize rest-table and fix/simplify SQL
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-video-imports / my-account-video-imports.component.ts
CommitLineData
ed31c059
C
1import { Component, OnInit } from '@angular/core'
2import { RestPagination, RestTable } from '@app/shared'
f77eb73b 3import { SortMeta } from 'primeng/api'
f8b2c1b4 4import { Notifier } from '@app/core'
ed31c059
C
5import { VideoImport, VideoImportState } from '../../../../../shared/models/videos'
6import { 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})
13export class MyAccountVideoImportsComponent extends RestTable implements OnInit {
14 videoImports: VideoImport[] = []
15 totalRecords = 0
ed31c059
C
16 sort: SortMeta = { field: 'createdAt', order: 1 }
17 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
18
19 constructor (
f8b2c1b4 20 private notifier: Notifier,
8e11a1b3 21 private videoImportService: VideoImportService
ed31c059
C
22 ) {
23 super()
24 }
25
26 ngOnInit () {
24b9417c 27 this.initialize()
ed31c059
C
28 }
29
8e11a1b3
C
30 getIdentifier () {
31 return 'MyAccountVideoImportsComponent'
32 }
33
ed31c059
C
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
f8b2c1b4 62 err => this.notifier.error(err.message)
ed31c059
C
63 )
64 }
65}