]>
Commit | Line | Data |
---|---|---|
ed31c059 C |
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' | |
9 | ||
10 | @Component({ | |
11 | selector: 'my-account-video-imports', | |
12 | templateUrl: './my-account-video-imports.component.html', | |
13 | styleUrls: [ './my-account-video-imports.component.scss' ] | |
14 | }) | |
15 | export class MyAccountVideoImportsComponent extends RestTable implements OnInit { | |
16 | videoImports: VideoImport[] = [] | |
17 | totalRecords = 0 | |
18 | rowsPerPage = 10 | |
19 | sort: SortMeta = { field: 'createdAt', order: 1 } | |
20 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } | |
21 | ||
22 | constructor ( | |
23 | private notificationsService: NotificationsService, | |
24 | private confirmService: ConfirmService, | |
25 | private videoImportService: VideoImportService, | |
26 | private i18n: I18n | |
27 | ) { | |
28 | super() | |
29 | } | |
30 | ||
31 | ngOnInit () { | |
32 | this.loadSort() | |
33 | } | |
34 | ||
35 | isVideoImportSuccess (videoImport: VideoImport) { | |
36 | return videoImport.state.id === VideoImportState.SUCCESS | |
37 | } | |
38 | ||
39 | isVideoImportPending (videoImport: VideoImport) { | |
40 | return videoImport.state.id === VideoImportState.PENDING | |
41 | } | |
42 | ||
43 | isVideoImportFailed (videoImport: VideoImport) { | |
44 | return videoImport.state.id === VideoImportState.FAILED | |
45 | } | |
46 | ||
47 | getVideoUrl (video: { uuid: string }) { | |
48 | return '/videos/watch/' + video.uuid | |
49 | } | |
50 | ||
51 | getEditVideoUrl (video: { uuid: string }) { | |
52 | return '/videos/update/' + video.uuid | |
53 | } | |
54 | ||
55 | protected loadData () { | |
56 | this.videoImportService.getMyVideoImports(this.pagination, this.sort) | |
57 | .subscribe( | |
58 | resultList => { | |
59 | this.videoImports = resultList.data | |
60 | this.totalRecords = resultList.total | |
61 | }, | |
62 | ||
63 | err => this.notificationsService.error(this.i18n('Error'), err.message) | |
64 | ) | |
65 | } | |
66 | } |