* Check if data is accessible, otherwise set grafanaId to undefined.
* Catch errors in 'Clients' tab and stop loading spinner. Display ViewCacheStatus Exception.
* Render the 'Enabled' column using the checkIcon cell template as other lists do.
Fixes: https://tracker.ceph.com/issues/40925
Signed-off-by: Volker Theile <vtheile@suse.com>
<cd-table [data]="clients.data"
[columns]="clients.columns"
- (fetchData)="refresh()"
+ (fetchData)="refresh($event)"
selectionType="single"
(updateSelection)="updateSelection($event)">
<cd-table-actions class="table-actions"
import { NotificationType } from '../../../shared/enum/notification-type.enum';
import { ViewCacheStatus } from '../../../shared/enum/view-cache-status.enum';
import { CdTableAction } from '../../../shared/models/cd-table-action';
+import { CdTableFetchDataContext } from '../../../shared/models/cd-table-fetch-data-context';
import { CdTableSelection } from '../../../shared/models/cd-table-selection';
import { Permission } from '../../../shared/models/permissions';
import { AuthStorageService } from '../../../shared/services/auth-storage.service';
this.viewCacheStatus = ViewCacheStatus.ValueNone;
}
- refresh() {
- this.cephfsService.getClients(this.id).subscribe((data: any) => {
- this.viewCacheStatus = data.status;
- this.clients.data = data.data;
- });
+ refresh(context?: CdTableFetchDataContext) {
+ this.cephfsService.getClients(this.id).subscribe(
+ (data: any) => {
+ this.viewCacheStatus = data.status;
+ this.clients.data = data.data;
+ },
+ () => {
+ this.viewCacheStatus = ViewCacheStatus.ValueException;
+ if (context) {
+ context.error();
+ }
+ }
+ );
}
updateSelection(selection: CdTableSelection) {
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
+import * as _ from 'lodash';
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import { ProgressbarModule } from 'ngx-bootstrap/progressbar';
import { TabsModule } from 'ngx-bootstrap/tabs';
import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper';
+import { CdTableSelection } from '../../../shared/models/cd-table-selection';
import { SharedModule } from '../../../shared/shared.module';
import { CephfsDetailComponent } from './cephfs-detail.component';
it('should create', () => {
expect(component).toBeTruthy();
});
+
+ it('should resist invalid mds info', () => {
+ component.selection = new CdTableSelection();
+ component.selection.selected = [
+ {
+ mdsmap: {
+ info: {}
+ }
+ }
+ ];
+ component.selection.update();
+ component.ngOnChanges();
+ expect(_.isUndefined(component.grafanaId)).toBeTruthy();
+ });
});
if (this.selection.hasSelection) {
this.selectedItem = this.selection.first();
const mdsInfo: any[] = this.selectedItem.mdsmap.info;
- this.grafanaId = Object.values(mdsInfo)[0].name;
+ const values = Object.values(mdsInfo);
+ this.grafanaId = values.length ? _.first(values).name : undefined;
if (this.id !== this.selectedItem.id) {
this.id = this.selectedItem.id;
this.pools.data = [];
this.standbys = [];
this.mdsCounters = {};
+ this.clientCount = 0;
}
+
+ // Immediately refresh the displayed data, don't wait until the
+ // table refreshes the data itself.
+ this.refresh();
}
}
import { I18n } from '@ngx-translate/i18n-polyfill';
import { CephfsService } from '../../../shared/api/cephfs.service';
+import { CellTemplate } from '../../../shared/enum/cell-template.enum';
import { CdTableColumn } from '../../../shared/models/cd-table-column';
import { CdTableFetchDataContext } from '../../../shared/models/cd-table-fetch-data-context';
import { CdTableSelection } from '../../../shared/models/cd-table-selection';
{
name: this.i18n('Enabled'),
prop: 'mdsmap.enabled',
- flexGrow: 1
+ flexGrow: 1,
+ cellTransformation: CellTemplate.checkIcon
}
];
}