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'
|
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 (
|
2018-12-19 16:04:34 +01:00
|
|
|
private notifier: Notifier,
|
2020-08-12 10:40:04 +02:00
|
|
|
private redundancyService: RedundancyService
|
|
|
|
) { }
|
2018-09-11 16:27:07 +02:00
|
|
|
|
|
|
|
updateRedundancyState () {
|
|
|
|
this.redundancyService.updateRedundancy(this.host, this.redundancyAllowed)
|
2018-12-19 16:04:34 +01:00
|
|
|
.subscribe(
|
|
|
|
() => {
|
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
|
|
|
|
2018-12-19 16:04:34 +01:00
|
|
|
err => this.notifier.error(err.message)
|
|
|
|
)
|
2018-09-11 16:27:07 +02:00
|
|
|
}
|
|
|
|
}
|