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

35 lines
1.1 KiB
TypeScript
Raw Normal View History

2018-09-11 16:27:07 +02:00
import { Component, Input } from '@angular/core'
import { Notifier } from '@app/core'
2024-03-04 10:01:52 +01:00
import { FormsModule } from '@angular/forms'
import { PeertubeCheckboxComponent } from '../../../shared/shared-forms/peertube-checkbox.component'
import { RedundancyService } from '@app/shared/shared-main/video/redundancy.service'
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 (
private notifier: Notifier,
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: () => {
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
2021-08-17 11:27:47 +02:00
error: err => this.notifier.error(err.message)
})
2018-09-11 16:27:07 +02:00
}
}