aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/follows/shared/redundancy-checkbox.component.ts
blob: 729b7f5991350876e186bc0fd00efb6a93a592d3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { Component, Input } from '@angular/core'
import { Notifier } from '@app/core'
import { RedundancyService } from '@app/shared/shared-main'

@Component({
  selector: 'my-redundancy-checkbox',
  templateUrl: './redundancy-checkbox.component.html',
  styleUrls: [ './redundancy-checkbox.component.scss' ]
})
export class RedundancyCheckboxComponent {
  @Input() redundancyAllowed: boolean
  @Input() host: string

  constructor (
    private notifier: Notifier,
    private redundancyService: RedundancyService
    ) { }

  updateRedundancyState () {
    this.redundancyService.updateRedundancy(this.host, this.redundancyAllowed)
        .subscribe(
          () => {
            const stateLabel = this.redundancyAllowed ? $localize`enabled` : $localize`disabled`

            this.notifier.success($localize`Redundancy for ${this.host} is ${stateLabel}`)
          },

          err => this.notifier.error(err.message)
        )
  }
}