]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Add CdDatePipe 21087/head
authorRicardo Marques <rimarques@suse.com>
Wed, 28 Mar 2018 06:47:37 +0000 (07:47 +0100)
committerRicardo Marques <rimarques@suse.com>
Tue, 3 Apr 2018 14:55:50 +0000 (15:55 +0100)
Signed-off-by: Ricardo Marques <rimarques@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/cd-date.pipe.spec.ts [new file with mode: 0644]
src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/cd-date.pipe.ts [new file with mode: 0644]
src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/pipes.module.ts

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 (file)
index 0000000..4270abe
--- /dev/null
@@ -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 (file)
index 0000000..f29b628
--- /dev/null
@@ -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');
+  }
+
+}
index 51dc736c8a694d8e416ca4323c7560a921f00af6..bb0e238cc03f7513eb6a49790bef6e2ddd2d85ce 100644 (file)
@@ -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 {}