]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - client/src/app/+admin/follows/shared/redundancy-checkbox.component.ts
Merge branch 'release/2.1.0' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / follows / shared / redundancy-checkbox.component.ts
... / ...
CommitLineData
1import { Component, Input } from '@angular/core'
2import { Notifier } from '@app/core'
3import { I18n } from '@ngx-translate/i18n-polyfill'
4import { RedundancyService } from '@app/shared/video/redundancy.service'
5
6@Component({
7 selector: 'my-redundancy-checkbox',
8 templateUrl: './redundancy-checkbox.component.html',
9 styleUrls: [ './redundancy-checkbox.component.scss' ]
10})
11export class RedundancyCheckboxComponent {
12 @Input() redundancyAllowed: boolean
13 @Input() host: string
14
15 constructor (
16 private notifier: Notifier,
17 private redundancyService: RedundancyService,
18 private i18n: I18n
19 ) { }
20
21 updateRedundancyState () {
22 this.redundancyService.updateRedundancy(this.host, this.redundancyAllowed)
23 .subscribe(
24 () => {
25 const stateLabel = this.redundancyAllowed ? this.i18n('enabled') : this.i18n('disabled')
26
27 this.notifier.success(this.i18n('Redundancy for {{host}} is {{stateLabel}}', { host: this.host, stateLabel }))
28 },
29
30 err => this.notifier.error(err.message)
31 )
32 }
33}