]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - 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
c48e82b5 1import { Component, Input } from '@angular/core'
f8b2c1b4 2import { Notifier } from '@app/core'
c48e82b5 3import { I18n } from '@ngx-translate/i18n-polyfill'
b764380a 4import { RedundancyService } from '@app/shared/video/redundancy.service'
c48e82b5
C
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 (
f8b2c1b4 16 private notifier: Notifier,
c48e82b5
C
17 private redundancyService: RedundancyService,
18 private i18n: I18n
19 ) { }
20
21 updateRedundancyState () {
22 this.redundancyService.updateRedundancy(this.host, this.redundancyAllowed)
f8b2c1b4
C
23 .subscribe(
24 () => {
25 const stateLabel = this.redundancyAllowed ? this.i18n('enabled') : this.i18n('disabled')
c48e82b5 26
f8b2c1b4
C
27 this.notifier.success(this.i18n('Redundancy for {{host}} is {{stateLabel}}', { host: this.host, stateLabel }))
28 },
c48e82b5 29
f8b2c1b4
C
30 err => this.notifier.error(err.message)
31 )
c48e82b5
C
32 }
33}