From: Volker Theile Date: Tue, 19 Feb 2019 13:22:13 +0000 (+0100) Subject: mgr/dashboard: Introduce upperFirst pipe X-Git-Tag: v14.1.1~126^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F26116%2Fhead;p=ceph.git mgr/dashboard: Introduce upperFirst pipe Signed-off-by: Volker Theile --- 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 ac89776424e..8ca806514b7 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 00000000000..072baa04b25 --- /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 00000000000..11d7fc97abe --- /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); + } +}