1 import { Component, OnDestroy, OnInit } from '@angular/core';
3 import _ from 'lodash';
4 import { Observable, ReplaySubject, Subscription } 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 { RgwUserService } from '~/app/shared/api/rgw-user.service';
15 import { PrometheusService } from '~/app/shared/api/prometheus.service';
17 import { RgwPromqls as queries } from '~/app/shared/enum/dashboard-promqls.enum';
18 import { HealthService } from '~/app/shared/api/health.service';
19 import { Icons } from '~/app/shared/enum/icons.enum';
20 import { RgwMultisiteService } from '~/app/shared/api/rgw-multisite.service';
21 import { shareReplay, switchMap, tap } from 'rxjs/operators';
22 import { RgwZonegroup } from '../models/rgw-multisite';
25 selector: 'cd-rgw-overview-dashboard',
26 templateUrl: './rgw-overview-dashboard.component.html',
27 styleUrls: ['./rgw-overview-dashboard.component.scss']
29 export class RgwOverviewDashboardComponent implements OnInit, OnDestroy {
32 interval = new Subscription();
33 permissions: Permissions;
36 rgwZonegroupCount = 0;
41 totalPoolUsedBytes = 0;
42 averageObjectSize = 0;
44 daemonSub: Subscription;
45 realmSub: Subscription;
46 multisiteInfo: object[] = [];
47 ZonegroupSub: Subscription;
48 ZoneSUb: Subscription;
49 UserSub: Subscription;
50 HealthSub: Subscription;
51 BucketSub: Subscription;
52 queriesResults: any = {
53 RGW_REQUEST_PER_SECOND: '',
58 timerGetPrometheusDataSub: Subscription;
59 chartTitles = ['Metadata Sync', 'Data Sync'];
63 metadataSyncInfo: string;
64 replicaZonesInfo: any = [];
66 showMultisiteCard = true;
68 multisiteSyncStatus$: Observable<any>;
69 subject = new ReplaySubject<any>();
70 syncCardLoading = true;
73 private authStorageService: AuthStorageService,
74 private healthService: HealthService,
75 private refreshIntervalService: RefreshIntervalService,
76 private rgwDaemonService: RgwDaemonService,
77 private rgwRealmService: RgwRealmService,
78 private rgwZonegroupService: RgwZonegroupService,
79 private rgwZoneService: RgwZoneService,
80 private rgwBucketService: RgwBucketService,
81 private rgwUserService: RgwUserService,
82 private prometheusService: PrometheusService,
83 private rgwMultisiteService: RgwMultisiteService
85 this.permissions = this.authStorageService.getPermissions();
89 this.interval = this.refreshIntervalService.intervalData$.subscribe(() => {
90 this.daemonSub = this.rgwDaemonService.list().subscribe((data: any) => {
91 this.rgwDaemonCount = data.length;
93 this.BucketSub = this.rgwBucketService.list().subscribe((data: any) => {
94 this.rgwBucketCount = data.length;
96 this.UserSub = this.rgwUserService.list().subscribe((data: any) => {
97 this.UserCount = data.length;
99 this.HealthSub = this.healthService.getClusterCapacity().subscribe((data: any) => {
100 this.objectCount = data['total_objects'];
101 this.totalPoolUsedBytes = data['total_pool_bytes_used'];
102 this.averageObjectSize = data['average_object_size'];
104 this.getSyncStatus();
106 this.realmSub = this.rgwRealmService.list().subscribe((data: any) => {
107 this.rgwRealmCount = data['realms'].length;
109 this.ZonegroupSub = this.rgwZonegroupService.list().subscribe((data: any) => {
110 this.rgwZonegroupCount = data['zonegroups'].length;
112 this.ZoneSUb = this.rgwZoneService.list().subscribe((data: any) => {
113 this.rgwZoneCount = data['zones'].length;
115 this.getPrometheusData(this.prometheusService.lastHourDateObject);
116 this.multisiteSyncStatus$ = this.subject.pipe(
118 this.rgwMultisiteService.getSyncStatus().pipe(
120 this.loading = false;
121 this.replicaZonesInfo = data['dataSyncInfo'];
122 this.metadataSyncInfo = data['metadataSyncInfo'];
123 [this.realm, this.zonegroup, this.zone] = data['primaryZoneData'];
128 const zonegroup = new RgwZonegroup();
129 zonegroup.name = this.zonegroup;
130 this.rgwZonegroupService.get(zonegroup).subscribe((data: any) => {
131 this.showMultisiteCard = data['zones'].length !== 1;
132 this.syncCardLoading = false;
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.UserSub.unsubscribe();
147 this.HealthSub.unsubscribe();
148 if (this.timerGetPrometheusDataSub) {
149 this.timerGetPrometheusDataSub.unsubscribe();
153 getPrometheusData(selectedTime: any) {
154 this.queriesResults = this.prometheusService.getPrometheusQueriesData(
166 trackByFn(zone: any) {