-import { Component, OnInit } from '@angular/core';
+import { Component, OnInit, OnDestroy } from '@angular/core';
import { GridModule, TilesModule } from 'carbon-components-angular';
import { OverviewStorageCardComponent } from './storage-card/overview-storage-card.component';
import { HealthService } from '~/app/shared/api/health.service';
templateUrl: './overview.component.html',
styleUrl: './overview.component.scss'
})
-export class OverviewComponent implements OnInit {
+export class OverviewComponent implements OnInit, OnDestroy {
totalCapacity: number;
usedCapacity: number;
private destroy$ = new Subject<void>();
-
- constructor(private healthService: HealthService, private refreshIntervalService: RefreshIntervalService) {}
+ constructor(
+ private healthService: HealthService,
+ private refreshIntervalService: RefreshIntervalService
+ ) {}
ngOnInit(): void {
- this.refreshIntervalObs(() => this.healthService.getHealthSnapshot()).subscribe({
+ this.refreshIntervalObs(() => this.healthService.getHealthSnapshot()).subscribe({
next: (healthData: HealthSnapshotMap) => {
- this.totalCapacity = healthData?.pgmap?.bytes_total;
- this.usedCapacity = healthData?.pgmap?.bytes_used;
- }});
+ this.totalCapacity = healthData?.pgmap?.bytes_total;
+ this.usedCapacity = healthData?.pgmap?.bytes_used;
+ }
+ });
}
- refreshIntervalObs(fn: Function) {
- return this.refreshIntervalService.intervalData$.pipe(
- exhaustMap(() => fn().pipe(catchError(() => EMPTY))),
- takeUntil(this.destroy$)
- );
- }
+ refreshIntervalObs(fn: Function) {
+ return this.refreshIntervalService.intervalData$.pipe(
+ exhaustMap(() => fn().pipe(catchError(() => EMPTY))),
+ takeUntil(this.destroy$)
+ );
+ }
ngOnDestroy() {
this.destroy$.next();
this.destroy$.complete();
}
-
}
class="cds--type-body-02"
i18n>{{usedRawUnit}} of {{totalRaw}} {{totalRawUnit}} used</span>
</h5>
- <cds-tooltip
- [autoAlign]="true"
- class="cds-mt-5 "
- title=""
- [caret]="true"
- description="An info tip about raw capacity"
- i18n-description>
- <cds-checkbox
- [checked]="isRawCapacity"
- (checkedChange)="toggleRawCapacity($event)"
+ <cds-checkbox
+ [checked]="isRawCapacity"
+ (checkedChange)="toggleRawCapacity($event)">
+ <cds-tooltip-definition
+ [autoAlign]="true"
+ [highContrast]="true"
+ [openOnHover]="false"
+ [dropShadow]="true"
+ title=""
+ [caret]="true"
+ description="Raw capacity includes all physical storage before replication or overhead."
+ i18n-description
i18n>
Raw capacity
- </cds-checkbox>
- </cds-tooltip>
+ </cds-tooltip-definition>
+ </cds-checkbox>
</div>
<ibm-meter-chart
[options]="options"
// }
/**
- * 1. Fetch snapshot query -> [pass total and used raw]
- * 2. Show the usage title -> always fixed
- * 3. The chart total -> raw total always fixed
* 4. Set data for block, file , object, all -> raw, sep queries
* 5. Set data for block, file object + replicated -> usable
* 6. Dont show what is 0
meter: {
proportional: {
total: null,
- unit: 'GB',
+ unit: '',
breakdownFormatter: (_e) => null,
totalFormatter: (_e) => null
}
allData = [
{
group: StorageType.BLOCK,
- value: 100,
+ value: 100
},
{
group: StorageType.FILE,
},
{
group: StorageType.OBJECT,
- value: 60 }
+ value: 60
+ }
];
dropdownItems = [
{ content: StorageType.ALL },
constructor(private dimlessBinaryPipe: DimlessBinaryPipe) {}
-ngOnChanges(): void {
- if (this.total == null || this.used == null) return;
+ ngOnChanges(): void {
+ if (this.total == null || this.used == null) return;
- const totalRaw = this.dimlessBinaryPipe.transform(this.total);
- const usedRaw = this.dimlessBinaryPipe.transform(this.used);
+ const totalRaw = this.dimlessBinaryPipe.transform(this.total);
+ const usedRaw = this.dimlessBinaryPipe.transform(this.used);
- const [totalValue, totalUnit] = totalRaw.split(/\s+/);
- const [usedValue, usedUnit] = usedRaw.split(/\s+/);
+ const [totalValue, totalUnit] = totalRaw.split(/\s+/);
+ const [usedValue, usedUnit] = usedRaw.split(/\s+/);
- const cleanedTotal = Number(totalValue.replace(/,/g, '').trim());
+ const cleanedTotal = Number(totalValue.replace(/,/g, '').trim());
- if (Number.isNaN(cleanedTotal)) return;
+ if (Number.isNaN(cleanedTotal)) return;
- this.totalRaw = totalValue;
- this.totalRawUnit = totalUnit;
- this.usedRaw = usedValue;
- this.usedRawUnit = usedUnit;
+ this.totalRaw = totalValue;
+ this.totalRawUnit = totalUnit;
+ this.usedRaw = usedValue;
+ this.usedRawUnit = usedUnit;
- // chart reacts to 'options' and 'data' changes only, hence mandatory to replace whole object
- this.options = {
- ...this.options,
- meter: {
- ...this.options.meter,
- proportional: {
- ...this.options.meter.proportional,
- total: cleanedTotal,
- unit: totalUnit
+ // chart reacts to 'options' and 'data' object changes only, hence mandatory to replace whole object
+ this.options = {
+ ...this.options,
+ meter: {
+ ...this.options.meter,
+ proportional: {
+ ...this.options.meter.proportional,
+ total: cleanedTotal,
+ unit: totalUnit
+ }
}
- }
- };
-}
+ };
+ }
toggleRawCapacity(isChecked: boolean) {
this.isRawCapacity = isChecked;