From: Pedro Gonzalez Gomez Date: Mon, 25 Jul 2022 19:50:47 +0000 (+0200) Subject: mgr/dashboard: dashboard-v3: details card X-Git-Tag: v18.1.0~361^2~4 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=cc93d5308002c21efae155cf97b6bddd73f9db17;p=ceph-ci.git mgr/dashboard: dashboard-v3: details card mgr/dashboard: added interface, changed html table to list, using mgrModuleService now tracker: https://tracker.ceph.com/issues/58731 Signed-off-by: Pedro Gonzalez Gomez --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/new-dashboard/dashboard/dashboard.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/new-dashboard/dashboard/dashboard.component.spec.ts index cf3f518f1cf..8e981a933cc 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/new-dashboard/dashboard/dashboard.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/new-dashboard/dashboard/dashboard.component.spec.ts @@ -1,22 +1,62 @@ +import { HttpClientTestingModule } from '@angular/common/http/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { RouterTestingModule } from '@angular/router/testing'; +import { BehaviorSubject, of } from 'rxjs'; + +import { ConfigurationService } from '~/app/shared/api/configuration.service'; +import { MgrModuleService } from '~/app/shared/api/mgr-module.service'; +import { SummaryService } from '~/app/shared/services/summary.service'; import { configureTestBed } from '~/testing/unit-test-helper'; import { CardComponent } from '../card/card.component'; import { DashboardComponent } from './dashboard.component'; +export class SummaryServiceMock { + summaryDataSource = new BehaviorSubject({ + version: + 'ceph version 17.0.0-12222-gcd0cd7cb ' + + '(b8193bb4cda16ccc5b028c3e1df62bc72350a15d) quincy (dev)' + }); + summaryData$ = this.summaryDataSource.asObservable(); + + subscribe(call: any) { + return this.summaryData$.subscribe(call); + } +} + describe('CardComponent', () => { let component: DashboardComponent; let fixture: ComponentFixture; + let configurationService: ConfigurationService; + let orchestratorService: MgrModuleService; + + const configValueData: any = { + value: [ + { + section: 'mgr', + value: 'e90a0d58-658e-4148-8f61-e896c86f0696' + } + ] + }; + + const orchData: any = { + log_level: '', + log_to_cluster: false, + log_to_cluster_level: 'info', + log_to_file: false, + orchestrator: 'cephadm' + }; configureTestBed({ - imports: [RouterTestingModule], - declarations: [DashboardComponent, CardComponent] + imports: [HttpClientTestingModule], + declarations: [DashboardComponent, CardComponent], + providers: [{ provide: SummaryService, useClass: SummaryServiceMock }] }); beforeEach(() => { fixture = TestBed.createComponent(DashboardComponent); component = fixture.componentInstance; + configurationService = TestBed.inject(ConfigurationService); + orchestratorService = TestBed.inject(MgrModuleService); }); it('should create', () => { @@ -27,4 +67,13 @@ describe('CardComponent', () => { const dashboardCards = fixture.debugElement.nativeElement.querySelectorAll('cd-card'); expect(dashboardCards.length).toBe(5); }); + + it('should get corresponding data into detailsCardData', () => { + spyOn(configurationService, 'get').and.returnValue(of(configValueData)); + spyOn(orchestratorService, 'getConfig').and.returnValue(of(orchData)); + component.ngOnInit(); + expect(component.detailsCardData.fsid).toBe('e90a0d58-658e-4148-8f61-e896c86f0696'); + expect(component.detailsCardData.orchestrator).toBe('Cephadm'); + expect(component.detailsCardData.cephVersion).toBe('17.0.0-12222-gcd0cd7cb quincy (dev)'); + }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/new-dashboard/dashboard/dashboard.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/new-dashboard/dashboard/dashboard.component.ts index 843bc863728..a43b319e00a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/new-dashboard/dashboard/dashboard.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/new-dashboard/dashboard/dashboard.component.ts @@ -1,4 +1,9 @@ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; + +import { ConfigurationService } from '~/app/shared/api/configuration.service'; +import { MgrModuleService } from '~/app/shared/api/mgr-module.service'; +import { DashboardDetails } from '~/app/shared/models/cd-details'; +import { SummaryService } from '~/app/shared/services/summary.service'; @Component({ selector: 'cd-dashboard', diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/models/cd-details.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/models/cd-details.ts new file mode 100644 index 00000000000..d021f19eba7 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/models/cd-details.ts @@ -0,0 +1,5 @@ +export interface DashboardDetails { + fsid?: string; + orchestrator?: string; + cephVersion?: string; +}