1 import { Component, OnDestroy, OnInit } from '@angular/core';
3 import _ from 'lodash';
4 import { Observable, ReplaySubject, Subscription, of } from 'rxjs';
6 import { Permissions } from '~/app/shared/models/permissions';
7 import { AuthStorageService } from '~/app/shared/services/auth-storage.service';
8 import { RefreshIntervalService } from '~/app/shared/services/refresh-interval.service';
9 import { RgwDaemonService } from '~/app/shared/api/rgw-daemon.service';
10 import { RgwRealmService } from '~/app/shared/api/rgw-realm.service';
11 import { RgwZoneService } from '~/app/shared/api/rgw-zone.service';
12 import { RgwZonegroupService } from '~/app/shared/api/rgw-zonegroup.service';
13 import { RgwBucketService } from '~/app/shared/api/rgw-bucket.service';
14 import { PrometheusService } from '~/app/shared/api/prometheus.service';
16 import { RgwPromqls as queries } from '~/app/shared/enum/dashboard-promqls.enum';
17 import { HealthService } from '~/app/shared/api/health.service';
18 import { Icons } from '~/app/shared/enum/icons.enum';
19 import { RgwMultisiteService } from '~/app/shared/api/rgw-multisite.service';
20 import { catchError, shareReplay, switchMap, tap } from 'rxjs/operators';
23 selector: 'cd-rgw-overview-dashboard',
24 templateUrl: './rgw-overview-dashboard.component.html',
25 styleUrls: ['./rgw-overview-dashboard.component.scss']
27 export class RgwOverviewDashboardComponent implements OnInit, OnDestroy {
30 interval = new Subscription();
31 permissions: Permissions;
34 rgwZonegroupCount = 0;
39 totalPoolUsedBytes = 0;
40 averageObjectSize = 0;
42 daemonSub: Subscription;
43 realmSub: Subscription;
44 multisiteInfo: object[] = [];
45 ZonegroupSub: Subscription;
46 ZoneSUb: Subscription;
47 HealthSub: Subscription;
48 BucketSub: Subscription;
49 queriesResults: any = {
50 RGW_REQUEST_PER_SECOND: '',
55 timerGetPrometheusDataSub: Subscription;
56 chartTitles = ['Metadata Sync', 'Data Sync'];
60 metadataSyncInfo: string;
61 replicaZonesInfo: any = [];
63 showMultisiteCard = true;
65 multisiteSyncStatus$: Observable<any>;
66 subject = new ReplaySubject<any>();
67 syncCardLoading = true;
70 private authStorageService: AuthStorageService,
71 private healthService: HealthService,
72 private refreshIntervalService: RefreshIntervalService,
73 private rgwDaemonService: RgwDaemonService,
74 private rgwRealmService: RgwRealmService,
75 private rgwZonegroupService: RgwZonegroupService,
76 private rgwZoneService: RgwZoneService,
77 private rgwBucketService: RgwBucketService,
78 private prometheusService: PrometheusService,
79 private rgwMultisiteService: RgwMultisiteService
81 this.permissions = this.authStorageService.getPermissions();
85 this.interval = this.refreshIntervalService.intervalData$.subscribe(() => {
86 this.daemonSub = this.rgwDaemonService.list().subscribe((data: any) => {
87 this.rgwDaemonCount = data.length;
89 this.HealthSub = this.healthService.getClusterCapacity().subscribe((data: any) => {
90 this.objectCount = data['total_objects'];
91 this.totalPoolUsedBytes = data['total_pool_bytes_used'];
92 this.averageObjectSize = data['average_object_size'];
96 this.BucketSub = this.rgwBucketService
97 .getTotalBucketsAndUsersLength()
98 .subscribe((data: any) => {
99 this.rgwBucketCount = data['buckets_count'];
100 this.UserCount = data['users_count'];
102 this.realmSub = this.rgwRealmService.list().subscribe((data: any) => {
103 this.rgwRealmCount = data['realms'].length;
105 this.ZonegroupSub = this.rgwZonegroupService.list().subscribe((data: any) => {
106 this.rgwZonegroupCount = data['zonegroups'].length;
108 this.ZoneSUb = this.rgwZoneService.list().subscribe((data: any) => {
109 this.rgwZoneCount = data['zones'].length;
111 this.getPrometheusData(this.prometheusService.lastHourDateObject);
112 this.multisiteSyncStatus$ = this.subject.pipe(
114 this.rgwMultisiteService.getSyncStatus().pipe(
116 this.loading = false;
117 this.replicaZonesInfo = data['dataSyncInfo'];
118 this.metadataSyncInfo = data['metadataSyncInfo'];
119 if (this.replicaZonesInfo.length === 0) {
120 this.showMultisiteCard = false;
121 this.syncCardLoading = false;
122 this.loading = false;
124 [this.realm, this.zonegroup, this.zone] = data['primaryZoneData'];
126 catchError((err) => {
127 this.showMultisiteCard = false;
128 this.syncCardLoading = false;
129 this.loading = false;
130 err.preventDefault();
140 this.interval.unsubscribe();
141 this.daemonSub.unsubscribe();
142 this.realmSub.unsubscribe();
143 this.ZonegroupSub.unsubscribe();
144 this.ZoneSUb.unsubscribe();
145 this.BucketSub.unsubscribe();
146 this.HealthSub.unsubscribe();
147 this.prometheusService.unsubscribe();
150 getPrometheusData(selectedTime: any) {
151 this.queriesResults = this.prometheusService.getPrometheusQueriesData(
163 trackByFn(zone: any) {