]>
Commit | Line | Data |
---|---|---|
c48e82b5 | 1 | import { Component, Input } from '@angular/core' |
f8b2c1b4 | 2 | import { Notifier } from '@app/core' |
c48e82b5 | 3 | import { I18n } from '@ngx-translate/i18n-polyfill' |
b764380a | 4 | import { RedundancyService } from '@app/shared/video/redundancy.service' |
c48e82b5 C |
5 | |
6 | @Component({ | |
7 | selector: 'my-redundancy-checkbox', | |
8 | templateUrl: './redundancy-checkbox.component.html', | |
9 | styleUrls: [ './redundancy-checkbox.component.scss' ] | |
10 | }) | |
11 | export class RedundancyCheckboxComponent { | |
12 | @Input() redundancyAllowed: boolean | |
13 | @Input() host: string | |
14 | ||
15 | constructor ( | |
f8b2c1b4 | 16 | private notifier: Notifier, |
c48e82b5 C |
17 | private redundancyService: RedundancyService, |
18 | private i18n: I18n | |
19 | ) { } | |
20 | ||
21 | updateRedundancyState () { | |
22 | this.redundancyService.updateRedundancy(this.host, this.redundancyAllowed) | |
f8b2c1b4 C |
23 | .subscribe( |
24 | () => { | |
25 | const stateLabel = this.redundancyAllowed ? this.i18n('enabled') : this.i18n('disabled') | |
c48e82b5 | 26 | |
f8b2c1b4 C |
27 | this.notifier.success(this.i18n('Redundancy for {{host}} is {{stateLabel}}', { host: this.host, stateLabel })) |
28 | }, | |
c48e82b5 | 29 | |
f8b2c1b4 C |
30 | err => this.notifier.error(err.message) |
31 | ) | |
c48e82b5 C |
32 | } |
33 | } |