Skip to content

Commit

Permalink
Merge pull request #22 from nightscout/dev
Browse files Browse the repository at this point in the history
Option to switch off bolus amount outputs (nightscout#5522)
  • Loading branch information
yeagerm authored Apr 14, 2020
2 parents 5a9224c + 17eb4ae commit be33871
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 18 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs/ or
* The `linear` option has equidistant tick marks; the range used is dynamic so that space at the top of chart isn't wasted.
* The `log-dynamic` is similar to the default `log` options, but uses the same dynamic range and the `linear` scale.
* `EDIT_MODE` (`on`) - possible values `on` or `off`. Enables the icon allowing for editing of treatments in the main view.
* `BOLUS_RENDER_OVER` (1) - U value over which the bolus values are rendered on the chart if the 'x U and Over' option is selected. This value can be an integer or a float, e.g. 0.3, 1.5, 2, etc...

### Predefined values for your server settings (optional)
* `INSECURE_USE_HTTP` (`false`) - Redirect unsafe http traffic to https. Possible values `false`, or `true`. Your site redirects to `https` by default. If you don't want that from Nightscout, but want to implement that with a Nginx or Apache proxy, set `INSECURE_USE_HTTP` to `true`. Note: This will allow (unsafe) http traffic to your Nightscout instance and is not recommended.
Expand Down
5 changes: 5 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@
"value": "180",
"required": false
},
"BOLUS_RENDER_OVER": {
"description": "U value over which the bolus values are rendered on the chart if the 'x U and Over' option is selected.",
"value": "1",
"required": false
},
"BRIDGE_PASSWORD": {
"description": "Your Dexcom account password, to receive CGM data from the Dexcom Share service. Also make sure to include 'bridge' in your ENABLE line.",
"value": "",
Expand Down
15 changes: 13 additions & 2 deletions lib/client/browser-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ function init (client, serverSettings, $) {

$('#basalrender').val(settings.extendedSettings.basal ? settings.extendedSettings.basal.render : 'none');

$('#bolusrender').val(settings.extendedSettings.bolus ? settings.extendedSettings.bolus.render : 'all');

if (settings.timeFormat === 24) {
$('#24-browser').prop('checked', true);
} else {
Expand Down Expand Up @@ -161,6 +163,7 @@ function init (client, serverSettings, $) {
storage.remove(name);
});
storage.remove('basalrender');
storage.remove('bolusrender');
event.preventDefault();
client.browserUtils.reload();
});
Expand Down Expand Up @@ -213,6 +216,7 @@ function init (client, serverSettings, $) {
, language: $('#language').val()
, scaleY: $('#scaleY').val()
, basalrender: $('#basalrender').val()
, bolusrender: $('#bolusrender').val()
, showPlugins: checkedPluginNames()
, storageVersion: STORAGE_VERSION
});
Expand Down Expand Up @@ -268,8 +272,15 @@ function init (client, serverSettings, $) {
settings.extendedSettings.basal = {};
}

var stored = storage.get('basalrender');
settings.extendedSettings.basal.render = stored !== null ? stored : settings.extendedSettings.basal.render;
var basalStored = storage.get('basalrender');
settings.extendedSettings.basal.render = basalStored !== null ? basalStored : settings.extendedSettings.basal.render;

if (!settings.extendedSettings.bolus) {
settings.extendedSettings.bolus = {};
}

var bolusStored = storage.get('bolusrender');
settings.extendedSettings.bolus.render = bolusStored !== null ? bolusStored : settings.extendedSettings.bolus.render;

} catch (err) {
console.error(err);
Expand Down
7 changes: 7 additions & 0 deletions lib/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,12 @@ client.load = function load (serverSettings, callback) {
}
}

function updateBolusRenderOver () {
var bolusRenderOver = (client.settings.bolusRenderOver || 1) + ' U and Over';
$('#bolusRenderOver').text(bolusRenderOver);
console.log('here');
}

function alarmingNow () {
return container.hasClass('alarming');
}
Expand Down Expand Up @@ -1240,6 +1246,7 @@ client.load = function load (serverSettings, callback) {

prepareEntries();
updateTitle();
updateBolusRenderOver();

// Don't invoke D3 in headless mode

Expand Down
36 changes: 20 additions & 16 deletions lib/client/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ function init (client, d3) {
};
}

function prepareArc (treatment, radius) {
function prepareArc (treatment, radius, renderBasal) {
var arc_data = [
// white carb half-circle on top
{ 'element': '', 'color': 'white', 'start': -1.5708, 'end': 1.5708, 'inner': 0, 'outer': radius.R1 }
Expand Down Expand Up @@ -568,16 +568,13 @@ function init (client, d3) {

if (treatment.insulin > 0) {
var dosage_units = '' + Math.round(treatment.insulin * 100) / 100;

var unit_of_measurement = ' U'; // One international unit of insulin (1 IU) is shown as '1 U'
var enteredBy = '' + treatment.enteredBy;

if ((treatment.insulin < 1 && !treatment.carbs && enteredBy.indexOf('openaps') > -1) || treatment.isSMB) { // don't show the unit of measurement for insulin boluses < 1 without carbs (e.g. oref0 SMB's). Otherwise lot's of small insulin only dosages are often unreadable
unit_of_measurement = '';
// remove leading zeros to avoid overlap with adjacent boluses

if (renderBasal === 'all-remove-zero-u') {
dosage_units = (dosage_units + "").replace(/^0/, "");
}

var unit_of_measurement = (renderBasal === 'all-remove-zero-u' ? '' : ' U'); // One international unit of insulin (1 IU) is shown as '1 U'

arc_data[3].element = dosage_units + unit_of_measurement;
}

Expand Down Expand Up @@ -971,11 +968,15 @@ function init (client, d3) {
.attr('id', 'label')
.style('fill', 'white');

// reduce the treatment label font size to make it readable with SMB
var fontBaseSize = (opts.treatments >= 30) ? 40 : 50 - Math.floor((25 - opts.treatments) / 30 * 10);

label.append('text')
.style('font-size', fontBaseSize / opts.scale)
.style('font-size', function(d) {
var fontSize = ( (opts.treatments >= 30) ? 40 : 50 - Math.floor((25 - opts.treatments) / 30 * 10) ) / opts.scale;
var elementValue = parseFloat(d.element);
if (!isNaN(elementValue) && elementValue < 1) {
fontSize = (25 + Math.floor(elementValue * 10)) / opts.scale;
}
return fontSize;
})
.style('text-shadow', '0px 0px 10px rgba(0, 0, 0, 1)')
.attr('text-anchor', 'middle')
.attr('dy', '.35em')
Expand All @@ -993,6 +994,7 @@ function init (client, d3) {
renderer.drawTreatments = function drawTreatments (client) {

var treatmentCount = 0;
var renderBasal = client.settings.extendedSettings.bolus.render;
chart().focus.selectAll('.draggable-treatment').remove();

_.forEach(client.ddata.treatments, function eachTreatment (d) {
Expand All @@ -1001,15 +1003,17 @@ function init (client, d3) {

// add treatment bubbles
_.forEach(client.ddata.treatments, function eachTreatment (d) {
var showLabels = ( !d.carbs && ( ( renderBasal == 'none') || ( renderBasal === 'over' && d.insulin < client.settings.bolusRenderOver) ) ) ? false : true;
renderer.drawTreatment(d, {
scale: renderer.bubbleScale()
, showLabels: true
, showLabels: showLabels
, treatments: treatmentCount
}, client.sbx.data.profile.getCarbRatio(new Date()));
}, client.sbx.data.profile.getCarbRatio(new Date()),
renderBasal);
});
};

renderer.drawTreatment = function drawTreatment (treatment, opts, carbratio) {
renderer.drawTreatment = function drawTreatment (treatment, opts, carbratio, renderBasal) {
if (!treatment.carbs && !treatment.protein && !treatment.fat && !treatment.insulin) {
return;
}
Expand All @@ -1027,7 +1031,7 @@ function init (client, d3) {
return;
}

var arc = prepareArc(treatment, radius);
var arc = prepareArc(treatment, radius, renderBasal);
var treatmentDots = appendTreatments(treatment, arc);
appendLabels(treatmentDots, arc, opts);
};
Expand Down
1 change: 1 addition & 0 deletions lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ function init () {
, deNormalizeDates: false
, showClockDelta: false
, showClockLastTime: false
, bolusRenderOver: 1
, frameUrl1: ''
, frameUrl2: ''
, frameUrl3: ''
Expand Down
12 changes: 12 additions & 0 deletions views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,18 @@
</select>
</dd>
</dl>
<dl>
<dt class="translate">Render Bolus Amount</dt>
<dd>
<select id="bolusrender">
<option class="translate" value="all">All</option>
<option class="translate" value="all-remove-zero-u">All (without leading zero and U)</option>
<option class="translate" id="bolusRenderOver" value="over">1 U and Over</option>
<option class="translate" value="none">None</option>
</select>
</dd>
</dl>

<dl class="toggle">
<dt><span class="translate">Enable Alarms</span> <a class="tip" original-title="When enabled an alarm may sound."><i class="icon-help-circled"></i></a></dt>
<dd><input type="checkbox" id="alarm-urgenthigh-browser"><label for="alarm-urgenthigh-browser" class="translate">Urgent High Alarm</label></dd>
Expand Down

0 comments on commit be33871

Please sign in to comment.