aboutsummaryrefslogblamecommitdiffhomepage
path: root/client/src/app/+admin/follows/shared/redundancy-checkbox.component.ts
blob: 3935ddc4ff09c347bea19e4ce82ecc8209349b79 (plain) (tree)
1
2
3
4
5
6
7
                                                
                                    
                                                           


                                     
                                                     





                                          
                               
                                                
       


                                                                              

                       
                                                                                                
 
                                                                                          
            
 

                                                        

   
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'
})
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({
          next: () => {
            const stateLabel = this.redundancyAllowed ? $localize`enabled` : $localize`disabled`

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

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