forceIdentifier="true"
selectionType="single"
[hasDetails]="true"
+ [autoReload]="false"
+ [status]="tableStatus"
+ (fetchData)="getTargets()"
(setExpandedRow)="setExpandedRow($event)"
(updateSelection)="updateSelection($event)">
<div class="table-actions btn-toolbar">
spyOn(iscsiService, 'status').and.returnValue(of({ available: true }));
spyOn(iscsiService, 'version').and.returnValue(of({ ceph_iscsi_config_version: 11 }));
+ spyOn(component, 'setTableRefreshTimeout').and.stub();
});
it('should create', () => {
summaryService['summaryDataSource'].error(undefined);
expect(component.table.reset).toHaveBeenCalled();
});
+
+ it('should call settings on the getTargets methods', () => {
+ spyOn(iscsiService, 'settings').and.callThrough();
+ component.getTargets();
+ expect(iscsiService.settings).toHaveBeenCalled();
+ });
});
describe('handling of executing tasks', () => {
-import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
+import { Component, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import _ from 'lodash';
private notAvailablePipe: NotAvailablePipe,
private modalService: ModalService,
private taskWrapper: TaskWrapperService,
- public actionLabels: ActionLabelsI18n
+ public actionLabels: ActionLabelsI18n,
+ protected ngZone: NgZone
) {
- super();
+ super(ngZone);
this.permission = this.authStorageService.getPermissions().iscsi;
this.tableActions = [
this.iscsiService.status().subscribe((result: any) => {
this.available = result.available;
- if (result.available) {
- this.iscsiService.version().subscribe((res: any) => {
- this.cephIscsiConfigVersion = res['ceph_iscsi_config_version'];
- this.taskListService.init(
- () => this.iscsiService.listTargets(),
- (resp) => this.prepareResponse(resp),
- (targets) => (this.targets = targets),
- () => this.onFetchError(),
- this.taskFilter,
- this.itemFilter,
- this.builders
- );
- });
-
- this.iscsiService.settings().subscribe((settings: any) => {
- this.settings = settings;
- });
- } else {
+ if (!result.available) {
this.status = result.message;
}
});
}
+ getTargets() {
+ if (this.available) {
+ this.setTableRefreshTimeout();
+ this.iscsiService.version().subscribe((res: any) => {
+ this.cephIscsiConfigVersion = res['ceph_iscsi_config_version'];
+ });
+ this.taskListService.init(
+ () => this.iscsiService.listTargets(),
+ (resp) => this.prepareResponse(resp),
+ (targets) => (this.targets = targets),
+ () => this.onFetchError(),
+ this.taskFilter,
+ this.itemFilter,
+ this.builders
+ );
+
+ this.iscsiService.settings().subscribe((settings: any) => {
+ this.settings = settings;
+ });
+ }
+ }
+
ngOnDestroy() {
if (this.summaryDataSubscription) {
this.summaryDataSubscription.unsubscribe();
rgwBucketServiceListSpy.and.returnValue(of([]));
fixture = TestBed.createComponent(RgwBucketListComponent);
component = fixture.componentInstance;
- spyOn(component, 'timeConditionReached').and.stub();
+ spyOn(component, 'setTableRefreshTimeout').and.stub();
fixture.detectChanges();
});
import { RgwBucketService } from '~/app/shared/api/rgw-bucket.service';
import { ListWithDetails } from '~/app/shared/classes/list-with-details.class';
-import { TableStatus } from '~/app/shared/classes/table-status';
import { CriticalConfirmationModalComponent } from '~/app/shared/components/critical-confirmation-modal/critical-confirmation-modal.component';
import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
import { TableComponent } from '~/app/shared/datatable/table/table.component';
columns: CdTableColumn[] = [];
buckets: object[] = [];
selection: CdTableSelection = new CdTableSelection();
- tableStatus = new TableStatus();
staleTimeout: number;
constructor(
private modalService: ModalService,
private urlBuilder: URLBuilderService,
public actionLabels: ActionLabelsI18n,
- private ngZone: NgZone
+ protected ngZone: NgZone
) {
- super();
+ super(ngZone);
}
ngOnInit() {
canBePrimary: (selection: CdTableSelection) => selection.hasMultiSelection
};
this.tableActions = [addAction, editAction, deleteAction];
- this.timeConditionReached();
+ this.setTableRefreshTimeout();
}
transformBucketData() {
});
}
- timeConditionReached() {
- clearTimeout(this.staleTimeout);
- this.ngZone.runOutsideAngular(() => {
- this.staleTimeout = window.setTimeout(() => {
- this.ngZone.run(() => {
- this.tableStatus = new TableStatus(
- 'warning',
- $localize`The bucket list data might be stale. If needed, you can manually reload it.`
- );
- });
- }, 10000);
- });
- }
-
getBucketList(context: CdTableFetchDataContext) {
- this.tableStatus = new TableStatus();
- this.timeConditionReached();
+ this.setTableRefreshTimeout();
this.rgwBucketService.list().subscribe(
(resp: object[]) => {
this.buckets = resp;
rgwUserServiceListSpy.and.returnValue(of([]));
fixture = TestBed.createComponent(RgwUserListComponent);
component = fixture.componentInstance;
- spyOn(component, 'timeConditionReached').and.stub();
+ spyOn(component, 'setTableRefreshTimeout').and.stub();
fixture.detectChanges();
});
import { RgwUserService } from '~/app/shared/api/rgw-user.service';
import { ListWithDetails } from '~/app/shared/classes/list-with-details.class';
-import { TableStatus } from '~/app/shared/classes/table-status';
import { CriticalConfirmationModalComponent } from '~/app/shared/components/critical-confirmation-modal/critical-confirmation-modal.component';
import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
import { TableComponent } from '~/app/shared/datatable/table/table.component';
columns: CdTableColumn[] = [];
users: object[] = [];
selection: CdTableSelection = new CdTableSelection();
- tableStatus = new TableStatus();
staleTimeout: number;
constructor(
private modalService: ModalService,
private urlBuilder: URLBuilderService,
public actionLabels: ActionLabelsI18n,
- private ngZone: NgZone
+ protected ngZone: NgZone
) {
- super();
+ super(ngZone);
}
ngOnInit() {
canBePrimary: (selection: CdTableSelection) => selection.hasMultiSelection
};
this.tableActions = [addAction, editAction, deleteAction];
- this.timeConditionReached();
- }
-
- timeConditionReached() {
- clearTimeout(this.staleTimeout);
- this.ngZone.runOutsideAngular(() => {
- this.staleTimeout = window.setTimeout(() => {
- this.ngZone.run(() => {
- this.tableStatus = new TableStatus(
- 'warning',
- $localize`The user list data might be stale. If needed, you can manually reload it.`
- );
- });
- }, 10000);
- });
+ this.setTableRefreshTimeout();
}
getUserList(context: CdTableFetchDataContext) {
- this.tableStatus = new TableStatus();
- this.timeConditionReached();
+ this.setTableRefreshTimeout();
this.rgwUserService.list().subscribe(
(resp: object[]) => {
this.users = resp;
+import { NgZone } from '@angular/core';
+
+import { TableStatus } from './table-status';
+
export class ListWithDetails {
expandedRow: any;
+ staleTimeout: number;
+ tableStatus: TableStatus;
+
+ constructor(protected ngZone?: NgZone) {}
setExpandedRow(expandedRow: any) {
this.expandedRow = expandedRow;
}
+
+ setTableRefreshTimeout() {
+ clearTimeout(this.staleTimeout);
+ this.ngZone.runOutsideAngular(() => {
+ this.staleTimeout = window.setTimeout(() => {
+ this.ngZone.run(() => {
+ this.tableStatus = new TableStatus(
+ 'warning',
+ $localize`The user list data might be stale. If needed, you can manually reload it.`
+ );
+ });
+ }, 10000);
+ });
+ }
}