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