]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/blob
77b49a9ba1806d43fedc44ab7550bd94ba69c5e7
[ceph-ci.git] /
1 import { TitleCasePipe } from '@angular/common';
2 import { Component, OnInit } from '@angular/core';
3 import { RgwMultisiteService } from '~/app/shared/api/rgw-multisite.service';
4 import { CellTemplate } from '~/app/shared/enum/cell-template.enum';
5 import { CdTableColumn } from '~/app/shared/models/cd-table-column';
6
7 @Component({
8   selector: 'cd-rgw-multisite-sync-policy',
9   templateUrl: './rgw-multisite-sync-policy.component.html',
10   styleUrls: ['./rgw-multisite-sync-policy.component.scss']
11 })
12 export class RgwMultisiteSyncPolicyComponent implements OnInit {
13   columns: Array<CdTableColumn> = [];
14   syncPolicyData: any = [];
15
16   constructor(
17     private rgwMultisiteService: RgwMultisiteService,
18     private titleCasePipe: TitleCasePipe
19   ) {}
20
21   ngOnInit(): void {
22     this.columns = [
23       {
24         name: $localize`Group Name`,
25         prop: 'groupName',
26         flexGrow: 1
27       },
28       {
29         name: $localize`Status`,
30         prop: 'status',
31         flexGrow: 1,
32         cellTransformation: CellTemplate.tooltip,
33         customTemplateConfig: {
34           map: {
35             Enabled: { class: 'badge-success', tooltip: 'sync is allowed and enabled' },
36             Allowed: { class: 'badge-info', tooltip: 'sync is allowed' },
37             Forbidden: {
38               class: 'badge-warning',
39               tooltip:
40                 'sync (as defined by this group) is not allowed and can override other groups'
41             }
42           }
43         },
44         pipe: this.titleCasePipe
45       },
46       {
47         name: $localize`Zonegroup`,
48         prop: 'zonegroup',
49         flexGrow: 1
50       },
51       {
52         name: $localize`Bucket`,
53         prop: 'bucket',
54         flexGrow: 1
55       }
56     ];
57
58     this.rgwMultisiteService
59       .getSyncPolicy('', '', true)
60       .subscribe((allSyncPolicyData: Array<Object>) => {
61         if (allSyncPolicyData && allSyncPolicyData.length > 0) {
62           allSyncPolicyData.forEach((policy) => {
63             this.syncPolicyData.push({
64               groupName: policy['id'],
65               status: policy['status'],
66               bucket: policy['bucketName'],
67               zonegroup: ''
68             });
69           });
70           this.syncPolicyData = [...this.syncPolicyData];
71         }
72       });
73   }
74 }