diff options
author | Chocobozzz <me@florianbigard.com> | 2021-02-10 11:06:32 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-02-10 11:36:40 +0100 |
commit | 5f46d28ccac4a20fcbb12c96a047a84a08e485ae (patch) | |
tree | 6529920195176736d187b93bcac8f3ad6920853d /client/src/app/+admin/config/edit-custom-config/edit-vod-transcoding.component.ts | |
parent | 53e4e201797aa1b581209ffd775bf05197efa78f (diff) | |
download | PeerTube-5f46d28ccac4a20fcbb12c96a047a84a08e485ae.tar.gz PeerTube-5f46d28ccac4a20fcbb12c96a047a84a08e485ae.tar.zst PeerTube-5f46d28ccac4a20fcbb12c96a047a84a08e485ae.zip |
Split admin conf page
Diffstat (limited to 'client/src/app/+admin/config/edit-custom-config/edit-vod-transcoding.component.ts')
-rw-r--r-- | client/src/app/+admin/config/edit-custom-config/edit-vod-transcoding.component.ts | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-vod-transcoding.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-vod-transcoding.component.ts new file mode 100644 index 000000000..d745912a0 --- /dev/null +++ b/client/src/app/+admin/config/edit-custom-config/edit-vod-transcoding.component.ts | |||
@@ -0,0 +1,78 @@ | |||
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 | } | ||