Skip to content

Commit

Permalink
Merge 91468b8 into 52e1ff0
Browse files Browse the repository at this point in the history
  • Loading branch information
jamespaulley committed Jul 4, 2018
2 parents 52e1ff0 + 91468b8 commit d5c35d5
Show file tree
Hide file tree
Showing 79 changed files with 10,925 additions and 4,213 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
@@ -1 +1 @@
8.9.1
8.9.x
4 changes: 3 additions & 1 deletion .travis.yml
Expand Up @@ -2,7 +2,9 @@ language: node_js
sudo: required
dist: trusty
node_js:
- "8.9.1"
- "8"
- "9"
before_install: if [[ `npm --version` != "5.8.0" ]]; then npm install -g npm@latest; npm --version; fi
matrix:
fast_finish: true
services:
Expand Down
15 changes: 12 additions & 3 deletions README.md
Expand Up @@ -58,6 +58,7 @@ Community maintained fork of the
- [Alarms](#alarms)
- [Core](#core)
- [Predefined values for your browser settings (optional)](#predefined-values-for-your-browser-settings-optional)
- [Views](#views)
- [Plugins](#plugins)
- [Default Plugins](#default-plugins)
- [`delta` (BG Delta)](#delta-bg-delta)
Expand Down Expand Up @@ -105,7 +106,8 @@ Community maintained fork of the

Requirements:

- [Node.js](http://nodejs.org/) 8.9.0 LTS (use [Install instructions for Node](https://nodejs.org/en/download/package-manager/) or `setup.sh`)
- [Node.js](http://nodejs.org/) 8.11.0 LTS or later or [Node.js](http://nodejs.org/) 9.10.0 or later. Use [Install instructions for Node](https://nodejs.org/en/download/package-manager/) or `setup.sh`)
- [MongoDB](https://www.mongodb.com/download-center?jmp=nav#community) 3.x. MongoDB 2.4 is only supported for Raspberry Pi.

Clone this repo then install dependencies into the root of the project:

Expand Down Expand Up @@ -228,7 +230,7 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm
* `NIGHT_MODE` (`off`) - possible values `on` or `off`
* `SHOW_RAWBG` (`never`) - possible values `always`, `never` or `noise`
* `CUSTOM_TITLE` (`Nightscout`) - Usually name of T1
* `THEME` (`default`) - possible values `default` or `colors`
* `THEME` (`default`) - possible values `default`, `colors`, or `colorblindfriendly`
* `ALARM_TIMEAGO_WARN` (`on`) - possible values `on` or `off`
* `ALARM_TIMEAGO_WARN_MINS` (`15`) - minutes since the last reading to trigger a warning
* `ALARM_TIMEAGO_URGENT` (`on`) - possible values `on` or `off`
Expand All @@ -242,6 +244,13 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm
* 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`. Enable or disable icon allowing enter treatments edit mode

### Views

There are a few alternate web views available that display a simplified BG stream. Append any of these to your Nightscout URL:
* `/clock.html` - Shows current BG. Grey text on a black background.
* `/bgclock.html` - Shows current BG, trend arrow, and time of day. Grey text on a black background.
* `/clock-color.html` - 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).

### Plugins

Plugins are used extend the way information is displayed, how notifications are sent, alarms are triggered, and more.
Expand Down Expand Up @@ -377,7 +386,7 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm
Generic Pump Monitoring for OpenAPS, MiniMed Connect, RileyLink, t:slim, with more on the way
* Requires `DEVICESTATUS_ADVANCED="true"` to be set
* `PUMP_ENABLE_ALERTS` (`false`) - Set to `true` to enable notifications for Pump battery and reservoir.
* `PUMP_WARNONSUSPEND` (`false`) - Set to `true` to get an alarm when the pump is suspended.
* `PUMP_WARN_ON_SUSPEND` (`false`) - Set to `true` to get an alarm when the pump is suspended.
* `PUMP_FIELDS` (`reservoir battery`) - The fields to display by default. Any of the following fields: `reservoir`, `battery`, `clock`, `status`, and `device`
* `PUMP_RETRO_FIELDS` (`reservoir battery clock`) - The fields to display in retro mode. Any of the above fields.
* `PUMP_WARN_CLOCK` (`30`) - The number of minutes ago that needs to be exceed before an alert is triggered.
Expand Down
52 changes: 21 additions & 31 deletions app.json
Expand Up @@ -8,7 +8,7 @@
"required": true
},
"API_SECRET": {
"description": "REQUIRED: A secret passphrase that must be at least 12 characters long, required to enable POST and PUT; also required for the Care Portal",
"description": "REQUIRED: A secret passphrase that must be at least 12 characters long, required to enable POST and PUT; also required for the Care Portal.",
"value": "",
"required": true
},
Expand All @@ -18,12 +18,12 @@
"required": false
},
"ENABLE": {
"description": "Used to enable optional features, expects a space delimited list, such as: careportal rawbg iob, see https://github.com/nightscout/cgm-remote-monitor/blob/master/README.md for more info",
"description": "Used to enable optional features, expects a space delimited list, such as: careportal rawbg iob, see https://github.com/nightscout/cgm-remote-monitor/blob/master/README.md for more info.",
"value": "",
"required": false
},
"DISABLE": {
"description": "Used to disable default features, expects a space delimited list, such as: direction upbat, see https://github.com/nightscout/cgm-remote-monitor/blob/master/README.md for more info",
"description": "Used to disable default features, expects a space delimited list, such as: direction upbat, see https://github.com/nightscout/cgm-remote-monitor/blob/master/README.md for more info.",
"value": "",
"required": false
},
Expand All @@ -33,22 +33,22 @@
"required": false
},
"BG_HIGH": {
"description": "Urgent high BG alarm. Default null value implies 260. Must be set in mg/dL. Only used with simple alarms.",
"description": "Urgent high BG alarm. Default null value implies 260. Must be set in mg/dL (multiply with 18 if you have a value in mmol/L). Only used with simple alarms.",
"value": "",
"required": false
},
"BG_TARGET_TOP": {
"description": "Non-urgent high BG alarm, the top of your target range. Default null value implies 180. Must be set in mg/dL. Only used with simple alarms.",
"description": "Non-urgent high BG alarm, the top of your target range. Default null value implies 180. Must be set in mg/dL (multiply with 18 if you have a value in mmol/L). Only used with simple alarms.",
"value": "",
"required": false
},
"BG_TARGET_BOTTOM": {
"description": "Non urgent low BG alarm, the bottom of your target range. Default null value implies 80. Must be set in mg/dL. Only used with simple alarms.",
"description": "Non urgent low BG alarm, the bottom of your target range. Default null value implies 80. Must be set in mg/dL (multiply with 18 if you have a value in mmol/L). Only used with simple alarms.",
"value": "",
"required": false
},
"BG_LOW": {
"description": "Urgent Low BG alarm. Default null value implies 55. Must be set in mg/dL. Only used with simple alarms.",
"description": "Urgent Low BG alarm. Default null value implies 55. Must be set in mg/dL (multiply with 18 if you have a value in mmol/L). Only used with simple alarms.",
"value": "",
"required": false
},
Expand All @@ -72,83 +72,73 @@
"value": "",
"required": false
},
"THEME": {
"description": "Possible values default, colors or colorblindfriendly",
"value": "",
"required": false
},
"SHOW_RAWBG": {
"description": "Possible values always, never or noise",
"value": "",
"required": false
},
"BRIDGE_USER_NAME": {
"description": "Share bridge - Your user name for the Share service. ENSURE bridge is in ENABLE if you want to use the share bridge",
"description": "Share bridge - Your user name for the Share service. ENSURE bridge is in ENABLE if you want to use the share bridge.",
"value": "",
"required": false
},
"BRIDGE_PASSWORD": {
"description": "Share bridge - Your password for the Share service. ENSURE bridge is in ENABLE if you want to use the share bridge",
"description": "Share bridge - Your password for the Share service. ENSURE bridge is in ENABLE if you want to use the share bridge.",
"value": "",
"required": false
},
"TIME_FORMAT": {
"description": "Browser default time mode valid settings are 12 or 24",
"description": "Browser default time mode. Valid settings are 12 or 24",
"value": "12",
"required": false
},
"NIGHT_MODE": {
"description": "Browser defaults to night mode valid settings are on or off",
"description": "Browser defaults to night mode. Valid settings are on or off",
"value": "off",
"required": false
},
"SHOW_RAWBG": {
"description": "Browser default raw display mode vaild settings are always never or noise",
"description": "Browser default raw display mode. Valid settings are always, never, or noise",
"value": "never",
"required": false
},
"THEME": {
"description": "Browser default theme setting vaild settings are default or colors",
"description": "Browser default theme setting. Valid settings are default, colors, or colorblindfriendly",
"value": "default",
"required": false
},
"ALARM_URGENT_HIGH": {
"description": "Browser default urgent high alarm enabled vaild settings are on or off",
"description": "Browser default urgent high alarm enabled. Valid settings are on or off",
"value": "on",
"required": false
},
"ALARM_HIGH": {
"description": "Browser default high alarm enabled vaild settings are on or off",
"description": "Browser default high alarm enabled. Valid settings are on or off",
"value": "on",
"required": false
},
"ALARM_LOW": {
"description": "Browser default low alarm enabled vaild settings are on or off",
"description": "Browser default low alarm enabled. Valid settings are on or off",
"value": "on",
"required": false
},
"ALARM_URGENT_LOW": {
"description": "Browser default urgent low alarm enabled vaild settings are on or off",
"description": "Browser default urgent low alarm enabled. Valid settings are on or off",
"value": "on",
"required": false
},
"ALARM_TIMEAGO_WARN": {
"description": "Browser default warn after time of last data exceeds ALARM_TIMEAGO_WARN_MINS alarm enabled vaild settings are on or off",
"description": "Browser default warn after time of last data exceeds ALARM_TIMEAGO_WARN_MINS alarm enabled. Valid settings are on or off",
"value": "on",
"required": false
},
"ALARM_TIMEAGO_WARN_MINS": {
"description": "Browser default minutes since the last reading to trigger a warning",
"description": "Browser default minutes since the last reading to trigger a warning.",
"value": "15",
"required": false
},
"ALARM_TIMEAGO_URGENT": {
"description": "Browser default urgent warning after time of last data exceeds ALARM_TIMEAGO_URGENT_MINS alarm enabled vaild settings are on or off",
"description": "Browser default urgent warning after time of last data exceeds ALARM_TIMEAGO_URGENT_MINS alarm enabled. Valid settings are on or off",
"value": "on",
"required": false
},
"ALARM_TIMEAGO_URGENT_MINS": {
"description": "Browser default minutes since last reading to trigger an urgent alarm",
"description": "Browser default minutes since last reading to trigger an urgent alarm.",
"value": "30",
"required": false
},
Expand Down
17 changes: 0 additions & 17 deletions bower.json

This file was deleted.

11 changes: 0 additions & 11 deletions env.js
Expand Up @@ -79,17 +79,6 @@ function setAPISecret() {

function setVersion() {
var software = require('./package.json');
var git = require('git-rev');

if (readENV('APPSETTING_ScmType') === readENV('ScmType') && readENV('ScmType') === 'GitHub') {
env.head = require('./scm-commit-id.json');
console.log('SCM COMMIT ID', env.head);
} else {
git.short(function record_git_head(head) {
console.log('GIT HEAD', head);
env.head = head || readENV('SCM_COMMIT_ID') || readENV('COMMIT_HASH', '');
});
}
env.version = software.version;
env.name = software.name;
}
Expand Down
19 changes: 0 additions & 19 deletions lib/api/entries/index.js
Expand Up @@ -94,25 +94,6 @@ function configure (app, wares, ctx) {
return next();
}

// check for last modified from query results

function ifModifiedSince (req, res, next) {

var lastEntryDate = new Date(_.last(res.entries).dateString);
res.setHeader('Last-Modified', lastEntryDate.toUTCString());

var ifModifiedSince = req.get('If-Modified-Since');

if (!ifModifiedSince) { return next(); }

if (lastEntryDate <= new Date(ifModifiedSince)) {
res.status(304).send({status:304, message: 'Not modified', type:'internal'});
return;
}

return next();
}

/**
* @method format_entries
* A final middleware to send payloads assembled by previous middlewares
Expand Down
6 changes: 1 addition & 5 deletions lib/api/index.js
Expand Up @@ -11,11 +11,7 @@ function create (env, ctx) {
// set up express app with our options
app.set('name', env.name);
app.set('version', env.version);
// app.set('head', env.head);
function get_head ( ) {
return env.head;
}
wares.get_head = get_head;

app.set('units', env.DISPLAY_UNITS);
// Only allow access to the API if API_SECRET is set on the server.
app.disable('api');
Expand Down
1 change: 0 additions & 1 deletion lib/api/status.js
Expand Up @@ -23,7 +23,6 @@ function configure (app, wares, env, ctx) {
, apiEnabled: app.enabled('api')
, careportalEnabled: app.enabled('api') && env.settings.enable.indexOf('careportal') > -1
, boluscalcEnabled: app.enabled('api') && env.settings.enable.indexOf('boluscalc') > -1
, head: wares.get_head( )
, settings: env.settings
, extendedSettings: app.extendedClientSettings
, authorized: ctx.authorization.authorize(req.query.token || '')
Expand Down
2 changes: 1 addition & 1 deletion lib/authorization/storage.js
Expand Up @@ -5,7 +5,7 @@ var crypto = require('crypto');
var shiroTrie = require('shiro-trie');
var ObjectID = require('mongodb').ObjectID;

var find_options = require('../query');
var find_options = require('../server/query');

function init (env, ctx) {
var storage = { };
Expand Down
1 change: 1 addition & 0 deletions lib/client/index.js
Expand Up @@ -1127,6 +1127,7 @@ client.load = function load(serverSettings, callback) {
chart.update(true);
} else if (!inRetroMode()) {
chart.update(false);
client.plugins.updateVisualisations(client.nowSBX);
}

}
Expand Down
7 changes: 0 additions & 7 deletions lib/client/receiveddata.js
Expand Up @@ -37,22 +37,15 @@ function mergeDataUpdate(isDelta, cachedDataArray, receivedDataArray, maxAge) {
}

// purge old data from cache before updating
var purgeCount = 0;
var mAge = (isNaN(maxAge) || maxAge == null) ? TWO_DAYS : maxAge;
var twoDaysAgo = new Date().getTime() - mAge;

for (var i = 0; i < cachedDataArray.length; i++) {
var element = cachedDataArray[i];
if (element !== null && element !== undefined && element.mills <= twoDaysAgo) {
cachedDataArray.splice(i,0);
purgeCount += 1;
}
}

//if (purgeCount > 0) {
// console.log('Purged ' + purgeCount + ' elements from cache due to age');
//}


// If this is delta, calculate the difference, merge and sort
var diff = nsArrayDiff(cachedDataArray, receivedDataArray);
Expand Down
15 changes: 7 additions & 8 deletions lib/client/renderer.js
Expand Up @@ -393,8 +393,6 @@ function init (client, d3) {

function calcTreatmentRadius(treatment, opts, carbratio) {
var CR = treatment.CR || carbratio || 20;
var carbs = treatment.carbs || CR;
var insulin = treatment.insulin || 1;
var carbsOrInsulin = CR;
if ( treatment.carbs ) {
carbsOrInsulin = treatment.carbs;
Expand Down Expand Up @@ -445,10 +443,10 @@ 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) { // 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
Expand Down Expand Up @@ -860,7 +858,7 @@ function init (client, d3) {
.attr('class', 'path')
.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);

Expand All @@ -881,13 +879,14 @@ function init (client, d3) {
}

renderer.drawTreatments = function drawTreatments(client) {

var treatmentCount = 0;
chart().focus.selectAll('.draggable-treatment').remove();

_.forEach(client.ddata.treatments, function eachTreatment (d) {
if (Number(d.insulin) > 0 || Number(d.carbs) > 0) { treatmentCount += 1; };
if (Number(d.insulin) > 0 || Number(d.carbs) > 0) { treatmentCount += 1; };
});

// add treatment bubbles
_.forEach(client.ddata.treatments, function eachTreatment (d) {
renderer.drawTreatment(d, {
Expand Down

0 comments on commit d5c35d5

Please sign in to comment.