]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+admin/follows/shared/redundancy-checkbox.component.ts
Basic video redundancy implementation
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / follows / shared / redundancy-checkbox.component.ts
1 import { Component, Input } from '@angular/core'
2 import { AuthService } from '@app/core'
3 import { RestExtractor } from '@app/shared/rest'
4 import { RedirectService } from '@app/core/routing/redirect.service'
5 import { NotificationsService } from 'angular2-notifications'
6 import { I18n } from '@ngx-translate/i18n-polyfill'
7 import { RedundancyService } from '@app/+admin/follows/shared/redundancy.service'
8
9 @Component({
10 selector: 'my-redundancy-checkbox',
11 templateUrl: './redundancy-checkbox.component.html',
12 styleUrls: [ './redundancy-checkbox.component.scss' ]
13 })
14 export class RedundancyCheckboxComponent {
15 @Input() redundancyAllowed: boolean
16 @Input() host: string
17
18 constructor (
19 private authService: AuthService,
20 private restExtractor: RestExtractor,
21 private redirectService: RedirectService,
22 private notificationsService: NotificationsService,
23 private redundancyService: RedundancyService,
24 private i18n: I18n
25 ) { }
26
27 updateRedundancyState () {
28 this.redundancyService.updateRedundancy(this.host, this.redundancyAllowed)
29 .subscribe(
30 () => {
31 const stateLabel = this.redundancyAllowed ? this.i18n('enabled') : this.i18n('disabled')
32
33 this.notificationsService.success(
34 this.i18n('Success'),
35 this.i18n('Redundancy for {{host}} is {{stateLabel}}', { host: this.host, stateLabel })
36 )
37 },
38
39 err => this.notificationsService.error(this.i18n('Error'), err.message)
40 )
41 }
42 }