From: Volker Theile Date: Fri, 9 Mar 2018 10:32:43 +0000 (+0100) Subject: mgr/dashboard v2: Don't show details if multiple OSDs are selected X-Git-Tag: v13.0.2~20^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F20772%2Fhead;p=ceph.git mgr/dashboard v2: Don't show details if multiple OSDs are selected Signed-off-by: Volker Theile --- diff --git a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/cluster.module.ts b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/cluster.module.ts index 8f5b7b44ba92..9b683f0a8d40 100644 --- a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/cluster.module.ts +++ b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/cluster.module.ts @@ -3,7 +3,7 @@ import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { RouterModule } from '@angular/router'; -import { AccordionModule, TabsModule } from 'ngx-bootstrap'; +import { TabsModule } from 'ngx-bootstrap'; import { ComponentsModule } from '../../shared/components/components.module'; import { SharedModule } from '../../shared/shared.module'; import { PerformanceCounterModule } from '../performance-counter/performance-counter.module'; @@ -26,7 +26,6 @@ import { OsdService } from './osd/osd.service'; CommonModule, PerformanceCounterModule, ComponentsModule, - AccordionModule, TabsModule, SharedModule, RouterModule, diff --git a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.html b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.html index ac1cde1fa509..831e5620dc30 100644 --- a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.html +++ b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.html @@ -1,42 +1,36 @@ - - -
- - - - - - - - - - - - - - -

- Histogram not available -> {{ osd.histogram_failed }} -

-
-
-

Writes

- - -
-
-

Reads

- - -
-
-
-
+ + + + + + + + + + + + + + +

+ Histogram not available -> {{ osd.histogram_failed }} +

+
+
+

Writes

+ + +
+
+

Reads

+ + +
- - +
+
diff --git a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.spec.ts b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.spec.ts index 45b4b15ff8b6..67eaaa9c41b0 100644 --- a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.spec.ts +++ b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.spec.ts @@ -1,7 +1,7 @@ import { HttpClientModule } from '@angular/common/http'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { AccordionConfig, AccordionModule, TabsModule } from 'ngx-bootstrap'; +import { TabsModule } from 'ngx-bootstrap'; import { DataTableModule } from '../../../../shared/datatable/datatable.module'; import { PerformanceCounterModule } from '../../../performance-counter/performance-counter.module'; @@ -19,8 +19,7 @@ describe('OsdDetailsComponent', () => { TestBed.configureTestingModule({ imports: [ HttpClientModule, - AccordionModule, - TabsModule, + TabsModule.forRoot(), PerformanceCounterModule, DataTableModule ], @@ -28,7 +27,7 @@ describe('OsdDetailsComponent', () => { OsdDetailsComponent, OsdPerformanceHistogramComponent ], - providers: [OsdService, AccordionConfig] + providers: [OsdService] }) .compileComponents(); })); diff --git a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.ts b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.ts index 28f22f3f67c8..572e0d65b549 100644 --- a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.ts +++ b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-details/osd-details.component.ts @@ -10,28 +10,34 @@ import { OsdService } from '../osd.service'; styleUrls: ['./osd-details.component.scss'] }) export class OsdDetailsComponent implements OnInit { - @Input() selected?: any[]; + osd: any; + + @Input() selected?: any[] = []; constructor(private osdService: OsdService) {} ngOnInit() { - _.each(this.selected, (osd) => { - this.refresh(osd); - osd.autoRefresh = () => { - this.refresh(osd); + this.osd = { + loaded: false + }; + if (this.selected.length > 0) { + this.osd = this.selected[0]; + this.osd.autoRefresh = () => { + this.refresh(); }; - }); + this.refresh(); + } } - refresh(osd: any) { - this.osdService.getDetails(osd.tree.id).subscribe((data: any) => { - osd.details = data; - if (!_.isObject(data.histogram)) { - osd.histogram_failed = data.histogram; - osd.details.histogram = undefined; - } - osd.loaded = true; - }); + refresh() { + this.osdService.getDetails(this.osd.tree.id) + .subscribe((data: any) => { + this.osd.details = data; + if (!_.isObject(data.histogram)) { + this.osd.histogram_failed = data.histogram; + this.osd.details.histogram = undefined; + } + this.osd.loaded = true; + }); } - } diff --git a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.html b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.html index e8b9a0ce3304..d67eefb55bf8 100644 --- a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.html +++ b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.html @@ -7,7 +7,8 @@ + [detailsComponent]="detailsComponent" + [beforeShowDetails]="beforeShowDetails"> diff --git a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.spec.ts b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.spec.ts index 4871fd62c03f..06faf69da28c 100644 --- a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.spec.ts +++ b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.spec.ts @@ -1,7 +1,7 @@ import { HttpClientModule } from '@angular/common/http'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { AccordionModule, TabsModule } from 'ngx-bootstrap'; +import { TabsModule } from 'ngx-bootstrap'; import { DataTableModule } from '../../../../shared/datatable/datatable.module'; import { DimlessPipe } from '../../../../shared/pipes/dimless.pipe'; @@ -22,7 +22,6 @@ describe('OsdListComponent', () => { TestBed.configureTestingModule({ imports: [ HttpClientModule, - AccordionModule, PerformanceCounterModule, TabsModule, DataTableModule diff --git a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts index a179ba1601ec..5573550e9825 100644 --- a/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts +++ b/src/pybind/mgr/dashboard_v2/frontend/src/app/ceph/cluster/osd/osd-list/osd-list.component.ts @@ -2,6 +2,7 @@ import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core'; import { CellTemplate } from '../../../../shared/enum/cell-template.enum'; import { CdTableColumn } from '../../../../shared/models/cd-table-column'; +import { CdTableSelection } from '../../../../shared/models/cd-table-selection'; import { DimlessPipe } from '../../../../shared/pipes/dimless.pipe'; import { OsdService } from '../osd.service'; @@ -62,4 +63,8 @@ export class OsdListComponent implements OnInit { const select = (onState, offState) => osd[onState] ? onState : offState; return [select('up', 'down'), select('in', 'out')]; } + + beforeShowDetails(selection: CdTableSelection) { + return selection.hasSingleSelection; + } } diff --git a/src/pybind/mgr/dashboard_v2/frontend/src/app/shared/datatable/table/table.component.ts b/src/pybind/mgr/dashboard_v2/frontend/src/app/shared/datatable/table/table.component.ts index 870ed29633d8..5ba9c0c7129c 100644 --- a/src/pybind/mgr/dashboard_v2/frontend/src/app/shared/datatable/table/table.component.ts +++ b/src/pybind/mgr/dashboard_v2/frontend/src/app/shared/datatable/table/table.component.ts @@ -228,6 +228,7 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O } if (_.isFunction(this.beforeShowDetails)) { if (!this.beforeShowDetails(this.selection)) { + this.detailTemplate.viewContainerRef.clear(); return; } }