Update to node 8.8.1. Merge branch 'dev' of https://github.com/nightscout/cgm-remote-monitor into 201710_pieterg_zt

This commit is contained in:
PieterGit
2017-10-27 15:47:39 +02:00
28 changed files with 7540 additions and 74 deletions
+1
View File
@@ -5,6 +5,7 @@ package-lock.json
bundle/bundle.out.js
.vscode/
.idea/
*.iml
my.env
+1 -1
View File
@@ -1 +1 @@
8.1.4
8.8.1
+2 -1
View File
@@ -1,7 +1,8 @@
language: node_js
sudo: required
dist: trusty
node_js:
- "8.5.0"
- "8.8.1"
matrix:
fast_finish: true
services:
+1 -1
View File
@@ -1,4 +1,4 @@
FROM node:8.5.0
FROM node:8.8.1
MAINTAINER Nightscout Contributors
+2 -2
View File
@@ -30,7 +30,7 @@ all: test
coverage:
NODE_ENV=test ${MONGO_SETTINGS} \
${ISTANBUL} cover ${MOCHA} -- --timeout 30000 -R tap ${TESTS}
${ISTANBUL} cover ${MOCHA} -- --timeout 15000 -R tap ${TESTS}
report:
test -f ${ANALYZED} && \
@@ -45,7 +45,7 @@ test:
travis:
NODE_ENV=test ${MONGO_SETTINGS} \
${ISTANBUL} cover ${MOCHA} --report lcovonly -- --timeout 50000 -R tap ${TESTS}
${ISTANBUL} cover ${MOCHA} --report lcovonly -- --timeout 5000 -R tap ${TESTS}
docker_release:
# Get the version from the package.json file
+2 -2
View File
@@ -105,7 +105,7 @@ Community maintained fork of the
Requirements:
- [Node.js](http://nodejs.org/)
- [Node.js](http://nodejs.org/) 8.8.1 (use [Install instructions for Node](https://nodejs.org/en/download/package-manager/) or `setup.sh`)
Clone this repo then install dependencies into the root of the project:
@@ -113,7 +113,7 @@ Clone this repo then install dependencies into the root of the project:
$ npm install
```
If deploying the software to Microsoft Azure, you must set *WEBSITE_NODE_DEFAULT_VERSION* in the app settings to *8.5.0* or the site deployment will fail. Other hosting environments do not require this setting.
If deploying the software to Microsoft Azure, you must set *WEBSITE_NODE_DEFAULT_VERSION* in the app settings to *8.8.1* **before** you deploy the latest Nightscout or the site deployment will likely fail. Other hosting environments do not require this setting.
# Usage
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "nightscout",
"version": "0.10.2-dev-20171016",
"version": "0.10.2-release-20171026",
"dependencies": {
"colorbrewer": "~1.0.0",
"jQuery-Storage-API": "~1.7.2",
+1 -1
View File
@@ -86,7 +86,7 @@ function configure (app, wares, ctx) {
var ifModifiedSince = req.get('If-Modified-Since');
if (!ifModifiedSince) { return next(); }
if (lastEntryDate <= new Date(ifModifiedSince)) {
if (lastEntryDate.getTime() <= new Date(ifModifiedSince).getTime()) {
res.status(304).send({status:304, message: 'Not modified', type:'internal'});
return;
}
+14 -3
View File
@@ -2,6 +2,7 @@
var _ = require('lodash');
var consts = require('../../constants');
var moment = require('moment');
function configure(app, wares, ctx) {
var express = require('express')
@@ -39,16 +40,26 @@ function configure(app, wares, ctx) {
t.carbs = Number(t.carbs);
t.insulin = Number(t.insulin);
var d2 = new Date(t.timestamp);
var d2 = null;
if (d1 == null || d2 > d1) {
if (t.hasOwnProperty('created_at')) {
d2 = new Date(t.created_at);
} else {
if (t.hasOwnProperty('timestamp')) {
d2 = new Date(t.timestamp);
}
}
if (d2 == null) { return; }
if (d1 == null || d2.getTime() > d1.getTime()) {
d1 = d2;
}
});
if (!_.isNil(d1)) res.setHeader('Last-Modified', d1.toUTCString());
if (ifModifiedSince && d1 <= new Date(ifModifiedSince)) {
if (ifModifiedSince && d1.getTime() <= moment(ifModifiedSince).valueOf()) {
res.status(304).send({
status: 304
, message: 'Not modified'
+27 -27
View File
@@ -621,41 +621,41 @@ function init(client, $) {
boluscalc.loadFoodDatabase = function loadFoodDatabase(event, callback) {
categories = [];
foodlist = [];
$.ajax('/api/v1/food/regular.json', {
headers: client.headers()
, success: function (records) {
records.forEach(function (r) {
foodlist.push(r);
if (r.category && !categories[r.category]) {
categories[r.category] = {};
}
if (r.category && r.subcategory) {
categories[r.category][r.subcategory] = true;
}
});
databaseloaded = true;
console.log('Food database loaded');
fillForm();
var records = client.sbx.data.food || [];
records.forEach(function (r) {
if (r.type == 'food') {
foodlist.push(r);
if (r.category && !categories[r.category]) {
categories[r.category] = {};
}
if (r.category && r.subcategory) {
categories[r.category][r.subcategory] = true;
}
}
}).done(function() { if (callback) { callback(); } });
});
databaseloaded = true;
console.log('Food database loaded');
fillForm();
maybePrevent(event);
if (callback) { callback(); }
};
boluscalc.loadFoodQuickpicks = function loadFoodQuickpicks( ) {
// Load quickpicks
$.ajax('/api/v1/food/quickpicks.json', {
headers: client.headers()
, success: function (records) {
quickpicks = records;
$('#bc_quickpick').empty().append('<option value="-1">' + translate('(none)') + '</option>');
for (var i=0; i<records.length; i++) {
var r = records[i];
$('#bc_quickpick').append('<option value="' + i +'">' + r.name + ' (' + r.carbs + ' g)</option>');
};
$('#bc_quickpick').val(-1);
$('#bc_quickpick').change(quickpickChange);
quickpicks = [];
var records = client.sbx.data.food || [];
records.forEach(function (r) {
if (r.type == 'quickpick') {
quickpicks.push(r);
}
});
$('#bc_quickpick').empty().append('<option value="-1">' + translate('(none)') + '</option>');
for (var i=0; i<records.length; i++) {
var r = records[i];
$('#bc_quickpick').append('<option value="' + i +'">' + r.name + ' (' + r.carbs + ' g)</option>');
};
$('#bc_quickpick').val(-1);
$('#bc_quickpick').change(quickpickChange);
};
function fillForm(event) {
+2 -2
View File
@@ -1080,9 +1080,9 @@ function init (client, d3) {
var sign = t.first ? '▲▲▲' : '▬▬▬';
var ret;
if (t.cutting) {
ret = sign + ' ' + t.cutting + ' ' + '►►►' + ' ' + t.profile + ' ' + sign;
ret = sign + ' ' + client.profilefunctions.profileSwitchName(t.cutting) + ' ' + '►►►' + ' ' + client.profilefunctions.profileSwitchName(t.profile) + ' ' + sign;
} else {
ret = sign + ' ' + t.profile + ' ' + sign;
ret = sign + ' ' + client.profilefunctions.profileSwitchName(t.profile) + ' ' + sign;
}
return ret;
};
+11 -1
View File
@@ -66,6 +66,7 @@ function init(env, ctx) {
, loadProfileSwitchTreatments.bind(null, ddata, ctx)
, loadSensorAndInsulinTreatments.bind(null, ddata, ctx)
, loadProfile.bind(null, ddata, ctx)
, loadFood.bind(null, ddata, ctx)
, loadDeviceStatus.bind(null, ddata, env, ctx)
], loadComplete);
@@ -249,7 +250,16 @@ function loadProfile (ddata, ctx, callback) {
});
}
function loadDeviceStatus (ddata, env, ctx, callback) {
function loadFood (ddata, ctx, callback) {
ctx.food.list(function (err, results) {
if (!err && results) {
ddata.food = results;
}
callback();
});
}
function loadDeviceStatus (ddata, env, ctx, callback) {
var dateRange = {
$gte: new Date(ddata.lastUpdated - ONE_DAY).toISOString()
};
+13 -1
View File
@@ -14,6 +14,7 @@ function init( ) {
, cals: []
, profiles: []
, devicestatus: []
, food: []
, lastUpdated: 0
};
@@ -63,9 +64,20 @@ function init( ) {
result.first.sgvs = ddata.sgvs.filter(filterMax);
result.first.cals = ddata.cals;
result.first.profiles = ddata.profiles;
var profiles = _.cloneDeep(ddata.profiles);
if (profiles && profiles[0])
for (var k in profiles[0].store) {
if (profiles[0].store.hasOwnProperty(k)) {
if (k.indexOf('@@@@@') > 0) {
delete profiles[0].store[k];
}
}
}
result.first.profiles = profiles;
result.rest.mbgs = ddata.mbgs.filter(filterMax);
result.rest.food = ddata.food;
console.log('results.first size', JSON.stringify(result.first).length,'bytes');
console.log('results.rest size', JSON.stringify(result.rest).length,'bytes');
+9
View File
@@ -10566,6 +10566,15 @@ function init() {
, sv: 'no'
, zh_cn: 'no'
, zh_tw: 'no'
},
'Fat [g]': {
cs: 'Tuk [g]'
},
'Protein [g]': {
cs: 'Proteiny [g]'
},
'Energy [kJ]': {
cs: 'Energie [kJ]'
}
};
+20
View File
@@ -235,9 +235,23 @@ function init (profileData) {
var duration = times.mins(t.duration || 0).msecs;
if (duration != 0 && time < t.mills + duration) {
treatment = t;
// if profile switch contains json of profile inject it in to store to be findable by profile name
if (treatment.profileJson && !profile.data[0].store[treatment.profile]) {
if (treatment.profile.indexOf("@@@@@") < 0)
treatment.profile += "@@@@@" + treatment.mills;
var json = JSON.parse(treatment.profileJson);
profile.data[0].store[treatment.profile] = json;
}
}
if (duration == 0) {
treatment = t;
// if profile switch contains json of profile inject it in to store to be findable by profile name
if (treatment.profileJson && !profile.data[0].store[treatment.profile]) {
if (treatment.profile.indexOf("@@@@@") < 0)
treatment.profile += "@@@@@" + treatment.mills;
var json = JSON.parse(treatment.profileJson);
profile.data[0].store[treatment.profile] = json;
}
}
}
});
@@ -248,6 +262,12 @@ function init (profileData) {
return returnValue;
};
profile.profileSwitchName = function profileSwitchName(name) {
var index = name.indexOf("@@@@@");
if (index < 0) return name;
else return name.substring(0, index);
}
profile.tempBasalTreatment = function tempBasalTreatment (time) {
// Most queries for the data in reporting will match the latest found value, caching that hugely improves performance
+2 -2
View File
@@ -832,9 +832,9 @@ daytoday.report = function report_daytoday(datastorage,sorteddaystoshow,options)
var sign = treatment.first ? '▲▲▲' : '▬▬▬';
var text;
if (treatment.cutting) {
text = sign + ' ' + treatment.cutting + ' ' + '►►►' + ' ' + treatment.profile + ' ' + sign;
text = sign + ' ' + client.profilefunctions.profileSwitchName(treatment.cutting) + ' ' + '►►►' + ' ' + client.profilefunctions.profileSwitchName(treatment.profile) + ' ' + sign;
} else {
text = sign + ' ' + treatment.profile + ' ' + sign;
text = sign + ' ' + client.profilefunctions.profileSwitchName(treatment.profile) + ' ' + sign;
}
context.append('text')
.style('font-size', 12)
+7341
View File
File diff suppressed because it is too large Load Diff
+11 -11
View File
@@ -1,6 +1,6 @@
{
"name": "Nightscout",
"version": "0.10.2-dev-20171016",
"version": "0.10.2-release-20171026",
"description": "Nightscout acts as a web-based CGM (Continuous Glucose Montinor) to allow multiple caregivers to remotely view a patients glucose data in realtime.",
"license": "AGPL-3.0",
"author": "Nightscout Team",
@@ -47,14 +47,14 @@
}
},
"engines": {
"node": "8.5.0"
"node": "8.8.1"
},
"dependencies": {
"ajv": "^5.2.2",
"ajv": "^5.3.0",
"async": "^0.9.2",
"body-parser": "^1.18.0",
"body-parser": "^1.18.2",
"bootevent": "0.0.1",
"compression": "^1.7.0",
"compression": "^1.7.1",
"css-loader": "^0.28.7",
"cssmin": "^0.4.3",
"d3": "^3.5.17",
@@ -63,7 +63,7 @@
"event-stream": "^3.3.4",
"expand-braces": "^0.1.2",
"expose-loader": "^0.7.3",
"express": "^4.15.4",
"express": "^4.16.2",
"express-extension-to-accept": "0.0.2",
"express-minify": "^0.2.0",
"file-loader": "^0.11.2",
@@ -79,9 +79,9 @@
"long": "^3.2.0",
"mfb": "^0.12.0",
"minimed-connect-to-nightscout": "git://github.com/mddub/minimed-connect-to-nightscout.git#v1.1.0",
"moment": "^2.18.1",
"moment": "^2.19.1",
"moment-timezone": "^0.5.13",
"mongodb": "^2.2.31",
"mongodb": "^2.2.33",
"mongomock": "^0.1.2",
"mqtt": "^0.3.13",
"node-cache": "^4.1.1",
@@ -90,7 +90,7 @@
"prettyjson": "^1.2.1",
"pushover-notifications": "^0.2.4",
"random-token": "0.0.8",
"request": "^2.81.0",
"request": "^2.83.0",
"sgvdata": "git://github.com/ktind/sgvdata.git#wip/protobuf",
"share2nightscout-bridge": "git://github.com/bewest/share2nightscout-bridge.git#wip/generalize",
"shiro-trie": "^0.3.13",
@@ -100,9 +100,9 @@
"sugar": "^1.5.0",
"sync-exec": "^0.6.2",
"traverse": "^0.6.6",
"uglify-js": "^3.1.0",
"uglify-js": "^3.1.5",
"uuid": "^3.1.0",
"webpack": "^3.5.6"
"webpack": "^3.8.1"
},
"devDependencies": {
"benv": "3.3.0",
+4 -4
View File
@@ -1,9 +1,9 @@
#!/bin/sh
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get update
sudo apt-get install -y python-software-properties python g++ make git
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install -y nodejs
sudo apt-get install -y python-software-properties python git
sudo apt-get install -y build-essential
npm install
+22 -4
View File
@@ -19,6 +19,9 @@ client.init(function loaded () {
, name: ''
, portion: 0
, carbs: 0
, fat: 0 // in grams
, protein: 0 // in grams
, energy: 0 // in kJ
, gi: 2
, unit: 'g'
};
@@ -222,7 +225,10 @@ client.init(function loaded () {
.append($('<span>').attr('class','width100px').css('text-align','center').append(translate('Carbs')))
.append($('<span>').attr('class','width100px').css('text-align','center').append(translate('GI')+' [1-3]'))
.append($('<span>').attr('class','width150px').append(translate('Category')))
.append($('<span>').attr('class','width150px').append(translate('Subcategory')));
.append($('<span>').attr('class','width150px').append(translate('Subcategory')))
.append($('<span>').attr('class','width100px').append(translate('Fat [g]')))
.append($('<span>').attr('class','width100px').append(translate('Protein [g]')))
.append($('<span>').attr('class','width100px').append(translate('Energy [kJ]')));
$('#fe_data').empty();
@@ -244,6 +250,9 @@ client.init(function loaded () {
.append($('<span>').addClass('width100px').css('text-align','center').append(foodlist[i].gi))
.append($('<span>').addClass('width150px').append(foodlist[i].category))
.append($('<span>').addClass('width150px').append(foodlist[i].subcategory))
.append($('<span>').addClass('width100px').append(foodlist[i].fat))
.append($('<span>').addClass('width100px').append(foodlist[i].protein))
.append($('<span>').addClass('width100px').append(foodlist[i].energy))
);
}
@@ -465,9 +474,12 @@ client.init(function loaded () {
$('#fe_name').val(foodrec.name);
$('#fe_portion').val(foodrec.portion ? foodrec.portion : '');
$('#fe_unit').val(foodrec.unit);
$('#fe_carbs').val(foodrec.carbs ? foodrec.carbs : '');
$('#fe_gi').val(foodrec.gi);
$('#fe_carbs').val(foodrec.carbs ? foodrec.carbs : '')
$('#fe_gi').val(foodrec.gi)
$('#fe_fat').val(foodrec.fat ? foodrec.fat : '')
$('#fe_protein').val(foodrec.protein ? foodrec.protein : '')
$('#fe_energy').val(foodrec.energy ? foodrec.energy : '');
$('#fe_quickpick_showhidden').prop('checked',showhidden);
console.info(JSON.stringify(foodrec));
@@ -488,6 +500,12 @@ client.init(function loaded () {
foodrec.unit = $('#fe_unit').val();
foodrec.carbs = parseInt($('#fe_carbs').val());
foodrec.carbs = foodrec.carbs || 0;
foodrec.fat = parseInt($('#fe_fat').val());
foodrec.fat = foodrec.fat || 0;
foodrec.protein = parseInt($('#fe_protein').val());
foodrec.protein = foodrec.protein || 0;
foodrec.energy = parseInt($('#fe_energy').val());
foodrec.energy = foodrec.energy || 0;
foodrec.gi = parseInt($('#fe_gi').val());
showhidden = $('#fe_quickpick_showhidden').is(':checked');
+1 -1
View File
@@ -57,7 +57,7 @@ var someData = {
describe('admintools', function ( ) {
var self = this;
this.timeout(30000);
this.timeout(30000); // TODO: see why this test takes longer on Travis to complete
before(function (done) {
benv.setup(function() {
+2
View File
@@ -13,6 +13,8 @@ var nowData = {
};
describe('client', function ( ) {
this.timeout(30000); // TODO: see why this test takes longer on Travis to complete
var self = this;
var headless = require('./fixtures/headless')(benv, this);
+29
View File
@@ -0,0 +1,29 @@
'use strict';
require('should');
let _ = require('lodash');
let renderer = require('../lib/client/renderer');
const MAX_DELTA = 0.0001;
const PREV_CHART_WIDTHS = [
{ width: 400, expectedScale: 3.5 }
, { width: 500, expectedScale: 2.625 }
, { width: 900, expectedScale: 1.75 }
];
describe('renderer', () => {
describe('bubbleScale', () => {
_.forEach(PREV_CHART_WIDTHS, (prev) => {
describe(`prevChartWidth < ${prev.width}`, () => {
let mockClient = {
utils: true
, chart: { prevChartWidth: prev.width }
, foucusRangeMS: true
};
it('scales correctly', () => {
renderer(mockClient, {}).bubbleScale().should.be.approximately(prev.expectedScale, MAX_DELTA);
});
});
});
});
});
+2 -5
View File
@@ -6,6 +6,8 @@ var read = require('fs').readFileSync;
var serverSettings = require('./fixtures/default-server-settings');
describe('hashauth', function ( ) {
this.timeout(40000); // TODO: see why this test takes longer on Travis to complete
var self = this;
var headless = require('./fixtures/headless')(benv, this);
@@ -63,7 +65,6 @@ describe('hashauth', function ( ) {
*/
it ('should make module unauthorized', function () {
this.timeout(50000);
var client = require('../lib/client');
var hashauth = require('../lib/hashauth');
@@ -82,7 +83,6 @@ describe('hashauth', function ( ) {
});
it ('should make module authorized', function () {
this.timeout(50000);
var client = require('../lib/client');
var hashauth = require('../lib/hashauth');
@@ -99,9 +99,6 @@ describe('hashauth', function ( ) {
});
it ('should store hash and the remove authentication', function () {
this.timeout(50000);
var client = require('../lib/client');
var hashauth = require('../lib/hashauth');
var localStorage = require('./fixtures/localstorage');
+2
View File
@@ -4,6 +4,8 @@ require('should');
var benv = require('benv');
describe('pluginbase', function ( ) {
this.timeout(40000); // TODO: see why this test takes longer on Travis to complete
var headless = require('./fixtures/headless')(benv, this);
before(function (done) {
+1 -1
View File
@@ -71,7 +71,7 @@ var someData = {
describe('Profile editor', function ( ) {
this.timeout(30000);
this.timeout(40000); //TODO: see why this test takes longer on Travis to complete
var headless = require('./fixtures/headless')(benv, this);
before(function (done) {
+9
View File
@@ -88,6 +88,15 @@
<br>
<input type="text" id="fe_subcategory">
</td>
<td>
<span class="translate">Fat [g]</span>:<br><input type="number" id="fe_fat">
</td>
<td>
<span class="translate">Protein [g]</span>:<br><input type="number" id="fe_protein">
</td>
<td>
<span class="translate">Energy [kJ]</span>:<br><input type="number" id="fe_energy">
</td>
</tr>
</table>
<button id="fe_editcreate" class="translate">Save</button>
+7 -3
View File
@@ -3,6 +3,8 @@ const webpack = require('webpack');
var pluginArray = [];
var sourceMapType = 'source-map';
if (process.env.NODE_ENV !== 'development') {
console.log('Production environment detected, enabling UglifyJsPlugin');
@@ -14,6 +16,7 @@ if (process.env.NODE_ENV !== 'development') {
output: {
comments: false
}
, sourceMap: true
});
pluginArray.push(uglify);
@@ -24,7 +27,7 @@ if (process.env.NODE_ENV === 'development') {
console.log('Development environment detected, enabling Bundle Analyzer');
var BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
pluginArray.push(new BundleAnalyzerPlugin({
@@ -78,9 +81,10 @@ module.exports = {
output: {
path: path.resolve(__dirname, './tmp'),
publicPath: '/',
filename: 'js/bundle.js'
filename: 'js/bundle.js',
sourceMapFilename: "js/bundle.js.map",
},
devtool: "#inline-source-map",
devtool: sourceMapType,
plugins: pluginArray,
module: {
rules: [{