]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Fix search in `Source` column of RBD configuration list 26765/head
authorPatrick Nawracay <pnawracay@suse.com>
Mon, 4 Feb 2019 17:45:34 +0000 (18:45 +0100)
committerPatrick Nawracay <pnawracay@suse.com>
Tue, 5 Mar 2019 10:30:30 +0000 (11:30 +0100)
Fixes: http://tracker.ceph.com/issues/37569
Signed-off-by: Patrick Nawracay <pnawracay@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/pipes.module.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/rbd-configuration-source.pipe.spec.ts [new file with mode: 0644]
src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/rbd-configuration-source.pipe.ts [new file with mode: 0644]
src/pybind/mgr/dashboard/frontend/src/locale/messages.xlf

index 80d0b94731befbc9f482deccedeaaab78aa2ce3e..12d61d86e558e681800110624a508e67b6ddf045 100644 (file)
@@ -1,15 +1,18 @@
-<cd-table [data]="data"
-          [columns]="poolConfigurationColumns"
-          identifier="name">
+<cd-table
+  #poolConfTable
+  [data]="data"
+  [columns]="poolConfigurationColumns"
+  identifier="name">
 </cd-table>
 
 <ng-template #configurationSourceTpl
              let-row="row"
              let-value="value">
-  <div [ngSwitch]="+value">
-    <span *ngSwitchCase="sourceField.global" i18n>Global</span>
-    <strong *ngSwitchCase="sourceField.image" i18n>Image</strong>
-    <strong *ngSwitchCase="sourceField.pool" i18n>Pool</strong>
+
+  <div [ngSwitch]="value">
+    <span *ngSwitchCase="'global'" i18n>{{ value | titlecase }}</span>
+    <strong *ngSwitchCase="'image'" i18n>{{ value | titlecase }}</strong>
+    <strong *ngSwitchCase="'pool'" i18n>{{ value | titlecase }}</strong>
   </div>
 </ng-template>
 
index 426c76b0c377184ffdf91ec06a936ff67a1a00d6..bab2324ac69f24fec1a4599bd928e054f0e19590 100644 (file)
@@ -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);
+  });
 });
index aff443b0f3df6910151c123a99bf327d3c9a5ab4..9dd6217771310796bbfa6398c89a81e5cfb21f4d 100644 (file)
@@ -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<any>;
   @ViewChild('configurationValueTpl')
   configurationValueTpl: TemplateRef<any>;
+  @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 }
     ];
   }
index 85db7a7c96f5c6bfc95aec629ab373d08e6f1328..b849af25bfd133294f8b8ab1e210430092285503 100644 (file)
@@ -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 (file)
index 0000000..9c0346b
--- /dev/null
@@ -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 (file)
index 0000000..bb42d3f
--- /dev/null
@@ -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];
+  }
+}
index 087c3313aeb8cffeaa5ad62a7e446df4db0541e4..411f5983fa7d6b4bd09e0825e83bdd2997428013 100644 (file)
           <context context-type="sourcefile">app/ceph/performance-counter/table-performance-counter/table-performance-counter.component.html</context>
           <context context-type="linenumber">12</context>
         </context-group>
-      </trans-unit><trans-unit id="5decb3917d46a9ac6e5813699801becb7c3c1455" datatype="html">
-        <source>Global</source>
+      </trans-unit><trans-unit id="a949d7e577902d0e5dc5d0971bb0170a21be7728" datatype="html">
+        <source><x id="INTERPOLATION" equiv-text="{{ value | titlecase }}"/></source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.html</context>
-          <context context-type="linenumber">10</context>
-        </context-group>
-        <context-group purpose="location">
-          <context context-type="sourcefile">app/ceph/block/rbd-details/rbd-details.component.html</context>
-          <context context-type="linenumber">137</context>
+          <context context-type="linenumber">13</context>
         </context-group>
-      </trans-unit><trans-unit id="a5f9ba9bb9faa8284bcadb1cdbc6aaf969e9c4bb" datatype="html">
-        <source>Image</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.html</context>
-          <context context-type="linenumber">11</context>
-        </context-group>
-        <context-group purpose="location">
-          <context context-type="sourcefile">app/ceph/block/rbd-details/rbd-details.component.html</context>
-          <context context-type="linenumber">135</context>
+          <context context-type="linenumber">14</context>
         </context-group>
-      </trans-unit><trans-unit id="e70fcca5a99575cffef3ff8cbd5e69f06ffd0f1c" datatype="html">
-        <source>Pool</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/rbd-configuration-list/rbd-configuration-list.component.html</context>
-          <context context-type="linenumber">12</context>
-        </context-group>
-        <context-group purpose="location">
-          <context context-type="sourcefile">app/ceph/block/rbd-details/rbd-details.component.html</context>
-          <context context-type="linenumber">18</context>
+          <context context-type="linenumber">15</context>
         </context-group>
       </trans-unit><trans-unit id="ff92fbdec9fdd5054493eeda0d7ee8b450f83e72" datatype="html">
         <source>RBD Configuration</source>
           <context context-type="sourcefile">app/ceph/block/rbd-details/rbd-details.component.html</context>
           <context context-type="linenumber">2</context>
         </context-group>
+      </trans-unit><trans-unit id="e70fcca5a99575cffef3ff8cbd5e69f06ffd0f1c" datatype="html">
+        <source>Pool</source>
+        <context-group purpose="location">
+          <context context-type="sourcefile">app/ceph/block/rbd-details/rbd-details.component.html</context>
+          <context context-type="linenumber">18</context>
+        </context-group>
       </trans-unit><trans-unit id="03cc5b14b0a20d075e9009ff021f4f1660ba348a" datatype="html">
         <source>Data Pool</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/rbd-details/rbd-details.component.html</context>
           <context context-type="linenumber">119</context>
         </context-group>
+      </trans-unit><trans-unit id="a5f9ba9bb9faa8284bcadb1cdbc6aaf969e9c4bb" datatype="html">
+        <source>Image</source>
+        <context-group purpose="location">
+          <context context-type="sourcefile">app/ceph/block/rbd-details/rbd-details.component.html</context>
+          <context context-type="linenumber">135</context>
+        </context-group>
       </trans-unit><trans-unit id="58e58f1a8786da9031a05e6770c5dafce82badf5" datatype="html">
         <source>This setting overrides the global value</source>
         <context-group purpose="location">
           <context context-type="sourcefile">app/ceph/block/rbd-details/rbd-details.component.html</context>
           <context context-type="linenumber">135</context>
         </context-group>
+      </trans-unit><trans-unit id="5decb3917d46a9ac6e5813699801becb7c3c1455" datatype="html">
+        <source>Global</source>
+        <context-group purpose="location">
+          <context context-type="sourcefile">app/ceph/block/rbd-details/rbd-details.component.html</context>
+          <context context-type="linenumber">137</context>
+        </context-group>
       </trans-unit><trans-unit id="36b46714164964c6258b08ed0a25f57d8a950f92" datatype="html">
         <source>This is the global value. No value for this option has been set for this image.</source>
         <context-group purpose="location">