From: Tiago Melo Date: Fri, 4 May 2018 19:07:21 +0000 (+0100) Subject: mgr/dashboard: Update RxJS to version 6 X-Git-Tag: v14.0.1~1192^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=61d8b95a2a6e30fd48aadfe2ac003de35eaed93a;p=ceph.git mgr/dashboard: Update RxJS to version 6 I used rxjs-tslint tool to automatically update most of the necessary code. I added a new package, rxjs-compat, to maintain the compatibility of external plugins that are still using RxJS v5.X. Signed-off-by: Tiago Melo --- diff --git a/src/pybind/mgr/dashboard/frontend/package.json b/src/pybind/mgr/dashboard/frontend/package.json index d089d0719f20..e5bedfbc3a44 100644 --- a/src/pybind/mgr/dashboard/frontend/package.json +++ b/src/pybind/mgr/dashboard/frontend/package.json @@ -49,7 +49,8 @@ "ng2-charts": "^1.6.0", "ng2-toastr": "4.1.2", "ngx-bootstrap": "^2.0.1", - "rxjs": "^5.5.2", + "rxjs": "^6.2.0", + "rxjs-compat": "^6.2.0", "zone.js": "^0.8.14" }, "devDependencies": { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/flatten-confirmation-modal/flatten-confimation-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/flatten-confirmation-modal/flatten-confimation-modal.component.ts index 6d9174f80b3d..bf9cd1647bf5 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/flatten-confirmation-modal/flatten-confimation-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/flatten-confirmation-modal/flatten-confimation-modal.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { BsModalRef } from 'ngx-bootstrap'; -import { Subject } from 'rxjs/Subject'; +import { Subject } from 'rxjs'; @Component({ selector: 'cd-flatten-confimation-modal', @@ -10,7 +10,6 @@ import { Subject } from 'rxjs/Subject'; styleUrls: ['./flatten-confimation-modal.component.scss'] }) export class FlattenConfirmationModalComponent implements OnInit { - child: string; parent: string; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/mirroring.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/mirroring.component.spec.ts index a9deeae7eec0..0fb423cc1fa2 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/mirroring.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/mirroring/mirroring.component.spec.ts @@ -3,7 +3,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { BsDropdownModule, TabsModule } from 'ngx-bootstrap'; import { ProgressbarModule } from 'ngx-bootstrap/progressbar'; -import { Observable } from 'rxjs/Observable'; +import { Observable } from 'rxjs'; import { RbdMirroringService } from '../../../shared/api/rbd-mirroring.service'; import { SharedModule } from '../../../shared/shared.module'; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.spec.ts index 3b97e9131457..9ec6577985ab 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-form/rbd-form.component.spec.ts @@ -3,8 +3,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ReactiveFormsModule } from '@angular/forms'; import { RouterTestingModule } from '@angular/router/testing'; -import 'rxjs/add/observable/of'; -import { Observable } from 'rxjs/Observable'; +import { of as observableOf } from 'rxjs'; import { PoolService } from '../../../shared/api/pool.service'; import { RbdService } from '../../../shared/api/rbd.service'; @@ -23,7 +22,7 @@ describe('RbdFormComponent', () => { subscribe: (name, metadata, onTaskFinished: (finishedTask: any) => any) => { return null; }, - defaultFeatures: () => Observable.of([]), + defaultFeatures: () => observableOf([]), list: (attrs = []) => { return new Promise(function(resolve, reject) { return; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.spec.ts index 6b535b368131..3e1d5c2d78fa 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.spec.ts @@ -11,8 +11,7 @@ import { TabsModule, TooltipModule } from 'ngx-bootstrap'; -import 'rxjs/add/observable/throw'; -import { Observable } from 'rxjs/Observable'; +import { throwError as observableThrowError } from 'rxjs'; import { RbdService } from '../../../shared/api/rbd.service'; import { ComponentsModule } from '../../../shared/components/components.module'; @@ -73,7 +72,7 @@ describe('RbdListComponent', () => { null, null ); - spyOn(rbdService, 'delete').and.returnValue(Observable.throw({ status: 500 })); + spyOn(rbdService, 'delete').and.returnValue(observableThrowError({ status: 500 })); spyOn(notificationService, 'notifyTask').and.stub(); component.modalRef = new BsModalRef(); component.modalRef.content = { diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-form/rbd-snapshot-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-form/rbd-snapshot-form.component.ts index e18e5bca110c..a0acb1c0bb4f 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-form/rbd-snapshot-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-form/rbd-snapshot-form.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; import { BsModalRef } from 'ngx-bootstrap'; -import { Subject } from 'rxjs/Subject'; +import { Subject } from 'rxjs'; import { RbdService } from '../../../shared/api/rbd.service'; import { FinishedTask } from '../../../shared/models/finished-task'; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.spec.ts index 54ebf3671aa4..2dd79cef41b1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-list/rbd-snapshot-list.component.spec.ts @@ -4,7 +4,7 @@ import { RouterTestingModule } from '@angular/router/testing'; import { ToastModule } from 'ng2-toastr'; import { BsModalRef, ModalModule } from 'ngx-bootstrap'; -import { Observable } from 'rxjs/Observable'; +import { throwError as observableThrowError } from 'rxjs'; import { ApiModule } from '../../../shared/api/api.module'; import { RbdService } from '../../../shared/api/rbd.service'; @@ -21,7 +21,7 @@ describe('RbdSnapshotListComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ RbdSnapshotListComponent ], + declarations: [RbdSnapshotListComponent], imports: [ DataTableModule, ComponentsModule, @@ -32,9 +32,8 @@ describe('RbdSnapshotListComponent', () => { HttpClientTestingModule, RouterTestingModule ], - providers: [ AuthStorageService ] - }) - .compileComponents(); + providers: [AuthStorageService] + }).compileComponents(); })); beforeEach(() => { @@ -56,13 +55,20 @@ describe('RbdSnapshotListComponent', () => { called = false; rbdService = new RbdService(null); notificationService = new NotificationService(null, null); - component = new RbdSnapshotListComponent(null, null, null, rbdService, null, null, - notificationService); - spyOn(rbdService, 'deleteSnapshot').and.returnValue(Observable.throw({status: 500})); + component = new RbdSnapshotListComponent( + null, + null, + null, + rbdService, + null, + null, + notificationService + ); + spyOn(rbdService, 'deleteSnapshot').and.returnValue(observableThrowError({ status: 500 })); spyOn(notificationService, 'notifyTask').and.stub(); component.modalRef = new BsModalRef(); component.modalRef.content = { - stopLoadingSpinner: () => called = true + stopLoadingSpinner: () => (called = true) }; }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rollback-confirmation-modal/rollback-confimation-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rollback-confirmation-modal/rollback-confimation-modal.component.ts index b95d7e47046f..bef646f92048 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rollback-confirmation-modal/rollback-confimation-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rollback-confirmation-modal/rollback-confimation-modal.component.ts @@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { BsModalRef } from 'ngx-bootstrap'; -import { Subject } from 'rxjs/Subject'; +import { Subject } from 'rxjs'; @Component({ selector: 'cd-rollback-confimation-modal', diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-clients/cephfs-clients.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-clients/cephfs-clients.component.spec.ts index d699a262a788..6d3402e04cae 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-clients/cephfs-clients.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-clients/cephfs-clients.component.spec.ts @@ -2,7 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { BsDropdownModule } from 'ngx-bootstrap'; -import { Observable } from 'rxjs/Observable'; +import { Observable } from 'rxjs'; import { CephfsService } from '../../../shared/api/cephfs.service'; import { SharedModule } from '../../../shared/shared.module'; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.spec.ts index b959aedb9120..6c27edb9be68 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.spec.ts @@ -4,7 +4,7 @@ import { RouterTestingModule } from '@angular/router/testing'; import { ChartsModule } from 'ng2-charts/ng2-charts'; import { BsDropdownModule, ProgressbarModule, TabsModule } from 'ngx-bootstrap'; -import { Observable } from 'rxjs/Observable'; +import { Observable } from 'rxjs'; import { CephfsService } from '../../../shared/api/cephfs.service'; import { SharedModule } from '../../../shared/shared.module'; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.ts index 378261026d19..21170748106b 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.ts @@ -1,6 +1,7 @@ import { Component, Input, OnChanges, OnInit, TemplateRef, ViewChild } from '@angular/core'; import * as _ from 'lodash'; +import { Subscription } from 'rxjs'; import { CephfsService } from '../../../shared/api/cephfs.service'; import { CdTableSelection } from '../../../shared/models/cd-table-selection'; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-list/cephfs-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-list/cephfs-list.component.spec.ts index 65856bd5c7bf..9b9acd3d8ec8 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-list/cephfs-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-list/cephfs-list.component.spec.ts @@ -1,7 +1,7 @@ import { Component, Input } from '@angular/core'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { Observable } from 'rxjs/Observable'; +import { Observable } from 'rxjs'; import { CephfsService } from '../../../shared/api/cephfs.service'; import { CdTableSelection } from '../../../shared/models/cd-table-selection'; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.spec.ts index 4ac81a1b77e7..7334b249bf5c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/configuration/configuration.component.spec.ts @@ -2,7 +2,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { FormsModule } from '@angular/forms'; import { TabsModule } from 'ngx-bootstrap/tabs/tabs.module'; -import { Observable } from 'rxjs/Observable'; +import { Observable } from 'rxjs'; import { ConfigurationService } from '../../../shared/api/configuration.service'; import { SharedModule } from '../../../shared/shared.module'; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.spec.ts index 012136cc450f..335d91e37da1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.spec.ts @@ -1,7 +1,7 @@ import { NO_ERRORS_SCHEMA } from '@angular/core'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { Observable } from 'rxjs/Observable'; +import { of as observableOf } from 'rxjs'; import { DashboardService } from '../../../shared/api/dashboard.service'; import { SharedModule } from '../../../shared/shared.module'; @@ -20,7 +20,7 @@ describe('HealthComponent', () => { const fakeService = { getHealth: () => { - return Observable.of({ + return observableOf({ health: {}, df: { stats: {} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.spec.ts index 77cd85f8a438..cbb82dab8ac3 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-form/rgw-bucket-form.component.spec.ts @@ -3,8 +3,7 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { FormControl, ReactiveFormsModule } from '@angular/forms'; import { RouterTestingModule } from '@angular/router/testing'; -import 'rxjs/add/observable/of'; -import { Observable } from 'rxjs/Observable'; +import { of as observableOf } from 'rxjs'; import { RgwBucketService } from '../../../shared/api/rgw-bucket.service'; import { RgwUserService } from '../../../shared/api/rgw-user.service'; @@ -18,7 +17,7 @@ describe('RgwBucketFormComponent', () => { class MockRgwBucketService extends RgwBucketService { enumerate() { - return Observable.of(queryResult); + return observableOf(queryResult); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-list/rgw-bucket-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-list/rgw-bucket-list.component.ts index 82e32c050fb2..a6dbd6bcd160 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-list/rgw-bucket-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-bucket-list/rgw-bucket-list.component.ts @@ -2,9 +2,7 @@ import { Component, ViewChild } from '@angular/core'; import { Router } from '@angular/router'; import { BsModalService } from 'ngx-bootstrap'; -import 'rxjs/add/observable/forkJoin'; -import { Observable } from 'rxjs/Observable'; -import { Subscriber } from 'rxjs/Subscriber'; +import { forkJoin as observableForkJoin, Observable, Subscriber } from 'rxjs'; import { RgwBucketService } from '../../../shared/api/rgw-bucket.service'; import { DeletionModalComponent } from '../../../shared/components/deletion-modal/deletion-modal.component'; @@ -67,7 +65,7 @@ export class RgwBucketListComponent { deletionObserver: (): Observable => { return new Observable((observer: Subscriber) => { // Delete all selected data table rows. - Observable.forkJoin( + observableForkJoin( this.selection.selected.map((bucket: any) => { return this.rgwBucketService.delete(bucket.bucket); }) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.spec.ts index 69cd35f39ae6..bcadfc442995 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.spec.ts @@ -4,8 +4,7 @@ import { FormControl, ReactiveFormsModule } from '@angular/forms'; import { RouterTestingModule } from '@angular/router/testing'; import { BsModalService } from 'ngx-bootstrap/modal'; -import 'rxjs/add/observable/of'; -import { Observable } from 'rxjs/Observable'; +import { of as observableOf } from 'rxjs'; import { RgwUserService } from '../../../shared/api/rgw-user.service'; import { SharedModule } from '../../../shared/shared.module'; @@ -18,7 +17,7 @@ describe('RgwUserFormComponent', () => { class MockRgwUserService extends RgwUserService { enumerate() { - return Observable.of(queryResult); + return observableOf(queryResult); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.ts index a9f0f0478fc9..66a447206809 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.ts @@ -11,8 +11,7 @@ import { ActivatedRoute, Router } from '@angular/router'; import * as _ from 'lodash'; import { BsModalService } from 'ngx-bootstrap'; -import 'rxjs/add/observable/forkJoin'; -import { Observable } from 'rxjs/Observable'; +import { forkJoin as observableForkJoin, Observable } from 'rxjs'; import { RgwUserService } from '../../../shared/api/rgw-user.service'; import { FormatterService } from '../../../shared/services/formatter.service'; @@ -163,7 +162,7 @@ export class RgwUserFormComponent implements OnInit { const observables = []; observables.push(this.rgwUserService.get(params.uid)); observables.push(this.rgwUserService.getQuota(params.uid)); - Observable.forkJoin(observables).subscribe( + observableForkJoin(observables).subscribe( (resp: any[]) => { this.loading = false; // Get the default values. @@ -248,7 +247,7 @@ export class RgwUserFormComponent implements OnInit { this.submitObservables.push(this.rgwUserService.putQuota(bucketQuotaArgs)); } // Finally execute all observables. - Observable.forkJoin(this.submitObservables).subscribe( + observableForkJoin(this.submitObservables).subscribe( () => { this.goToListView(); }, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-list/rgw-user-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-list/rgw-user-list.component.ts index 70c4d9142b25..49b0e0401877 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-list/rgw-user-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-list/rgw-user-list.component.ts @@ -2,9 +2,7 @@ import { Component, ViewChild } from '@angular/core'; import { Router } from '@angular/router'; import { BsModalService } from 'ngx-bootstrap'; -import 'rxjs/add/observable/forkJoin'; -import { Observable } from 'rxjs/Observable'; -import { Subscriber } from 'rxjs/Subscriber'; +import { forkJoin as observableForkJoin, Observable, Subscriber } from 'rxjs'; import { RgwUserService } from '../../../shared/api/rgw-user.service'; import { DeletionModalComponent } from '../../../shared/components/deletion-modal/deletion-modal.component'; @@ -84,7 +82,7 @@ export class RgwUserListComponent { deletionObserver: (): Observable => { return new Observable((observer: Subscriber) => { // Delete all selected data table rows. - Observable.forkJoin( + observableForkJoin( this.selection.selected.map((user: any) => { return this.rgwUserService.delete(user.user_id); }) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/performance-counter.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/performance-counter.service.ts index d4ae1fecdfee..05317bc28a6e 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/performance-counter.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/performance-counter.service.ts @@ -1,12 +1,11 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import 'rxjs/add/observable/of'; -import { Observable } from 'rxjs/Observable'; +import { of as observableOf } from 'rxjs'; +import { mergeMap } from 'rxjs/operators'; @Injectable() export class PerformanceCounterService { - private url = 'api/perf_counters'; constructor(private http: HttpClient) {} @@ -17,9 +16,10 @@ export class PerformanceCounterService { get(service_type: string, service_id: string) { const serviceType = service_type.replace('-', '_'); - return this.http.get(`${this.url}/${serviceType}/${service_id}`) - .flatMap((resp) => { - return Observable.of(resp['counters']); - }); + return this.http.get(`${this.url}/${serviceType}/${service_id}`).pipe( + mergeMap((resp) => { + return observableOf(resp['counters']); + }) + ); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-bucket.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-bucket.service.ts index 0740d6dd4c3c..acf03f664192 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-bucket.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-bucket.service.ts @@ -2,9 +2,8 @@ import { HttpClient, HttpParams } from '@angular/common/http'; import { Injectable } from '@angular/core'; import * as _ from 'lodash'; -import 'rxjs/add/observable/forkJoin'; -import 'rxjs/add/observable/of'; -import { Observable } from 'rxjs/Observable'; +import { forkJoin as observableForkJoin, of as observableOf } from 'rxjs'; +import { mergeMap } from 'rxjs/operators'; @Injectable() export class RgwBucketService { @@ -17,16 +16,16 @@ export class RgwBucketService { * @return {Observable} */ list() { - return this.enumerate().flatMap((buckets: string[]) => { - if (buckets.length > 0) { - return Observable.forkJoin( - buckets.map((bucket: string) => { - return this.get(bucket); - }) - ); - } - return Observable.of([]); - }); + return this.enumerate().pipe( + mergeMap((buckets: string[]) => { + if (buckets.length > 0) { + return observableForkJoin( + buckets.map((bucket: string) => { + return this.get(bucket); + })); + } + return observableOf([]); + })); } /** @@ -72,9 +71,10 @@ export class RgwBucketService { * @return {Observable} */ exists(bucket: string) { - return this.enumerate().flatMap((resp: string[]) => { - const index = _.indexOf(resp, bucket); - return Observable.of(-1 !== index); - }); + return this.enumerate().pipe( + mergeMap((resp: string[]) => { + const index = _.indexOf(resp, bucket); + return observableOf(-1 !== index); + })); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-user.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-user.service.ts index d3f9d9f65c40..d031dde446f8 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-user.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/api/rgw-user.service.ts @@ -2,9 +2,8 @@ import { HttpClient, HttpParams } from '@angular/common/http'; import { Injectable } from '@angular/core'; import * as _ from 'lodash'; -import 'rxjs/add/observable/forkJoin'; -import 'rxjs/add/observable/of'; -import { Observable } from 'rxjs/Observable'; +import {forkJoin as observableForkJoin, of as observableOf } from 'rxjs'; +import { mergeMap } from 'rxjs/operators'; @Injectable() export class RgwUserService { @@ -17,16 +16,16 @@ export class RgwUserService { * @return {Observable} */ list() { - return this.enumerate().flatMap((uids: string[]) => { - if (uids.length > 0) { - return Observable.forkJoin( - uids.map((uid: string) => { - return this.get(uid); - }) - ); - } - return Observable.of([]); - }); + return this.enumerate().pipe( + mergeMap((uids: string[]) => { + if (uids.length > 0) { + return observableForkJoin( + uids.map((uid: string) => { + return this.get(uid); + })); + } + return observableOf([]); + })); } /** @@ -161,9 +160,10 @@ export class RgwUserService { * @return {Observable} */ exists(uid: string) { - return this.enumerate().flatMap((resp: string[]) => { - const index = _.indexOf(resp, uid); - return Observable.of(-1 !== index); - }); + return this.enumerate().pipe( + mergeMap((resp: string[]) => { + const index = _.indexOf(resp, uid); + return observableOf(-1 !== index); + })); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-modal/deletion-modal.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-modal/deletion-modal.component.spec.ts index 9ac9876826a8..84bdf0a9d5e8 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-modal/deletion-modal.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-modal/deletion-modal.component.spec.ts @@ -3,8 +3,7 @@ import { async, ComponentFixture, fakeAsync, TestBed, tick } from '@angular/core import { ReactiveFormsModule } from '@angular/forms'; import { BsModalRef, BsModalService, ModalModule } from 'ngx-bootstrap'; -import { Observable } from 'rxjs/Observable'; -import { Subscriber } from 'rxjs/Subscriber'; +import { Observable, Subscriber, timer as observableTimer } from 'rxjs'; import { ModalComponent } from '../modal/modal.component'; import { DeletionModalComponent } from './deletion-modal.component'; @@ -76,7 +75,7 @@ class MockComponent { fakeDelete() { return (): Observable => { return new Observable((observer: Subscriber) => { - Observable.timer(100).subscribe(() => { + observableTimer(100).subscribe(() => { observer.next(this.finish()); observer.complete(); }); @@ -85,7 +84,7 @@ class MockComponent { } fakeDeleteController() { - Observable.timer(100).subscribe(() => { + observableTimer(100).subscribe(() => { this.finish(); this.ctrlRef.hide(); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-modal/deletion-modal.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-modal/deletion-modal.component.ts index d30d2e69e4eb..a4a9b3489542 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-modal/deletion-modal.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/deletion-modal/deletion-modal.component.ts @@ -4,7 +4,7 @@ import { import { FormControl, FormGroup, Validators } from '@angular/forms'; import { BsModalRef } from 'ngx-bootstrap'; -import { Observable } from 'rxjs/Observable'; +import { Observable } from 'rxjs'; import { SubmitButtonComponent } from '../submit-button/submit-button.component'; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts index fe9035ad2b93..d196125e8517 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/datatable/table/table.component.ts @@ -11,16 +11,15 @@ import { TemplateRef, ViewChild } from '@angular/core'; + import { DatatableComponent, SortDirection, SortPropDir, TableColumnProp } from '@swimlane/ngx-datatable'; - import * as _ from 'lodash'; -import 'rxjs/add/observable/timer'; -import { Observable } from 'rxjs/Observable'; +import { Observable, timer as observableTimer } from 'rxjs'; import { CellTemplate } from '../../enum/cell-template.enum'; import { CdTableColumn } from '../../models/cd-table-column'; @@ -48,15 +47,15 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O // Each item -> { prop: 'attribute name', dir: 'asc'||'desc'} @Input() sorts?: SortPropDir[]; // Method used for setting column widths. - @Input() columnMode ?= 'flex'; + @Input() columnMode? = 'flex'; // Display the tool header, including reload button, pagination and search fields? - @Input() toolHeader ?= true; + @Input() toolHeader? = true; // Display the table header? - @Input() header ?= true; + @Input() header? = true; // Display the table footer? - @Input() footer ?= true; + @Input() footer? = true; // Page size to show. Set to 0 to show unlimited number of rows. - @Input() limit ?= 10; + @Input() limit? = 10; /** * Auto reload time in ms - per default every 5s @@ -107,7 +106,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O tableColumns: CdTableColumn[]; cellTemplates: { - [key: string]: TemplateRef + [key: string]: TemplateRef; } = {}; search = ''; rows = []; @@ -138,8 +137,9 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O const exists = _.findIndex(this.columns, ['prop', this.identifier]) !== -1; // Auto-build the sorting configuration. If the specified identifier doesn't exist, // then use the property of the first column. - this.sorts = this.createSortingDefinition(exists ? - this.identifier : this.columns[0].prop + ''); + this.sorts = this.createSortingDefinition( + exists ? this.identifier : this.columns[0].prop + '' + ); // If the specified identifier doesn't exist and it is not forced to use it anyway, // then use the property of the first column. if (!exists && !this.forceIdentifier) { @@ -147,7 +147,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O } } this.initUserConfig(); - this.columns.forEach(c => { + this.columns.forEach((c) => { if (c.cellTransformation) { c.cellTemplate = this.cellTemplates[c.cellTransformation]; } @@ -166,9 +166,9 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O if (this.fetchData.observers.length > 0) { this.loadingIndicator = true; } - if (_.isInteger(this.autoReload) && (this.autoReload > 0)) { + if (_.isInteger(this.autoReload) && this.autoReload > 0) { this.ngZone.runOutsideAngular(() => { - this.reloadSubscriber = Observable.timer(0, this.autoReload).subscribe(x => { + this.reloadSubscriber = observableTimer(0, this.autoReload).subscribe((x) => { this.ngZone.run(() => { return this.reloadData(); }); @@ -179,7 +179,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O } } - initUserConfig () { + initUserConfig() { if (this.autoSave) { this.tableName = this._calculateUniqueTableName(this.columns); this._loadUserConfig(); @@ -200,7 +200,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O } } - _calculateUniqueTableName (columns) { + _calculateUniqueTableName(columns) { const stringToNumber = (s) => { if (!_.isString(s)) { return 0; @@ -211,12 +211,16 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O } return result; }; - return columns.reduce((result, value, index) => - ((stringToNumber(value.prop) + stringToNumber(value.name)) * (index + 1)) + result, - 0).toString(); + return columns + .reduce( + (result, value, index) => + (stringToNumber(value.prop) + stringToNumber(value.name)) * (index + 1) + result, + 0 + ) + .toString(); } - _loadUserConfig () { + _loadUserConfig() { const loaded = this.localStorage.getItem(this.tableName); if (loaded) { this.userConfig = JSON.parse(loaded); @@ -228,7 +232,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O this.saveSubscriber = source.subscribe(this._saveUserConfig.bind(this)); } - _initUserConfigProxy (observer) { + _initUserConfigProxy(observer) { this.userConfig = new Proxy(this.userConfig, { set(config, prop, value) { config[prop] = value; @@ -238,20 +242,20 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O }); } - _saveUserConfig (config) { + _saveUserConfig(config) { this.localStorage.setItem(this.tableName, JSON.stringify(config)); } - updateUserColumns () { - this.userConfig.columns = this.columns.map(c => ({ + updateUserColumns() { + this.userConfig.columns = this.columns.map((c) => ({ prop: c.prop, name: c.name, isHidden: !!c.isHidden })); } - filterHiddenColumns () { - this.tableColumns = this.columns.filter(c => !c.isHidden); + filterHiddenColumns() { + this.tableColumns = this.columns.filter((c) => !c.isHidden); } ngOnDestroy() { @@ -302,7 +306,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O } } - refreshBtn () { + refreshBtn() { this.loadingIndicator = true; this.reloadData(); } @@ -366,18 +370,18 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O this.updateColumns(); } - updateColumns () { + updateColumns() { this.updateUserColumns(); this.filterHiddenColumns(); const sortProp = this.userConfig.sorts[0].prop; if (!_.find(this.tableColumns, (c: CdTableColumn) => c.prop === sortProp)) { this.userConfig.sorts = this.createSortingDefinition(this.tableColumns[0].prop); - this.table.onColumnSort({sorts: this.userConfig.sorts}); + this.table.onColumnSort({ sorts: this.userConfig.sorts }); } this.table.recalculate(); } - createSortingDefinition (prop: TableColumnProp): SortPropDir[] { + createSortingDefinition(prop: TableColumnProp): SortPropDir[] { return [ { prop: prop, @@ -386,7 +390,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O ]; } - changeSorting ({sorts}) { + changeSorting({ sorts }) { this.userConfig.sorts = sorts; } @@ -395,23 +399,26 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O this.search = ''; } let search = this.search.toLowerCase().replace(/,/g, ''); - const columns = this.columns.filter(c => c.cellTransformation !== CellTemplate.sparkline); + const columns = this.columns.filter((c) => c.cellTransformation !== CellTemplate.sparkline); if (search.match(/['"][^'"]+['"]/)) { search = search.replace(/['"][^'"]+['"]/g, (match: string) => { return match.replace(/(['"])([^'"]+)(['"])/g, '$2').replace(/ /g, '+'); }); } // update the rows - this.rows = this.subSearch(this.data, search.split(' ').filter(s => s.length > 0), columns); + this.rows = this.subSearch(this.data, search.split(' ').filter((s) => s.length > 0), columns); // Whenever the filter changes, always go back to the first page this.table.offset = 0; } - subSearch (data: any[], currentSearch: string[], columns: CdTableColumn[]) { + subSearch(data: any[], currentSearch: string[], columns: CdTableColumn[]) { if (currentSearch.length === 0 || data.length === 0) { return data; } - const searchTerms: string[] = currentSearch.pop().replace('+', ' ').split(':'); + const searchTerms: string[] = currentSearch + .pop() + .replace('+', ' ') + .split(':'); const columnsClone = [...columns]; const dataClone = [...data]; const filterColumns = (columnName: string) => @@ -432,22 +439,24 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O if (searchTerm.length === 0) { return data; } - return data.filter(d => { - return columns.filter(c => { - let cellValue: any = _.get(d, c.prop); - if (!_.isUndefined(c.pipe)) { - cellValue = c.pipe.transform(cellValue); - } - if (_.isUndefined(cellValue)) { - return; - } - if (_.isArray(cellValue)) { - cellValue = cellValue.join(' '); - } else if (_.isNumber(cellValue) || _.isBoolean(cellValue)) { - cellValue = cellValue.toString(); - } - return cellValue.toLowerCase().indexOf(searchTerm) !== -1; - }).length > 0; + return data.filter((d) => { + return ( + columns.filter((c) => { + let cellValue: any = _.get(d, c.prop); + if (!_.isUndefined(c.pipe)) { + cellValue = c.pipe.transform(cellValue); + } + if (_.isUndefined(cellValue)) { + return; + } + if (_.isArray(cellValue)) { + cellValue = cellValue.join(' '); + } else if (_.isNumber(cellValue) || _.isBoolean(cellValue)) { + cellValue = cellValue.toString(); + } + return cellValue.toLowerCase().indexOf(searchTerm) !== -1; + }).length > 0 + ); }); } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/api-interceptor.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/api-interceptor.service.ts index 40fae89b00ae..b706cd55d4f8 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/api-interceptor.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/api-interceptor.service.ts @@ -9,9 +9,8 @@ import { Injectable } from '@angular/core'; import { Router } from '@angular/router'; import * as _ from 'lodash'; -import 'rxjs/add/observable/throw'; -import 'rxjs/add/operator/catch'; -import { Observable } from 'rxjs/Observable'; +import { Observable, throwError as observableThrowError } from 'rxjs'; +import { catchError } from 'rxjs/operators'; import { NotificationType } from '../enum/notification-type.enum'; import { FinishedTask } from '../models/finished-task'; @@ -20,71 +19,76 @@ import { NotificationService } from './notification.service'; @Injectable() export class ApiInterceptorService implements HttpInterceptor { - - constructor(private router: Router, - private authStorageService: AuthStorageService, - public notificationService: NotificationService) {} + constructor( + private router: Router, + private authStorageService: AuthStorageService, + public notificationService: NotificationService + ) {} intercept(request: HttpRequest, next: HttpHandler): Observable> { - return next.handle(request).catch((resp) => { - if (resp instanceof HttpErrorResponse) { - let showNotification = true; - switch (resp.status) { - case 400: - const finishedTask = new FinishedTask(); + return next.handle(request).pipe( + catchError((resp) => { + if (resp instanceof HttpErrorResponse) { + let showNotification = true; + switch (resp.status) { + case 400: + const finishedTask = new FinishedTask(); - const task = resp.error.task; - if (_.isPlainObject(task)) { - task.metadata.component = task.metadata.component || resp.error.component; + const task = resp.error.task; + if (_.isPlainObject(task)) { + task.metadata.component = task.metadata.component || resp.error.component; - finishedTask.name = task.name; - finishedTask.metadata = task.metadata; - } else { - finishedTask.metadata = resp.error; - } + finishedTask.name = task.name; + finishedTask.metadata = task.metadata; + } else { + finishedTask.metadata = resp.error; + } - finishedTask.success = false; - finishedTask.exception = resp.error; - this.notificationService.notifyTask(finishedTask); - showNotification = false; - break; - case 401: - this.authStorageService.remove(); - this.router.navigate(['/login']); - break; - case 404: - this.router.navigate(['/404']); - break; - } + finishedTask.success = false; + finishedTask.exception = resp.error; + this.notificationService.notifyTask(finishedTask); + showNotification = false; + break; + case 401: + this.authStorageService.remove(); + this.router.navigate(['/login']); + break; + case 404: + this.router.navigate(['/404']); + break; + } - let timeoutId; - if (showNotification) { - timeoutId = this.notificationService.show(NotificationType.error, - resp.error.detail || '', - `${resp.status} - ${resp.statusText}`); - } + let timeoutId; + if (showNotification) { + timeoutId = this.notificationService.show( + NotificationType.error, + resp.error.detail || '', + `${resp.status} - ${resp.statusText}` + ); + } - /** - * Decorated preventDefault method (in case error previously had - * preventDefault method defined). If called, it will prevent a - * notification to be shown. - */ - resp['preventDefault'] = () => { - this.notificationService.cancel(timeoutId); - }; + /** + * Decorated preventDefault method (in case error previously had + * preventDefault method defined). If called, it will prevent a + * notification to be shown. + */ + resp['preventDefault'] = () => { + this.notificationService.cancel(timeoutId); + }; - /** - * If called, it will prevent a notification for the specific status code. - * @param {number} status The status code to be ignored. - */ - resp['ignoreStatusCode'] = function(status: number) { - if (this.status === status) { - this.preventDefault(); - } - }; - } - // Return the error to the method that called it. - return Observable.throw(resp); - }); + /** + * If called, it will prevent a notification for the specific status code. + * @param {number} status The status code to be ignored. + */ + resp['ignoreStatusCode'] = function(status: number) { + if (this.status === status) { + this.preventDefault(); + } + }; + } + // Return the error to the method that called it. + return observableThrowError(resp); + }) + ); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.spec.ts index 6ffe06433f80..e1b259687083 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.spec.ts @@ -4,8 +4,7 @@ import { fakeAsync, TestBed, tick } from '@angular/core/testing'; import { ActivatedRouteSnapshot, Router, Routes } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; -import 'rxjs/add/observable/of'; -import { Observable } from 'rxjs/Observable'; +import { of as observableOf } from 'rxjs'; import { ModuleStatusGuardService } from './module-status-guard.service'; @@ -47,7 +46,7 @@ describe('ModuleStatusGuardService', () => { } }; const httpClient = TestBed.get(HttpClient); - spyOn(httpClient, 'get').and.returnValue(Observable.of({ available: true, message: 'foo' })); + spyOn(httpClient, 'get').and.returnValue(observableOf({ available: true, message: 'foo' })); service.canActivate(route, null).subscribe((resp) => { result = resp; }); @@ -70,7 +69,7 @@ describe('ModuleStatusGuardService', () => { }; const httpClient = TestBed.get(HttpClient); const router = TestBed.get(Router); - spyOn(httpClient, 'get').and.returnValue(Observable.of({ available: false, message: null })); + spyOn(httpClient, 'get').and.returnValue(observableOf({ available: false, message: null })); service.canActivateChild(route, null).subscribe((resp) => { result = resp; }); @@ -94,7 +93,7 @@ describe('ModuleStatusGuardService', () => { }; const httpClient = TestBed.get(HttpClient); const router = TestBed.get(Router); - spyOn(httpClient, 'get').and.returnValue(Observable.of(null)); + spyOn(httpClient, 'get').and.returnValue(observableOf(null)); service.canActivateChild(route, null).subscribe((resp) => { result = resp; }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.ts index 8ef40c416396..a70e75d6fcde 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/module-status-guard.service.ts @@ -8,9 +8,8 @@ import { RouterStateSnapshot } from '@angular/router'; -import 'rxjs/add/observable/of'; -import 'rxjs/add/operator/catch'; -import { Observable } from 'rxjs/Observable'; +import { of as observableOf } from 'rxjs'; +import { catchError, map } from 'rxjs/operators'; /** * This service checks if a route can be activated by executing a @@ -51,17 +50,17 @@ export class ModuleStatusGuardService implements CanActivate, CanActivateChild { private doCheck(route: ActivatedRouteSnapshot) { const config = route.data['moduleStatusGuardConfig']; - return this.http - .get(`/api/${config.apiPath}/status`) - .map((resp: any) => { + return this.http.get(`/api/${config.apiPath}/status`).pipe( + map((resp: any) => { if (!resp.available) { this.router.navigate([config.redirectTo, resp.message || '']); } return resp.available; - }) - .catch(() => { + }), + catchError(() => { this.router.navigate([config.redirectTo]); - return Observable.of(false); - }); + return observableOf(false); + }) + ); } } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/notification.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/notification.service.ts index a80d25930313..d698ee4a7391 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/notification.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/notification.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import * as _ from 'lodash'; import { ToastsManager } from 'ng2-toastr'; -import { BehaviorSubject } from 'rxjs/BehaviorSubject'; +import { BehaviorSubject } from 'rxjs'; import { NotificationType } from '../enum/notification-type.enum'; import { CdNotification } from '../models/cd-notification'; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.spec.ts index 697e9401a084..269278ab8635 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.spec.ts @@ -1,8 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { fakeAsync, TestBed, tick } from '@angular/core/testing'; -import 'rxjs/add/observable/of'; -import { Observable } from 'rxjs/Observable'; +import { of as observableOf } from 'rxjs'; import { AuthStorageService } from './auth-storage.service'; import { SummaryService } from './summary.service'; @@ -13,7 +12,7 @@ describe('SummaryService', () => { const httpClientSpy = { get: () => - Observable.of({ + observableOf({ executing_tasks: [], health_status: 'HEALTH_OK', mgr_id: 'x', @@ -42,18 +41,21 @@ describe('SummaryService', () => { expect(summaryService).toBeTruthy(); }); - it('should call refresh', fakeAsync(() => { - authStorageService.set('foobar'); - let result = false; - summaryService.refresh(); - summaryService.summaryData$.subscribe((res) => { - result = true; - }); - tick(5000); - spyOn(summaryService, 'refresh').and.callFake(() => true); - tick(5000); - expect(result).toEqual(true); - })); + it( + 'should call refresh', + fakeAsync(() => { + authStorageService.set('foobar'); + let result = false; + summaryService.refresh(); + summaryService.summaryData$.subscribe((res) => { + result = true; + }); + tick(5000); + spyOn(summaryService, 'refresh').and.callFake(() => true); + tick(5000); + expect(result).toEqual(true); + }) + ); it('should get summary', () => { expect(summaryService.get()).toEqual(jasmine.any(Object)); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.ts index a6fb493bcc6d..b597fb96c1ad 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/summary.service.ts @@ -1,7 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { Injectable, NgZone } from '@angular/core'; -import { Subject } from 'rxjs/Subject'; +import { Subject } from 'rxjs'; import { AuthStorageService } from './auth-storage.service'; diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager.service.spec.ts index 1daa3044c3c8..f57b5adb682c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-manager.service.spec.ts @@ -1,8 +1,7 @@ import { fakeAsync, TestBed, tick } from '@angular/core/testing'; import * as _ from 'lodash'; -import 'rxjs/add/observable/of'; -import { Subject } from 'rxjs/Subject'; +import { Subject } from 'rxjs'; import { SummaryService } from './summary.service'; import { TaskManagerService } from './task-manager.service'; diff --git a/src/pybind/mgr/dashboard/frontend/src/setupJest.ts b/src/pybind/mgr/dashboard/frontend/src/setupJest.ts index c5e3f7e8de05..f695767e6075 100644 --- a/src/pybind/mgr/dashboard/frontend/src/setupJest.ts +++ b/src/pybind/mgr/dashboard/frontend/src/setupJest.ts @@ -1,12 +1,4 @@ import 'jest-preset-angular'; import 'jest-zone-patch'; -// common rxjs imports -import 'rxjs/add/observable/throw'; -import 'rxjs/add/operator/catch'; -import 'rxjs/add/operator/do'; -import 'rxjs/add/operator/map'; -import 'rxjs/add/operator/switchMap'; -// ... - import './jestGlobalMocks'; diff --git a/src/pybind/mgr/dashboard/frontend/tslint.json b/src/pybind/mgr/dashboard/frontend/tslint.json index d915d4d8fe19..7b1536d7e940 100644 --- a/src/pybind/mgr/dashboard/frontend/tslint.json +++ b/src/pybind/mgr/dashboard/frontend/tslint.json @@ -10,7 +10,10 @@ "curly": true, "eofline": true, "forin": true, - "import-blacklist": [true, "rxjs", "rxjs/Rx"], + "import-blacklist": [ + true, + "rxjs/Rx" + ], "import-spacing": true, "indent": [true, "spaces"], "interface-over-type-literal": true,