]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+my-account/my-account-video-imports/my-account-video-imports.component.ts
Add users search filter
[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/components/common/sortmeta'
4 import { NotificationsService } from 'angular2-notifications'
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 notificationsService: NotificationsService,
23 private videoImportService: VideoImportService,
24 private i18n: I18n
25 ) {
26 super()
27 }
28
29 ngOnInit () {
30 this.initialize()
31 }
32
33 isVideoImportSuccess (videoImport: VideoImport) {
34 return videoImport.state.id === VideoImportState.SUCCESS
35 }
36
37 isVideoImportPending (videoImport: VideoImport) {
38 return videoImport.state.id === VideoImportState.PENDING
39 }
40
41 isVideoImportFailed (videoImport: VideoImport) {
42 return videoImport.state.id === VideoImportState.FAILED
43 }
44
45 getVideoUrl (video: { uuid: string }) {
46 return '/videos/watch/' + video.uuid
47 }
48
49 getEditVideoUrl (video: { uuid: string }) {
50 return '/videos/update/' + video.uuid
51 }
52
53 protected loadData () {
54 this.videoImportService.getMyVideoImports(this.pagination, this.sort)
55 .subscribe(
56 resultList => {
57 this.videoImports = resultList.data
58 this.totalRecords = resultList.total
59 },
60
61 err => this.notificationsService.error(this.i18n('Error'), err.message)
62 )
63 }
64 }