From 454fe07d4935823643ef48c2e35bac96f734240b Mon Sep 17 00:00:00 2001 From: Zak Timson Date: Tue, 1 Jan 2019 22:53:19 -0500 Subject: [PATCH] Cleaned up dashboard --- .../widget/batteryWidget.component.html | 7 ++-- src/app/dashboard/dashboard.component.html | 32 +++++++++---------- src/app/dashboard/dashboard.component.ts | 13 ++++++++ .../widget/weatherWidget.component.html | 5 +-- 4 files changed, 31 insertions(+), 26 deletions(-) diff --git a/src/app/battery/widget/batteryWidget.component.html b/src/app/battery/widget/batteryWidget.component.html index 389c1aa..ea7c69a 100644 --- a/src/app/battery/widget/batteryWidget.component.html +++ b/src/app/battery/widget/batteryWidget.component.html @@ -1,9 +1,6 @@
-
{{batteryService.icon}}
-
-

Powerwall: {{batteryService.charge | round}} V

-

{{batteryService.temp | round}} °C

-
+ {{batteryService.icon}} +

Powerwall: {{batteryService.charge | round}} V

diff --git a/src/app/dashboard/dashboard.component.html b/src/app/dashboard/dashboard.component.html index 397b2ac..9558955 100644 --- a/src/app/dashboard/dashboard.component.html +++ b/src/app/dashboard/dashboard.component.html @@ -1,24 +1,22 @@
-
-

{{now | async | date: 'fullDate'}}

-

{{now | async | date: 'mediumTime'}}

-
-
-
- - - - - +
+
+

{{formatDate(now | async)}}

-
- - - - - +
+

{{formatTime(now | async)}}

+ + + + + + + + + +
diff --git a/src/app/dashboard/dashboard.component.ts b/src/app/dashboard/dashboard.component.ts index 0df59aa..78784b4 100644 --- a/src/app/dashboard/dashboard.component.ts +++ b/src/app/dashboard/dashboard.component.ts @@ -10,4 +10,17 @@ export class DashboardComponent { now = timer(0, 1000).pipe(map(() => new Date())); constructor() { } + + formatTime(date: Date) { + if(!date) return ''; + let hours = date.getHours(); + let minutes = date.getMinutes(); + if(hours > 12) hours -= 12; + return `${hours < 10 ? `0${hours}` : hours}:${minutes < 10 ? `0${minutes}` : minutes}` + } + + formatDate(date: Date) { + if(!date) return ''; + return `${date.toDateString().substr(4, 3)} ${date.getDate()}`; + } } diff --git a/src/app/weather/widget/weatherWidget.component.html b/src/app/weather/widget/weatherWidget.component.html index 5614741..f806f32 100644 --- a/src/app/weather/widget/weatherWidget.component.html +++ b/src/app/weather/widget/weatherWidget.component.html @@ -1,9 +1,6 @@
+

{{weatherService.weather?.currently.summary}}

-
-

London, ON

-

{{weatherService.weather?.currently.summary}}

-