PeerTube/client/src/app/+admin/follows/shared/redundancy-checkbox.compone...

32 lines
941 B
TypeScript
Raw Normal View History

2018-09-11 16:27:07 +02:00
import { Component, Input } from '@angular/core'
import { Notifier } from '@app/core'
2020-06-23 14:10:17 +02:00
import { RedundancyService } from '@app/shared/shared-main'
2018-09-11 16:27:07 +02:00
@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
) { }
2018-09-11 16:27:07 +02:00
updateRedundancyState () {
this.redundancyService.updateRedundancy(this.host, this.redundancyAllowed)
.subscribe(
() => {
const stateLabel = this.redundancyAllowed ? $localize`enabled` : $localize`disabled`
2018-09-11 16:27:07 +02:00
this.notifier.success($localize`Redundancy for ${this.host} is ${stateLabel}`)
},
2018-09-11 16:27:07 +02:00
err => this.notifier.error(err.message)
)
2018-09-11 16:27:07 +02:00
}
}