]>
Commit | Line | Data |
---|---|---|
5f46d28c C |
1 | |
2 | import { SelectOptionsItem } from 'src/types/select-options-item.model' | |
3 | import { Component, Input, OnInit } from '@angular/core' | |
4 | import { FormGroup } from '@angular/forms' | |
5 | import { ServerConfig } from '@shared/models' | |
6 | import { ConfigService } from '../shared/config.service' | |
7 | import { EditConfigurationService, ResolutionOption } from './edit-configuration.service' | |
8 | ||
9 | @Component({ | |
10 | selector: 'my-edit-vod-transcoding', | |
11 | templateUrl: './edit-vod-transcoding.component.html', | |
12 | styleUrls: [ './edit-custom-config.component.scss' ] | |
13 | }) | |
14 | export class EditVODTranscodingComponent implements OnInit { | |
15 | @Input() form: FormGroup | |
16 | @Input() formErrors: any | |
17 | @Input() serverConfig: ServerConfig | |
18 | ||
19 | transcodingThreadOptions: SelectOptionsItem[] = [] | |
20 | resolutions: ResolutionOption[] = [] | |
21 | ||
22 | constructor ( | |
23 | private configService: ConfigService, | |
24 | private editConfigurationService: EditConfigurationService | |
25 | ) { } | |
26 | ||
27 | ngOnInit () { | |
28 | this.transcodingThreadOptions = this.configService.transcodingThreadOptions | |
29 | this.resolutions = this.editConfigurationService.getVODResolutions() | |
30 | ||
31 | this.checkTranscodingFields() | |
32 | } | |
33 | ||
34 | getAvailableTranscodingProfile () { | |
35 | const profiles = this.serverConfig.transcoding.availableProfiles | |
36 | ||
37 | return profiles.map(p => ({ id: p, label: p })) | |
38 | } | |
39 | ||
40 | getResolutionKey (resolution: string) { | |
41 | return 'transcoding.resolutions.' + resolution | |
42 | } | |
43 | ||
44 | isTranscodingEnabled () { | |
45 | return this.editConfigurationService.isTranscodingEnabled(this.form) | |
46 | } | |
47 | ||
48 | getTotalTranscodingThreads () { | |
49 | return this.editConfigurationService.getTotalTranscodingThreads(this.form) | |
50 | } | |
51 | ||
52 | private checkTranscodingFields () { | |
53 | const hlsControl = this.form.get('transcoding.hls.enabled') | |
54 | const webtorrentControl = this.form.get('transcoding.webtorrent.enabled') | |
55 | ||
56 | webtorrentControl.valueChanges | |
57 | .subscribe(newValue => { | |
58 | if (newValue === false && !hlsControl.disabled) { | |
59 | hlsControl.disable() | |
60 | } | |
61 | ||
62 | if (newValue === true && !hlsControl.enabled) { | |
63 | hlsControl.enable() | |
64 | } | |
65 | }) | |
66 | ||
67 | hlsControl.valueChanges | |
68 | .subscribe(newValue => { | |
69 | if (newValue === false && !webtorrentControl.disabled) { | |
70 | webtorrentControl.disable() | |
71 | } | |
72 | ||
73 | if (newValue === true && !webtorrentControl.enabled) { | |
74 | webtorrentControl.enable() | |
75 | } | |
76 | }) | |
77 | } | |
78 | } |