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

0.8.2 beta1 #1252

Closed
wants to merge 105 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
fb97987
codacy report.css
MilosKozak Sep 18, 2015
0d77827
Merge pull request #1056 from MilosKozak/dev
MilosKozak Sep 18, 2015
343ced6
codacy percentil.js
MilosKozak Sep 18, 2015
3fadc96
codacy report.js
MilosKozak Sep 18, 2015
d61972e
reuse rawbg.calc
MilosKozak Sep 18, 2015
29792b1
daysfilter() change
MilosKozak Sep 18, 2015
04eb505
Merge pull request #1057 from MilosKozak/dev
MilosKozak Sep 18, 2015
070d19e
comment units, fix incorrect units in delayedCarbs calculation, and a…
scottleibrand Sep 19, 2015
df0d880
parentheses for clarity
scottleibrand Sep 19, 2015
26ebe88
remove commented old incorrect-units code
scottleibrand Sep 19, 2015
135b35d
Bulgarian language - 20 Sept.
xpucuto Sep 20, 2015
40d7946
svedisk language update
sebastianlorant Sep 20, 2015
92edaae
Merge pull request #1069 from sebastianlorant/patch-4
MilosKozak Sep 20, 2015
0412d03
Merge pull request #1068 from xpucuto/patch-8
MilosKozak Sep 20, 2015
ec74763
Merge pull request #1064 from scottleibrand/fix-delayedCarbs
jasoncalabrese Sep 21, 2015
d36d05b
filter in report fix, 1 missing translation
MilosKozak Sep 22, 2015
ca2b697
Merge pull request #1082 from MilosKozak/dev
MilosKozak Sep 22, 2015
887c02e
unify timeFormat to number
MilosKozak Sep 23, 2015
da9cceb
admin tools initial release
MilosKozak Sep 16, 2015
f807262
typo
MilosKozak Sep 16, 2015
f96ffdf
codacy
MilosKozak Sep 17, 2015
719d32c
missing semicolon
MilosKozak Sep 17, 2015
469d09e
ALL -> * in URL
MilosKozak Sep 17, 2015
c4e69a2
Admin Tools to menu
MilosKozak Sep 17, 2015
c3c6eff
load max 500 records
MilosKozak Sep 17, 2015
764a954
2nd admin plugin futuretreatments
MilosKozak Sep 17, 2015
bb7205a
clear html at the end fix
MilosKozak Sep 17, 2015
c05e54d
=== instead of >
MilosKozak Sep 17, 2015
8d7a3b9
rename futuretreatments -> futureentries
MilosKozak Sep 17, 2015
2f40661
future entries
MilosKozak Sep 17, 2015
e3e1fc9
remove entries one by one
MilosKozak Sep 24, 2015
c501e6c
codacy, hide button after use
MilosKozak Sep 24, 2015
4a50e41
missing semicolon
MilosKozak Sep 24, 2015
e29627d
translations for admin tools
MilosKozak Sep 24, 2015
3f00074
tools -> Tools for translations
MilosKozak Sep 24, 2015
aebbb3d
Merge pull request #1087 from MilosKozak/wip/timeformat
jasoncalabrese Sep 24, 2015
58cdd2b
grab some profiles
MilosKozak Sep 23, 2015
3b3857f
d3locales module
MilosKozak Sep 24, 2015
b018bd5
format -> timeFormat
MilosKozak Sep 24, 2015
baa127b
de_DE locale
MilosKozak Sep 24, 2015
2dbe6cb
fi_FI locale
MilosKozak Sep 24, 2015
a1007f4
codacy on report.css
MilosKozak Sep 24, 2015
6461bf2
codacy on lib/api/entries/index.js
MilosKozak Sep 24, 2015
109b2c1
Merge pull request #1094 from nightscout/MilosKozak-patch-2
MilosKozak Sep 24, 2015
564e28e
Merge pull request #1093 from nightscout/MilosKozak-patch-1
MilosKozak Sep 24, 2015
dbff118
cz -> cs in language.js
MilosKozak Sep 24, 2015
9c1bea5
Merge pull request #1095 from nightscout/MilosKozak-patch-1
MilosKozak Sep 24, 2015
1b474a3
Mixed double and single quotes
MilosKozak Sep 25, 2015
ff01245
Merge pull request #1040 from MilosKozak/wip/admin
jasoncalabrese Sep 26, 2015
c7747b3
Should fix iOS converting the direction arrows to Emoji on most iOS v…
sulkaharo Sep 27, 2015
836ed35
expect the iOS ︎ hack after the direction arrow
jasoncalabrese Sep 27, 2015
2182c6e
Merge pull request #1112 from nightscout/wip/emojifix
jasoncalabrese Sep 27, 2015
4ac6d80
Merge pull request #1097 from MilosKozak/wip/d3locale
jasoncalabrese Sep 27, 2015
4a8660b
fix formatting of the Y axis
jasoncalabrese Sep 27, 2015
b417929
Merge pull request #1114 from nightscout/wip/yaxis-fix
jasoncalabrese Sep 27, 2015
a710de4
Clarified BWP wording
sulkaharo Sep 28, 2015
5fa0a50
Added glucometer use warning as a safeguard
sulkaharo Sep 28, 2015
f699321
typo
MilosKozak Sep 28, 2015
7cf5b4a
Merge pull request #1126 from MilosKozak/wip/admintest
MilosKozak Sep 28, 2015
d42ba65
admintools test
MilosKozak Sep 28, 2015
96d574e
codacy
MilosKozak Sep 28, 2015
4a77015
;
MilosKozak Sep 28, 2015
dad71be
Romanian ro_RO d3locales
bogdangorescu Sep 29, 2015
b599529
Merge pull request #1131 from bogdangorescu/patch-3
MilosKozak Sep 29, 2015
fb37b3b
Ensure the profile returns numbers
sulkaharo Sep 29, 2015
01423be
1 day shift fix, added missing translations
MilosKozak Sep 29, 2015
f5fbae9
report fix
MilosKozak Sep 29, 2015
7923c8a
disable log again
MilosKozak Sep 29, 2015
d7213c9
Fixes tests
sulkaharo Sep 29, 2015
91e72a8
Merge pull request #1133 from MilosKozak/wip/reportfix
jasoncalabrese Sep 30, 2015
a3be6e8
Fixing a typo
sulkaharo Sep 30, 2015
8897a55
Merge pull request #1122 from sulkaharo/wip/bwpclarification
jasoncalabrese Sep 30, 2015
45fed34
try fix travis
MilosKozak Sep 30, 2015
0f3391b
codacy
MilosKozak Sep 30, 2015
423769e
Bulgarian -1st Oct.
xpucuto Oct 1, 2015
b534f32
Bulgarian language -1st Oct.
xpucuto Oct 1, 2015
a3de62d
Merge pull request #1145 from xpucuto/patch-9
MilosKozak Oct 1, 2015
8f0e21c
Merge pull request #1146 from xpucuto/patch-10
MilosKozak Oct 1, 2015
93341d0
Bulgarian small corrections 1st Oct.
xpucuto Oct 1, 2015
4d9d758
Merge pull request #1150 from xpucuto/patch-11
MilosKozak Oct 1, 2015
3e5e8ab
Norwegian
skjelland Oct 1, 2015
deb3d7f
Norwegian
skjelland Oct 1, 2015
c7923b6
Norwegian
skjelland Oct 1, 2015
ddd2577
Merge pull request #1151 from skjelland/dev
MilosKozak Oct 1, 2015
e6858bc
Merge pull request #1127 from MilosKozak/wip/admintest
MilosKozak Oct 8, 2015
ad1e18c
RO update Oct, 11 2015
bianca2015 Oct 11, 2015
483cff8
Merge pull request #1191 from bianca2015/patch-1
MilosKozak Oct 11, 2015
f13f39b
uppercase
skjelland Oct 12, 2015
e7676db
Merge pull request #1192 from skjelland/dev
jasoncalabrese Oct 12, 2015
c0697d0
duration in careportal
MilosKozak Oct 4, 2015
1318f1a
fix eventType translation
MilosKozak Oct 5, 2015
d9194e0
duration visualisation in reports
MilosKozak Oct 6, 2015
f60b9f5
fix test
MilosKozak Oct 6, 2015
48e7ca6
<none> option to eventType
MilosKozak Oct 7, 2015
8676b36
no stroke on duration rect
MilosKozak Oct 7, 2015
760525c
move brush extent under context in DOM
MilosKozak Oct 7, 2015
13ebc66
Basal & Temp Basal handling and visualisation
MilosKozak Oct 17, 2015
16ba0dc
convert absolute to number too
MilosKozak Oct 17, 2015
97dc2a1
handle fake basal eventType in editing
MilosKozak Oct 17, 2015
e30d7fb
test fix pass 1
MilosKozak Oct 17, 2015
1ee0e4b
test fix pass 2
MilosKozak Oct 17, 2015
5347019
codacy
MilosKozak Oct 17, 2015
0b83447
@jasoncalabrese careportal matrix change
MilosKozak Oct 17, 2015
6ff37fd
Merge pull request #1178 from MilosKozak/wip/duration
jasoncalabrese Oct 17, 2015
04770f0
version bump for 0.8.2-beta1
jasoncalabrese Oct 17, 2015
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
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nightscout",
"version": "0.8.1",
"version": "0.8.2-beta1",
"dependencies": {
"jquery": "2.1.0",
"jQuery-Storage-API": "~1.7.2",
Expand Down
1 change: 1 addition & 0 deletions bundle/bundle.source.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
, units: require('../lib/units')()
, plugins: require('../lib/plugins/')().registerClientDefaults()
, report_plugins: require('../lib/report_plugins/')()
, admin_plugins: require('../lib/admin_plugins/')()
};

console.info('Nightscout bundle ready');
Expand Down
70 changes: 70 additions & 0 deletions lib/admin_plugins/cleanstatusdb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
'use strict';

var cleanstatusdb = {
name: 'cleanstatusdb'
, label: 'Clean Mongo status database'
, pluginType: 'admin'
};

function init() {
return cleanstatusdb;
}

module.exports = init;

cleanstatusdb.actions = [
{
name: 'Delete all documents from devicestatus collection'
, description: 'This task removes all documents from devicestatus collection. Useful when uploader battery status is not properly updated.'
, buttonLabel: 'Delete all documents'
, confirmText: 'Delete all documents from devicestatus collection?'
}
];

cleanstatusdb.actions[0].init = function init(client, callback) {
var translate = client.translate;
var $status = $('#admin_' + cleanstatusdb.name + '_0_status');

$status.hide().text(translate('Loading database ...')).fadeIn('slow');
$.ajax('/api/v1/devicestatus.json?count=500', {
success: function (records) {
var recs = (records.length === 500 ? '500+' : records.length);
$status.hide().text(translate('Database contains %1 records',{ params: [recs] })).fadeIn('slow');
},
error: function () {
$status.hide().text(translate('Error loading database')).fadeIn('slow');
}
}).done(function () { if (callback) { callback(); } });
};

cleanstatusdb.actions[0].code = function deleteRecords(client, callback) {
var translate = client.translate;
var $status = $('#admin_' + cleanstatusdb.name + '_0_status');

if (!client.hashauth.isAuthenticated()) {
alert(translate('Your device is not authenticated yet'));
if (callback) {
callback();
}
return;
};

$status.hide().text(translate('Deleting records ...')).fadeIn('slow');
$.ajax({
method: 'DELETE'
, url: '/api/v1/devicestatus/*'
, headers: {
'api-secret': client.hashauth.hash()
}
}).done(function success () {
$status.hide().text(translate('All records removed ...')).fadeIn('slow');
if (callback) {
callback();
}
}).fail(function fail() {
$status.hide().text(translate('Error')).fadeIn('slow');
if (callback) {
callback();
}
});
};
172 changes: 172 additions & 0 deletions lib/admin_plugins/futureitems.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
'use strict';

var futureitems = {
name: 'futureitems'
, label: 'Remove future items from mongo database'
, pluginType: 'admin'
};

function init() {
return futureitems;
}

module.exports = init;

futureitems.actions = [
{
name: 'Find and remove treatments in the future'
, description: 'This task find and remove treatments in the future.'
, buttonLabel: 'Remove treatments in the future'
}
, {
name: 'Find and remove entries in the future'
, description: 'This task find and remove CGM data in the future created by uploader with wrong date/time.'
, buttonLabel: 'Remove entries in the future'
}
];

futureitems.actions[0].init = function init(client, callback) {
var translate = client.translate;
var $status = $('#admin_' + futureitems.name + '_0_status');

function valueOrEmpty (value) {
return value ? value : '';
}

function showOneTreatment (tr, table) {
table.append($('<tr>').css('background-color','#0f0f0f')
.append($('<td>').attr('width','20%').append(new Date(tr.created_at).toLocaleString().replace(/([\d]+:[\d]{2})(:[\d]{2})(.*)/, '$1$3')))
.append($('<td>').attr('width','20%').append(tr.eventType ? translate(client.careportal.resolveEventName(tr.eventType)) : ''))
.append($('<td>').attr('width','10%').attr('align','center').append(tr.glucose ? tr.glucose + ' ('+translate(tr.glucoseType)+')' : ''))
.append($('<td>').attr('width','10%').attr('align','center').append(valueOrEmpty(tr.insulin)))
.append($('<td>').attr('width','10%').attr('align','center').append(valueOrEmpty(tr.carbs)))
.append($('<td>').attr('width','10%').append(valueOrEmpty(tr.enteredBy)))
.append($('<td>').attr('width','20%').append(valueOrEmpty(tr.notes)))
);
}

function showTreatments(treatments, table) {
table.append($('<tr>').css('background','#040404')
.append($('<th>').css('width','80px').attr('align','left').append(translate('Time')))
.append($('<th>').css('width','150px').attr('align','left').append(translate('Event Type')))
.append($('<th>').css('width','150px').attr('align','left').append(translate('Blood Glucose')))
.append($('<th>').css('width','50px').attr('align','left').append(translate('Insulin')))
.append($('<th>').css('width','50px').attr('align','left').append(translate('Carbs')))
.append($('<th>').css('width','150px').attr('align','left').append(translate('Entered By')))
.append($('<th>').css('width','300px').attr('align','left').append(translate('Notes')))
);
for (var t=0; t<treatments.length; t++) {
showOneTreatment (treatments[t], table);
}
};

$status.hide().text(translate('Loading database ...')).fadeIn('slow');
var nowiso = new Date().toISOString();
$.ajax('/api/v1/treatments.json?&find[created_at][$gte]=' + nowiso, {
success: function (records) {
futureitems.treatmentrecords = records;
$status.hide().text(translate('Database contains %1 future records',{ params: [records.length] })).fadeIn('slow');
var table = $('<table>').css('margin-top','10px');
$('#admin_' + futureitems.name + '_0_html').append(table);
showTreatments(records, table);
futureitems.actions[0].confirmText = translate('Remove %1 selected records?', { params: [records.length] });
},
error: function () {
$status.hide().text(translate('Error loading database')).fadeIn('slow');
futureitems.treatmentrecords = [];
}
}).done(function () { if (callback) { callback(); } });
};

futureitems.actions[0].code = function deleteRecords(client, callback) {
var translate = client.translate;
var $status = $('#admin_' + futureitems.name + '_0_status');

if (!client.hashauth.isAuthenticated()) {
alert(translate('Your device is not authenticated yet'));
if (callback) {
callback();
}
return;
};

function deleteRecordById (_id) {
$.ajax({
method: 'DELETE'
, url: '/api/v1/treatments/' + _id
, headers: {
'api-secret': client.hashauth.hash()
}
}).done(function success () {
$status.text(translate('Record %1 removed ...', { params: [_id] }));
}).fail(function fail() {
$status.text(translate('Error removing record %1', { params: [_id] }));
});
}

$status.hide().text(translate('Deleting records ...')).fadeIn('slow');
for (var i = 0; i < futureitems.treatmentrecords.length; i++) {
deleteRecordById(futureitems.treatmentrecords[i]._id);
}
$('#admin_' + futureitems.name + '_0_html').html('');

if (callback) {
callback();
}
};

futureitems.actions[1].init = function init(client, callback) {
var translate = client.translate;
var $status = $('#admin_' + futureitems.name + '_1_status');

$status.hide().text(translate('Loading database ...')).fadeIn('slow');
var now = new Date().getTime();
$.ajax('/api/v1/entries.json?&find[date][$gte]=' + now, {
success: function (records) {
futureitems.entriesrecords = records;
$status.hide().text(translate('Database contains %1 future records',{ params: [records.length] })).fadeIn('slow');
futureitems.actions[1].confirmText = translate('Remove %1 selected records?', { params: [records.length] });
},
error: function () {
$status.hide().text(translate('Error loading database')).fadeIn('slow');
futureitems.entriesrecords = [];
}
}).done(function () { if (callback) { callback(); } });
};

futureitems.actions[1].code = function deleteRecords(client, callback) {
var translate = client.translate;
var $status = $('#admin_' + futureitems.name + '_1_status');

if (!client.hashauth.isAuthenticated()) {
alert(translate('Your device is not authenticated yet'));
if (callback) {
callback();
}
return;
};

function deteleteRecordById (_id) {
$.ajax({
method: 'DELETE'
, url: '/api/v1/entries/' + _id
, headers: {
'api-secret': client.hashauth.hash()
}
}).done(function success () {
$status.text(translate('Record %1 removed ...', { params: [_id] }));
}).fail(function fail() {
$status.text(translate('Error removing record %1', { params: [_id] }));
});
}


$status.hide().text(translate('Deleting records ...')).fadeIn('slow');
for (var i = 0; i < futureitems.entriesrecords.length; i++) {
deteleteRecordById(futureitems.entriesrecords[i]._id);
}

if (callback) {
callback();
}
};
79 changes: 79 additions & 0 deletions lib/admin_plugins/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
'use strict';

var _ = require('lodash');

function init() {
var allPlugins = [
require('./cleanstatusdb')()
, require('./futureitems')()
];

function plugins(name) {
if (name) {
return _.find(allPlugins, {name: name});
} else {
return plugins;
}
}

plugins.eachPlugin = function eachPlugin(f) {
_.each(allPlugins, f);
};

plugins.createHTML = function createHTML(client) {
var translate = client.translate;
plugins.eachPlugin(function addHtml(p) {
var fs = $('<fieldset>');
$('#admin_placeholder').append(fs);
fs.append($('<legend>').append(translate(p.label)));
for (var i = 0; i < p.actions.length; i++) {
if (i !== 0) {
fs.append('<hr>');
}
var a = p.actions[i];
// add main plugin html
fs.append($('<b>').css('text-decoration','underline').append(translate(a.name)));
fs.append('<br>');
fs.append($('<i>').append(translate(a.description)));
fs.append($('<div>').attr('id','admin_' + p.name + '_' + i + '_html'));
fs.append($('<button>').addClass('adminButton').attr('plugin',p.name).attr('action',i).append(translate(a.buttonLabel)));
fs.append($('<span>').attr('id','admin_' + p.name + '_' + i + '_status'));
if (a.init) {
a.init(client);
}
}
// add css
if (p.css) {
$('<style>')
.prop('type', 'text/css')
.html(p.css)
.appendTo('head');
}
});
$('.adminButton').click(plugins.doAction);
};

plugins.doAction = function doAction(event) {
var Nightscout = window.Nightscout;
var plugin = $(this).attr('plugin');
var action = $(this).attr('action');
var a = plugins(plugin).actions[action];
var ok = true;
if (a.confirmText) {
ok = window.confirm(Nightscout.client.translate(a.confirmText));
}
if (ok) {
console.log('Running action', action, 'on plugin', plugin);
a.code(Nightscout.client);
$(this).css('display','none');
}
if (event) {
event.preventDefault();
}
};

return plugins();

}

module.exports = init;
10 changes: 10 additions & 0 deletions lib/api/devicestatus/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ function configure (app, wares, ctx) {
}
});
});
// delete record
api.delete('/devicestatus/:_id', wares.verifyAuthorization, function(req, res) {
ctx.devicestatus.remove(req.params._id, function (err, removed) {
if (err) {
res.sendJSONStatus(res, consts.HTTP_INTERNAL_ERROR, 'Mongo Error', err);
} else {
res.json(removed);
}
});
});

}

Expand Down
2 changes: 1 addition & 1 deletion lib/api/entries/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ function configure (app, wares, ctx) {
if (entry) {
req.query.find.type = entry.type;
} else {
res.entries_err = "No such id: '" + req.params.spec + "'";
res.entries_err = 'No such id: \'' + req.params.spec + '\'';
}
next();
});
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 @@ -123,7 +123,7 @@ function init (client, plugins, serverSettings, $) {
showRawbg: $('input:radio[name=show-rawbg]:checked').val(),
customTitle: $('input#customTitle').prop('value'),
theme: $('input:radio[name=theme-browser]:checked').val(),
timeFormat: $('input:radio[name=timeformat-browser]:checked').val(),
timeFormat: parseInt($('input:radio[name=timeformat-browser]:checked').val()),
language: $('#language').val(),
showPlugins: checkedPluginNames()
});
Expand Down
Loading