Add more almanac display

This commit is contained in:
2019-10-08 18:50:46 -04:00
parent aeb191f66d
commit 166576ab4d
9 changed files with 99 additions and 10 deletions

View File

@@ -1943,6 +1943,14 @@
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==", "integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==",
"dev": true "dev": true
}, },
"@types/moment-duration-format": {
"version": "2.2.2",
"resolved": "https://registry.npmjs.org/@types/moment-duration-format/-/moment-duration-format-2.2.2.tgz",
"integrity": "sha512-CuYswsMI3y5uR5sD9i/VUqIbZrsYN2eaCs7nH3qpDl2CZlNI48mjMf4ve2RpQ/65irprtnQVetfnea9my+jqcg==",
"requires": {
"moment": ">=2.14.0"
}
},
"@types/node": { "@types/node": {
"version": "8.9.5", "version": "8.9.5",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.9.5.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-8.9.5.tgz",
@@ -7816,6 +7824,11 @@
"resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz", "resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz",
"integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==" "integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg=="
}, },
"moment-duration-format": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/moment-duration-format/-/moment-duration-format-2.3.2.tgz",
"integrity": "sha512-cBMXjSW+fjOb4tyaVHuaVE/A5TqkukDWiOfxxAjY+PEqmmBQlLwn+8OzwPiG3brouXKY5Un4pBjAeB6UToXHaQ=="
},
"move-concurrently": { "move-concurrently": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz", "resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz",

View File

@@ -23,6 +23,7 @@
"@angular/platform-browser-dynamic": "~8.2.4", "@angular/platform-browser-dynamic": "~8.2.4",
"@angular/router": "~8.2.4", "@angular/router": "~8.2.4",
"@aspnet/signalr": "^1.1.4", "@aspnet/signalr": "^1.1.4",
"@types/moment-duration-format": "^2.2.2",
"@types/regression": "^2.0.0", "@types/regression": "^2.0.0",
"@types/suncalc": "^1.8.0", "@types/suncalc": "^1.8.0",
"angular-gridster2": "^8.2.0", "angular-gridster2": "^8.2.0",
@@ -30,6 +31,7 @@
"hammerjs": "^2.0.8", "hammerjs": "^2.0.8",
"highcharts": "^7.2.0", "highcharts": "^7.2.0",
"moment": "^2.24.0", "moment": "^2.24.0",
"moment-duration-format": "^2.3.2",
"ngx-moment": "^3.4.0", "ngx-moment": "^3.4.0",
"ngx-socket-io": "^3.0.1", "ngx-socket-io": "^3.0.1",
"regression": "^2.0.1", "regression": "^2.0.1",

View File

@@ -1,6 +1,6 @@
.laundry-current { .laundry-current {
font-size: 14px; font-size: 14px;
padding: 20px; padding: 10px;
} }
.laundry-current-header { .laundry-current-header {

View File

@@ -8,16 +8,40 @@
<td class="almanac-table-header"> <td class="almanac-table-header">
Sunrise Sunrise
</td> </td>
<td> <td colspan="2">
{{ sun.sunrise | amLocal | amDateFormat: 'hh:mm:ss A' }} {{ sunTimes.sunrise | amLocal | amDateFormat: 'hh:mm:ss A' }}
</td> </td>
</tr> </tr>
<tr> <tr>
<td class="almanac-table-header"> <td class="almanac-table-header">
Sunset Sunset
</td> </td>
<td> <td colspan="2">
{{ sun.sunset | amLocal | amDateFormat: 'hh:mm:ss A' }} {{ sunTimes.sunset | amLocal | amDateFormat: 'hh:mm:ss A' }}
</td>
</tr>
<tr>
<td class="almanac-table-header">
Day length
</td>
<td colspan="2">
{{ dayLength() }}
</td>
</tr>
<tr>
<td class="almanac-table-header">
Moonrise
</td>
<td colspan="2">
{{ moonTimes.rise | amLocal | amDateFormat: 'hh:mm:ss A' }}
</td>
</tr>
<tr>
<td class="almanac-table-header">
Moonset
</td>
<td colspan="2">
{{ moonTimes.set | amLocal | amDateFormat: 'hh:mm:ss A' }}
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -25,7 +49,14 @@
Moon Moon
</td> </td>
<td> <td>
{{ moonPhaseName(moon.phase) }} - {{ (moon.fraction * 100).toFixed(0) }}% illuminated {{ moonPhaseName(moon.phase) }}
<br>
{{ (moon.fraction * 100).toFixed(1) }}% illuminated
</td>
<td>
<div class="moon-phase">
{{ moonPhaseLetter(moon.phase) }}
</div>
</td> </td>
</tr> </tr>
</table> </table>

View File

@@ -1,10 +1,19 @@
.almanac-content { .almanac-content {
font-size: 14px; font-size: 14px;
padding: 20px; padding: 10px;
} }
.almanac-table-header { .almanac-table-header {
font-weight: 500; font-weight: 500;
text-align: right; text-align: right;
padding-right: 10px; padding-right: 10px;
white-space: nowrap;
}
.moon-phase {
font-family: moon;
font-size: 28px;
margin-left: 10px;
display: block;
margin-top: 1px;
} }

View File

@@ -4,6 +4,8 @@ import { WeatherService } from 'src/app/services/weather/weather.service';
import { first } from 'rxjs/operators'; import { first } from 'rxjs/operators';
import * as SunCalc from 'suncalc'; import * as SunCalc from 'suncalc';
import * as moment from 'moment';
import 'moment-duration-format';
@Component({ @Component({
selector: 'app-almanac', selector: 'app-almanac',
@@ -13,7 +15,8 @@ import * as SunCalc from 'suncalc';
export class AlmanacComponent implements OnInit { export class AlmanacComponent implements OnInit {
public loaded = false; public loaded = false;
public latestReading: WeatherReading; public latestReading: WeatherReading;
public sun: SunCalc.GetTimesResult; public sunTimes: SunCalc.GetTimesResult;
public moonTimes: SunCalc.GetMoonTimes;
public moon: SunCalc.GetMoonIlluminationResult; public moon: SunCalc.GetMoonIlluminationResult;
constructor(private weatherService: WeatherService) { } constructor(private weatherService: WeatherService) { }
@@ -30,7 +33,8 @@ export class AlmanacComponent implements OnInit {
const date = new Date(); const date = new Date();
this.sun = SunCalc.getTimes(date, this.latestReading.Latitude, this.latestReading.Longitude); this.sunTimes = SunCalc.getTimes(date, this.latestReading.Latitude, this.latestReading.Longitude);
this.moonTimes = SunCalc.getMoonTimes(date, this.latestReading.Latitude, this.latestReading.Longitude);
this.moon = SunCalc.getMoonIllumination(date); this.moon = SunCalc.getMoonIllumination(date);
this.loaded = true; this.loaded = true;
@@ -56,4 +60,29 @@ export class AlmanacComponent implements OnInit {
return 'Waning Crescent'; return 'Waning Crescent';
} }
} }
moonPhaseLetter(phase: number): string {
if (phase === 0) {
return '0';
} else if (phase < 0.25) {
return 'D';
} else if (phase === 0.25) {
return 'G';
} else if (phase < 0.5) {
return 'I';
} else if (phase === 0.5) {
return '1';
} else if (phase < 0.75) {
return 'Q';
} else if (phase === 0.75) {
return 'T';
} else if (phase < 1.0) {
return 'W';
}
}
dayLength(): string {
const duration = moment.duration((this.sunTimes.sunset.valueOf() - this.sunTimes.sunrise.valueOf()));
return duration.format('hh [hours] mm [minutes]');
}
} }

View File

@@ -1,6 +1,6 @@
.weather-current { .weather-current {
font-size: 14px; font-size: 14px;
padding: 20px; padding: 10px;
} }
.weather-current-header { .weather-current-header {

Binary file not shown.

View File

@@ -13,3 +13,8 @@ body {
top: 150px; top: 150px;
left: calc(50% - 50px); left: calc(50% - 50px);
} }
@font-face {
font-family: moon;
src: url(assets/moon_phases.ttf) format("opentype");
}