]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+my-library/my-video-imports/my-video-imports.component.ts
Reduce advanced search input debounce time
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-library / my-video-imports / my-video-imports.component.ts
CommitLineData
f77eb73b 1import { SortMeta } from 'primeng/api'
67ed6552
C
2import { Component, OnInit } from '@angular/core'
3import { Notifier, RestPagination, RestTable } from '@app/core'
4import { VideoImportService } from '@app/shared/shared-main'
5import { VideoImport, VideoImportState } from '@shared/models'
ed31c059
C
6
7@Component({
17119e4a
C
8 templateUrl: './my-video-imports.component.html',
9 styleUrls: [ './my-video-imports.component.scss' ]
ed31c059 10})
17119e4a 11export class MyVideoImportsComponent extends RestTable implements OnInit {
ed31c059
C
12 videoImports: VideoImport[] = []
13 totalRecords = 0
ed31c059
C
14 sort: SortMeta = { field: 'createdAt', order: 1 }
15 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
16
17 constructor (
f8b2c1b4 18 private notifier: Notifier,
8e11a1b3 19 private videoImportService: VideoImportService
ed31c059
C
20 ) {
21 super()
22 }
23
24 ngOnInit () {
24b9417c 25 this.initialize()
ed31c059
C
26 }
27
8e11a1b3 28 getIdentifier () {
17119e4a 29 return 'MyVideoImportsComponent'
8e11a1b3
C
30 }
31
4f5d0459
RK
32 getVideoImportStateClass (state: VideoImportState) {
33 switch (state) {
34 case VideoImportState.FAILED:
35 return 'badge-red'
36 case VideoImportState.REJECTED:
37 return 'badge-banned'
38 case VideoImportState.PENDING:
39 return 'badge-yellow'
40 default:
41 return 'badge-green'
42 }
43 }
44
ed31c059
C
45 isVideoImportSuccess (videoImport: VideoImport) {
46 return videoImport.state.id === VideoImportState.SUCCESS
47 }
48
49 isVideoImportPending (videoImport: VideoImport) {
50 return videoImport.state.id === VideoImportState.PENDING
51 }
52
53 isVideoImportFailed (videoImport: VideoImport) {
54 return videoImport.state.id === VideoImportState.FAILED
55 }
56
57 getVideoUrl (video: { uuid: string }) {
58 return '/videos/watch/' + video.uuid
59 }
60
61 getEditVideoUrl (video: { uuid: string }) {
62 return '/videos/update/' + video.uuid
63 }
64
65 protected loadData () {
66 this.videoImportService.getMyVideoImports(this.pagination, this.sort)
67 .subscribe(
68 resultList => {
69 this.videoImports = resultList.data
70 this.totalRecords = resultList.total
71 },
72
f8b2c1b4 73 err => this.notifier.error(err.message)
ed31c059
C
74 )
75 }
76}