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 { ConfirmService } from '@app/core'
6 import { I18n } from '@ngx-translate/i18n-polyfill'
7 import { VideoImport, VideoImportState } from '../../../../../shared/models/videos'
8 import { VideoImportService } from '@app/shared/video-import'
11 selector: 'my-account-video-imports',
12 templateUrl: './my-account-video-imports.component.html',
13 styleUrls: [ './my-account-video-imports.component.scss' ]
15 export class MyAccountVideoImportsComponent extends RestTable implements OnInit {
16 videoImports: VideoImport[] = []
19 sort: SortMeta = { field: 'createdAt', order: 1 }
20 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
23 private notificationsService: NotificationsService,
24 private confirmService: ConfirmService,
25 private videoImportService: VideoImportService,
35 isVideoImportSuccess (videoImport: VideoImport) {
36 return videoImport.state.id === VideoImportState.SUCCESS
39 isVideoImportPending (videoImport: VideoImport) {
40 return videoImport.state.id === VideoImportState.PENDING
43 isVideoImportFailed (videoImport: VideoImport) {
44 return videoImport.state.id === VideoImportState.FAILED
47 getVideoUrl (video: { uuid: string }) {
48 return '/videos/watch/' + video.uuid
51 getEditVideoUrl (video: { uuid: string }) {
52 return '/videos/update/' + video.uuid
55 protected loadData () {
56 this.videoImportService.getMyVideoImports(this.pagination, this.sort)
59 this.videoImports = resultList.data
60 this.totalRecords = resultList.total
63 err => this.notificationsService.error(this.i18n('Error'), err.message)