]>
Commit | Line | Data |
---|---|---|
f77eb73b | 1 | import { SortMeta } from 'primeng/api' |
67ed6552 C |
2 | import { Component, OnInit } from '@angular/core' |
3 | import { Notifier, RestPagination, RestTable } from '@app/core' | |
d4a8e7a6 | 4 | import { Video, VideoImportService } from '@app/shared/shared-main' |
67ed6552 | 5 | import { VideoImport, VideoImportState } from '@shared/models' |
ed31c059 C |
6 | |
7 | @Component({ | |
17119e4a C |
8 | templateUrl: './my-video-imports.component.html', |
9 | styleUrls: [ './my-video-imports.component.scss' ] | |
ed31c059 | 10 | }) |
17119e4a | 11 | export class MyVideoImportsComponent extends RestTable implements OnInit { |
ed31c059 C |
12 | videoImports: VideoImport[] = [] |
13 | totalRecords = 0 | |
ed31c059 C |
14 | sort: SortMeta = { field: 'createdAt', order: 1 } |
15 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } | |
16 | ||
17 | constructor ( | |
f8b2c1b4 | 18 | private notifier: Notifier, |
8e11a1b3 | 19 | private videoImportService: VideoImportService |
ed31c059 C |
20 | ) { |
21 | super() | |
22 | } | |
23 | ||
24 | ngOnInit () { | |
24b9417c | 25 | this.initialize() |
ed31c059 C |
26 | } |
27 | ||
8e11a1b3 | 28 | getIdentifier () { |
17119e4a | 29 | return 'MyVideoImportsComponent' |
8e11a1b3 C |
30 | } |
31 | ||
4f5d0459 RK |
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 | ||
ed31c059 C |
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 }) { | |
d4a8e7a6 | 58 | return Video.buildWatchUrl(video) |
ed31c059 C |
59 | } |
60 | ||
61 | getEditVideoUrl (video: { uuid: string }) { | |
d4a8e7a6 | 62 | return Video.buildUpdateUrl(video) |
ed31c059 C |
63 | } |
64 | ||
2e46eb97 | 65 | protected reloadData () { |
ed31c059 | 66 | this.videoImportService.getMyVideoImports(this.pagination, this.sort) |
1378c0d3 C |
67 | .subscribe({ |
68 | next: resultList => { | |
ed31c059 C |
69 | this.videoImports = resultList.data |
70 | this.totalRecords = resultList.total | |
71 | }, | |
72 | ||
1378c0d3 C |
73 | error: err => this.notifier.error(err.message) |
74 | }) | |
ed31c059 C |
75 | } |
76 | } |