Skip to content

Commit

Permalink
Merge branch 'dev' into plugin_pref_ui
Browse files Browse the repository at this point in the history
  • Loading branch information
sulkaharo committed Jul 26, 2019
2 parents 99ac3a6 + 71981de commit 6499480
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 20 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,13 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm
* `SECURE_CSP` (`false`) - Add Content Security Policy headers. Possible values `false`, or `true`.
* `SECURE_CSP_REPORT_ONLY` (`false`) - If set to `true` allows to experiment with policies by monitoring (but not enforcing) their effects. Possible values `false`, or `true`.

### Views
### Views

There are a few alternate web views available from the main menu that display a simplified BG stream. (If you launch one of these in a fullscreen view in iOS, you can use a left-to-right swipe gesture to exit the view.)
* `Clock` - Shows current BG, trend arrow, and time of day. Grey text on a black background.
* `Color` - Shows current BG and trend arrow. White text on a background that changes color to indicate current BG threshold (green = in range; blue = below range; yellow = above range; red = urgent below/above).
* `Simple` - Shows current BG. Grey text on a black background.
* Optional configuration: set `SHOW_CLOCK_CLOSEBUTTON` (`true`) to `false` to hide the small X button to close the views

### Plugins

Expand Down
19 changes: 19 additions & 0 deletions lib/client/clock-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ client.render = function render (xhr) {
if (m < 10) m = "0" + m;
$('#clock').text(h + ":" + m);

if (!window.serverSettings.settings.showClockClosebutton) {
$('#close').css('display', 'none');
}

// defined in the template this is loaded into
// eslint-disable-next-line no-undef
if (clockFace == 'clock-color') {
Expand All @@ -82,6 +86,11 @@ client.render = function render (xhr) {
var green = 'rgba(134,207,70,1)';
var blue = 'rgba(78,143,207,1)';

var darkRed = 'rgba(183,9,21,1)';
var darkYellow = 'rgba(214,168,0,1)';
var darkGreen = 'rgba(110,192,70,1)';
var darkBlue = 'rgba(78,143,187,1)';

var elapsedMins = Math.round(((now - last) / 1000) / 60);

// Insert the BG stale time text.
Expand All @@ -90,18 +99,28 @@ client.render = function render (xhr) {
// Threshold background coloring.
if (bgNum < bgLow) {
$('body').css('background-color', red);
$('#close').css('border-color', darkRed);
$('#close').css('color', darkRed);
}
if ((bgLow <= bgNum) && (bgNum < bgTargetBottom)) {
$('body').css('background-color', blue);
$('#close').css('border-color', darkBlue);
$('#close').css('color', darkBlue);
}
if ((bgTargetBottom <= bgNum) && (bgNum < bgTargetTop)) {
$('body').css('background-color', green);
$('#close').css('border-color', darkGreen);
$('#close').css('color', darkGreen);
}
if ((bgTargetTop <= bgNum) && (bgNum < bgHigh)) {
$('body').css('background-color', yellow);
$('#close').css('border-color', darkYellow);
$('#close').css('color', darkYellow);
}
if (bgNum >= bgHigh) {
$('body').css('background-color', red);
$('#close').css('border-color', darkRed);
$('#close').css('color', darkRed);
}

// Restyle body bg, and make the "x minutes ago" visible too.
Expand Down
33 changes: 17 additions & 16 deletions lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var _ = require('lodash');
var levels = require('./levels');

function init ( ) {
function init () {

var settings = {
units: 'mg/dL'
Expand Down Expand Up @@ -41,12 +41,13 @@ function init ( ) {
, bgTargetTop: 180
, bgTargetBottom: 80
, bgLow: 55
},
insecureUseHttp: false,
secureHstsHeader: true,
secureHstsHeaderIncludeSubdomains: false,
secureHstsHeaderPreload: false,
secureCsp: false
}
, insecureUseHttp: false
, secureHstsHeader: true
, secureHstsHeaderIncludeSubdomains: false
, secureHstsHeaderPreload: false
, secureCsp: false
, showClockClosebutton: true
};

var valueMappers = {
Expand All @@ -67,7 +68,7 @@ function init ( ) {
, insecureUseHttp: mapTruthy
, secureHstsHeader: mapTruthy
, secureCsp: mapTruthy

, showClockClosebutton: mapTruthy
};

function mapNumberArray (value) {
Expand All @@ -77,7 +78,7 @@ function init ( ) {

if (isNaN(value)) {
var rawValues = value && value.split(' ') || [];
return _.map(rawValues, function (num) {
return _.map(rawValues, function(num) {
return isNaN(num) ? null : Number(num);
});
} else {
Expand Down Expand Up @@ -153,18 +154,18 @@ function init ( ) {
}

function anyEnabled (features) {
return _.findIndex(features, function (feature) {
return _.findIndex(features, function(feature) {
return enable.indexOf(feature) > -1;
}) > -1;
}

function prepareAlarmTypes ( ) {
function prepareAlarmTypes () {
var alarmTypes = _.filter(getAndPrepare('alarmTypes'), function onlyKnownTypes (type) {
return type === 'predict' || type === 'simple';
});

if (alarmTypes.length === 0) {
var thresholdWasSet = _.findIndex(wasSet, function (name) {
var thresholdWasSet = _.findIndex(wasSet, function(name) {
return name.indexOf('bg') === 0;
}) > -1;
alarmTypes = thresholdWasSet ? ['simple'] : ['predict'];
Expand Down Expand Up @@ -209,7 +210,7 @@ function init ( ) {
adjustShownPlugins();
}

function verifyThresholds() {
function verifyThresholds () {
var thresholds = settings.thresholds;

if (thresholds.bgTargetBottom >= thresholds.bgTargetTop) {
Expand All @@ -234,7 +235,7 @@ function init ( ) {
}
}

function adjustShownPlugins ( ) {
function adjustShownPlugins () {
var showPluginsUnset = settings.showPlugins && 0 === settings.showPlugins.length;

settings.showPlugins += ' delta direction upbat';
Expand All @@ -245,7 +246,7 @@ function init ( ) {
if (showPluginsUnset) {
//assume all enabled features are plugins and they should be shown for now
//it would be better to use the registered plugins, but it's not loaded yet...
_.forEach(settings.enable, function showFeature(feature) {
_.forEach(settings.enable, function showFeature (feature) {
if (isEnabled(feature)) {
settings.showPlugins += ' ' + feature;
}
Expand Down Expand Up @@ -289,7 +290,7 @@ function init ( ) {
var snoozeTime;

if (notify.eventName === 'high' && notify.level === levels.URGENT && settings.alarmUrgentHigh) {
snoozeTime = settings.alarmUrgentHighMins;
snoozeTime = settings.alarmUrgentHighMins;
} else if (notify.eventName === 'high' && settings.alarmHigh) {
snoozeTime = settings.alarmHighMins;
} else if (notify.eventName === 'low' && notify.level === levels.URGENT && settings.alarmUrgentLow) {
Expand Down
12 changes: 12 additions & 0 deletions views/clockviews/bgclock.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ main {
height: 100vh;
}

#close {
position: absolute;
top: 10px;
right: 10px;
color: #333;
border-radius: 5px;
border: 2px solid #333;
padding: 5px;
width: 20px;
height: 20px;
}

.inner {
width: 100%;
-webkit-transform: translateY(-2%);
Expand Down
12 changes: 12 additions & 0 deletions views/clockviews/clock-color.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ main {
height: 100vh;
}

#close {
position: absolute;
top: 10px;
right: 10px;
color: grey;
border-radius: 5px;
border: 2px solid grey;
padding: 5px;
width: 20px;
height: 20px;
}

.inner {
width: 100%;
-webkit-transform: translateY(-5%);
Expand Down
14 changes: 13 additions & 1 deletion views/clockviews/clock.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ main {
height: 100vh;
}

#close {
position: absolute;
top: 10px;
right: 10px;
color: #333;
border-radius: 5px;
border: 2px solid #333;
padding: 5px;
width: 20px;
height: 20px;
}

.inner {
width: 100%;
-webkit-transform: translateY(-5%);
Expand Down Expand Up @@ -51,4 +63,4 @@ main {

#clock {
display: none;
}
}
2 changes: 1 addition & 1 deletion views/clockviews/shared.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</head>

<body>
<a href="/"><div style="position: absolute; top: 10px; right: 10px; color: grey; border-radius: 5px; border: 2px solid grey; padding: 5px; width: 20px; height: 20px; ">X</div></a>
<a href="/"><div id="close">X</div></a>
<main>
<div class="inner">
<div id="trend">
Expand Down
2 changes: 1 addition & 1 deletion views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
</div>
<div class="container loading" id="container">
<div id="toolbar">
<div id="buttonbar" style="margin-right: 15px;" role="navigation" aria-label="Menu" >
<div id="buttonbar" style="margin-right: 0px;" role="navigation" aria-label="Menu" >
<a id="editbutton" class="tip" original-title="Edit Mode" aria-label="Edit Mode" href="#" style="display:none;"><i class="icon-edit"></i></a>
<a id="testAlarms" class="tip" original-title="Alarm Test / Smartphone Enable" aria-label="Alarm Test / Smartphone Enable" href="#"><i class="icon-volume"></i></a>
<a id="drawerToggle" class="tip" original-title="Settings" aria-label="Settings" href="#"><i class="icon-menu"></i></a>
Expand Down

0 comments on commit 6499480

Please sign in to comment.