From 87ab0dac19f94784b0a7181f7bbb81432e218f18 Mon Sep 17 00:00:00 2001 From: Volker Theile Date: Tue, 19 Feb 2019 14:22:13 +0100 Subject: [PATCH] mgr/dashboard: Introduce upperFirst pipe Signed-off-by: Volker Theile --- .../src/app/shared/pipes/pipes.module.ts | 10 +++++++--- .../app/shared/pipes/upper-first.pipe.spec.ts | 17 +++++++++++++++++ .../src/app/shared/pipes/upper-first.pipe.ts | 12 ++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/upper-first.pipe.spec.ts create mode 100644 src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/upper-first.pipe.ts 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 ac89776424eff..8ca806514b7db 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 @@ -18,6 +18,7 @@ import { MillisecondsPipe } from './milliseconds.pipe'; import { OrdinalPipe } from './ordinal.pipe'; import { RelativeDatePipe } from './relative-date.pipe'; import { RoundPipe } from './round.pipe'; +import { UpperFirstPipe } from './upper-first.pipe'; @NgModule({ imports: [CommonModule], @@ -38,7 +39,8 @@ import { RoundPipe } from './round.pipe'; RoundPipe, OrdinalPipe, MillisecondsPipe, - IopsPipe + IopsPipe, + UpperFirstPipe ], exports: [ DimlessBinaryPipe, @@ -57,7 +59,8 @@ import { RoundPipe } from './round.pipe'; RoundPipe, OrdinalPipe, MillisecondsPipe, - IopsPipe + IopsPipe, + UpperFirstPipe ], providers: [ DatePipe, @@ -74,7 +77,8 @@ import { RoundPipe } from './round.pipe'; EncodeUriPipe, OrdinalPipe, IopsPipe, - MillisecondsPipe + MillisecondsPipe, + UpperFirstPipe ] }) export class PipesModule {} diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/upper-first.pipe.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/upper-first.pipe.spec.ts new file mode 100644 index 0000000000000..072baa04b256e --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/upper-first.pipe.spec.ts @@ -0,0 +1,17 @@ +import { UpperFirstPipe } from './upper-first.pipe'; + +describe('UpperFirstPipe', () => { + const pipe = new UpperFirstPipe(); + + it('create an instance', () => { + expect(pipe).toBeTruthy(); + }); + + it('transforms "foo"', () => { + expect(pipe.transform('foo')).toEqual('Foo'); + }); + + it('transforms "BAR"', () => { + expect(pipe.transform('BAR')).toEqual('BAR'); + }); +}); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/upper-first.pipe.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/upper-first.pipe.ts new file mode 100644 index 0000000000000..11d7fc97abeb8 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/upper-first.pipe.ts @@ -0,0 +1,12 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +import * as _ from 'lodash'; + +@Pipe({ + name: 'upperFirst' +}) +export class UpperFirstPipe implements PipeTransform { + transform(value: string): string { + return _.upperFirst(value); + } +} -- 2.39.5