This PR introduces the 'ngx-pipe-function' package to call functions in templates.
Fixes: https://tracker.ceph.com/issues/48051
Signed-off-by: Volker Theile <vtheile@suse.com>
}
}
},
+ "ngx-pipe-function": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/ngx-pipe-function/-/ngx-pipe-function-1.0.0.tgz",
+ "integrity": "sha512-AFWZ3icsq+0/nxFZtqRGZ03nRFoHcxVkZNGIi4ZQbdl5QLP3FmNTHGMmigohSeCV785l3YmPDUEx+6qwdGynMw==",
+ "requires": {
+ "tslib": "^1.9.0"
+ },
+ "dependencies": {
+ "tslib": {
+ "version": "1.14.1",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
+ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
+ }
+ }
+ },
"ngx-toastr": {
"version": "13.1.0",
"resolved": "https://registry.npmjs.org/ngx-toastr/-/ngx-toastr-13.1.0.tgz",
"ng-block-ui": "3.0.2",
"ng-click-outside": "7.0.0",
"ng2-charts": "2.3.0",
+ "ngx-pipe-function": "^1.0.0",
"ngx-toastr": "13.1.0",
"rxjs": "6.6.3",
"simplebar-angular": "2.3.0",
import { NgbNavModule } from '@ng-bootstrap/ng-bootstrap';
import { TablePerformanceCounterComponent } from '~/app/ceph/performance-counter/table-performance-counter/table-performance-counter.component';
-import { DeviceListComponent } from '~/app/ceph/shared/device-list/device-list.component';
-import { SmartListComponent } from '~/app/ceph/shared/smart-list/smart-list.component';
+import { CephSharedModule } from '~/app/ceph/shared/ceph-shared.module';
import { SharedModule } from '~/app/shared/shared.module';
import { configureTestBed } from '~/testing/unit-test-helper';
import { OsdDetailsComponent } from './osd-details.component';
let fixture: ComponentFixture<OsdDetailsComponent>;
configureTestBed({
- imports: [HttpClientTestingModule, NgbNavModule, SharedModule],
- declarations: [
- OsdDetailsComponent,
- DeviceListComponent,
- SmartListComponent,
- TablePerformanceCounterComponent
- ]
+ imports: [HttpClientTestingModule, NgbNavModule, SharedModule, CephSharedModule],
+ declarations: [OsdDetailsComponent, TablePerformanceCounterComponent]
});
beforeEach(() => {
import { NgModule } from '@angular/core';
import { NgbNavModule } from '@ng-bootstrap/ng-bootstrap';
+import { NgxPipeFunctionModule } from 'ngx-pipe-function';
import { DataTableModule } from '~/app/shared/datatable/datatable.module';
import { SharedModule } from '~/app/shared/shared.module';
import { SmartListComponent } from './smart-list/smart-list.component';
@NgModule({
- imports: [CommonModule, DataTableModule, SharedModule, NgbNavModule],
+ imports: [CommonModule, DataTableModule, SharedModule, NgbNavModule, NgxPipeFunctionModule],
exports: [DeviceListComponent, SmartListComponent],
declarations: [DeviceListComponent, SmartListComponent]
})
dashboard.</cd-alert-panel>
<ng-container *ngIf="!error && !incompatible">
- <cd-alert-panel *ngIf="isEmpty(data)"
+ <cd-alert-panel *ngIf="data | pipeFunction:isEmpty"
type="info"
i18n>No SMART data available.</cd-alert-panel>
- <ng-container *ngIf="!isEmpty(data)">
+ <ng-container *ngIf="!(data | pipeFunction:isEmpty)">
<ul ngbNav
#nav="ngbNav"
class="nav-tabs">
</ng-container>
<ng-template #noError>
- <cd-alert-panel *ngIf="isEmpty(device.value.info?.smart_status); else hasSmartStatus"
+ <cd-alert-panel *ngIf="device.value.info?.smart_status | pipeFunction:isEmpty; else hasSmartStatus"
id="alert-self-test-unknown"
size="slim"
type="warning"
</ng-template>
</ng-template>
- <ng-container *ngIf="!isEmpty(device.value.info) || !isEmpty(device.value.smart)">
+ <ng-container *ngIf="!(device.value.info | pipeFunction:isEmpty) || !(device.value.smart | pipeFunction:isEmpty)">
<ul ngbNav
#innerNav="ngbNav"
class="nav-tabs">
<a ngbNavLink
i18n>Device Information</a>
<ng-template ngbNavContent>
- <cd-table-key-value *ngIf="!isEmpty(device.value.info)"
+ <cd-table-key-value *ngIf="!(device.value.info | pipeFunction:isEmpty)"
[renderObjects]="true"
[data]="device.value.info"></cd-table-key-value>
- <cd-alert-panel *ngIf="isEmpty(device.value.info)"
+ <cd-alert-panel *ngIf="device.value.info | pipeFunction:isEmpty"
id="alert-device-info-unavailable"
type="info"
i18n>No device information available for this device.</cd-alert-panel>
import { NgbNavModule } from '@ng-bootstrap/ng-bootstrap';
import _ from 'lodash';
+import { NgxPipeFunctionModule } from 'ngx-pipe-function';
import { of } from 'rxjs';
import { OsdService } from '~/app/shared/api/osd.service';
configureTestBed({
declarations: [SmartListComponent],
- imports: [BrowserAnimationsModule, SharedModule, HttpClientTestingModule, NgbNavModule]
+ imports: [
+ BrowserAnimationsModule,
+ SharedModule,
+ HttpClientTestingModule,
+ NgbNavModule,
+ NgxPipeFunctionModule
+ ]
});
beforeEach(() => {
smartDataColumns: CdTableColumn[];
+ isEmpty = _.isEmpty;
+
constructor(private osdService: OsdService, private hostService: HostService) {}
isSmartError(data: any): data is SmartError {
}
}
- isEmpty(value: any) {
- return _.isEmpty(value);
- }
-
ngOnInit() {
this.smartDataColumns = [
{ prop: 'id', name: $localize`ID` },