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

Update dev #3

Merged
merged 8 commits into from
Jun 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,29 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs/ or

### 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.)
Nightscout allows to create custom, simplified views using a predefined set of elements. This option is available under `[+]` link in the main menu.

List of available items:
* `SGV` - Sensor Glucose Value
* `SGV age` - time since the last SGV read
* `SGV delta` - change of SGV in the last 5 minutes
* `Trend arrow` - icon of the SG trend
* `Time` - current time
* `Line break` - invisible item that will move following items to the next line (by default all are showing on the same level)

All visible items have `Size` property which allows to customize the view even more. Also, all items may appear multiple times on the view.

Apart from adding items, it is possible to customize other aspects of the views, like selecting `Color` or `Black` background. The first one will indicate current BG threshold (green = in range; blue = below range; yellow = above range; red = urgent below/above).
`Show SGV age` option will make `SGV age` item appear `Always` or only if the predefined threshold is reached: `Only after threshold`. Breaching `SGV age threshold` will also make `Color` background turn grey and strike through `SGV`.
`Clock view configurator` will generate an URL (available under `Open my clock view!` link) that could be bookmarked.

There are a few default views available from the main menu:
* `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). Set `SHOW_CLOCK_DELTA` to `true` to show BG change in the last 5 minutes, set `SHOW_CLOCK_LAST_TIME` to `true` to always show BG age.
* `Color` - Shows current BG and trend arrow. White text on a color background.
* `Simple` - Shows current BG. Grey text on a black background.

If you launch one of these views in a fullscreen view in iOS, you can use a left-to-right swipe gesture to exit the view.

### Split View

Some users will need easy access to multiple Nightscout views at the same time. We have a special view for this case, accessed on /split path on your Nightscout URL. The view supports any number of sites between 1 to 8 way split, where the content for the screen can be loaded from multiple Nightscout instances. Note you still need to host separate instances for each Nightscout being monitored including the one that hosts the split view page - these variables only add the ability to load multiple views into one browser page. To set the URLs from which the content is loaded, set:
Expand Down Expand Up @@ -557,6 +575,7 @@ For remote overrides, the following extended settings must be configured:
Plugins only have access to their own extended settings, all the extended settings of client plugins will be sent to the browser.

* `DEVICESTATUS_ADVANCED` (`true`) - Defaults to true. Users who only have a single device uploading data to Nightscout can set this to false to reduce the data use of the site.
* `DEVICESTATUS_DAYS` (`1`) - Defaults to 1, can optionally be set to 2. Users can use this to show 48 hours of device status data for in retro mode, rather than the default 24 hours. Setting this value to 2 will roughly double the bandwidth usage of nightscout, so users with a data cap may not want to update this setting.

#### Pushover
In addition to the normal web based alarms, there is also support for [Pushover](https://pushover.net/) based alarms and notifications.
Expand Down
2 changes: 2 additions & 0 deletions env.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ function findExtendedSettings (envs) {

extended.devicestatus = {};
extended.devicestatus.advanced = true;
extended.devicestatus.days = 1;
if(process.env['DEVICESTATUS_DAYS'] && process.env['DEVICESTATUS_DAYS'] == '2') extended.devicestatus.days = 1;

function normalizeEnv (key) {
return key.toUpperCase().replace('CUSTOMCONNSTR_', '');
Expand Down
25 changes: 25 additions & 0 deletions lib/api/profile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,31 @@ function configure (app, wares, ctx) {
api.use(wares.bodyParser.urlencoded({ extended: true }));

api.use(ctx.authorization.isPermitted('api:profile:read'));


/**
* @function query_models
* Perform the standard query logic, translating API parameters into mongo
* db queries in a fairly regimented manner.
* This middleware executes the query, returning the results as JSON
*/
function query_models (req, res, next) {
var query = req.query;

// If "?count=" is present, use that number to decide how many to return.
if (!query.count) {
query.count = consts.ENTRIES_DEFAULT_COUNT;
}

// perform the query
ctx.profile.list_query(query, function payload(err, profiles) {
return res.json(profiles);
});
}

// List profiles available
api.get('/profiles/', query_models);

// List profiles available
api.get('/profile/', function(req, res) {
ctx.profile.list(function (err, attribute) {
Expand Down
1 change: 1 addition & 0 deletions lib/client/browser-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ function init (client, serverSettings, $) {
settings.thresholds = serverSettings.settings.thresholds;
}


if (serverSettings.settings.enable) {
settings.enable = serverSettings.settings.enable;
}
Expand Down
45 changes: 42 additions & 3 deletions lib/client/careportal.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function init (client, $) {
submitHooks = {};

_.forEach(careportal.allEventTypes, function each (event) {
inputMatrix[event.val] = _.pick(event, ['bg', 'insulin', 'carbs', 'protein', 'fat', 'prebolus', 'duration', 'percent', 'absolute', 'profile', 'split', 'reasons', 'targets']);
inputMatrix[event.val] = _.pick(event, ['otp','remoteCarbs', 'remoteAbsorption', 'remoteBolus', 'bg', 'insulin', 'carbs', 'protein', 'fat', 'prebolus', 'duration', 'percent', 'absolute', 'profile', 'split', 'reasons', 'targets']);
submitHooks[event.val] = event.submitHook;
});
}
Expand Down Expand Up @@ -80,11 +80,18 @@ function init (client, $) {
$('#reasonLabel').css('display', displayType(reasons && reasons.length > 0));
$('#targets').css('display', displayType(inputMatrix[eventType]['targets']));

$('#otpLabel').css('display', displayType(inputMatrix[eventType]['otp']));
$('#remoteCarbsLabel').css('display', displayType(inputMatrix[eventType]['remoteCarbs']));
$('#remoteAbsorptionLabel').css('display', displayType(inputMatrix[eventType]['remoteAbsorption']));
$('#remoteBolusLabel').css('display', displayType(inputMatrix[eventType]['remoteBolus']));

$('#bg').css('display', displayType(inputMatrix[eventType]['bg']));
$('#insulinGivenLabel').css('display', displayType(inputMatrix[eventType]['insulin']));

$('#carbsGivenLabel').css('display', displayType(inputMatrix[eventType]['carbs']));
$('#proteinGivenLabel').css('display', displayType(inputMatrix[eventType]['protein']));
$('#fatGivenLabel').css('display', displayType(inputMatrix[eventType]['fat']));

$('#durationLabel').css('display', displayType(inputMatrix[eventType]['duration']));
$('#percentLabel').css('display', displayType(inputMatrix[eventType]['percent'] && $('#absolute').val() === ''));
$('#absoluteLabel').css('display', displayType(inputMatrix[eventType]['absolute'] && $('#percent').val() === ''));
Expand All @@ -99,6 +106,11 @@ function init (client, $) {

careportal.reasonable();

resetIfHidden(inputMatrix[eventType]['otp'], '#otp');
resetIfHidden(inputMatrix[eventType]['remoteCarbs'], '#remoteCarbs');
resetIfHidden(inputMatrix[eventType]['remoteAbsorption'], '#remoteAbsorption');
resetIfHidden(inputMatrix[eventType]['remoteBolus'], '#remoteBolus');

resetIfHidden(inputMatrix[eventType]['insulin'], '#insulinGiven');
resetIfHidden(inputMatrix[eventType]['carbs'], '#carbsGiven');
resetIfHidden(inputMatrix[eventType]['protein'], '#proteinGiven');
Expand Down Expand Up @@ -192,6 +204,12 @@ function init (client, $) {
$('#eventType').val('<none>');
$('#glucoseValue').val('').attr('placeholder', translate('Value in') + ' ' + client.settings.units);
$('#meter').prop('checked', true);

$('#otp').val('');
$('#remoteCarbs').val('');
$('#remoteAbsorption').val('');
$('#remoteBolus').val('');

$('#carbsGiven').val('');
$('#proteinGiven').val('');
$('#fatGiven').val('');
Expand All @@ -214,6 +232,10 @@ function init (client, $) {
var data = {
enteredBy: $('#enteredBy').val()
, eventType: eventType
, otp: $('#otp').val()
, remoteCarbs: $('#remoteCarbs').val()
, remoteAbsorption: $('#remoteAbsorption').val()
, remoteBolus: $('#remoteBolus').val()
, glucose: $('#glucoseValue').val().replace(',', '.')
, reason: selectedReason
, targetTop: $('#targetTop').val().replace(',', '.')
Expand All @@ -226,11 +248,17 @@ function init (client, $) {
, duration: times.msecs(parse_duration($('#duration').val())).mins < 1 ? $('#duration').val() : times.msecs(parse_duration($('#duration').val())).mins
, percent: $('#percent').val()
, profile: $('#profile').val()
, preBolus: parseInt($('#preBolus').val())
, preBolus: $('#preBolus').val()
, notes: $('#notes').val()
, units: client.settings.units
};

data.preBolus = parseInt(data.preBolus);

if (isNaN(data.preBolus)) {
delete data.preBolus;
}

var reasons = inputMatrix[eventType]['reasons'];
var reason = _.find(reasons, function matches (r) {
return r.name === selectedReason;
Expand Down Expand Up @@ -273,7 +301,11 @@ function init (client, $) {
data.splitExt = parseInt($('#insulinSplitExt').val()) || 0;
}

return data;
let d = {};
Object.keys(data).forEach(function(key) {
if (data[key] != "" && data[key] != null) d[key] = data[key];
});
return d;
}

careportal.save = function save (event) {
Expand Down Expand Up @@ -327,6 +359,8 @@ function init (client, $) {
}
}

// TODO: add check for remote (Bolus, Carbs, Absorption)

return {
allOk
, messages
Expand All @@ -350,6 +384,11 @@ function init (client, $) {
text[text.length - 1] += ' ' + translate('Cancel');
}

pushIf(data.remoteCarbs, translate('Remote Carbs') + ': ' + data.remoteCarbs);
pushIf(data.remoteAbsorption, translate('Remote Absorption') + ': ' + data.remoteAbsorption);
pushIf(data.remoteBolus, translate('Remote Bolus') + ': ' + data.remoteBolus);
pushIf(data.otp, translate('One Time Pascode') + ': ' + data.otp);

pushIf(data.glucose, translate('Blood Glucose') + ': ' + data.glucose);
pushIf(data.glucose, translate('Measurement Method') + ': ' + translate(data.glucoseType));

Expand Down
19 changes: 13 additions & 6 deletions lib/client/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,13 @@ function init (client, d3, $) {

function brushEnded () {
// update the opacity of the context data points to brush extent
var selectedRange = chart.createAdjustedRange();
var from = selectedRange[0].getTime();
var to = selectedRange[1].getTime();

chart.context.selectAll('circle')
.data(client.entries)
.style('opacity', function(d) { return renderer.highlightBrushPoints(d) });
.style('opacity', function(d) { return renderer.highlightBrushPoints(d, from, to) });
}

var extent = client.dataExtent();
Expand Down Expand Up @@ -251,6 +255,7 @@ function init (client, d3, $) {

chart.createBrushedRange = function() {
var brushedRange = chart.theBrush && d3.brushSelection(chart.theBrush.node()) || null;

var range = brushedRange && brushedRange.map(chart.xScale2.invert);
var dataExtent = client.dataExtent();

Expand All @@ -267,6 +272,8 @@ function init (client, d3, $) {
range[1] = new Date(end);
range[0] = new Date(end - client.focusRangeMS);

// console.log('createBrushedRange: ', brushedRange, range);

return range;
}

Expand Down Expand Up @@ -375,7 +382,8 @@ function init (client, d3, $) {

chart.theBrush.selectAll('rect')
.attr('y', 0)
.attr('height', contextHeight);
.attr('height', contextHeight)
.attr('width', '100%');

// disable resizing of brush
chart.context.select('.x.brush').select('.overlay').style('cursor', 'move');
Expand Down Expand Up @@ -507,7 +515,7 @@ function init (client, d3, $) {
.attr('y', 0)
.attr('height', contextHeight);

// console.log('Redrawing old brush with new dimensions: ', currentBrushExtent);
// console.log('chart.update(): Redrawing old brush with new dimensions: ', currentBrushExtent);

// redraw old brush with new dimensions
chart.theBrush.call(chart.brush.move, currentBrushExtent.map(chart.xScale2));
Expand Down Expand Up @@ -578,7 +586,7 @@ function init (client, d3, $) {

chart.xScaleBasals.domain(dataRange);

// console.log('Redrawing brush due to update: ', currentBrushExtent);
// console.log('chart.update(): Redrawing brush due to update: ', currentBrushExtent);

chart.theBrush.call(chart.brush.move, currentBrushExtent.map(chart.xScale2));
};
Expand Down Expand Up @@ -663,8 +671,7 @@ function init (client, d3, $) {
renderer.addTreatmentProfiles(client);
renderer.drawTreatments(client);


// console.log('Redrawing brush due to update: ', currentBrushExtent);
// console.log('scrollUpdate(): Redrawing brush due to update: ', currentBrushExtent);

chart.theBrush.call(chart.brush.move, currentBrushExtent.map(chart.xScale2));

Expand Down
Loading