From 778fb2d701eccab7d0145c1408c19d4d986eca60 Mon Sep 17 00:00:00 2001 From: "Maxence G. de Montauzan" Date: Sat, 14 Oct 2017 04:01:54 +0200 Subject: [PATCH] Convert Ms unit + fun with approximative pipe --- dashboard/src/app/app.module.ts | 2 ++ dashboard/src/app/convertms.pipe.ts | 8 ++++---- dashboard/src/app/dashboard.component.html | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dashboard/src/app/app.module.ts b/dashboard/src/app/app.module.ts index 78e8ff3..1991c95 100644 --- a/dashboard/src/app/app.module.ts +++ b/dashboard/src/app/app.module.ts @@ -13,6 +13,7 @@ import { ElsService } from './els.service'; import { AppRoutingModule } from './app-routing.module'; import { ConvertMsPipe } from './convertms.pipe'; +import { ConvertMoreExactPipe } from './convert-more-exact.pipe'; import { SortByPipe } from './sort-by.pipe'; @NgModule({ @@ -28,6 +29,7 @@ import { SortByPipe } from './sort-by.pipe'; ArtistComponent, GenreComponent, ConvertMsPipe, + ConvertMoreExactPipe, SortByPipe ], providers: [ diff --git a/dashboard/src/app/convertms.pipe.ts b/dashboard/src/app/convertms.pipe.ts index 48601c6..6854c62 100644 --- a/dashboard/src/app/convertms.pipe.ts +++ b/dashboard/src/app/convertms.pipe.ts @@ -23,10 +23,10 @@ export class ConvertMsPipe implements PipeTransform { // Final string let ret = ''; - if (days > 0) { ret += ('0' + days).slice(-2) + ':'; } - if (hours > 0) { ret += ('0' + hours).slice(-2) + ':'; } - if (minutes > 0) { ret += ('0' + minutes).slice(-2) + ':'; } - if (seconds > 0) { ret += ('0' + seconds).slice(-2); } + if (days > 0) { ret += ('0' + days).slice(-2) + 'd'; } + if (hours > 0) { ret += ('0' + hours).slice(-2) + 'h'; } + if (minutes > 0) { ret += ('0' + minutes).slice(-2) + 'm'; } + if (seconds > 0) { ret += ('0' + seconds).slice(-2) + 's'; } return ret; // return ('0' + days).slice(-2) + ':' + ('0' + hours).slice(-2) + ':' + ('0' + minutes).slice(-2) + ':' + ('0' + seconds).slice(-2); diff --git a/dashboard/src/app/dashboard.component.html b/dashboard/src/app/dashboard.component.html index 584f270..f153ff7 100644 --- a/dashboard/src/app/dashboard.component.html +++ b/dashboard/src/app/dashboard.component.html @@ -15,7 +15,7 @@

{{totalTime | convertMs}}

-

Total time
+

Total time ({{totalTime | convertMoreExact}})