1 import { Component, OnDestroy, OnInit } from '@angular/core';
3 import _ from 'lodash';
4 import { Subscription } from 'rxjs';
6 import { HealthService } from '~/app/shared/api/health.service';
7 import { Permissions } from '~/app/shared/models/permissions';
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 { AuthStorageService } from '~/app/shared/services/auth-storage.service';
19 } from '~/app/shared/services/feature-toggles.service';
22 selector: 'cd-rgw-overview-dashboard',
23 templateUrl: './rgw-overview-dashboard.component.html',
24 styleUrls: ['./rgw-overview-dashboard.component.scss']
26 export class RgwOverviewDashboardComponent implements OnInit, OnDestroy {
27 interval = new Subscription();
28 permissions: Permissions;
29 enabledFeature$: FeatureTogglesMap$;
32 rgwZonegroupCount = 0;
37 totalPoolUsedBytes = 0;
38 averageObjectSize = 0;
40 daemonSub: Subscription;
41 realmSub: Subscription;
42 ZonegroupSub: Subscription;
43 ZoneSUb: Subscription;
44 UserSub: Subscription;
45 HealthSub: Subscription;
46 BucketSub: Subscription;
49 private authStorageService: AuthStorageService,
50 private featureToggles: FeatureTogglesService,
51 private healthService: HealthService,
52 private refreshIntervalService: RefreshIntervalService,
53 private rgwDaemonService: RgwDaemonService,
54 private rgwRealmService: RgwRealmService,
55 private rgwZonegroupService: RgwZonegroupService,
56 private rgwZoneService: RgwZoneService,
57 private rgwBucketService: RgwBucketService,
58 private rgwUserService: RgwUserService
60 this.permissions = this.authStorageService.getPermissions();
61 this.enabledFeature$ = this.featureToggles.get();
65 this.interval = this.refreshIntervalService.intervalData$.subscribe(() => {
66 this.daemonSub = this.rgwDaemonService.list().subscribe((data: any) => {
67 this.rgwDaemonCount = data.length;
69 this.BucketSub = this.rgwBucketService.list().subscribe((data: any) => {
70 this.rgwBucketCount = data.length;
72 this.UserSub = this.rgwUserService.list().subscribe((data: any) => {
73 this.UserCount = data.length;
75 this.HealthSub = this.healthService.getClusterCapacity().subscribe((data: any) => {
76 this.objectCount = data['total_objects'];
77 this.totalPoolUsedBytes = data['total_pool_bytes_used'];
78 this.averageObjectSize = data['average_object_size'];
81 this.realmSub = this.rgwRealmService.list().subscribe((data: any) => {
82 this.rgwRealmCount = data['realms'].length;
84 this.ZonegroupSub = this.rgwZonegroupService.list().subscribe((data: any) => {
85 this.rgwZonegroupCount = data['zonegroups'].length;
87 this.ZoneSUb = this.rgwZoneService.list().subscribe((data: any) => {
88 this.rgwZoneCount = data['zones'].length;
93 this.interval.unsubscribe();
94 this.daemonSub.unsubscribe();
95 this.realmSub.unsubscribe();
96 this.ZonegroupSub.unsubscribe();
97 this.ZoneSUb.unsubscribe();
98 this.BucketSub.unsubscribe();
99 this.UserSub.unsubscribe();
100 this.HealthSub.unsubscribe();