Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release Nightscout 0.12.4 #4927

Merged
merged 35 commits into from
Sep 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6c5bc21
Don't show calculated insulin from carbs
bassettb Jul 29, 2019
4638db5
staleTime div is missing in the clockview
ireneusz-ptak Jul 30, 2019
9897926
Bump version to 0.12.4-dev
sulkaharo Jul 30, 2019
1a26b2a
Remove profile conversion warning
unsoluble Jul 31, 2019
23e9db9
Rewording of the "wrong profile" dialog
unsoluble Jul 31, 2019
8c9d51f
Fixed plugin settings being displayed in other settings pages
Erin879 Aug 3, 2019
54ae531
Allow start nightscout from other directories but cgm-remote-monitor
GermanBluefox Aug 3, 2019
5e88388
Formatting
GermanBluefox Aug 3, 2019
1c9d5b1
Use not only from cgm-remote-monitor
GermanBluefox Aug 3, 2019
f7dc1f8
Merge pull request #4848 from Erin879/dev
sulkaharo Aug 4, 2019
503a029
Merge pull request #4846 from GermanBluefox/patch-1
sulkaharo Aug 4, 2019
eacc560
Merge pull request #4831 from ireneusz-ptak/patch-1
sulkaharo Aug 4, 2019
d47fd21
Merge pull request #4833 from bassettb/daytoday-carbs-dont-need-IC-calc
sulkaharo Aug 4, 2019
98c22d9
Merge pull request #4837 from unsoluble/patch-6
sulkaharo Aug 4, 2019
f2b0550
Update language.js per #4837 and #4838
unsoluble Aug 4, 2019
5be345b
Merge pull request #1 from nightscout/dev
Erin879 Aug 5, 2019
cf89f37
fixed issue with incorrect target validation
Erin879 Aug 6, 2019
0f7c03d
Merge pull request #4861 from Erin879/dev
sulkaharo Aug 11, 2019
46070c9
Merge pull request #4851 from unsoluble/patch-1
sulkaharo Aug 11, 2019
23ac70a
Merge pull request #4838 from unsoluble/patch-7
sulkaharo Aug 11, 2019
d0e14de
Fix clock if authentication is enabled (#4914)
PieterGit Aug 22, 2019
3b5430d
German language updates (#4895)
herzogmedia Aug 23, 2019
20823d3
upgrade minimed-connect-to-nightscout to fix GuardianConnect for US s…
PieterGit Aug 24, 2019
7c0a005
Wip/clock hide state management (#4944)
sulkaharo Sep 15, 2019
380f0e3
api-docs.html -> /api-docs/ (#4942)
aviau Sep 15, 2019
1ddc641
mongolab -> mLab (#4926)
aviau Sep 15, 2019
db6520f
fixed unit conversion in basal pill, openaps pill, temporary targets,…
Erin879 Sep 15, 2019
8ce6e24
Use Babel to transpile the client bundle to be compatible with old br…
sulkaharo Sep 17, 2019
e06e372
Rewording the "store hash" label (#4930)
unsoluble Sep 17, 2019
0898ec1
Russian translation proofreading minor corrections, up to line 8000 (…
apanasef Sep 17, 2019
196bcd6
Fixed error if latestSGV not filled (#4919)
GermanBluefox Sep 17, 2019
1878833
Change a let to var in clock views to allow running on old devices
sulkaharo Sep 18, 2019
fdfb224
Bump version to 0.12.4 for release
sulkaharo Sep 18, 2019
3c99ba7
Updated the browser requirements in README
sulkaharo Sep 18, 2019
146f09a
Merge branch 'master' into dev
sulkaharo Sep 18, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env"]
}
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Nightscout is a Node.js application. The basic installation of the software for

We develop on the `dev` branch. All new pull requests should be targeted to `dev`. The `master` branch is only used for distributing the latest version of the tested sources.

You can get the dev branch checked out using `git checkout dev`.
You can get the `dev` branch checked out using `git checkout dev`.

Once checked out, install the dependencies using `npm install`, then copy the included `my.env.template`file to `my.env` and edit the file to include your settings (like the Mongo URL). Leave the `NODE_ENV=development` line intact. Once set, run the site using `npm run dev`. This will start Nigthscout in the development mode, with different code packaging rules and automatic restarting of the server using nodemon, when you save changed files on disk. The client also hot-reloads new code in, but it's recommended to reload the the website after changes due to the way the plugin sandbox works.

Expand Down Expand Up @@ -119,8 +119,9 @@ We assume all new Pull Requests are at least smoke tested by the author and all
Please include a description of what the features do and rationalize why the changes are needed.

If you add any new NPM module dependencies, you have to rationalize why there are needed - we prefer pull requests that reduce dependencies, not add them.
Before releasing a a new version, we check with `npm audit` if our dependencies don't have known security issues.

When adding new features that add confugration options, please ensure the `README` document is amended with information on the new configuration.
When adding new features that add configuration options, please ensure the `README` document is amended with information on the new configuration.

## Bug fixing

Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ If you plan to use Nightscout, we recommend using [Heroku](http://www.nightscout
- Linux based install (Debian, Ubuntu, Raspbian) install with own Node.JS and MongoDB install (see software requirements below)
- Windows based install with own Node.JS and MongoDB install (see software requirements below)

## Minimum browser requirements for viewing the site:
## Recommended minimum browser versions for using Nightscout:

Older versions of the browsers might work, but are untested.

- Android 4
- Chrome 68
Expand Down Expand Up @@ -170,9 +172,9 @@ Wanna help with development, or just see how Nigthscout works? Great! See [CONTR
# Usage

The data being uploaded from the server to the client is from a
MongoDB server such as [mongolab][mongodb].
MongoDB server such as [mLab][mLab].

[mongodb]: https://mongolab.com
[mLab]: https://mlab.com/
[autoconfigure]: https://nightscout.github.io/pages/configure/
[mongostring]: https://nightscout.github.io/pages/mongostring/

Expand Down Expand Up @@ -200,7 +202,7 @@ The server status and settings are available from `/api/v1/status.json`.
By default the `/entries` and `/treatments` APIs limit results to the the most recent 10 values from the last 2 days.
You can get many more results, by using the `count`, `date`, `dateString`, and `created_at` parameters, depending on the type of data you're looking for.

Once you've installed Nightscout, you can access API documentation by loading `/api-docs` URL in your instance.
Once you've installed Nightscout, you can access API documentation by loading `/api-docs/` URL in your instance.

#### Example Queries

Expand All @@ -213,7 +215,7 @@ Once you've installed Nightscout, you can access API documentation by loading `/
* Boluses over 2U: `http://localhost:1337/api/v1/treatments.json?find[insulin][$gte]=2`

The API is Swagger enabled, so you can generate client code to make working with the API easy.
To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.html or review [swagger.yaml](swagger.yaml).
To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs/ or review [swagger.yaml](swagger.yaml).

## Environment

Expand Down
25 changes: 18 additions & 7 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ function create (env, ctx) {
if (!insecureUseHttp) {
console.info('Redirecting http traffic to https because INSECURE_USE_HTTP=', insecureUseHttp);
app.use((req, res, next) => {
if (req.header('x-forwarded-proto') == 'https' || req.secure) {
if (req.header('x-forwarded-proto') === 'https' || req.secure) {
next();
} else {
res.redirect(307, `https://${req.header('host')}${req.url}`);
}
})
});
if (secureHstsHeader) { // Add HSTS (HTTP Strict Transport Security) header
console.info('Enabled SECURE_HSTS_HEADER (HTTP Strict Transport Security)');
const helmet = require('helmet');
Expand Down Expand Up @@ -61,7 +61,7 @@ function create (env, ctx) {
}));
app.use(helmet.referrerPolicy({ policy: 'no-referrer' }));
app.use(helmet.featurePolicy({ features: { payment: ["'none'"], } }));
app.use(bodyParser.json({ type: ['json', 'application/csp-report'] }))
app.use(bodyParser.json({ type: ['json', 'application/csp-report'] }));
app.post('/report-violation', (req, res) => {
if (req.body) {
console.log('CSP Violation: ', req.body)
Expand All @@ -84,7 +84,11 @@ function create (env, ctx) {

let cacheBuster = 'developmentMode';
if (process.env.NODE_ENV !== 'development') {
cacheBuster = fs.readFileSync(process.cwd() + '/tmp/cacheBusterToken').toString().trim();
if (fs.existsSync(process.cwd() + '/tmp/cacheBusterToken')) {
cacheBuster = fs.readFileSync(process.cwd() + '/tmp/cacheBusterToken').toString().trim();
} else {
cacheBuster = fs.readFileSync(__dirname + '/tmp/cacheBusterToken').toString().trim();
}
}
app.locals.cachebuster = cacheBuster;

Expand Down Expand Up @@ -254,9 +258,16 @@ function create (env, ctx) {
}

// Production bundling
var tmpFiles = express.static('tmp', {
maxAge: maxAge
});
var tmpFiles;
if (fs.existsSync(process.cwd() + '/tmp/cacheBusterToken')) {
tmpFiles = express.static('tmp', {
maxAge: maxAge
});
} else {
tmpFiles = express.static(__dirname + '/tmp', {
maxAge: maxAge
});
}

// serve the static content
app.use('/bundle', tmpFiles);
Expand Down
2 changes: 1 addition & 1 deletion lib/client/browser-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function init (client, serverSettings, $) {

showPluginsSettings.toggle(hasPluginsToShow);

const bs = $('.browserSettings');
const bs = $('#browserSettings');
const toggleCheckboxes = [];

if (pluginPrefs.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion lib/client/careportal.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ function init (client, $) {

console.log('Validating careportal entry: ', data.eventType);

if (data.eventType == 'Temporary Target') {
if (data.duration !== 0 && data.eventType == 'Temporary Target') {
if (isNaN(data.targetTop) || isNaN(data.targetBottom) || !data.targetBottom || !data.targetTop) {
console.log('Bottom or Top target missing');
allOk = false;
Expand Down
57 changes: 45 additions & 12 deletions lib/client/clock-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,27 @@ client.settings = browserSettings(client, window.serverSettings, $);

client.query = function query () {
console.log('query');
$.ajax('/api/v1/entries.json?count=3', {
var parts = (location.search || '?').substring(1).split('&');
var token = '';
parts.forEach(function (val) {
if (val.startsWith('token=')) {
token = val.substring('token='.length);
}
});

var secret = localStorage.getItem('apisecrethash');
var src = '/api/v1/entries.json?count=3&t=' + new Date().getTime();

if (secret) {
src += '&secret=' + secret;
} else if (token) {
src += '&token=' + token;
}

$.ajax(src, {
success: client.render
});
}
};

client.render = function render (xhr) {
console.log('got data', xhr);
Expand All @@ -28,11 +45,27 @@ client.render = function render (xhr) {
}
});

let $errorMessage = $('#errorMessage');

// If no one measured value found => show "-?-"
if (!rec) {
if (!$errorMessage.length) {
$('#arrowDiv').append('<div id="errorMessage" title="No data found in DB">-?-</div>');
$('#arrow').hide();
} else {
$errorMessage.show();
}
return;
} else {
$errorMessage.length && $errorMessage.hide();
$('#arrow').show();
}

let last = new Date(rec.date);
let now = new Date();

// Convert BG to mmol/L if necessary.
if (window.serverSettings.settings.units == 'mmol') {
if (window.serverSettings.settings.units === 'mmol') {
var displayValue = window.Nightscout.units.mgdlToMMOL(rec.sgv);
} else {
displayValue = rec.sgv;
Expand All @@ -42,7 +75,7 @@ client.render = function render (xhr) {
$('#bgnow').html(displayValue);

// Insert the trend arrow.
$('#arrow').attr('src', '/images/' + rec.direction + '.svg');
$('#arrow').attr('src', '/images/' + (!rec.direction || rec.direction === 'NOT COMPUTABLE' ? 'NONE' : rec.direction) + '.svg');

// Time before data considered stale.
let staleMinutes = 13;
Expand All @@ -52,13 +85,13 @@ client.render = function render (xhr) {
$('#bgnow').toggleClass('stale', (now - last > threshold));

// Generate and insert the clock.
let timeDivisor = (client.settings.timeFormat) ? client.settings.timeFormat : 12;
let timeDivisor = parseInt(client.settings.timeFormat ? client.settings.timeFormat : 12, 10);
let today = new Date()
, h = today.getHours() % timeDivisor;
if (timeDivisor == 12) {
h = (h == 0) ? 12 : h; // In the case of 00:xx, change to 12:xx for 12h time
if (timeDivisor === 12) {
h = (h === 0) ? 12 : h; // In the case of 00:xx, change to 12:xx for 12h time
}
if (timeDivisor == 24) {
if (timeDivisor === 24) {
h = (h < 10) ? ("0" + h) : h; // Pad the hours with a 0 in 24h time
}
let m = today.getMinutes();
Expand All @@ -67,14 +100,14 @@ client.render = function render (xhr) {

var queryDict = {};
location.search.substr(1).split("&").forEach(function(item) { queryDict[item.split("=")[0]] = item.split("=")[1] });

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

// defined in the template this is loaded into
// eslint-disable-next-line no-undef
if (clockFace == 'clock-color') {
if (clockFace === 'clock-color') {

var bgHigh = window.serverSettings.settings.thresholds.bgHigh;
var bgLow = window.serverSettings.settings.thresholds.bgLow;
Expand Down Expand Up @@ -138,12 +171,12 @@ client.render = function render (xhr) {
$('#arrow').css('filter', 'brightness(100%)');
}
}
}
};

client.init = function init () {
console.log('init');
client.query();
setInterval(client.query, 1 * 60 * 1000);
}
};

module.exports = client;
20 changes: 16 additions & 4 deletions lib/client/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
'use strict';
'use strict';

var _ = require('lodash');
var $ = (global && global.$) || require('jquery');
Expand Down Expand Up @@ -64,7 +63,7 @@ client.init = function init (callback) {
}).fail(function fail (jqXHR, textStatus, errorThrown) {

// check if we couldn't reach the server at all, show offline message
if (jqXHR.readyState == 0) {
if (!jqXHR.readyState) {
console.log('Application appears to be OFFLINE');
$('#loadingMessageText').html('Connecting to Nightscout server failed, retrying every 2 seconds');
window.setTimeout(window.Nightscout.client.init(), 2000);
Expand All @@ -76,7 +75,20 @@ client.init = function init (callback) {
console.log('Already tried to get settings after auth, but failed');
} else {
client.settingsFailed = true;
language.set('en');

// detect browser language
var lang = Storages.localStorage.get('language') || (navigator.language || navigator.userLanguage).toLowerCase();
if (lang !== 'zh_cn' && lang !== 'zh-cn' && lang !== 'zh_tw' && lang !== 'zh-tw') {
lang = lang.substring(0, 2);
} else {
lang = lang.replace('-', '_');
}
if (language.languages.find(l => l.code === lang)) {
language.set(lang);
} else {
language.set('en');
}

client.translate = language.translate;
// auth failed, hide loader and request for key
$('#centerMessagePanel').hide();
Expand Down Expand Up @@ -993,7 +1005,7 @@ client.load = function load (serverSettings, callback) {
socket.on('notification', function(notify) {
console.log('notification from server:', notify);

if (notify.timestamp && previousNotifyTimestamp != notify.timestamp) {
if (notify.timestamp && previousNotifyTimestamp !== notify.timestamp) {
previousNotifyTimestamp = notify.timestamp;
client.plugins.visualizeAlarm(client.sbx, notify, notify.title + ' ' + notify.message);
} else {
Expand Down
Loading