From: Tiago Melo Date: Wed, 9 May 2018 17:24:03 +0000 (+0100) Subject: mgr/dashboard: Rename cephfs component to 'cephfs-detail' X-Git-Tag: v14.0.1~1205^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=5097d841903df21be86a55b897db07d130974666;p=ceph-ci.git mgr/dashboard: Rename cephfs component to 'cephfs-detail' Signed-off-by: Tiago Melo --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.html new file mode 100644 index 00000000000..f56117085b8 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.html @@ -0,0 +1,60 @@ + + +
+
+
+ Ranks + + + +
+ + + +
+ +
+
+ Pools + + + + +
+
+
+ +
+
+ +
+
+ + + + + + + + {{ row.state === 'standby-replay' ? 'Evts' : 'Reqs' }}: {{ value | dimless }} /s + +
+ + + +
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.scss b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.scss new file mode 100644 index 00000000000..d82829af85c --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.scss @@ -0,0 +1,3 @@ +.progress { + margin-bottom: 0px; +} 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 new file mode 100644 index 00000000000..f1d19b46691 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.spec.ts @@ -0,0 +1,66 @@ +import { Component, Input } from '@angular/core'; +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +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 { CephfsService } from '../../../shared/api/cephfs.service'; +import { SharedModule } from '../../../shared/shared.module'; +import { CephfsChartComponent } from '../cephfs-chart/cephfs-chart.component'; +import { ClientsComponent } from '../clients/clients.component'; +import { CephfsDetailComponent } from './cephfs-detail.component'; + +@Component({ selector: 'cd-cephfs-chart', template: '' }) +class CephfsChartStubComponent { + @Input() mdsCounter: any; +} + +@Component({ selector: 'cd-clients', template: '' }) +class ClientsStubComponent { + @Input() mdsCounter: any; +} + +describe('CephfsDetailComponent', () => { + let component: CephfsDetailComponent; + let fixture: ComponentFixture; + + const fakeFilesystemService = { + getCephfs: (id) => { + return Observable.create((observer) => { + return () => console.log('disposed'); + }); + }, + getMdsCounters: (id) => { + return Observable.create((observer) => { + return () => console.log('disposed'); + }); + } + }; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + imports: [ + SharedModule, + ChartsModule, + RouterTestingModule, + BsDropdownModule.forRoot(), + ProgressbarModule.forRoot(), + TabsModule.forRoot() + ], + declarations: [CephfsDetailComponent, CephfsChartStubComponent, ClientsStubComponent], + providers: [{ provide: CephfsService, useValue: fakeFilesystemService }] + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(CephfsDetailComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); 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 new file mode 100644 index 00000000000..378261026d1 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-detail/cephfs-detail.component.ts @@ -0,0 +1,129 @@ +import { Component, Input, OnChanges, OnInit, TemplateRef, ViewChild } from '@angular/core'; + +import * as _ from 'lodash'; + +import { CephfsService } from '../../../shared/api/cephfs.service'; +import { CdTableSelection } from '../../../shared/models/cd-table-selection'; +import { DimlessBinaryPipe } from '../../../shared/pipes/dimless-binary.pipe'; +import { DimlessPipe } from '../../../shared/pipes/dimless.pipe'; + +@Component({ + selector: 'cd-cephfs-detail', + templateUrl: './cephfs-detail.component.html', + styleUrls: ['./cephfs-detail.component.scss'] +}) +export class CephfsDetailComponent implements OnChanges, OnInit { + @ViewChild('poolUsageTpl') poolUsageTpl: TemplateRef; + @ViewChild('activityTmpl') activityTmpl: TemplateRef; + + @Input() selection: CdTableSelection; + + selectedItem: any; + + id: number; + name: string; + ranks: any; + pools: any; + standbys = []; + clientCount: number; + mdsCounters = {}; + + objectValues = Object.values; + clientsSelect = false; + + constructor( + private cephfsService: CephfsService, + private dimlessBinary: DimlessBinaryPipe, + private dimless: DimlessPipe + ) {} + + ngOnChanges() { + if (this.selection.hasSelection) { + this.selectedItem = this.selection.first(); + + if (this.id !== this.selectedItem.id) { + this.id = this.selectedItem.id; + this.ranks.data = []; + this.pools.data = []; + this.standbys = []; + this.mdsCounters = {}; + } + } + } + + ngOnInit() { + this.ranks = { + columns: [ + { prop: 'rank' }, + { prop: 'state' }, + { prop: 'mds', name: 'Daemon' }, + { prop: 'activity', cellTemplate: this.activityTmpl }, + { prop: 'dns', name: 'Dentries', pipe: this.dimless }, + { prop: 'inos', name: 'Inodes', pipe: this.dimless } + ], + data: [] + }; + + this.pools = { + columns: [ + { prop: 'pool' }, + { prop: 'type' }, + { prop: 'size', pipe: this.dimlessBinary }, + { + name: 'Usage', + cellTemplate: this.poolUsageTpl, + comparator: (valueA, valueB, rowA, rowB, sortDirection) => { + const valA = rowA.used / rowA.avail; + const valB = rowB.used / rowB.avail; + + if (valA === valB) { + return 0; + } + + if (valA > valB) { + return 1; + } else { + return -1; + } + } + } + ], + data: [] + }; + } + + refresh() { + this.cephfsService.getCephfs(this.id).subscribe((data: any) => { + this.ranks.data = data.cephfs.ranks; + this.pools.data = data.cephfs.pools; + this.pools.data.forEach((pool) => { + pool.size = pool.used + pool.avail; + }); + this.standbys = [ + { + key: 'Standby daemons', + value: data.standbys.map((value) => value.name).join(', ') + } + ]; + this.name = data.cephfs.name; + this.clientCount = data.cephfs.client_count; + }); + + this.cephfsService.getMdsCounters(this.id).subscribe((data) => { + _.each(this.mdsCounters, (value, key) => { + if (data[key] === undefined) { + delete this.mdsCounters[key]; + } + }); + + _.each(data, (mdsData: any, mdsName) => { + mdsData.name = mdsName; + this.mdsCounters[mdsName] = mdsData; + }); + }); + } + + trackByFn(index, item) { + return item.name; + } +} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-list/cephfs-list.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-list/cephfs-list.component.html index e72238d0eb6..6494b2f1405 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-list/cephfs-list.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs-list/cephfs-list.component.html @@ -13,7 +13,7 @@ forceIdentifier="true" selectionType="single" (updateSelection)="updateSelection($event)"> - - + 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 96497150b07..65856bd5c7b 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 @@ -8,8 +8,8 @@ import { CdTableSelection } from '../../../shared/models/cd-table-selection'; import { SharedModule } from '../../../shared/shared.module'; import { CephfsListComponent } from './cephfs-list.component'; -@Component({ selector: 'cd-cephfs', template: '' }) -class CephfsStubComponent { +@Component({ selector: 'cd-cephfs-detail', template: '' }) +class CephfsDetailStubComponent { @Input() selection: CdTableSelection; } @@ -28,7 +28,7 @@ describe('CephfsListComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [SharedModule], - declarations: [CephfsListComponent, CephfsStubComponent], + declarations: [CephfsListComponent, CephfsDetailStubComponent], providers: [{ provide: CephfsService, useValue: fakeService }] }).compileComponents(); })); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs.module.ts index 62a9f368042..eb6d2979f62 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs.module.ts @@ -8,8 +8,8 @@ import { TabsModule } from 'ngx-bootstrap/tabs'; import { AppRoutingModule } from '../../app-routing.module'; import { SharedModule } from '../../shared/shared.module'; import { CephfsChartComponent } from './cephfs-chart/cephfs-chart.component'; +import { CephfsDetailComponent } from './cephfs-detail/cephfs-detail.component'; import { CephfsListComponent } from './cephfs-list/cephfs-list.component'; -import { CephfsComponent } from './cephfs/cephfs.component'; import { ClientsComponent } from './clients/clients.component'; @NgModule({ @@ -21,6 +21,6 @@ import { ClientsComponent } from './clients/clients.component'; ProgressbarModule.forRoot(), TabsModule.forRoot() ], - declarations: [CephfsComponent, ClientsComponent, CephfsChartComponent, CephfsListComponent] + declarations: [CephfsDetailComponent, ClientsComponent, CephfsChartComponent, CephfsListComponent] }) export class CephfsModule {} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs/cephfs.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs/cephfs.component.html deleted file mode 100644 index 219defb8ffb..00000000000 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs/cephfs.component.html +++ /dev/null @@ -1,59 +0,0 @@ - - -
-
-
- Ranks - - - -
- - - -
- -
-
- Pools - - - - -
-
-
- -
-
- -
-
- - - - - - - - {{ row.state === 'standby-replay' ? 'Evts' : 'Reqs' }}: {{ value | dimless }} /s - -
- - - -
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs/cephfs.component.scss b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs/cephfs.component.scss deleted file mode 100644 index d82829af85c..00000000000 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs/cephfs.component.scss +++ /dev/null @@ -1,3 +0,0 @@ -.progress { - margin-bottom: 0px; -} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs/cephfs.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs/cephfs.component.spec.ts deleted file mode 100644 index 9d6fe412247..00000000000 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs/cephfs.component.spec.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { NO_ERRORS_SCHEMA } from '@angular/core'; -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { RouterTestingModule } from '@angular/router/testing'; - -import { Observable } from 'rxjs/Observable'; - -import { CephfsService } from '../../../shared/api/cephfs.service'; -import { DimlessBinaryPipe } from '../../../shared/pipes/dimless-binary.pipe'; -import { DimlessPipe } from '../../../shared/pipes/dimless.pipe'; -import { FormatterService } from '../../../shared/services/formatter.service'; -import { CephfsComponent } from './cephfs.component'; - -describe('CephfsComponent', () => { - let component: CephfsComponent; - let fixture: ComponentFixture; - - const fakeFilesystemService = { - getCephfs: (id) => { - return Observable.create((observer) => { - return () => console.log('disposed'); - }); - }, - getMdsCounters: (id) => { - return Observable.create((observer) => { - return () => console.log('disposed'); - }); - } - }; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [RouterTestingModule], - schemas: [NO_ERRORS_SCHEMA], - declarations: [CephfsComponent, DimlessPipe], - providers: [ - DimlessPipe, - DimlessBinaryPipe, - FormatterService, - { provide: CephfsService, useValue: fakeFilesystemService } - ] - }).compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(CephfsComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs/cephfs.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs/cephfs.component.ts deleted file mode 100644 index f35dee2519b..00000000000 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cephfs/cephfs/cephfs.component.ts +++ /dev/null @@ -1,129 +0,0 @@ -import { Component, Input, OnChanges, OnInit, TemplateRef, ViewChild } from '@angular/core'; - -import * as _ from 'lodash'; - -import { CephfsService } from '../../../shared/api/cephfs.service'; -import { CdTableSelection } from '../../../shared/models/cd-table-selection'; -import { DimlessBinaryPipe } from '../../../shared/pipes/dimless-binary.pipe'; -import { DimlessPipe } from '../../../shared/pipes/dimless.pipe'; - -@Component({ - selector: 'cd-cephfs', - templateUrl: './cephfs.component.html', - styleUrls: ['./cephfs.component.scss'] -}) -export class CephfsComponent implements OnChanges, OnInit { - @ViewChild('poolUsageTpl') poolUsageTpl: TemplateRef; - @ViewChild('activityTmpl') activityTmpl: TemplateRef; - - @Input() selection: CdTableSelection; - - selectedItem: any; - - id: number; - name: string; - ranks: any; - pools: any; - standbys = []; - clientCount: number; - mdsCounters = {}; - - objectValues = Object.values; - clientsSelect = false; - - constructor( - private cephfsService: CephfsService, - private dimlessBinary: DimlessBinaryPipe, - private dimless: DimlessPipe - ) {} - - ngOnChanges() { - if (this.selection.hasSelection) { - this.selectedItem = this.selection.first(); - - if (this.id !== this.selectedItem.id) { - this.id = this.selectedItem.id; - this.ranks.data = []; - this.pools.data = []; - this.standbys = []; - this.mdsCounters = {}; - } - } - } - - ngOnInit() { - this.ranks = { - columns: [ - { prop: 'rank' }, - { prop: 'state' }, - { prop: 'mds', name: 'Daemon' }, - { prop: 'activity', cellTemplate: this.activityTmpl }, - { prop: 'dns', name: 'Dentries', pipe: this.dimless }, - { prop: 'inos', name: 'Inodes', pipe: this.dimless } - ], - data: [] - }; - - this.pools = { - columns: [ - { prop: 'pool' }, - { prop: 'type' }, - { prop: 'size', pipe: this.dimlessBinary }, - { - name: 'Usage', - cellTemplate: this.poolUsageTpl, - comparator: (valueA, valueB, rowA, rowB, sortDirection) => { - const valA = rowA.used / rowA.avail; - const valB = rowB.used / rowB.avail; - - if (valA === valB) { - return 0; - } - - if (valA > valB) { - return 1; - } else { - return -1; - } - } - } - ], - data: [] - }; - } - - refresh() { - this.cephfsService.getCephfs(this.id).subscribe((data: any) => { - this.ranks.data = data.cephfs.ranks; - this.pools.data = data.cephfs.pools; - this.pools.data.forEach((pool) => { - pool.size = pool.used + pool.avail; - }); - this.standbys = [ - { - key: 'Standby daemons', - value: data.standbys.map((value) => value.name).join(', ') - } - ]; - this.name = data.cephfs.name; - this.clientCount = data.cephfs.client_count; - }); - - this.cephfsService.getMdsCounters(this.id).subscribe((data) => { - _.each(this.mdsCounters, (value, key) => { - if (data[key] === undefined) { - delete this.mdsCounters[key]; - } - }); - - _.each(data, (mdsData: any, mdsName) => { - mdsData.name = mdsName; - this.mdsCounters[mdsName] = mdsData; - }); - }); - } - - trackByFn(index, item) { - return item.name; - } -}