]>
Commit | Line | Data |
---|---|---|
c48e82b5 | 1 | import { Component, Input } from '@angular/core' |
c48e82b5 C |
2 | import { NotificationsService } from 'angular2-notifications' |
3 | import { I18n } from '@ngx-translate/i18n-polyfill' | |
4 | import { RedundancyService } from '@app/+admin/follows/shared/redundancy.service' | |
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 ( | |
c48e82b5 C |
16 | private notificationsService: NotificationsService, |
17 | private redundancyService: RedundancyService, | |
18 | private i18n: I18n | |
19 | ) { } | |
20 | ||
21 | updateRedundancyState () { | |
22 | this.redundancyService.updateRedundancy(this.host, this.redundancyAllowed) | |
23 | .subscribe( | |
24 | () => { | |
25 | const stateLabel = this.redundancyAllowed ? this.i18n('enabled') : this.i18n('disabled') | |
26 | ||
27 | this.notificationsService.success( | |
28 | this.i18n('Success'), | |
29 | this.i18n('Redundancy for {{host}} is {{stateLabel}}', { host: this.host, stateLabel }) | |
30 | ) | |
31 | }, | |
32 | ||
33 | err => this.notificationsService.error(this.i18n('Error'), err.message) | |
34 | ) | |
35 | } | |
36 | } |