import { RgwRealmService } from '~/app/shared/api/rgw-realm.service';
import { RgwZoneService } from '~/app/shared/api/rgw-zone.service';
import { RgwZonegroupService } from '~/app/shared/api/rgw-zonegroup.service';
+import { ToastrModule } from 'ngx-toastr';
+import { SharedModule } from '~/app/shared/shared.module';
+import { ActivatedRoute } from '@angular/router';
describe('RgwOverviewDashboardComponent', () => {
let component: RgwOverviewDashboardComponent;
let listZonesSpy: jest.SpyInstance;
let fetchAndTransformBucketsSpy: jest.SpyInstance;
let totalBucketsAndUsersSpy: jest.SpyInstance;
+ let params: Record<string, any>;
const totalNumObjectsSubject = new BehaviorSubject<number>(290);
const totalUsedCapacitySubject = new BehaviorSubject<number>(9338880);
averageObjectSize$: averageObjectSizeSubject.asObservable(),
getTotalBucketsAndUsersLength: jest.fn()
}
+ },
+ {
+ provide: ActivatedRoute,
+ useValue: { params: { subscribe: (fn: Function) => fn(params) } }
}
],
- imports: [HttpClientTestingModule]
+ imports: [HttpClientTestingModule, ToastrModule.forRoot(), SharedModule]
}).compileComponents();
fixture = TestBed.createComponent(RgwOverviewDashboardComponent);
component = fixture.componentInstance;
import { Icons } from '~/app/shared/enum/icons.enum';
import { RgwMultisiteService } from '~/app/shared/api/rgw-multisite.service';
import { catchError, shareReplay, switchMap, tap } from 'rxjs/operators';
+import { NotificationService } from '~/app/shared/services/notification.service';
+import { NotificationType } from '~/app/shared/enum/notification-type.enum';
@Component({
selector: 'cd-rgw-overview-dashboard',
loading = true;
multisiteSyncStatus$: Observable<any>;
subject = new ReplaySubject<any>();
- syncCardLoading = true;
fetchDataSub: Subscription;
constructor(
private rgwZoneService: RgwZoneService,
private rgwBucketService: RgwBucketService,
private prometheusService: PrometheusService,
- private rgwMultisiteService: RgwMultisiteService
+ private rgwMultisiteService: RgwMultisiteService,
+ private notificationService: NotificationService
) {
this.permissions = this.authStorageService.getPermissions();
}
this.averageObjectSize = averageSize;
this.rgwBucketCount = bucketData.buckets_count;
this.UserCount = bucketData.users_count;
- this.getSyncStatus();
});
+ this.getSyncStatus();
});
this.realmSub = this.rgwRealmService.list().subscribe((data: any) => {
this.rgwRealmCount = data['realms'].length;
this.metadataSyncInfo = data['metadataSyncInfo'];
if (this.replicaZonesInfo.length === 0) {
this.showMultisiteCard = false;
- this.syncCardLoading = false;
this.loading = false;
}
[this.realm, this.zonegroup, this.zone] = data['primaryZoneData'];
}),
catchError((err) => {
- this.showMultisiteCard = false;
- this.syncCardLoading = false;
- this.loading = false;
err.preventDefault();
+ this.loading = false;
+ this.showMultisiteCard = false;
+ const errorMessage = $localize`Unable to fetch sync status`;
+ this.notificationService.show(
+ NotificationType.error,
+ errorMessage,
+ err.error.detail || err.error.message
+ );
return of(true);
})
)