From 3f3dd14e8fb84fdb4e6198b38124763ef192663c Mon Sep 17 00:00:00 2001 From: Tim Herbst Date: Mon, 28 Dec 2020 11:58:22 +0100 Subject: [PATCH] humanize seconds in table --- projects/project-3/frontend/package-lock.json | 5 +++++ projects/project-3/frontend/package.json | 1 + .../frontend/src/app/dashboard/dashboard.component.html | 4 ++-- .../frontend/src/app/dashboard/dashboard.component.ts | 7 ++++--- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/projects/project-3/frontend/package-lock.json b/projects/project-3/frontend/package-lock.json index 484f971..d0fee32 100644 --- a/projects/project-3/frontend/package-lock.json +++ b/projects/project-3/frontend/package-lock.json @@ -10761,6 +10761,11 @@ "ajv-keywords": "^3.5.2" } }, + "seconds-to-human-time": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/seconds-to-human-time/-/seconds-to-human-time-1.0.0.tgz", + "integrity": "sha512-ojOSaCcU8nkmR3tC/5GPIwmBAH4go7q1iyWRZhxB+tIKbR3rO3dDW5L73ZVRmAMNbK2AY1otz4QXCTxZXUHcXg==" + }, "select-hose": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz", diff --git a/projects/project-3/frontend/package.json b/projects/project-3/frontend/package.json index 2fe1c2b..c344448 100644 --- a/projects/project-3/frontend/package.json +++ b/projects/project-3/frontend/package.json @@ -31,6 +31,7 @@ "ng-apexcharts": "^1.5.6", "popper.js": "^1.14.3", "rxjs": "~6.6.0", + "seconds-to-human-time": "^1.0.0", "tslib": "^2.0.0", "zone.js": "~0.10.2" }, diff --git a/projects/project-3/frontend/src/app/dashboard/dashboard.component.html b/projects/project-3/frontend/src/app/dashboard/dashboard.component.html index 2e451a9..44d91a0 100644 --- a/projects/project-3/frontend/src/app/dashboard/dashboard.component.html +++ b/projects/project-3/frontend/src/app/dashboard/dashboard.component.html @@ -92,7 +92,7 @@ average lend duration - {{element.avgDuration}} + {{humanizeAvgDuration(element.avgDuration)}} @@ -114,7 +114,7 @@ average lend duration - {{element.avgDuration}} + {{humanizeAvgDuration(element.avgDuration)}} diff --git a/projects/project-3/frontend/src/app/dashboard/dashboard.component.ts b/projects/project-3/frontend/src/app/dashboard/dashboard.component.ts index e5d2c1d..df95fd4 100644 --- a/projects/project-3/frontend/src/app/dashboard/dashboard.component.ts +++ b/projects/project-3/frontend/src/app/dashboard/dashboard.component.ts @@ -5,7 +5,8 @@ import {IDashboardCommonBikePoint} from '../service/domain/dashboard-common-bike import {MatTableDataSource} from '@angular/material/table'; import {FormBuilder, FormControl, FormGroup} from '@angular/forms'; import {MapService} from '../service/map.service'; -import 'humanize-duration/humanize-duration'; +import stht from "seconds-to-human-time"; + import { ApexAxisChartSeries, @@ -473,7 +474,7 @@ export class DashboardComponent implements OnInit { }); } - routeToStation(stationId: string): void { - this.router.navigate(['/dashboard', stationId]); + humanizeAvgDuration(avgDuration: number): string { + return stht(avgDuration); } }