Skip to content

Commit c819972

Browse files
authored
Alarm handling changes, Firefox tweaks (#78)
* Disabled alarm handling improvements. * Try to prevent future Raspbian detection failure from messing up admin functionality. Improving development testing features. * Position planets back over the top of clock hands. * Firefox dialog layout adjustments.
1 parent 3dbc7d1 commit c819972

14 files changed

Lines changed: 153 additions & 31 deletions

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 3.2.3
2+
3+
* Position planets back over the top of clock hands.
4+
* Improvements in handling of temporarily disabled alarms.
5+
16
## 3.2.2
27

38
* Fix availability of Update button.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aw-clock",
3-
"version": "3.2.2",
3+
"version": "3.2.3",
44
"license": "MIT",
55
"author": "Kerry Shetline <kerry@shetline.com>",
66
"scripts": {

sass/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sass/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aw-clock-sass",
3-
"version": "3.2.2",
3+
"version": "3.2.3",
44
"description": "SASS builder for aw-clock",
55
"keywords": [
66
"sass"

server/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aw-clock-server",
3-
"version": "3.2.2",
3+
"version": "3.2.3",
44
"license": "MIT",
55
"author": "Kerry Shetline <kerry@shetline.com>",
66
"private": true,

src/alarm-monitor.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ export class AlarmMonitor {
6767
const alarm = alarms[i];
6868
const isDaily = alarm.time < 1440;
6969
let alarmTime = alarm.time;
70+
let canAddAlarm = true;
7071

7172
if (this.activeAlarms.find(a => isEqual(a, alarm)) || this.silencedAlarms.find(sa => isEqual(sa.alarm, alarm)))
72-
continue;
73+
canAddAlarm = false;
7374

7475
const snoozed = this.snoozedAlarms.find(sa => isEqual(sa.alarm, alarm));
7576

@@ -106,7 +107,7 @@ export class AlarmMonitor {
106107
next24Hours = min(alarmTime, next24Hours);
107108
}
108109

109-
if (alarmTime <= nowMinutes && alarmTime >= nowMinutes - 60) {
110+
if (canAddAlarm && alarmTime <= nowMinutes && alarmTime >= nowMinutes - 60) {
110111
newActiveAlarms.push(alarm);
111112

112113
if (snoozed)
@@ -136,6 +137,11 @@ export class AlarmMonitor {
136137
return alarms;
137138
}
138139

140+
resetAlarmState(): void {
141+
this.silencedAlarms = [];
142+
this.snoozedAlarms = [];
143+
}
144+
139145
private updateActiveAlarms(newAlarms: AlarmInfo[], latestSound: string): void {
140146
this.activeAlarms.push(...newAlarms);
141147

src/index.html

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,6 @@
122122
</g>
123123
<g id="risen-tracks"></g>
124124
<g id="night-sky-tracks"></g>
125-
<g id="planets">
126-
<circle id="saturn" cx="72" cy="50" r="0.75" stroke="black" stroke-width="0" fill="#FF8"/>
127-
<circle id="jupiter" cx="70" cy="50" r="0.75" stroke="black" stroke-width="0" fill="orange"/>
128-
<circle id="mars" cx="68" cy="50" r="0.75" stroke="black" stroke-width="0" fill="red"/>
129-
<circle id="venus" cx="66" cy="50" r="0.75" stroke="black" stroke-width="0" fill="#FFF"/>
130-
<circle id="mercury" cx="64" cy="50" r="0.75" stroke="black" stroke-width="0" fill="#BBB"/>
131-
<circle id="moon" cx="62" cy="50" r="0.75" stroke="black" stroke-width="0" fill="#BDF"/>
132-
<circle id="sun" cx="60" cy="50" r="0.75" stroke="black" stroke-width="0" fill="yellow"/>
133-
</g>
134125
<text id="utc-date" x="50" y="99" text-anchor="middle"></text>
135126
<text id="time" x="50" y="105" text-anchor="middle">--:--:--</text>
136127
<text id="dut1-label" x="73.6" y="102.5" text-anchor="start">&nbsp;ΔUT1:&nbsp;</text>
@@ -395,6 +386,20 @@
395386
</svg>
396387
</div>
397388

389+
<div id="planet-overlay">
390+
<svg id="planet-overlay-svg" viewBox="0 0 172 108">
391+
<g id="planets">
392+
<circle id="saturn" cx="72" cy="50" r="0.75" stroke="black" stroke-width="0" fill="#FF8"/>
393+
<circle id="jupiter" cx="70" cy="50" r="0.75" stroke="black" stroke-width="0" fill="orange"/>
394+
<circle id="mars" cx="68" cy="50" r="0.75" stroke="black" stroke-width="0" fill="red"/>
395+
<circle id="venus" cx="66" cy="50" r="0.75" stroke="black" stroke-width="0" fill="#FFF"/>
396+
<circle id="mercury" cx="64" cy="50" r="0.75" stroke="black" stroke-width="0" fill="#BBB"/>
397+
<circle id="moon" cx="62" cy="50" r="0.75" stroke="black" stroke-width="0" fill="#BDF"/>
398+
<circle id="sun" cx="60" cy="50" r="0.75" stroke="black" stroke-width="0" fill="yellow"/>
399+
</g>
400+
</svg>
401+
</div>
402+
398403
<div id="marquee-outer-wrapper"><div
399404
id="marquee-wrapper"><div class="marquee-spacer">&nbsp;</div><div id="marquee"></div></div></div>
400405
<div class="weather-logo">

src/main.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { DateTime, Timezone, parseISODateTime, pollForTimezoneUpdates, zonePolle
2828
import { abs, ceil, floor, irandom, max, min, sqrt } from '@tubular/math';
2929
import { eventToKey, isBoolean, isEffectivelyFullScreen, isEqual, isFirefox, isObject, setFullScreen } from '@tubular/util';
3030
import { Sensors } from './sensors';
31-
import { apiServer, localServer, raspbianChromium, runningDev, Settings } from './settings';
31+
import { allowAdminFeatures, apiServer, localServer, runningDev, Settings } from './settings';
3232
import { SettingsDialog } from './settings-dialog';
3333
import { AwcDefaults, TimeInfo } from '../server/src/shared-types';
3434
import { reflow, updateSvgFlowItems } from './svg-flow';
@@ -74,6 +74,7 @@ class AwClockApp implements AppService {
7474
private clockOverlaySvg: JQuery;
7575
private dimmer: JQuery;
7676
private readonly testTime: JQuery;
77+
private planetOverlaySvg: JQuery;
7778
private updateAvailable: JQuery;
7879
private updateCaption: JQuery;
7980

@@ -132,14 +133,15 @@ class AwClockApp implements AppService {
132133
this.dimmer = $('#dimmer');
133134
setTimeout(() => this.dimmer.css('transition', 'opacity 5s ease-in'));
134135
this.clockOverlaySvg = $('#clock-overlay-svg');
136+
this.planetOverlaySvg = $('#planet-overlay-svg');
135137
this.testTime = $('#test-time');
136138

137139
$('#clock').on('click', evt => stopPropagation(evt, this.clockClick));
138140

139141
this.updateAvailable = $('#update-available');
140142
this.updateCaption = $('#update-caption');
141143
this.updateAvailable.add(this.updateCaption).on('click', () => {
142-
if (raspbianChromium && this.adminAllowed) {
144+
if (allowAdminFeatures && this.adminAllowed) {
143145
this.alarmMonitor.stopAlarms();
144146
this.settingsDialog.openSettings(this.settings, true);
145147
}
@@ -218,6 +220,8 @@ class AwClockApp implements AppService {
218220

219221
// Firefox doesn't detect clicks on the following SVG elements without this extra help.
220222
if (isFirefox()) {
223+
document.body.classList.add('firefox-mods');
224+
221225
const clickTargets = Array.from(document.getElementsByClassName('ff-click'));
222226

223227
window.addEventListener('click', evt => {
@@ -392,7 +396,7 @@ class AwClockApp implements AppService {
392396
Promise.allSettled(promises)
393397
.then(dataPairs => {
394398
const data = dataPairs.map(item => item.status === 'rejected' ? null : item.value);
395-
const localInstallation = raspbianChromium && (localServer || runningDev);
399+
const localInstallation = allowAdminFeatures && (localServer || runningDev);
396400
let citySet = false;
397401
let countryCode = '';
398402
const showUpdate = (localInstallation && this.adminAllowed && data[0]?.updateAvailable &&
@@ -694,6 +698,7 @@ class AwClockApp implements AppService {
694698
this.showSkyMap = true;
695699
this.skyCanvas.style.pointerEvents = 'all';
696700
this.skyCanvas.style.opacity = '1';
701+
this.planetOverlaySvg.css('opacity', '1');
697702
this.updateSkyMap();
698703
}
699704

@@ -711,11 +716,13 @@ class AwClockApp implements AppService {
711716
this.clockOverlaySvg.removeClass('solid');
712717

713718
this.clockOverlaySvg.css('opacity', '1');
719+
this.planetOverlaySvg.css('opacity', '0');
714720
}
715721
else {
716722
this.clockOverlaySvg.removeClass('float');
717723
this.clockOverlaySvg.removeClass('solid');
718724
this.clockOverlaySvg.css('opacity', this.showSkyMap ? '0' : '1');
725+
this.planetOverlaySvg.css('opacity', this.showSkyMap ? '0' : '1');
719726
}
720727
}
721728

@@ -747,16 +754,17 @@ class AwClockApp implements AppService {
747754

748755
if (!evt.repeat && (skipTargetTest || evt.target === document.body)) {
749756
let handled = true;
757+
const isTestTime = ((evt.target as any)?.id === 'test-time');
750758

751759
if (key === 'F' || evt.key === 'f')
752760
setFullScreen(true);
753761
else if (key === 'N' || key === 'n')
754762
setFullScreen(false);
755763
else if (key === 'Enter' || key === ' ')
756764
this.alarmMonitor.stopAlarms();
757-
else if (key === '5')
765+
else if (key === '5' && !isTestTime)
758766
this.alarmMonitor.snoozeAlarms(5);
759-
else if (key === '0' || key === 'S' || key === 's')
767+
else if ((key === '0' && !isTestTime) || key === 'S' || key === 's')
760768
this.alarmMonitor.snoozeAlarms(10);
761769
else if (key === '.')
762770
this.alarmMonitor.snoozeAlarms(15);
@@ -772,6 +780,10 @@ class AwClockApp implements AppService {
772780
this.testTime.val(this.testTimeStr);
773781
this.updateTestTime();
774782
}
783+
else if ((key === 'X' || key === 'x') && this.testTimeStr) {
784+
this.alarmMonitor.resetAlarmState();
785+
this.updateTestTime();
786+
}
775787
else
776788
handled = false;
777789

0 commit comments

Comments
 (0)