From: Patrick Nawracay Date: Mon, 4 Feb 2019 17:45:34 +0000 (+0100) Subject: mgr/dashboard: Fix search in `Source` column of RBD configuration list X-Git-Tag: v14.2.0~36^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7c6587f959dfeef364b960e4d2522eea873bfc8a;p=ceph-ci.git mgr/dashboard: Fix search in `Source` column of RBD configuration list Fixes: http://tracker.ceph.com/issues/37569 Signed-off-by: Patrick Nawracay --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.html index 80d0b94731b..12d61d86e55 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.html @@ -1,15 +1,18 @@ - + -
- Global - Image - Pool + +
+ {{ value | titlecase }} + {{ value | titlecase }} + {{ value | titlecase }}
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.spec.ts index 426c76b0c37..bab2324ac69 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.spec.ts @@ -63,4 +63,40 @@ describe('RbdConfigurationListComponent', () => { expect(component.data.length).toBe(1); expect(component.data.pop()).toBe(realOption); }); + + it('should filter the source column by its piped value', () => { + const poolConfTable = component.poolConfTable; + poolConfTable.data = [ + { + name: 'rbd_qos_read_iops_burst', + source: 0, + value: '50' + }, + { + name: 'rbd_qos_read_iops_limit', + source: 1, + value: '50' + }, + { + name: 'rbd_qos_write_iops_limit', + source: 0, + value: '100' + }, + { + name: 'rbd_qos_write_iops_burst', + source: 2, + value: '100' + } + ]; + const filter = (keyword) => { + poolConfTable.search = keyword; + poolConfTable.updateFilter(); + return poolConfTable.rows; + }; + expect(filter('').length).toBe(4); + expect(filter('source:global').length).toBe(2); + expect(filter('source:pool').length).toBe(1); + expect(filter('source:image').length).toBe(1); + expect(filter('source:zero').length).toBe(0); + }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.ts index aff443b0f3d..9dd62177713 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.ts @@ -1,12 +1,14 @@ import { Component, Input, OnChanges, OnInit, TemplateRef, ViewChild } from '@angular/core'; import { I18n } from '@ngx-translate/i18n-polyfill'; +import { TableComponent } from '../../../shared/datatable/table/table.component'; import { CdTableColumn } from '../../../shared/models/cd-table-column'; import { RbdConfigurationEntry, RbdConfigurationSourceField, RbdConfigurationType } from '../../../shared/models/configuration'; +import { RbdConfigurationSourcePipe } from '../../../shared/pipes/rbd-configuration-source.pipe'; import { FormatterService } from '../../../shared/services/formatter.service'; import { RbdConfigurationService } from '../../../shared/services/rbd-configuration.service'; @@ -23,6 +25,8 @@ export class RbdConfigurationListComponent implements OnInit, OnChanges { configurationSourceTpl: TemplateRef; @ViewChild('configurationValueTpl') configurationValueTpl: TemplateRef; + @ViewChild('poolConfTable') + poolConfTable: TableComponent; readonly sourceField = RbdConfigurationSourceField; readonly typeField = RbdConfigurationType; @@ -38,7 +42,12 @@ export class RbdConfigurationListComponent implements OnInit, OnChanges { { prop: 'displayName', name: this.i18n('Name') }, { prop: 'description', name: this.i18n('Description') }, { prop: 'name', name: this.i18n('Key') }, - { prop: 'source', name: this.i18n('Source'), cellTemplate: this.configurationSourceTpl }, + { + prop: 'source', + name: this.i18n('Source'), + cellTemplate: this.configurationSourceTpl, + pipe: new RbdConfigurationSourcePipe() + }, { prop: 'value', name: this.i18n('Value'), cellTemplate: this.configurationValueTpl } ]; } diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/pipes.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/pipes.module.ts index 85db7a7c96f..b849af25bfd 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/pipes.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/pipes.module.ts @@ -17,6 +17,7 @@ import { ListPipe } from './list.pipe'; import { LogPriorityPipe } from './log-priority.pipe'; import { MillisecondsPipe } from './milliseconds.pipe'; import { OrdinalPipe } from './ordinal.pipe'; +import { RbdConfigurationSourcePipe } from './rbd-configuration-source.pipe'; import { RelativeDatePipe } from './relative-date.pipe'; import { RoundPipe } from './round.pipe'; import { UpperFirstPipe } from './upper-first.pipe'; @@ -42,7 +43,8 @@ import { UpperFirstPipe } from './upper-first.pipe'; OrdinalPipe, MillisecondsPipe, IopsPipe, - UpperFirstPipe + UpperFirstPipe, + RbdConfigurationSourcePipe ], exports: [ BooleanTextPipe, @@ -63,7 +65,8 @@ import { UpperFirstPipe } from './upper-first.pipe'; OrdinalPipe, MillisecondsPipe, IopsPipe, - UpperFirstPipe + UpperFirstPipe, + RbdConfigurationSourcePipe ], providers: [ BooleanTextPipe, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/rbd-configuration-source.pipe.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/rbd-configuration-source.pipe.spec.ts new file mode 100644 index 00000000000..9c0346bd688 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/rbd-configuration-source.pipe.spec.ts @@ -0,0 +1,22 @@ +import { RbdConfigurationSourcePipe } from './rbd-configuration-source.pipe'; + +describe('RbdConfigurationSourcePipePipe', () => { + let pipe: RbdConfigurationSourcePipe; + + beforeEach(() => { + pipe = new RbdConfigurationSourcePipe(); + }); + + it('create an instance', () => { + expect(pipe).toBeTruthy(); + }); + + it('should transform correctly', () => { + expect(pipe.transform('foo')).not.toBeDefined(); + expect(pipe.transform(-1)).not.toBeDefined(); + expect(pipe.transform(0)).toBe('global'); + expect(pipe.transform(1)).toBe('pool'); + expect(pipe.transform(2)).toBe('image'); + expect(pipe.transform(-3)).not.toBeDefined(); + }); +}); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/rbd-configuration-source.pipe.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/rbd-configuration-source.pipe.ts new file mode 100644 index 00000000000..bb42d3f1c02 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/rbd-configuration-source.pipe.ts @@ -0,0 +1,15 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'rbdConfigurationSource' +}) +export class RbdConfigurationSourcePipe implements PipeTransform { + transform(value: any): any { + const sourceMap = { + 0: 'global', + 1: 'pool', + 2: 'image' + }; + return sourceMap[value]; + } +} diff --git a/src/pybind/mgr/dashboard/frontend/src/locale/messages.xlf b/src/pybind/mgr/dashboard/frontend/src/locale/messages.xlf index 087c3313aeb..411f5983fa7 100644 --- a/src/pybind/mgr/dashboard/frontend/src/locale/messages.xlf +++ b/src/pybind/mgr/dashboard/frontend/src/locale/messages.xlf @@ -3556,35 +3556,19 @@ app/ceph/performance-counter/table-performance-counter/table-performance-counter.component.html 12 - - Global + + app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.html - 10 - - - app/ceph/block/rbd-details/rbd-details.component.html - 137 + 13 - - Image app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.html - 11 - - - app/ceph/block/rbd-details/rbd-details.component.html - 135 + 14 - - Pool app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.html - 12 - - - app/ceph/block/rbd-details/rbd-details.component.html - 18 + 15 RBD Configuration @@ -3873,6 +3857,12 @@ app/ceph/block/rbd-details/rbd-details.component.html 2 + + Pool + + app/ceph/block/rbd-details/rbd-details.component.html + 18 + Data Pool @@ -3943,12 +3933,24 @@ app/ceph/block/rbd-details/rbd-details.component.html 119 + + Image + + app/ceph/block/rbd-details/rbd-details.component.html + 135 + This setting overrides the global value app/ceph/block/rbd-details/rbd-details.component.html 135 + + Global + + app/ceph/block/rbd-details/rbd-details.component.html + 137 + This is the global value. No value for this option has been set for this image.