From: Ricardo Marques Date: Wed, 28 Mar 2018 06:47:37 +0000 (+0100) Subject: mgr/dashboard: Add CdDatePipe X-Git-Tag: v13.1.0~410^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=803dd504d2b69ad8518003f23dcd06be752775d8;p=ceph.git mgr/dashboard: Add CdDatePipe Signed-off-by: Ricardo Marques --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/cd-date.pipe.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/cd-date.pipe.spec.ts new file mode 100644 index 0000000000000..4270abef97329 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/cd-date.pipe.spec.ts @@ -0,0 +1,8 @@ +import { CdDatePipe } from './cd-date.pipe'; + +describe('CdDatePipe', () => { + it('create an instance', () => { + const pipe = new CdDatePipe(null); + expect(pipe).toBeTruthy(); + }); +}); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/cd-date.pipe.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/cd-date.pipe.ts new file mode 100644 index 0000000000000..f29b628597a40 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/cd-date.pipe.ts @@ -0,0 +1,20 @@ +import { DatePipe } from '@angular/common'; +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'cdDate' +}) +export class CdDatePipe implements PipeTransform { + + constructor(private datePipe: DatePipe) { + } + + transform(value: any, args?: any): any { + if (value === null || value === '') { + return ''; + } + return this.datePipe.transform(value, 'shortDate') + ' ' + + this.datePipe.transform(value, 'mediumTime'); + } + +} 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 51dc736c8a694..bb0e238cc03f7 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 @@ -1,6 +1,7 @@ -import { CommonModule } from '@angular/common'; +import { CommonModule, DatePipe } from '@angular/common'; import { NgModule } from '@angular/core'; +import { CdDatePipe } from './cd-date.pipe'; import { CephShortVersionPipe } from './ceph-short-version.pipe'; import { DimlessBinaryPipe } from './dimless-binary.pipe'; import { DimlessPipe } from './dimless.pipe'; @@ -18,7 +19,8 @@ import { RelativeDatePipe } from './relative-date.pipe'; CephShortVersionPipe, RelativeDatePipe, ListPipe, - FilterPipe + FilterPipe, + CdDatePipe ], exports: [ DimlessBinaryPipe, @@ -27,14 +29,17 @@ import { RelativeDatePipe } from './relative-date.pipe'; CephShortVersionPipe, RelativeDatePipe, ListPipe, - FilterPipe + FilterPipe, + CdDatePipe ], providers: [ + DatePipe, CephShortVersionPipe, DimlessBinaryPipe, DimlessPipe, RelativeDatePipe, - ListPipe + ListPipe, + CdDatePipe ] }) export class PipesModule {}