From: Sebastian Krah Date: Tue, 29 Jan 2019 13:32:52 +0000 (+0100) Subject: mgr/dashboard: Refactor log pipe X-Git-Tag: v14.1.0~242^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2a42aef5d55d7f741b773c4a841d3cc008c58441;p=ceph.git mgr/dashboard: Refactor log pipe 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 --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/dashboard.module.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/dashboard.module.ts index 7d751f0362bc..49630da4ec5d 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/dashboard.module.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/dashboard.module.ts @@ -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, diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/log-priority.pipe.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/log-priority.pipe.spec.ts index 58514878cb2a..45d677c2abae 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/log-priority.pipe.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/log-priority.pipe.spec.ts @@ -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(''); }); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/log-priority.pipe.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/log-priority.pipe.ts index eb60ddba4c33..ea46d16c0e3a 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/log-priority.pipe.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/log-priority.pipe.ts @@ -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 } } } 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 3da26d7a1657..cb5b69c0a205 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 @@ -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