]>
Commit | Line | Data |
---|---|---|
1 | import { SortMeta } from 'primeng/api' | |
2 | import { Component, OnInit } from '@angular/core' | |
3 | import { Notifier, RestPagination, RestTable } from '@app/core' | |
4 | import { Video, VideoImportService } from '@app/shared/shared-main' | |
5 | import { VideoImport, VideoImportState } from '@shared/models' | |
6 | ||
7 | @Component({ | |
8 | templateUrl: './my-video-imports.component.html', | |
9 | styleUrls: [ './my-video-imports.component.scss' ] | |
10 | }) | |
11 | export class MyVideoImportsComponent extends RestTable implements OnInit { | |
12 | videoImports: VideoImport[] = [] | |
13 | totalRecords = 0 | |
14 | sort: SortMeta = { field: 'createdAt', order: 1 } | |
15 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } | |
16 | ||
17 | constructor ( | |
18 | private notifier: Notifier, | |
19 | private videoImportService: VideoImportService | |
20 | ) { | |
21 | super() | |
22 | } | |
23 | ||
24 | ngOnInit () { | |
25 | this.initialize() | |
26 | } | |
27 | ||
28 | getIdentifier () { | |
29 | return 'MyVideoImportsComponent' | |
30 | } | |
31 | ||
32 | getVideoImportStateClass (state: VideoImportState) { | |
33 | switch (state) { | |
34 | case VideoImportState.FAILED: | |
35 | return 'badge-red' | |
36 | case VideoImportState.REJECTED: | |
37 | return 'badge-banned' | |
38 | case VideoImportState.PENDING: | |
39 | return 'badge-yellow' | |
40 | default: | |
41 | return 'badge-green' | |
42 | } | |
43 | } | |
44 | ||
45 | isVideoImportSuccess (videoImport: VideoImport) { | |
46 | return videoImport.state.id === VideoImportState.SUCCESS | |
47 | } | |
48 | ||
49 | isVideoImportPending (videoImport: VideoImport) { | |
50 | return videoImport.state.id === VideoImportState.PENDING | |
51 | } | |
52 | ||
53 | isVideoImportFailed (videoImport: VideoImport) { | |
54 | return videoImport.state.id === VideoImportState.FAILED | |
55 | } | |
56 | ||
57 | getVideoUrl (video: { uuid: string }) { | |
58 | return Video.buildWatchUrl(video) | |
59 | } | |
60 | ||
61 | getEditVideoUrl (video: { uuid: string }) { | |
62 | return Video.buildUpdateUrl(video) | |
63 | } | |
64 | ||
65 | protected reloadData () { | |
66 | this.videoImportService.getMyVideoImports(this.pagination, this.sort) | |
67 | .subscribe({ | |
68 | next: resultList => { | |
69 | this.videoImports = resultList.data | |
70 | this.totalRecords = resultList.total | |
71 | }, | |
72 | ||
73 | error: err => this.notifier.error(err.message) | |
74 | }) | |
75 | } | |
76 | } |