]> git.apps.os.sepia.ceph.com Git - ceph.git/blob
a3116834b5963a5dff892db95b54be951c74e01b
[ceph.git] /
1 import { Component, OnDestroy, OnInit } from '@angular/core';
2
3 import _ from 'lodash';
4 import { Subscription } from 'rxjs';
5
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';
16 import {
17   FeatureTogglesMap$,
18   FeatureTogglesService
19 } from '~/app/shared/services/feature-toggles.service';
20
21 @Component({
22   selector: 'cd-rgw-overview-dashboard',
23   templateUrl: './rgw-overview-dashboard.component.html',
24   styleUrls: ['./rgw-overview-dashboard.component.scss']
25 })
26 export class RgwOverviewDashboardComponent implements OnInit, OnDestroy {
27   interval = new Subscription();
28   permissions: Permissions;
29   enabledFeature$: FeatureTogglesMap$;
30   rgwDaemonCount = 0;
31   rgwRealmCount = 0;
32   rgwZonegroupCount = 0;
33   rgwZoneCount = 0;
34   rgwBucketCount = 0;
35   objectCount = 0;
36   UserCount = 0;
37   totalPoolUsedBytes = 0;
38   averageObjectSize = 0;
39   realmData: any;
40   daemonSub: Subscription;
41   realmSub: Subscription;
42   ZonegroupSub: Subscription;
43   ZoneSUb: Subscription;
44   UserSub: Subscription;
45   HealthSub: Subscription;
46   BucketSub: Subscription;
47
48   constructor(
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
59   ) {
60     this.permissions = this.authStorageService.getPermissions();
61     this.enabledFeature$ = this.featureToggles.get();
62   }
63
64   ngOnInit() {
65     this.interval = this.refreshIntervalService.intervalData$.subscribe(() => {
66       this.daemonSub = this.rgwDaemonService.list().subscribe((data: any) => {
67         this.rgwDaemonCount = data.length;
68       });
69       this.BucketSub = this.rgwBucketService.list().subscribe((data: any) => {
70         this.rgwBucketCount = data.length;
71       });
72       this.UserSub = this.rgwUserService.list().subscribe((data: any) => {
73         this.UserCount = data.length;
74       });
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'];
79       });
80     });
81     this.realmSub = this.rgwRealmService.list().subscribe((data: any) => {
82       this.rgwRealmCount = data['realms'].length;
83     });
84     this.ZonegroupSub = this.rgwZonegroupService.list().subscribe((data: any) => {
85       this.rgwZonegroupCount = data['zonegroups'].length;
86     });
87     this.ZoneSUb = this.rgwZoneService.list().subscribe((data: any) => {
88       this.rgwZoneCount = data['zones'].length;
89     });
90   }
91
92   ngOnDestroy() {
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();
101   }
102 }