]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: dashboard-v3: details card
authorPedro Gonzalez Gomez <pegonzal@redhat.com>
Mon, 25 Jul 2022 19:50:47 +0000 (21:50 +0200)
committerPedro Gonzalez Gomez <pegonzal@redhat.com>
Wed, 15 Feb 2023 12:18:08 +0000 (13:18 +0100)
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 <pegonzal@redhat.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/new-dashboard/dashboard/dashboard.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/new-dashboard/dashboard/dashboard.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/models/cd-details.ts [new file with mode: 0644]

index cf3f518f1cf20856711dfca4321e20d624e8f74f..8e981a933cc1b52edc76f36eab46e0553963a327 100644 (file)
@@ -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<DashboardComponent>;
+  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)');
+  });
 });
index 843bc863728ea248f97e761fb0382110ce862df4..a43b319e00ad68f51fa6748856e433af3b572d9d 100644 (file)
@@ -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 (file)
index 0000000..d021f19
--- /dev/null
@@ -0,0 +1,5 @@
+export interface DashboardDetails {
+  fsid?: string;
+  orchestrator?: string;
+  cephVersion?: string;
+}