aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/follows/shared/redundancy-checkbox.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+admin/follows/shared/redundancy-checkbox.component.ts')
-rw-r--r--client/src/app/+admin/follows/shared/redundancy-checkbox.component.ts42
1 files changed, 42 insertions, 0 deletions
diff --git a/client/src/app/+admin/follows/shared/redundancy-checkbox.component.ts b/client/src/app/+admin/follows/shared/redundancy-checkbox.component.ts
new file mode 100644
index 000000000..ff4725e91
--- /dev/null
+++ b/client/src/app/+admin/follows/shared/redundancy-checkbox.component.ts
@@ -0,0 +1,42 @@
1import { Component, Input } from '@angular/core'
2import { AuthService } from '@app/core'
3import { RestExtractor } from '@app/shared/rest'
4import { RedirectService } from '@app/core/routing/redirect.service'
5import { NotificationsService } from 'angular2-notifications'
6import { I18n } from '@ngx-translate/i18n-polyfill'
7import { 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})
14export 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}