Skip to content

Commit

Permalink
Merge branch 'wip/bewest/mmconnect' of github.com:nightscout/cgm-remo…
Browse files Browse the repository at this point in the history
…te-monitor into wip/bewest/mmconnect
  • Loading branch information
bewest committed Dec 30, 2020
2 parents fc9fd34 + e3784ea commit 76f198a
Show file tree
Hide file tree
Showing 34 changed files with 801 additions and 215 deletions.
2 changes: 1 addition & 1 deletion lib/admin_plugins/roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = init;
var $status = null;

roles.actions = [{
description: 'Each role will have a 1 or more permissions. The <em>*</em> permission is a wildcard, permissions are a hierarchy using <em>:</em> as a seperator.'
description: 'Each role will have a 1 or more permissions. The <em>*</em> permission is a wildcard, permissions are a hierarchy using <em>:</em> as a separator.'
, buttonLabel: 'Add new Role'
, init: function init (client, callback) {
$status = $('#admin_' + roles.name + '_0_status');
Expand Down
13 changes: 10 additions & 3 deletions lib/authorization/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ function init (env, ctx) {

console.error('Resolving secret/token to permissions failed');
addFailedRequest(data.ip);
callback('All validation failed', {});
if (callback) { callback('All validation failed', {}); }
return {};

};
Expand Down Expand Up @@ -275,11 +275,18 @@ function init (env, ctx) {
*/
authorization.authorize = function authorize (accessToken) {

var subject = storage.findSubject(accessToken);
let userToken = accessToken
const decodedToken = jwt.decode(accessToken);

if (decodedToken && decodedToken.accessToken) {
userToken = decodedToken.accessToken;
}

var subject = storage.findSubject(userToken);
var authorized = null;

if (subject) {
var token = jwt.sign({ accessToken: subject.accessToken }, env.api_secret, { expiresIn: '1h' });
var token = jwt.sign({ accessToken: subject.accessToken }, env.api_secret, { expiresIn: '8h' });

//decode so we can tell the client the issued and expired times
var decoded = jwt.decode(token);
Expand Down
1 change: 0 additions & 1 deletion lib/authorization/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ function init (env, ctx) {

if (!accessToken) return null;


function checkToken(accessToken) {
var split_token = accessToken.split('-');
var prefix = split_token ? _.last(split_token) : '';
Expand Down
5 changes: 3 additions & 2 deletions lib/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -814,12 +814,13 @@ client.load = function load (serverSettings, callback) {
}

function refreshAuthIfNeeded () {
var token = client.browserUtils.queryParms().token;
var clientToken = client.authorized ? client.authorized.token : null;
var token = client.browserUtils.queryParms().token || clientToken;
if (token && client.authorized) {
var renewTime = (client.authorized.exp * 1000) - times.mins(15).msecs - Math.abs((client.authorized.iat * 1000) - client.authorized.lat);
var refreshIn = Math.round((renewTime - client.now) / 1000);
if (client.now > renewTime) {
console.info('Refreshing authorization');
console.info('Refreshing authorization renewal');
$.ajax('/api/v2/authorization/request/' + token, {
success: function(authorized) {
if (authorized) {
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/upbat.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function init(ctx) {

sbx.notifications.requestNotify({
level: prop.min.notification
, title: levels.toDisplay(prop.min.notification) + ' Uploader Battery is Low'
, title: ctx.levels.toDisplay(prop.min.notification) + ' Uploader Battery is Low'
, message: message
, pushoverSound: 'echo'
, group: 'Uploader Battery'
Expand Down
8 changes: 4 additions & 4 deletions lib/report/reportclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ var init = function init () {

function countDays () {
for (var d in daystoshow) {
if (daystoshow.hasOwnProperty(d)) {
if (Object.prototype.hasOwnProperty.call(daystoshow, d)) {
if (daystoshow[d] === matchesneeded) {
if (dayscount < maxdays) {
dayscount++;
Expand All @@ -441,7 +441,7 @@ var init = function init () {

function addPreviousDayTreatments () {
for (var d in daystoshow) {
if (daystoshow.hasOwnProperty(d)) {
if (Object.prototype.hasOwnProperty.call(daystoshow, d)) {
var day = moment.tz(d, zone);
var previous = day.subtract(1, 'days');
var formated = previous.format('YYYY-MM-DD');
Expand Down Expand Up @@ -514,7 +514,7 @@ var init = function init () {
datastorage.treatments.sort(function sort (a, b) { return a.mills - b.mills; });

for (var d in daystoshow) {
if (daystoshow.hasOwnProperty(d)) {
if (Object.prototype.hasOwnProperty.call(daystoshow, d)) {
if (daystoshow[d].treatmentsonly) {
delete daystoshow[d];
delete datastorage[d];
Expand Down Expand Up @@ -749,7 +749,7 @@ var init = function init () {
});
}

function loadProfilesRangeCore (dateFrom, dateTo, dayCount) {
function loadProfilesRangeCore (dateFrom, dateTo) {
$('#info > b').html('<b>' + translate('Loading core profiles') + ' ...</b>');

//The results must be returned in descending order to work with key logic in routines such as getCurrentProfile
Expand Down
4 changes: 2 additions & 2 deletions lib/report_plugins/success.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var times = require('../times');

var success = {
name: 'success'
, label: 'Weekly success'
, label: 'Weekly Distribution'
, pluginType: 'report'
};

Expand All @@ -17,7 +17,7 @@ module.exports = init;
success.html = function html (client) {
var translate = client.translate;
var ret =
'<h2>' + translate('Weekly Success') + '</h2>' +
'<h2>' + translate('Weekly Distribution') + '</h2>' +
'<div id="success-grid"></div>';
return ret;
};
Expand Down
27 changes: 25 additions & 2 deletions translations/bg_BG.json
Original file line number Diff line number Diff line change
Expand Up @@ -660,5 +660,28 @@
"Data reads enabled": "Data reads enabled",
"Data writes enabled": "Data writes enabled",
"Data writes not enabled": "Data writes not enabled",
"Color prediction lines": "Color prediction lines"
}
"Color prediction lines": "Color prediction lines",
"Release Notes": "Release Notes",
"Check for Updates": "Check for Updates",
"Open Source": "Open Source",
"Nightscout Info": "Nightscout Info",
"The primary purpose of Loopalyzer is to visualise how the Loop closed loop system performs. It may work with other setups as well, both closed and open loop, and non loop. However depending on which uploader you use, how frequent it is able to capture your data and upload, and how it is able to backfill missing data some graphs may have gaps or even be completely empty. Always ensure the graphs look reasonable. Best is to view one day at a time and scroll through a number of days first to see.": "The primary purpose of Loopalyzer is to visualise how the Loop closed loop system performs. It may work with other setups as well, both closed and open loop, and non loop. However depending on which uploader you use, how frequent it is able to capture your data and upload, and how it is able to backfill missing data some graphs may have gaps or even be completely empty. Always ensure the graphs look reasonable. Best is to view one day at a time and scroll through a number of days first to see.",
"Loopalyzer includes a time shift feature. If you for example have breakfast at 07:00 one day and at 08:00 the day after your average blood glucose curve these two days will most likely look flattened and not show the actual response after a breakfast. Time shift will compute the average time these meals were eaten and then shift all data (carbs, insulin, basal etc.) during both days the corresponding time difference so that both meals align with the average meal start time.": "Loopalyzer includes a time shift feature. If you for example have breakfast at 07:00 one day and at 08:00 the day after your average blood glucose curve these two days will most likely look flattened and not show the actual response after a breakfast. Time shift will compute the average time these meals were eaten and then shift all data (carbs, insulin, basal etc.) during both days the corresponding time difference so that both meals align with the average meal start time.",
"In this example all data from first day is pushed 30 minutes forward in time and all data from second day 30 minutes backward in time so it appears as if you had had breakfast at 07:30 both days. This allows you to see your actual average blood glucose response from a meal.": "In this example all data from first day is pushed 30 minutes forward in time and all data from second day 30 minutes backward in time so it appears as if you had had breakfast at 07:30 both days. This allows you to see your actual average blood glucose response from a meal.",
"Time shift highlights the period after the average meal start time in gray, for the duration of the DIA (Duration of Insulin Action). As all data points the entire day are shifted the curves outside the gray area may not be accurate.": "Time shift highlights the period after the average meal start time in gray, for the duration of the DIA (Duration of Insulin Action). As all data points the entire day are shifted the curves outside the gray area may not be accurate.",
"Note that time shift is available only when viewing multiple days.": "Note that time shift is available only when viewing multiple days.",
"Please select a maximum of two weeks duration and click Show again.": "Please select a maximum of two weeks duration and click Show again.",
"Show profiles table": "Show profiles table",
"Show predictions": "Show predictions",
"Timeshift on meals larger than": "Timeshift on meals larger than",
"g carbs": "g carbs'",
"consumed between": "consumed between",
"Previous": "Previous",
"Previous day": "Previous day",
"Next day": "Next day",
"Next": "Next",
"Temp basal delta": "Temp basal delta",
"Authorized by token": "Authorized by token",
"Auth role": "Auth role",
"view without token": "view without token"
}
27 changes: 25 additions & 2 deletions translations/cs_CZ.json
Original file line number Diff line number Diff line change
Expand Up @@ -660,5 +660,28 @@
"Data reads enabled": "Čtení dat povoleno",
"Data writes enabled": "Zápis dat povolen",
"Data writes not enabled": "Zápis dat není povolen",
"Color prediction lines": "Color prediction lines"
}
"Color prediction lines": "Color prediction lines",
"Release Notes": "Poznámky k vydání",
"Check for Updates": "Zkontrolovat aktualizace",
"Open Source": "Open Source",
"Nightscout Info": "Informace o Nightscoutu",
"The primary purpose of Loopalyzer is to visualise how the Loop closed loop system performs. It may work with other setups as well, both closed and open loop, and non loop. However depending on which uploader you use, how frequent it is able to capture your data and upload, and how it is able to backfill missing data some graphs may have gaps or even be completely empty. Always ensure the graphs look reasonable. Best is to view one day at a time and scroll through a number of days first to see.": "Hlavním úkolem Loopalyzeru je vizualizace systému uzavřené smyčky. Funguje to při jakémkoliv nastavení - s uzavřenou či otevřenou smyčkou, nebo bez smyčky. Nicméně v návaznosti na tom, jaký uploader používáte, jaká data je schopen načíst a následně odeslat, jak je schopen doplňovat chybějící údaje, mohou některé grafy obsahovat chybějící data, nebo dokonce mohou být prázdné. Vždy si zajistěte, aby grafy vypadaly rozumně. Nejlepší je zobrazit nejprve jeden den, a až pak zobrazit více dní najednou.",
"Loopalyzer includes a time shift feature. If you for example have breakfast at 07:00 one day and at 08:00 the day after your average blood glucose curve these two days will most likely look flattened and not show the actual response after a breakfast. Time shift will compute the average time these meals were eaten and then shift all data (carbs, insulin, basal etc.) during both days the corresponding time difference so that both meals align with the average meal start time.": "Loopalyzer obsahuje funkci časového posunu. Například máte-li snídani jeden den v 7:00, a den poté v 8:00, budou průměrné křivky glykémie za tyto 2 dny pravděpodobně vypadat zploštělé, a odezva smyčky pak bude zkreslená. Časový posun vypočítá průměrnou dobu, po kterou byla tato jídla konzumována, poté posune všechna data (sacharidy, inzulín, bazál atd.) během obou dnů o odpovídající časový rozdíl tak, aby obě jídla odpovídala průměrné době začátku jídla.",
"In this example all data from first day is pushed 30 minutes forward in time and all data from second day 30 minutes backward in time so it appears as if you had had breakfast at 07:30 both days. This allows you to see your actual average blood glucose response from a meal.": "V tomto příkladu jsou všechna data z prvního dne posunuta o 30 minut vpřed, a všechna data z druhého dne o 30 minut zpět, takže to vypadá, jako byste oba dny měli snídani v 7:30. To vám umožní zobrazit průměrnou reakci na glukózu v krvi z jídla.",
"Time shift highlights the period after the average meal start time in gray, for the duration of the DIA (Duration of Insulin Action). As all data points the entire day are shifted the curves outside the gray area may not be accurate.": "Časový posun zvýrazňuje šedou barvou období po průměrné době zahájení jídla po dobu trvání DIA (doba působení inzulínu). Protože jsou všechny datové body za celý den posunuté, nemusí být křivky mimo šedou oblast přesné.",
"Note that time shift is available only when viewing multiple days.": "Berte na vědomí, že časový posun je k dispozici pouze při prohlížení více dní.",
"Please select a maximum of two weeks duration and click Show again.": "Vyberte, prosím, dobu trvání maximálně 2 týdny, a klepněte na tlačítko Zobrazit znovu.",
"Show profiles table": "Zobrazit tabulku profilů",
"Show predictions": "Zobrazit predikce",
"Timeshift on meals larger than": "Časový limit jídla větší než",
"g carbs": "g sacharidů",
"consumed between": "spotřebováno mezi",
"Previous": "Předchozí",
"Previous day": "Předchozí den",
"Next day": "Následující den",
"Next": "Další",
"Temp basal delta": "Rozdíl dočasného bazálu",
"Authorized by token": "Autorizováno pomocí tokenu",
"Auth role": "Autorizační role",
"view without token": "zobrazit bez tokenu"
}
27 changes: 25 additions & 2 deletions translations/da_DK.json
Original file line number Diff line number Diff line change
Expand Up @@ -660,5 +660,28 @@
"Data reads enabled": "Data reads enabled",
"Data writes enabled": "Data writes enabled",
"Data writes not enabled": "Data writes not enabled",
"Color prediction lines": "Color prediction lines"
}
"Color prediction lines": "Color prediction lines",
"Release Notes": "Release Notes",
"Check for Updates": "Check for Updates",
"Open Source": "Open Source",
"Nightscout Info": "Nightscout Info",
"The primary purpose of Loopalyzer is to visualise how the Loop closed loop system performs. It may work with other setups as well, both closed and open loop, and non loop. However depending on which uploader you use, how frequent it is able to capture your data and upload, and how it is able to backfill missing data some graphs may have gaps or even be completely empty. Always ensure the graphs look reasonable. Best is to view one day at a time and scroll through a number of days first to see.": "The primary purpose of Loopalyzer is to visualise how the Loop closed loop system performs. It may work with other setups as well, both closed and open loop, and non loop. However depending on which uploader you use, how frequent it is able to capture your data and upload, and how it is able to backfill missing data some graphs may have gaps or even be completely empty. Always ensure the graphs look reasonable. Best is to view one day at a time and scroll through a number of days first to see.",
"Loopalyzer includes a time shift feature. If you for example have breakfast at 07:00 one day and at 08:00 the day after your average blood glucose curve these two days will most likely look flattened and not show the actual response after a breakfast. Time shift will compute the average time these meals were eaten and then shift all data (carbs, insulin, basal etc.) during both days the corresponding time difference so that both meals align with the average meal start time.": "Loopalyzer includes a time shift feature. If you for example have breakfast at 07:00 one day and at 08:00 the day after your average blood glucose curve these two days will most likely look flattened and not show the actual response after a breakfast. Time shift will compute the average time these meals were eaten and then shift all data (carbs, insulin, basal etc.) during both days the corresponding time difference so that both meals align with the average meal start time.",
"In this example all data from first day is pushed 30 minutes forward in time and all data from second day 30 minutes backward in time so it appears as if you had had breakfast at 07:30 both days. This allows you to see your actual average blood glucose response from a meal.": "In this example all data from first day is pushed 30 minutes forward in time and all data from second day 30 minutes backward in time so it appears as if you had had breakfast at 07:30 both days. This allows you to see your actual average blood glucose response from a meal.",
"Time shift highlights the period after the average meal start time in gray, for the duration of the DIA (Duration of Insulin Action). As all data points the entire day are shifted the curves outside the gray area may not be accurate.": "Time shift highlights the period after the average meal start time in gray, for the duration of the DIA (Duration of Insulin Action). As all data points the entire day are shifted the curves outside the gray area may not be accurate.",
"Note that time shift is available only when viewing multiple days.": "Note that time shift is available only when viewing multiple days.",
"Please select a maximum of two weeks duration and click Show again.": "Please select a maximum of two weeks duration and click Show again.",
"Show profiles table": "Show profiles table",
"Show predictions": "Show predictions",
"Timeshift on meals larger than": "Timeshift on meals larger than",
"g carbs": "g carbs'",
"consumed between": "consumed between",
"Previous": "Previous",
"Previous day": "Previous day",
"Next day": "Next day",
"Next": "Next",
"Temp basal delta": "Temp basal delta",
"Authorized by token": "Authorized by token",
"Auth role": "Auth role",
"view without token": "view without token"
}
Loading

0 comments on commit 76f198a

Please sign in to comment.