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'
|
2018-09-11 16:27:07 +02:00
|
|
|
import { I18n } from '@ngx-translate/i18n-polyfill'
|
2020-01-10 10:11:28 +01:00
|
|
|
import { RedundancyService } from '@app/shared/video/redundancy.service'
|
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,
|
2018-09-11 16:27:07 +02:00
|
|
|
private redundancyService: RedundancyService,
|
|
|
|
private i18n: I18n
|
|
|
|
) { }
|
|
|
|
|
|
|
|
updateRedundancyState () {
|
|
|
|
this.redundancyService.updateRedundancy(this.host, this.redundancyAllowed)
|
2018-12-19 16:04:34 +01:00
|
|
|
.subscribe(
|
|
|
|
() => {
|
|
|
|
const stateLabel = this.redundancyAllowed ? this.i18n('enabled') : this.i18n('disabled')
|
2018-09-11 16:27:07 +02:00
|
|
|
|
2018-12-19 16:04:34 +01:00
|
|
|
this.notifier.success(this.i18n('Redundancy for {{host}} is {{stateLabel}}', { host: this.host, stateLabel }))
|
|
|
|
},
|
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
|
|
|
}
|
|
|
|
}
|