1 import { Component, Input } from '@angular/core'
2 import { AuthService } from '@app/core'
3 import { RestExtractor } from '@app/shared/rest'
4 import { RedirectService } from '@app/core/routing/redirect.service'
5 import { NotificationsService } from 'angular2-notifications'
6 import { I18n } from '@ngx-translate/i18n-polyfill'
7 import { RedundancyService } from '@app/+admin/follows/shared/redundancy.service'
10 selector: 'my-redundancy-checkbox',
11 templateUrl: './redundancy-checkbox.component.html',
12 styleUrls: [ './redundancy-checkbox.component.scss' ]
14 export class RedundancyCheckboxComponent {
15 @Input() redundancyAllowed: boolean
19 private authService: AuthService,
20 private restExtractor: RestExtractor,
21 private redirectService: RedirectService,
22 private notificationsService: NotificationsService,
23 private redundancyService: RedundancyService,
27 updateRedundancyState () {
28 this.redundancyService.updateRedundancy(this.host, this.redundancyAllowed)
31 const stateLabel = this.redundancyAllowed ? this.i18n('enabled') : this.i18n('disabled')
33 this.notificationsService.success(
35 this.i18n('Redundancy for {{host}} is {{stateLabel}}', { host: this.host, stateLabel })
39 err => this.notificationsService.error(this.i18n('Error'), err.message)