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