2018-09-11 16:27:07 +02:00
|
|
|
import { Component, Input } from '@angular/core'
|
2018-12-19 16:04:34 +01:00
|
|
|
import { Notifier } from '@app/core'
|
2020-06-23 14:10:17 +02:00
|
|
|
import { RedundancyService } from '@app/shared/shared-main'
|
2024-03-04 10:01:52 +01:00
|
|
|
import { FormsModule } from '@angular/forms'
|
|
|
|
import { PeertubeCheckboxComponent } from '../../../shared/shared-forms/peertube-checkbox.component'
|
2018-09-11 16:27:07 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'my-redundancy-checkbox',
|
2024-03-04 10:01:52 +01:00
|
|
|
templateUrl: './redundancy-checkbox.component.html',
|
|
|
|
standalone: true,
|
|
|
|
imports: [ PeertubeCheckboxComponent, FormsModule ]
|
2018-09-11 16:27:07 +02:00
|
|
|
})
|
|
|
|
export class RedundancyCheckboxComponent {
|
|
|
|
@Input() redundancyAllowed: boolean
|
|
|
|
@Input() host: string
|
|
|
|
|
|
|
|
constructor (
|
2018-12-19 16:04:34 +01:00
|
|
|
private notifier: Notifier,
|
2020-08-12 10:40:04 +02:00
|
|
|
private redundancyService: RedundancyService
|
2021-08-17 14:42:53 +02:00
|
|
|
) { }
|
2018-09-11 16:27:07 +02:00
|
|
|
|
|
|
|
updateRedundancyState () {
|
|
|
|
this.redundancyService.updateRedundancy(this.host, this.redundancyAllowed)
|
2021-08-17 11:27:47 +02:00
|
|
|
.subscribe({
|
|
|
|
next: () => {
|
2020-08-12 10:40:04 +02:00
|
|
|
const stateLabel = this.redundancyAllowed ? $localize`enabled` : $localize`disabled`
|
2018-09-11 16:27:07 +02:00
|
|
|
|
2020-08-12 10:40:04 +02:00
|
|
|
this.notifier.success($localize`Redundancy for ${this.host} is ${stateLabel}`)
|
2018-12-19 16:04:34 +01:00
|
|
|
},
|
2018-09-11 16:27:07 +02:00
|
|
|
|
2021-08-17 11:27:47 +02:00
|
|
|
error: err => this.notifier.error(err.message)
|
|
|
|
})
|
2018-09-11 16:27:07 +02:00
|
|
|
}
|
|
|
|
}
|