]>
Commit | Line | Data |
---|---|---|
ed31c059 C |
1 | import { Component, OnInit } from '@angular/core' |
2 | import { RestPagination, RestTable } from '@app/shared' | |
f77eb73b | 3 | import { SortMeta } from 'primeng/api' |
f8b2c1b4 | 4 | import { Notifier } from '@app/core' |
ed31c059 C |
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 ( | |
f8b2c1b4 | 22 | private notifier: Notifier, |
8e11a1b3 | 23 | private videoImportService: VideoImportService |
ed31c059 C |
24 | ) { |
25 | super() | |
26 | } | |
27 | ||
28 | ngOnInit () { | |
24b9417c | 29 | this.initialize() |
ed31c059 C |
30 | } |
31 | ||
8e11a1b3 C |
32 | getIdentifier () { |
33 | return 'MyAccountVideoImportsComponent' | |
34 | } | |
35 | ||
ed31c059 C |
36 | isVideoImportSuccess (videoImport: VideoImport) { |
37 | return videoImport.state.id === VideoImportState.SUCCESS | |
38 | } | |
39 | ||
40 | isVideoImportPending (videoImport: VideoImport) { | |
41 | return videoImport.state.id === VideoImportState.PENDING | |
42 | } | |
43 | ||
44 | isVideoImportFailed (videoImport: VideoImport) { | |
45 | return videoImport.state.id === VideoImportState.FAILED | |
46 | } | |
47 | ||
48 | getVideoUrl (video: { uuid: string }) { | |
49 | return '/videos/watch/' + video.uuid | |
50 | } | |
51 | ||
52 | getEditVideoUrl (video: { uuid: string }) { | |
53 | return '/videos/update/' + video.uuid | |
54 | } | |
55 | ||
56 | protected loadData () { | |
57 | this.videoImportService.getMyVideoImports(this.pagination, this.sort) | |
58 | .subscribe( | |
59 | resultList => { | |
60 | this.videoImports = resultList.data | |
61 | this.totalRecords = resultList.total | |
62 | }, | |
63 | ||
f8b2c1b4 | 64 | err => this.notifier.error(err.message) |
ed31c059 C |
65 | ) |
66 | } | |
67 | } |