]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: Refactor log pipe
authorSebastian Krah <skrah@suse.com>
Tue, 29 Jan 2019 13:32:52 +0000 (14:32 +0100)
committerSebastian Krah <skrah@suse.com>
Tue, 29 Jan 2019 13:59:14 +0000 (14:59 +0100)
The pipe returns a class name instead of an object now. This has the advantage,
that the layout can be modified directly in scss and keeps the code seperated
from the layout.

Fixes: https://tracker.ceph.com/issues/37916
Signed-off-by: Sebastian Krah <skrah@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/dashboard.module.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/log-priority.pipe.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/log-priority.pipe.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/pipes.module.ts

index 7d751f0362bc65dba664df0a05dec308c45d2909..49630da4ec5d6861dfc765f972911c5adeeb9206 100644 (file)
@@ -13,7 +13,6 @@ import { HealthPieComponent } from './health-pie/health-pie.component';
 import { HealthComponent } from './health/health.component';
 import { InfoCardComponent } from './info-card/info-card.component';
 import { InfoGroupComponent } from './info-group/info-group.component';
-import { LogColorPipe } from './log-color.pipe';
 import { MdsSummaryPipe } from './mds-summary.pipe';
 import { MgrSummaryPipe } from './mgr-summary.pipe';
 import { MonSummaryPipe } from './mon-summary.pipe';
@@ -35,7 +34,6 @@ import { OsdSummaryPipe } from './osd-summary.pipe';
     DashboardComponent,
     MonSummaryPipe,
     OsdSummaryPipe,
-    LogColorPipe,
     MgrSummaryPipe,
     MdsSummaryPipe,
     HealthPieComponent,
index 58514878cb2a7604dddb29fe15e96bf89ea28a4c..45d677c2abae057ad8d64d046dbe7b41b5de3ac4 100644 (file)
@@ -1,34 +1,32 @@
-import { LogColorPipe } from './log-color.pipe';
+import { LogPriorityPipe } from './log-priority.pipe';
 
-describe('LogColorPipe', () => {
-  const pipe = new LogColorPipe();
+describe('LogPriorityPipe', () => {
+  const pipe = new LogPriorityPipe();
 
   it('create an instance', () => {
     expect(pipe).toBeTruthy();
   });
 
   it('transforms "INF"', () => {
-    const value = { priority: '[INF]' };
-    expect(pipe.transform(value)).toBe('');
+    const value = '[INF]';
+    const result = 'info';
+    expect(pipe.transform(value)).toEqual(result);
   });
 
   it('transforms "WRN"', () => {
-    const value = { priority: '[WRN]' };
-    const result = {
-      color: '#ffa500',
-      'font-weight': 'bold'
-    };
+    const value = '[WRN]';
+    const result = 'warn';
     expect(pipe.transform(value)).toEqual(result);
   });
 
   it('transforms "ERR"', () => {
-    const value = { priority: '[ERR]' };
-    const result = { color: '#FF2222' };
+    const value = '[ERR]';
+    const result = 'err';
     expect(pipe.transform(value)).toEqual(result);
   });
 
   it('transforms others', () => {
-    const value = { priority: '[foo]' };
+    const value = '[foo]';
     expect(pipe.transform(value)).toBe('');
   });
 });
index eb60ddba4c336e498322bb2dacf6fb37af7c234f..ea46d16c0e3a070087c9778717f5f3d99299e4ca 100644 (file)
@@ -1,21 +1,18 @@
 import { Pipe, PipeTransform } from '@angular/core';
 
 @Pipe({
-  name: 'logColor'
+  name: 'logPriority'
 })
-export class LogColorPipe implements PipeTransform {
+export class LogPriorityPipe implements PipeTransform {
   transform(value: any, args?: any): any {
-    if (value.priority === '[INF]') {
-      return ''; // Inherit
-    } else if (value.priority === '[WRN]') {
-      return {
-        color: '#ffa500',
-        'font-weight': 'bold'
-      };
-    } else if (value.priority === '[ERR]') {
-      return { color: '#FF2222' };
+    if (value === '[INF]') {
+      return 'info';
+    } else if (value === '[WRN]') {
+      return 'warn';
+    } else if (value === '[ERR]') {
+      return 'err';
     } else {
-      return '';
+      return ''; // Inherit
     }
   }
 }
index 3da26d7a16576d380ffe1bdae03f5c7e67642293..cb5b69c0a205bfba9945cc17e83e09f1bbb75b43 100644 (file)
@@ -11,6 +11,7 @@ import { EncodeUriPipe } from './encode-uri.pipe';
 import { FilterPipe } from './filter.pipe';
 import { HealthColorPipe } from './health-color.pipe';
 import { ListPipe } from './list.pipe';
+import { LogPriorityPipe } from './log-priority.pipe';
 import { RelativeDatePipe } from './relative-date.pipe';
 import { RoundPipe } from './round.pipe';
 
@@ -24,6 +25,7 @@ import { RoundPipe } from './round.pipe';
     CephReleaseNamePipe,
     RelativeDatePipe,
     ListPipe,
+    LogPriorityPipe,
     FilterPipe,
     CdDatePipe,
     EmptyPipe,
@@ -38,6 +40,7 @@ import { RoundPipe } from './round.pipe';
     CephReleaseNamePipe,
     RelativeDatePipe,
     ListPipe,
+    LogPriorityPipe,
     FilterPipe,
     CdDatePipe,
     EmptyPipe,
@@ -52,6 +55,7 @@ import { RoundPipe } from './round.pipe';
     DimlessPipe,
     RelativeDatePipe,
     ListPipe,
+    LogPriorityPipe,
     CdDatePipe,
     EmptyPipe,
     EncodeUriPipe