From: Ricardo Marques Date: Thu, 2 Aug 2018 10:41:21 +0000 (+0100) Subject: mgr/dashboard: Fix redirect to login page on session lost X-Git-Tag: v14.0.1~573^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e74354326af688673aedcb6b5e06180d037b2ba2;p=ceph.git mgr/dashboard: Fix redirect to login page on session lost Fixes: https://tracker.ceph.com/issues/25344 Signed-off-by: Ricardo Marques --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-form/rbd-snapshot-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-form/rbd-snapshot-form.component.spec.ts index 4c624dd8d8e2..f07f9734dd4c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-form/rbd-snapshot-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-snapshot-form/rbd-snapshot-form.component.spec.ts @@ -1,6 +1,7 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ReactiveFormsModule } from '@angular/forms'; +import { RouterTestingModule } from '@angular/router/testing'; import { ToastModule } from 'ng2-toastr'; import { BsModalRef, BsModalService } from 'ngx-bootstrap'; @@ -23,7 +24,8 @@ describe('RbdSnapshotFormComponent', () => { HttpClientTestingModule, ServicesModule, ApiModule, - ToastModule.forRoot() + ToastModule.forRoot(), + RouterTestingModule ], declarations: [RbdSnapshotFormComponent], providers: [BsModalRef, BsModalService, AuthStorageService] diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.spec.ts index 3e18c5490b8e..e6a61bba47f0 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/dashboard-help/dashboard-help.component.spec.ts @@ -1,5 +1,6 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { RouterTestingModule } from '@angular/router/testing'; import { configureTestBed } from '../../../../testing/unit-test-helper'; import { SharedModule } from '../../../shared/shared.module'; @@ -10,7 +11,7 @@ describe('DashboardHelpComponent', () => { let fixture: ComponentFixture; configureTestBed({ - imports: [HttpClientTestingModule, SharedModule], + imports: [HttpClientTestingModule, SharedModule, RouterTestingModule], declarations: [DashboardHelpComponent] }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/task-manager/task-manager.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/task-manager/task-manager.component.spec.ts index 8b8f4a25cc86..879af018fead 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/task-manager/task-manager.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/core/navigation/task-manager/task-manager.component.spec.ts @@ -1,5 +1,6 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { RouterTestingModule } from '@angular/router/testing'; import { PopoverModule } from 'ngx-bootstrap'; @@ -18,7 +19,7 @@ describe('TaskManagerComponent', () => { }; configureTestBed({ - imports: [SharedModule, PopoverModule.forRoot(), HttpClientTestingModule], + imports: [SharedModule, PopoverModule.forRoot(), HttpClientTestingModule, RouterTestingModule], declarations: [TaskManagerComponent] }); 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 3a8547cf7c12..4dd03110c13f 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,5 +1,6 @@ import { HttpClient } from '@angular/common/http'; import { fakeAsync, TestBed, tick } from '@angular/core/testing'; +import { RouterTestingModule } from '@angular/router/testing'; import { of as observableOf, Subscriber } from 'rxjs'; @@ -28,6 +29,7 @@ describe('SummaryService', () => { }; configureTestBed({ + imports: [RouterTestingModule], providers: [ SummaryService, AuthStorageService, 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 f7060361040c..e6f3e11ffb2b 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,11 +1,11 @@ import { HttpClient } from '@angular/common/http'; import { Injectable, NgZone } from '@angular/core'; +import { Router } from '@angular/router'; import * as _ from 'lodash'; import { BehaviorSubject, Subscription } from 'rxjs'; import { ExecutingTask } from '../models/executing-task'; -import { AuthStorageService } from './auth-storage.service'; import { ServicesModule } from './services.module'; @Injectable({ @@ -18,16 +18,12 @@ export class SummaryService { // Observable streams summaryData$ = this.summaryDataSource.asObservable(); - constructor( - private http: HttpClient, - private authStorageService: AuthStorageService, - private ngZone: NgZone - ) { + constructor(private http: HttpClient, private router: Router, private ngZone: NgZone) { this.refresh(); } refresh() { - if (this.authStorageService.isLoggedIn()) { + if (this.router.url !== '/login') { this.http.get('api/summary').subscribe((data) => { this.summaryDataSource.next(data); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.spec.ts index acd09955e784..ce64d7d4c097 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/task-wrapper.service.spec.ts @@ -1,5 +1,6 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { inject, TestBed } from '@angular/core/testing'; +import { RouterTestingModule } from '@angular/router/testing'; import { ToastModule } from 'ng2-toastr'; import { Observable } from 'rxjs/Observable'; @@ -16,7 +17,7 @@ describe('TaskWrapperService', () => { let service: TaskWrapperService; configureTestBed({ - imports: [HttpClientTestingModule, ToastModule.forRoot(), SharedModule], + imports: [HttpClientTestingModule, ToastModule.forRoot(), SharedModule, RouterTestingModule], providers: [TaskWrapperService] });