From 257cb4a58f03ffd7bc1d2cbb326eb5f65ffaddae Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Thu, 27 Aug 2015 00:11:22 +0200 Subject: [PATCH 001/176] extracted needed files --- README.md | 1 + env.js | 3 +++ lib/api/index.js | 2 ++ lib/api/treatments/index.js | 27 +++++++++++++++++++++++++-- lib/treatments.js | 34 +++++++++++++++++++++++++++------- 5 files changed, 58 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index fe85ee1a0b5..86766140681 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,7 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm * `BG_LOW` (`55`) - must be set using mg/dl units; the low BG outside the target range that is considered urgent * `ALARM_TYPES` (`simple` if any `BG_`* ENV's are set, otherwise `predict`) - currently 2 alarm types are supported, and can be used independently or combined. The `simple` alarm type only compares the current BG to `BG_` thresholds above, the `predict` alarm type uses highly tuned formula that forecasts where the BG is going based on it's trend. `predict` **DOES NOT** currently use any of the `BG_`* ENV's * `BASE_URL` - Used for building links to your sites api, ie pushover callbacks, usually the URL of your Nightscout site you may want https instead of http + * `TREATMENTS_AUTH` (`off`) - possible values `on` or `off`. When on device must be authenticated by entering `API_SECRET` to create treatments ### Core diff --git a/env.js b/env.js index c12c4c32a4a..cd6f103dd8f 100644 --- a/env.js +++ b/env.js @@ -26,6 +26,9 @@ function config ( ) { setMongo(); updateSettings(); + // require authorization for entering treatments + env.treatments_auth = readENV('TREATMENTS_AUTH',false); + return env; } diff --git a/lib/api/index.js b/lib/api/index.js index 268122db8ca..a409801161a 100644 --- a/lib/api/index.js +++ b/lib/api/index.js @@ -34,6 +34,8 @@ function create (env, ctx) { app.set('title', [app.get('name'), 'API', app.get('version')].join(' ')); + app.set('treatments_auth', env.treatments_auth); + // Start setting up routes if (app.enabled('api')) { // experiments diff --git a/lib/api/treatments/index.js b/lib/api/treatments/index.js index 71687d4aec1..cec3a375fab 100644 --- a/lib/api/treatments/index.js +++ b/lib/api/treatments/index.js @@ -24,17 +24,40 @@ function configure (app, wares, ctx) { function config_authed (app, api, wares, ctx) { - api.post('/treatments/', /*TODO: auth disabled for now, need to get login figured out... wares.verifyAuthorization, */ function(req, res) { + function post_response(req, res) { var treatment = req.body; ctx.treatments.create(treatment, function (err, created) { + if (err) + res.sendJSONStatus(res, consts.HTTP_INTERNAL_ERROR, 'Mongo Error', err); + else + res.json(created); + }); + } + if (app.treatments_auth) + api.post('/treatments/', wares.verifyAuthorization, post_response); + else + api.post('/treatments/', post_response); + + api.delete('/treatments/:_id', wares.verifyAuthorization, function(req, res) { + ctx.treatments.remove(req.params._id, function ( ) { + res.json({ }); + }); + }); + + // update record + api.put('/treatments/', wares.verifyAuthorization, function(req, res) { + var data = req.body; + ctx.treatments.save(data, function (err, created) { if (err) { res.sendJSONStatus(res, consts.HTTP_INTERNAL_ERROR, 'Mongo Error', err); + console.log('Error saving treatment'); + console.log(err); } else { res.json(created); + console.log('Treatment saved'); } }); }); - } if (app.enabled('api') && app.enabled('careportal')) { diff --git a/lib/treatments.js b/lib/treatments.js index 3adf50fbb87..94d7c3cba92 100644 --- a/lib/treatments.js +++ b/lib/treatments.js @@ -3,6 +3,19 @@ var find_options = require('./query'); function storage (env, ctx) { + var ObjectID = require('mongodb').ObjectID; + + // allow regexp search + // /api/v1/treatments.json?find[notes]=/sometext/i + function find_query (opts) { + var reg; + ['notes','eventType'].forEach(function(d) { + if (opts && opts.find && opts.find[d] && (reg=/\/(.*)\/(.*)/.exec(opts.find[d]))) { + opts.find[d] = new RegExp(reg[1],reg[2]); + } + }); + return opts; + } function create (obj, fn) { @@ -41,13 +54,25 @@ function storage (env, ctx) { .toArray(fn); } + function remove (_id, fn) { + return api( ).remove({ "_id": new ObjectID(_id) }, fn); + } + + function save (obj, fn) { + obj._id = new ObjectID(obj._id); + api().save(obj, fn); + } + + function api ( ) { return ctx.store.db.collection(env.treatments_collection); } api.list = list; api.create = create; - api.indexedFields = ['created_at', 'eventType', 'insulin', 'carbs', 'glucose']; + api.indexedFields = ['created_at', 'eventType', 'insulin', 'carbs', 'glucose', 'boluscalc.foods._id', 'notes']; + api.remove = remove; + api.save = save; return api; } @@ -59,11 +84,6 @@ function prepareData(obj) { , preBolusCarbs: '' }; - obj.glucose = Number(obj.glucose); - obj.carbs = Number(obj.carbs); - obj.insulin = Number(obj.insulin); - obj.preBolus = Number(obj.preBolus); - var eventTime; if (obj.eventTime) { eventTime = new Date(obj.eventTime); @@ -94,7 +114,7 @@ function prepareData(obj) { deleteIfEmpty('notes'); deleteIfEmpty('preBolus'); - if (obj.glucose === 0 || isNaN(obj.glucose)) { + if (!obj.glucose || obj.glucose === 0) { delete obj.glucose; delete obj.glucoseType; delete obj.units; From 5951797c4a0c086c195dbaf6ded524b31a703905 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Thu, 27 Aug 2015 15:06:52 +0200 Subject: [PATCH 002/176] added report files --- static/report/index.html | 245 ++++++++++ static/report/js/calibrations.js | 279 +++++++++++ static/report/js/dailystats.js | 116 +++++ static/report/js/daytoday.js | 367 ++++++++++++++ static/report/js/flotcandle.js | 85 ++++ static/report/js/glucosedistribution.js | 99 ++++ static/report/js/hourlystats.js | 106 +++++ static/report/js/percentile.js | 152 ++++++ static/report/js/report.js | 608 ++++++++++++++++++++++++ static/report/js/success.js | 178 +++++++ static/report/js/time.js | 318 +++++++++++++ static/report/js/treatments.js | 154 ++++++ 12 files changed, 2707 insertions(+) create mode 100644 static/report/index.html create mode 100644 static/report/js/calibrations.js create mode 100644 static/report/js/dailystats.js create mode 100644 static/report/js/daytoday.js create mode 100644 static/report/js/flotcandle.js create mode 100644 static/report/js/glucosedistribution.js create mode 100644 static/report/js/hourlystats.js create mode 100644 static/report/js/percentile.js create mode 100644 static/report/js/report.js create mode 100644 static/report/js/success.js create mode 100644 static/report/js/time.js create mode 100644 static/report/js/treatments.js diff --git a/static/report/index.html b/static/report/index.html new file mode 100644 index 00000000000..d04be3aac72 --- /dev/null +++ b/static/report/index.html @@ -0,0 +1,245 @@ + + + + Nightscout reporting + + + + +

Nightscout

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ From: + To: + Today + Last 2 days + Last 3 days + Last week + Last 2 weeks + Last month + Last 3 months +
+ Category: + Subcategory: + Name: +
+ + + Food: +
+ Notes contain: +
+ Event type contains: +
+ Mo + Tu + We + Th + Fr + Sa + Su +
+ Target bg range bottom: + + top: + +
+ +
+
+
+ Display: + Insulin + Carbs + Notes + Food + Raw + IOB + COB +  Size: + +
+ Scale: + + Linear + + Logarithmic +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/report/js/calibrations.js b/static/report/js/calibrations.js new file mode 100644 index 00000000000..c66275e4968 --- /dev/null +++ b/static/report/js/calibrations.js @@ -0,0 +1,279 @@ +function report_calibrations(datastorage,daystoshow,options) { + var padding = { top: 15, right: 15, bottom: 30, left: 70 }; + var treatments = []; + Object.keys(daystoshow).forEach(function (day) { + treatments = treatments.concat(datastorage[day].treatments.filter(function (t) { + if (t.eventType == "Sensor Start") return true; + if (t.eventType == "Sensor Change") return true; + return false; + })); + }); + + var cals = []; + Object.keys(daystoshow).forEach(function (day) { + cals = cals.concat(datastorage[day].cal); + }); + + var sgvs = []; + Object.keys(daystoshow).forEach(function (day) { + sgvs = sgvs.concat(datastorage[day].sgv); + }); + + var mbgs = []; + Object.keys(daystoshow).forEach(function (day) { + mbgs = mbgs.concat(datastorage[day].mbg); + }); + mbgs.forEach(function (mbg) { calibrations_calcmbg(mbg); }); + + + var events = treatments.concat(cals).concat(mbgs).sort(function(a, b) { return a.x - b.x; }); + + var colors = ['Aqua','Blue','Brown','Chartreuse','Coral','CornflowerBlue','DarkCyan','DarkMagenta','DarkOrange','Fuchsia','Green','Yellow']; + var colorindex = 0; + var html = ''; + var lastmbg = null; + for (var i=0; i'; + }; + + html += '
'; + e.bgcolor = colors[colorindex]; + if (e.eventType) + html += ''+translate(e.eventType)+':
'; + else if (typeof e.device !== 'undefined') { + html += ' '; + html += 'MBG: ' + e.y + ' Raw: '+e.raw+'
'; + lastmbg = e; + e.cals = []; + e.checked = false; + } else if (typeof e.scale !== 'undefined') { + html += 'CAL: ' + ' Scale: ' + e.scale.toFixed(2) + ' Intercept: ' + e.intercept.toFixed(0) + ' Slope: ' + e.slope.toFixed(2) + '
'; + if (lastmbg) lastmbg.cals.push(e); + } else html += JSON.stringify(e); + html += '
'; + + $('#calibrations-list').html(html); + + // select last 3 mbgs + var maxcals = 3; + for (var i=events.length-1; i>0; i--) { + if (typeof events[i].device !== 'undefined') { + events[i].checked = true; + $('#calibrations-'+i).prop('checked',true); + if (--maxcals<1) break; + } + } + calibrations_drawelements(); + + $('.calibrations-checkbox').change(calibrations_checkboxevent); + + function calibrations_checkboxevent(event) { + var index = $(this).attr('index'); + events[index].checked = $(this).is(':checked'); + calibrations_drawelements(); + event.preventDefault(); + } + + function calibrations_drawelements() { + calibrations_drawChart(); + for (var i=0; i5*60*1000) { + console.log('Last SGV too old for MBG. Time diff: '+((mbg.x-lastsgv.x)/1000/60).toFixed(1)+' min',mbg); + } else { + mbg.raw = lastsgv.filtered || lastsgv.unfiltered; + } + } else { + console.log('Last entry not found for MBG ',mbg); + } + } + + function calibrations_drawmbg(mbg,color) { + if (mbg.raw) { + calibration_context.append('circle') + .attr('cx', xScale2(mbg.y) + padding.left) + .attr('cy', yScale2(mbg.raw) + padding.top) + .attr('fill', color) + .style('opacity', 1) + .attr('stroke-width', 1) + .attr('stroke', 'black') + .attr('r', 5); + } + } + + function calibrations_findlatest(date,storage) { + var last = null; + var time = date.getTime(); + for (var i=0; i time) + return last; + last = storage[i]; + } + return last; + } + +} diff --git a/static/report/js/dailystats.js b/static/report/js/dailystats.js new file mode 100644 index 00000000000..18df7786ea0 --- /dev/null +++ b/static/report/js/dailystats.js @@ -0,0 +1,116 @@ + function report_dailystats(datastorage,daystoshow,options) { + var todo = []; +// var data = o[0]; +// var days = 7; +// var config = { low: convertBg(low), high: convertBg(high) }; // options.targetLow options.targetHigh +// var sevendaysago = Date.now() - days.days(); + var report = $("#dailystats-report"); + var minForDay, maxForDay; + var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"]; + +// data = data.filter(function(record) { +// return "bgValue" in record && /\d+/.test(record.bgValue.toString()); +// }).filter(function(record) { +// return record.displayTime > sevendaysago; +// }); + report.empty(); + var table = $(''); + report.append(table); + var thead = $(""); + $("").appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + thead.appendTo(table); + + Object.keys(daystoshow).forEach(function (day) { + var tr = $(""); + var dayInQuestion = new Date(day); + + var daysRecords = datastorage[day].statsrecords; + + if (daysRecords.length == 0) { + $("").appendTo(tr); + $('').appendTo(tr); + table.append(tr); + return;; + } + + minForDay = daysRecords[0].sgv; + maxForDay = daysRecords[0].sgv; + var stats = daysRecords.reduce(function(out, record) { + record.sgv = parseFloat(record.sgv); + if (record.sgv < options.targetLow) { + out.lows++; + } else if (record.sgv < options.targetHigh) { + out.normal++; + } else { + out.highs++; + } + if (minForDay > record.sgv) minForDay = record.sgv; + if (maxForDay < record.sgv) maxForDay = record.sgv; + return out; + }, { + lows: 0, + normal: 0, + highs: 0 + }); + var bgValues = daysRecords.map(function(r) { return r.sgv; }); + $("").appendTo(tr); + + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + + table.append(tr); + var inrange = [ + { + label: translate('Low'), + data: Math.floor(stats.lows * 1000 / daysRecords.length) / 10 + }, + { + label: translate('In range'), + data: Math.floor(stats.normal * 1000 / daysRecords.length) / 10 + }, + { + label: translate('High'), + data: Math.floor(stats.highs * 1000 / daysRecords.length) / 10 + } + ]; + $.plot( + "#dailystat-chart-" + day.toString(), + inrange, + { + series: { + pie: { + show: true + } + }, + colors: ["#f88", "#8f8", "#ff8"] + } + ); + }); + + setTimeout(function() { + todo.forEach(function(fn) { + fn(); + }); + }, 50); + } \ No newline at end of file diff --git a/static/report/js/daytoday.js b/static/report/js/daytoday.js new file mode 100644 index 00000000000..371628d15dc --- /dev/null +++ b/static/report/js/daytoday.js @@ -0,0 +1,367 @@ + function report_daytoday(datastorage,daystoshow,options) { + var translate = Nightscout.language.translate; + + var padding = { top: 15, right: 15, bottom: 30, left: 35 }; + var + FORMAT_TIME_12 = '%I' + , FORMAT_TIME_24 = '%H'; + + for (day in daystoshow) { + drawChart(day,datastorage[day],options); + } + + function getTimeFormat() { + var timeFormat = FORMAT_TIME_12; + if (serverSettings.defaults.timeFormat == '24') { + timeFormat = FORMAT_TIME_24; + } + return timeFormat; + } + + function drawChart(day,data,options) { + var tickValues + , charts + , context + , xScale2, yScale2 + , yInsulinScale, yCarbsScale + , xAxis2, yAxis2 + , dateFn = function (d) { return new Date(d.date) } + , foodtexts = 0; + + // Tick Values + if (options.scale == SCALE_LOG) { + if (serverSettings.units == 'mmol') { + tickValues = [ + 2.0 + , 3.0 + , options.targetLow + , 6.0 + , 8.0 + , options.targetHigh + , 16.0 + , 22.0 + ]; + } else { + tickValues = [ + 40 + , 60 + , options.targetLow + , 120 + , 160 + , options.targetHigh + , 250 + , 400 + ]; + } + } else { + if (serverSettings.units == 'mmol') { + tickValues = [ + 2.0 + , 4.0 + , 6.0 + , 8.0 + , 10.0 + , 12.0 + , 14.0 + , 16.0 + , 18.0 + , 20.0 + , 22.0 + ]; + } else { + tickValues = [ + 40 + , 80 + , 120 + , 160 + , 200 + , 240 + , 280 + , 320 + , 360 + , 400 + ]; + } + } + + // create svg and g to contain the chart contents + charts = d3.select('#'+containerprefix+day).html( + ''+ + localeDate(day)+ + '
' + ).append('svg'); + + charts.append("rect") + .attr("width", "100%") + .attr("height", "100%") + .attr("fill", "WhiteSmoke"); + + context = charts.append('g'); + + // define the parts of the axis that aren't dependent on width or height + xScale2 = d3.time.scale() + .domain(d3.extent(data.sgv, function (d) { return d.date; })); + + if (options.scale == SCALE_LOG) { + yScale2 = d3.scale.log() + .domain([scaleBg(36), scaleBg(420)]); + } else { + yScale2 = d3.scale.linear() + .domain([scaleBg(36), scaleBg(420)]); + } + + yInsulinScale = d3.scale.linear() + .domain([0, options.maxInsulinValue*2]); + + yCarbsScale = d3.scale.linear() + .domain([0, options.maxCarbsValue*1.25]); + + xAxis2 = d3.svg.axis() + .scale(xScale2) + .tickFormat(d3.time.format(getTimeFormat(true))) + .ticks(24) + .orient('bottom'); + + yAxis2 = d3.svg.axis() + .scale(yScale2) + .tickFormat(d3.format('d')) + .tickValues(tickValues) + .orient('left'); + + // get current data range + var dataRange = d3.extent(data.sgv, dateFn); + + // get the entire container height and width subtracting the padding + var chartWidth = options.width - padding.left - padding.right; + var chartHeight = options.height - padding.top - padding.bottom; + + //set the width and height of the SVG element + charts.attr('width', options.width) + .attr('height', options.height); + + // ranges are based on the width and height available so reset + xScale2.range([0, chartWidth]); + yScale2.range([chartHeight,0]); + yInsulinScale.range([chartHeight,0]); + yCarbsScale.range([chartHeight,0]); + + // add target BG rect + context.append('rect') + .attr('x', xScale2(dataRange[0])+padding.left) + .attr('y', yScale2(options.targetHigh)+padding.top) + .attr('width', xScale2(dataRange[1]- xScale2(dataRange[0]))) + .attr('height', yScale2(options.targetLow)-yScale2(options.targetHigh)) + .style('fill', '#D6FFD6') + .attr('stroke', 'grey'); + + // create the x axis container + context.append('g') + .attr('class', 'x axis'); + + // create the y axis container + context.append('g') + .attr('class', 'y axis'); + + context.select('.y') + .attr('transform', 'translate(' + (/*chartWidth + */ padding.left) + ',' + padding.top + ')') + .style('stroke', 'black') + .style('shape-rendering', 'crispEdges') + .style('fill', 'none') + .call(yAxis2); + + // if first run then just display axis with no transition + context.select('.x') + .attr('transform', 'translate(' + padding.left + ',' + (chartHeight + padding.top) + ')') + .style('stroke', 'black') + .style('shape-rendering', 'crispEdges') + .style('fill', 'none') + .call(xAxis2); + + for (var li in tickValues) { + context.append('line') + .attr('class', 'high-line') + .attr('x1', xScale2(dataRange[0])+padding.left) + .attr('y1', yScale2(tickValues[li])+padding.top) + .attr('x2', xScale2(dataRange[1])+padding.left) + .attr('y2', yScale2(tickValues[li])+padding.top) + .style('stroke-dasharray', ('3, 3')) + .attr('stroke', 'grey'); + } + + // bind up the context chart data to an array of circles + var contextCircles = context.selectAll('circle') + .data(data.sgv); + + function prepareContextCircles(sel) { + var badData = []; + sel.attr('cx', function (d) { + return xScale2(d.date) + padding.left; + }) + .attr('cy', function (d) { + if (isNaN(d.sgv)) { + badData.push(d); + return yScale2(scaleBg(450) + padding.top); + } else { + return yScale2(d.sgv) + padding.top; + } + }) + .attr('fill', function (d) { + if (d.color == 'gray' && !options.raw) { + return 'transparent'; + } + return d.color; + }) + .style('opacity', function (d) { 0.5 }) + .attr('stroke-width', function (d) {if (d.type == 'mbg') return 2; else return 0; }) + .attr('stroke', function (d) { return 'black'; }) + .attr('r', function(d) { if (d.type == 'mbg') { return 4; } else { return 2; }}); + + if (badData.length > 0) { + console.warn("Bad Data: isNaN(sgv)", badData); + } + return sel; + } + + // if new circle then just display + prepareContextCircles(contextCircles.enter().append('circle')); + + contextCircles.exit() + .remove(); + + var to = moment(day).add(1, 'days') //.add(new Date().getTimezoneOffset(), 'minutes'); + var from = moment(day); //.add(new Date().getTimezoneOffset(), 'minutes'); + var iobpolyline = '', cobpolyline = ''; + for (var dt=from; dt < to; dt.add(5, 'minutes')) { + if (options.iob) { + var iob = Nightscout.plugins('iob').calcTotal(data.treatments,Nightscout.profile,dt.toDate()).iob; + if (dt!=from) { + iobpolyline += ', '; + } + iobpolyline += (xScale2(dt) + padding.left) + ',' + (yInsulinScale(iob) + padding.top) + ' '; + } + if (options.cob) { + var cob = Nightscout.plugins('cob').cobTotal(data.treatments,Nightscout.profile,dt.toDate()).cob; +console.log(dt.toDate().toLocaleTimeString(),cob); + if (dt!=from) { + cobpolyline += ', '; + } + cobpolyline += (xScale2(dt.toDate()) + padding.left) + ',' + (yCarbsScale(cob) + padding.top) + ' '; + } + } + if (options.iob) { + context.append('polyline') + .attr('stroke', 'blue') + .attr('opacity', '0.5') + .attr('fill-opacity', '0.1') + .attr('points',iobpolyline); + } + if (options.cob) { + context.append('polyline') + .attr('stroke', 'red') + .attr('opacity', '0.5') + .attr('fill-opacity', '0.1') + .attr('points',cobpolyline); + } + + data.treatments.forEach(function (treatment) { + if (treatment.boluscalc && treatment.boluscalc.foods && treatment.boluscalc.foods.length > 0 || treatment.notes) { + var lastfoodtext = foodtexts; + var drawpointer = false; + if (treatment.boluscalc && treatment.boluscalc.foods && treatment.boluscalc.foods.length > 0 && options.food) { + var foods = treatment.boluscalc.foods; + for (var fi=0; fi y){ + ctx.beginPath(); + ctx.moveTo(lineX,y); + ctx.lineTo(lineX,lowY); + ctx.closePath(); + ctx.stroke(); + } + } + } + + $.plot.plugins.push({ + init: init, + options: options, + name: 'candle', + version: '1.0' + }); +})(jQuery); \ No newline at end of file diff --git a/static/report/js/glucosedistribution.js b/static/report/js/glucosedistribution.js new file mode 100644 index 00000000000..16ac13d5d0b --- /dev/null +++ b/static/report/js/glucosedistribution.js @@ -0,0 +1,99 @@ + function report_glucosedistribution(datastorage,daystoshow,options) { + var Statician = ss; + var report = $("#glucosedistribution-report"); + report.empty(); + var minForDay, maxForDay; + var stats = []; + var table = $('
'+translate('Date')+''+translate('Low')+''+translate('Normal')+''+translate('High')+''+translate('Readings')+''+translate('Min')+''+translate('Max')+''+translate('StDev')+''+translate('25%')+''+translate('Median')+''+translate('75%')+'
").appendTo(tr); + $("" + localeDate(dayInQuestion) + "'+translate('No data available')+'
" + localeDate(dayInQuestion) + "" + Math.floor((100 * stats.lows) / daysRecords.length) + "%" + Math.floor((100 * stats.normal) / daysRecords.length) + "%" + Math.floor((100 * stats.highs) / daysRecords.length) + "%" + daysRecords.length +"" + minForDay +"" + maxForDay +"" + Math.floor(ss.standard_deviation(bgValues)) + "" + ss.quantile(bgValues, 0.25) + "" + ss.quantile(bgValues, 0.5) + "" + ss.quantile(bgValues, 0.75) + "
'); + var thead = $(""); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + thead.appendTo(table); + + var data = []; + var days = 0; + Object.keys(daystoshow).forEach(function (day) { + data = data.concat(datastorage[day].statsrecords); + days++; + }); + + $('#glucosedistribution-days').text(days+' '+translate('days total')); + + ['Low', 'Normal', 'High'].forEach(function(range) { + var tr = $(""); + var rangeRecords = data.filter(function(r) { + if (range == "Low") { + return r.sgv > 0 && r.sgv < options.targetLow; + } else if (range == "Normal") { + return r.sgv >= options.targetLow && r.sgv < options.targetHigh; + } else { + return r.sgv >= options.targetHigh; + } + }); + stats.push(rangeRecords.length); + rangeRecords.sort(function(a,b) { + return a.sgv - b.sgv; + }); + var localBgs = rangeRecords.map(function(r) { return r.sgv; }).filter(function(bg) { return !!bg; }); + + var midpoint = Math.floor(rangeRecords.length / 2); + //var statistics = ss.(new Statician(rangeRecords.map(function(r) { return r.sgv; }))).stats; + + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + if (rangeRecords.length > 0) { + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + } else { + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + } + + table.append(tr); + }); + + var tr = $(""); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + if (data.length > 0) { + var localBgs = data.map(function(r) { return r.sgv; }).filter(function(bg) { return !!bg; }); + var mgDlBgs = data.map(function(r) { return r.bgValue; }).filter(function(bg) { return !!bg; }); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + } else { + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + } + table.append(tr); + report.append(table); + + setTimeout(function() { + $.plot( + "#glucosedistribution-overviewchart", + stats, + { + series: { + pie: { + show: true + } + }, + colors: ["#f88", "#8f8", "#ff8"] + } + ); + }); + } diff --git a/static/report/js/hourlystats.js b/static/report/js/hourlystats.js new file mode 100644 index 00000000000..23dd1ce6949 --- /dev/null +++ b/static/report/js/hourlystats.js @@ -0,0 +1,106 @@ + function report_hourlystats(datastorage,daystoshow,options) { + var report = $("#hourlystats-report"); + var stats = []; + var pivotedByHour = {}; + + var data = []; + var days = 0; + Object.keys(daystoshow).forEach(function (day) { + data = data.concat(datastorage[day].statsrecords); + days++; + }); + + for (var i = 0; i < 24; i++) { + pivotedByHour[i] = []; + } + data.forEach(function(record) { + var d = new Date(record.displayTime); + pivotedByHour[d.getHours()].push(record); + }); + var table = $("
'+translate('Range')+''+translate('% of Readings')+''+translate('# of Readings')+''+translate('Mean')+''+translate('Median')+''+translate('Standard Deviation')+''+translate('A1c estimation*')+'
" + translate(range) + ": " + Math.floor(100 * rangeRecords.length / data.length) + "%" + rangeRecords.length + "" + Math.floor(10*Statician.mean(localBgs))/10 + "" + rangeRecords[midpoint].sgv + "" + Math.floor(Statician.standard_deviation(localBgs)*10)/10 + " N/AN/AN/A
"+translate("Overall")+": " + data.length + "" + Math.round(10*ss.mean(localBgs))/10 + "" + Math.round(10*ss.quantile(localBgs, 0.5))/10+ "" + Math.round(ss.standard_deviation(localBgs)*10)/10 + "
" + Math.round(10*(ss.mean(mgDlBgs)+46.7)/28.7)/10 + "%DCCT | " +Math.round(((ss.mean(mgDlBgs)+46.7)/28.7 - 2.15)*10.929) + "IFCC
N/AN/AN/AN/A
"); + var thead = $(""); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + thead.appendTo(table); + + [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23].forEach(function(hour) { + var tr = $(""); + var display = hour % 12; + if (hour === 0) { + display = "12"; + } + display += ":00 "; + if (hour >= 12) { + display += "PM"; + } else { + display += "AM"; + } + + var avg = Math.floor(pivotedByHour[hour].map(function(r) { return r.sgv; }).reduce(function(o,v){ return o+v; }, 0) / pivotedByHour[hour].length); + var d = new Date(hour.hours()); + // d.setHours(hour); + // d.setMinutes(0); + // d.setSeconds(0); + // d.setMilliseconds(0); + + var dev = ss.standard_deviation(pivotedByHour[hour].map(function(r) { return r.sgv; })); + stats.push([ + new Date(d), + ss.quantile(pivotedByHour[hour].map(function(r) { return r.sgv; }), 0.25), + ss.quantile(pivotedByHour[hour].map(function(r) { return r.sgv; }), 0.75), + avg - dev, + avg + dev + // Math.min.apply(Math, pivotedByHour[hour].map(function(r) { return r.sgv; })), + // Math.max.apply(Math, pivotedByHour[hour].map(function(r) { return r.sgv; })) + ]); + var tmp; + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + table.append(tr); + }); + + report.empty(); + report.append(table); + + $.plot( + "#hourlystats-overviewchart", + [{ + data:stats, + candle:true + }], + { + series: { + candle: true, + lines: false //Somehow it draws lines if you dont disable this. Should investigate and fix this ;) + }, + xaxis: { + mode: "time", + timeFormat: "%h:00", + min: 0, + max: (24).hours()-(1).seconds() + }, + yaxis: { + min: 0, + max: serverSettings.units == 'mmol' ? 22: 400, + show: true + }, + grid: { + show: true + } + } + ); + } \ No newline at end of file diff --git a/static/report/js/percentile.js b/static/report/js/percentile.js new file mode 100644 index 00000000000..3a22cf19519 --- /dev/null +++ b/static/report/js/percentile.js @@ -0,0 +1,152 @@ + function report_percentile(datastorage,daystoshow,options) { + var Statician = ss; + var window = 30; //minute-window should be a divisor of 60 + + var data = []; + var days = 0; + Object.keys(daystoshow).forEach(function (day) { + data = data.concat(datastorage[day].statsrecords); + days++; + }); + + var bins = []; + for (hour = 0; hour < 24; hour++) { + for (minute = 0; minute < 60; minute = minute + window) { + var date = new Date(); + date.setHours(hour); + date.setMinutes(minute); + var readings = data.filter(function(record) { + var recdate = new Date(record.displayTime); + return recdate.getHours() == hour && recdate.getMinutes() >= minute && + recdate.getMinutes() < minute + window;; + }); + readings = readings.map(function(record) { + return record.sgv; + }); + bins.push([date, readings]); + //console.log(date + " - " + readings.length); + //readings.forEach(function(x){console.log(x)}); + } + } + dat10 = bins.map(function(bin) { + return [bin[0], ss.quantile(bin[1], 0.1)]; + }); + dat25 = bins.map(function(bin) { + return [bin[0], ss.quantile(bin[1], 0.25)]; + }); + dat50 = bins.map(function(bin) { + return [bin[0], ss.quantile(bin[1], 0.5)]; + }); + dat75 = bins.map(function(bin) { + return [bin[0], ss.quantile(bin[1], 0.75)]; + }); + dat90 = bins.map(function(bin) { + return [bin[0], ss.quantile(bin[1], 0.9)]; + }); + high = options.targetHigh; + low = options.targetLow; + //dat50.forEach(function(x){console.log(x[0] + " - " + x[1])}); + $.plot( + "#percentile-chart", [{ + label: translate("Median"), + data: dat50, + id: 'c50', + color: "#000000", + points: { + show: false + }, + lines: { + show: true, + //fill: true + } + }, { + label: "25%/75% "+translate("percentile"), + data: dat25, + id: 'c25', + color: "#000055", + points: { + show: false + }, + lines: { + show: true, + fill: true + }, + fillBetween: 'c50' + }, { + data: dat75, + id: 'c75', + color: "#000055", + points: { + show: false + }, + lines: { + show: true, + fill: true + }, + fillBetween: 'c50' + }, { + label: "10%/90% "+translate("percentile"), + data: dat10, + id: 'c10', + color: "#a0a0FF", + points: { + show: false + }, + lines: { + show: true, + fill: true + }, + fillBetween: 'c25' + }, { + data: dat90, + id: 'c90', + color: "#a0a0FF", + points: { + show: false + }, + lines: { + show: true, + fill: true + }, + fillBetween: 'c75' + }, { + label: translate("High"), + data: [], + color: '#FFFF00', + }, { + label: translate("Low"), + data: [], + color: '#FF0000', + }], { + xaxis: { + mode: "time", + timezone: "browser", + timeformat: "%H:%M", + tickColor: "#555", + }, + yaxis: { + min: 0, + max: serverSettings.units == 'mmol' ? 22: 400, + tickColor: "#555", + }, + grid: { + markings: [{ + color: '#FF0000', + lineWidth: 2, + yaxis: { + from: low, + to: low + } + }, { + color: '#FFFF00', + lineWidth: 2, + yaxis: { + from: high, + to: high + } + }], + //hoverable: true + } + } + ); + } diff --git a/static/report/js/report.js b/static/report/js/report.js new file mode 100644 index 00000000000..b63828ab9aa --- /dev/null +++ b/static/report/js/report.js @@ -0,0 +1,608 @@ + 'use strict'; + + var translate = Nightscout.language.translate; + + var maxInsulinValue = 0 + ,maxCarbsValue = 0; + var containerprefix = 'chart-'; + var maxdays = 3 * 31; + var datastorage = {}; + var daystoshow = {}; + + var targetBGdefault = { + "mg/dl": { low: 72, high: 180 }, + "mmol": { low: 4, high: 10 } + }; + + var + ONE_MIN_IN_MS = 60000 + , SIX_MINS_IN_MS = 360000; + + var + SCALE_LINEAR = 0 + , SCALE_LOG = 1; + + + var categories = []; + var foodlist = []; + + + + function rawIsigToRawBg(entry, cal) { + var raw = 0 + , unfiltered = parseInt(entry.unfiltered) || 0 + , filtered = parseInt(entry.filtered) || 0 + , sgv = entry.y + , scale = parseFloat(cal.scale) || 0 + , intercept = parseFloat(cal.intercept) || 0 + , slope = parseFloat(cal.slope) || 0; + + if (slope == 0 || unfiltered == 0 || scale == 0) { + raw = 0; + } else if (filtered == 0 || sgv < 40) { + raw = scale * (unfiltered - intercept) / slope; + } else { + var ratio = scale * (filtered - intercept) / slope / sgv; + raw = scale * ( unfiltered - intercept) / slope / ratio; + } + return Math.round(raw); + } + + function sgvToColor(sgv,options) { + var color = 'darkgreen'; + + if (sgv > options.targetHigh) { + color = 'red'; + } else if (sgv < options.targetLow) { + color = 'red'; + } + + return color; + } + + $('#info').html(''+translate('Loading profile')+' ...'); + $.ajax('/api/v1/profile', { + success: function (record) { + Nightscout.profile.loadData(record); + } + }).done(function() { + $('#info').html(''+translate('Loading food database')+' ...'); + $.ajax('/api/v1/food/regular.json', { + 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; + }); + fillForm(); + } + }).done(function() { + $('#info').html(''); + $('.presetdates').click(function(e) { var days = $(this).attr('days'); setDataRange(e,days); }); + + $('#rp_show').click(show); + $('#rp_food').change(function (event) { + event.preventDefault(); + $('#rp_enablefood').prop('checked',true); + }); + $('#rp_notes').change(function (event) { + event.preventDefault(); + $('#rp_enablenotes').prop('checked',true); + }); + + $('#rp_targetlow').val(targetBGdefault[serverSettings.units].low); + $('#rp_targethigh').val(targetBGdefault[serverSettings.units].high); + + $('.menutab').click(switchtab); + + setDataRange(null,7); + + }); + }); + + function show(event) { + var options = { + width: 1000, + height: 300, + targetLow: 3.5, + targetHigh: 10, + raw: true, + notes: true, + food: true, + insulin: true, + carbs: true, + iob : true, + cob : true, + scale: SCALE_LINEAR + }; + + options.targetLow = parseFloat($('#rp_targetlow').val().replace(',','.')); + options.targetHigh = parseFloat($('#rp_targethigh').val().replace(',','.')); + options.raw = $('#rp_optionsraw').is(':checked'); + options.iob = $('#rp_optionsiob').is(':checked'); + options.cob = $('#rp_optionscob').is(':checked'); + options.notes = $('#rp_optionsnotes').is(':checked'); + options.food = $('#rp_optionsfood').is(':checked'); + options.insulin = $('#rp_optionsinsulin').is(':checked'); + options.carbs = $('#rp_optionscarbs').is(':checked'); + options.scale = $('#rp_linear').is(':checked') ? SCALE_LINEAR : SCALE_LOG; + options.width = parseInt($('#rp_size :selected').attr('x')); + options.height = parseInt($('#rp_size :selected').attr('y')); + + var matchesneeded = 0; + + // date range + function datefilter() { + if ($('#rp_enabledate').is(':checked')) { + matchesneeded++; + var from = moment($('#rp_from').val()); + var to = moment($('#rp_to').val()); + + while (from <= to) { + if (daystoshow[from.format('YYYY-MM-DD')]) daystoshow[from.format('YYYY-MM-DD')]++; + else daystoshow[from.format('YYYY-MM-DD')] = 1; + from.add(1, 'days'); + } + } + console.log('Dayfilter: ',daystoshow); + foodfilter(); + } + + //food filter + function foodfilter() { + if ($('#rp_enablefood').is(':checked')) { + matchesneeded++; + var _id = $('#rp_food').val(); + if (_id) { + var treatmentData; + var tquery = '?find[boluscalc.foods._id]='+_id; + $.ajax('/api/v1/treatments.json'+tquery, { + success: function (xhr) { + treatmentData = xhr.map(function (treatment) { + return moment(treatment.mills).format('YYYY-MM-DD'); + }); + // unique it + treatmentData = $.grep(treatmentData, function(v, k){ + return $.inArray(v ,treatmentData) === k; + }); + treatmentData.sort(function(a, b) { return a > b; }); + } + }).done(function () { + console.log('Foodfilter: ',treatmentData); + for (var d=0; d b; }); + } + }).done(function () { + console.log('Notesfilter: ',treatmentData); + for (var d=0; d b; }); + } + }).done(function () { + console.log('Eventtypefilter: ',treatmentData); + for (var d=0; d'+translate('Loading')+' ...'); + $('#charts').html(''); + for (var d in daystoshow) { + if (daystoshow[d]==matchesneeded) { + if (displayeddays < maxdays) { + $('#charts').append($('
')); + loadData(d,options); + displayeddays++; + } else { + $('#charts').append($('
'+d+' '+translate('not displayed')+'.
')); + } + } else { + delete daystoshow[d]; + } + } + if (displayeddays==0) { + $('#charts').html(''+translate('Result is empty')+''); + $('#info').empty(); + } + } + + $('#rp_show').css('display','none'); + daystoshow = {}; + datefilter(); + if (event) event.preventDefault(); + } + + function showreports(options) { + // wait for all loads + for (var d in daystoshow) { + if (!datastorage[d]) return; // all data not loaded yet + } + + ['daytoday','dailystats','percentile','glucosedistribution','hourlystats','success','treatments','calibrations'].forEach(function (chart) { + // jquery plot doesn't draw to hidden div + $('#'+chart+'-placeholder').css('display',''); + eval('report_'+chart+'(datastorage,daystoshow,options);'); + if (!$('#'+chart).hasClass('selected')) + $('#'+chart+'-placeholder').css('display','none'); + }); + + $('#info').html(''); + $('#rp_show').css('display',''); + } + + function setDataRange(event,days) { + $('#rp_to').val(moment().format('YYYY-MM-DD')); + $('#rp_from').val(moment().add(-days+1, 'days').format('YYYY-MM-DD')); + + if (event) event.preventDefault(); + } + + function switchtab(event) { + var id = $(this).attr('id'); + + $('.menutab').removeClass('selected'); + $('#'+id).addClass('selected'); + + $('.tabplaceholder').css('display','none'); + $('#'+id+'-placeholder').css('display',''); + + } + + function localeDate(day) { + var ret = + [translate("Sunday"),translate("Monday"),translate("Tuesday"),translate("Wednesday"),translate("Thursday"),translate("Friday"),translate("Saturday")][new Date(day).getDay()]; + ret += ' '; + ret += new Date(day).toLocaleDateString(); + return ret; + } + + function localeDateTime(day) { + var ret = new Date(day).toLocaleDateString() + ' ' + new Date(day).toLocaleTimeString(); + return ret; + } + + function loadData(day,options) { + // check for loaded data + if (datastorage[day] && day != moment().format('YYYY-MM-DD')) { + showreports(options); + return; + } + // patientData = [actual, predicted, mbg, treatment, cal, devicestatusData]; + var data = {}; + var cgmData = [] + , mbgData = [] + , treatmentData = [] + , calData = [] + ; + var dt = new Date(day); + var from = dt.getTime() + dt.getTimezoneOffset() * 60 * 1000; + var to = from + 1000 * 60 * 60 * 24; + var query = '?find[date][$gte]='+from+'&find[date][$lt]='+to+'&count=10000'; + + $('#'+containerprefix+day).html(''+translate('Loading CGM data of')+' '+day+' ...'); + $.ajax('/api/v1/entries.json'+query, { + success: function (xhr) { + xhr.forEach(function (element) { + if (element) { + if (element.mbg) { + mbgData.push({ + y: element.mbg + , x: element.date + , d: element.dateString + , device: element.device + }); + } else if (element.sgv) { + cgmData.push({ + y: element.sgv + , x: element.date + , d: element.dateString + , device: element.device + , filtered: element.filtered + , unfiltered: element.unfiltered + , noise: element.noise + , rssi: element.rssi + , sgv: element.sgv + }); + } else if (element.type == 'cal') { + calData.push({ + x: element.date + , d: element.dateString + , scale: element.scale + , intercept: element.intercept + , slope: element.slope + }); + } + } + }); + // sometimes cgm contains duplicates. uniq it. + data.sgv = cgmData.slice(); + data.sgv.sort(function(a, b) { return a.x - b.x; }); + var lastDate = 0; + data.sgv = data.sgv.filter(function(d) { + var ok = (lastDate + ONE_MIN_IN_MS) < d.x; + lastDate = d.x; + return ok; + }); + data.mbg = mbgData.slice(); + data.mbg.sort(function(a, b) { return a.x - b.x; }); + data.cal = calData.slice(); + data.cal.sort(function(a, b) { return a.x - b.x; }); + } + }).done(function () { + $('#'+containerprefix+day).html(''+translate('Loading treatments data of')+' '+day+' ...'); + var tquery = '?find[created_at][$gte]='+new Date(from).toISOString()+'&find[created_at][$lt]='+new Date(to).toISOString(); + $.ajax('/api/v1/treatments.json'+tquery, { + success: function (xhr) { + treatmentData = xhr.map(function (treatment) { + var timestamp = new Date(treatment.timestamp || treatment.created_at); + treatment.mills = timestamp.getTime(); + return treatment; + }); + data.treatments = treatmentData.slice(); + data.treatments.sort(function(a, b) { return a.mills - b.mills; }); + } + }).done(function () { + $('#'+containerprefix+day).html(''+translate('Processing data of')+' '+day+' ...'); + processData(data,day,options); + }); + + }); + } + + function processData(data,day,options) { + // treatments + data.treatments.forEach(function (d) { + if (parseFloat(d.insulin) > maxInsulinValue) maxInsulinValue = parseFloat(d.insulin); + if (parseFloat(d.carbs) > maxCarbsValue) maxCarbsValue = parseFloat(d.carbs); + }); + + var cal = data.cal[data.cal.length-1]; + var temp1 = [ ]; + if (cal) { + temp1 = data.sgv.map(function (entry) { + var noise = entry.noise || 0; + var rawBg = rawIsigToRawBg(entry, cal); + return { x: entry.x, date: new Date(entry.x - 2 * 1000), y: rawBg, sgv: scaleBg(rawBg), color: 'gray', type: 'rawbg', filtered: entry.filtered, unfiltered: entry.unfiltered } + }).filter(function(entry) { return entry.y > 0}); + } + var temp2 = data.sgv.map(function (obj) { + return { x: obj.x, date: new Date(obj.x), y: obj.y, sgv: scaleBg(obj.y), color: sgvToColor(scaleBg(obj.y),options), type: 'sgv', noise: obj.noise, filtered: obj.filtered, unfiltered: obj.unfiltered} + }); + data.sgv = [].concat(temp1, temp2); + + //Add MBG's also, pretend they are SGV's + data.sgv = data.sgv.concat(data.mbg.map(function (obj) { return { date: new Date(obj.x), y: obj.y, sgv: scaleBg(obj.y), color: 'red', type: 'mbg', device: obj.device } })); + + // make sure data range will be exactly 24h + var from = new Date(new Date(day).getTime() + (new Date().getTimezoneOffset()*60*1000)); + var to = new Date(from.getTime() + 1000 * 60 * 60 * 24); + data.sgv.push({ date: from, y: 40, sgv: 40, color: 'transparent', type: 'rawbg'}); + data.sgv.push({ date: to, y: 40, sgv: 40, color: 'transparent', type: 'rawbg'}); + + // clear error data. we don't need it to display them + data.sgv = data.sgv.filter(function (d) { + if (d.y < 39) return false; + return true; + }); + + //delete data.cal; + //delete data.mbg; + + // for other reports + data.statsrecords = data.sgv.filter(function(r) { + if (r.type) return r.type == 'sgv'; + else return true; + }).map(function (r) { + var ret = {}; + ret.sgv = parseFloat(r.sgv); + ret.bgValue = parseInt(r.y); + ret.displayTime = r.date; + return ret; + }); + + + datastorage[day] = data; + options.maxInsulinValue = maxInsulinValue; + options.maxCarbsValue = maxCarbsValue; + showreports(options); + } + + // Filtering food code + // ------------------- + var categories = []; + var foodlist = []; + var filter = { + category: '' + , subcategory: '' + , name: '' + }; + + function fillForm(event) { + $('#rp_category').empty().append(new Option(translate('(none)'),'')); + for (var s in categories) { + $('#rp_category').append(new Option(s,s)); + } + filter.category = ''; + fillSubcategories(); + + $('#rp_category').change(fillSubcategories); + $('#rp_subcategory').change(doFilter); + $('#rp_name').on('input',doFilter); + + if (event) event.preventDefault(); + return false; + } + + function fillSubcategories(event) { + if (event) { + event.preventDefault(); + } + filter.category = $('#rp_category').val(); + filter.subcategory = ''; + $('#rp_subcategory').empty().append(new Option(translate('(none)'),'')); + if (filter.category != '') { + for (var s in categories[filter.category]) { + $('#rp_subcategory').append(new Option(s,s)); + } + } + doFilter(); + } + + function doFilter(event) { + if (event) { + filter.category = $('#rp_category').val(); + filter.subcategory = $('#rp_subcategory').val(); + filter.name = $('#rp_name').val(); + } + $('#rp_food').empty(); + for (var i=0; i 0 ? (totalBG / closeBGs.length) : 450; + } + + var treatmentGlucose = null; + + if (treatment.glucose && isNaN(treatment.glucose)) { + console.warn('found an invalid glucose value', treatment); + } else { + if (treatment.glucose && treatment.units && serverSettings.units) { + if (treatment.units != serverSettings.units) { + console.info('found mismatched glucose units, converting ' + treatment.units + ' into ' + serverSettings.units, treatment); + if (treatment.units == 'mmol') { + //BG is in mmol and display in mg/dl + treatmentGlucose = Math.round(treatment.glucose * 18) + } else { + //BG is in mg/dl and display in mmol + treatmentGlucose = scaleBg(treatment.glucose); + } + } else { + treatmentGlucose = treatment.glucose; + } + } else if (treatment.glucose) { + //no units, assume everything is the same + console.warn('found an glucose value with any units, maybe from an old version?', treatment); + treatmentGlucose = treatment.glucose; + } + } + + return treatmentGlucose || scaleBg(calcBGByTime(treatment.mills)); + } + + function scaleBg(bg) { + if (serverSettings.units === 'mmol') { + return Nightscout.units.mgdlToMMOL(bg); + } else { + return bg; + } + } diff --git a/static/report/js/success.js b/static/report/js/success.js new file mode 100644 index 00000000000..85311b42624 --- /dev/null +++ b/static/report/js/success.js @@ -0,0 +1,178 @@ +function report_success(datastorage,daystoshow,options) { + var low = parseInt(options.targetLow), + high = parseInt(options.targetHigh); + + var data = []; + var days = 0; + Object.keys(daystoshow).forEach(function (day) { + data = data.concat(datastorage[day].statsrecords); + days++; + }); + + var now = Date.now(); + var period = (7).days(); + var firstDataPoint = data.reduce(function(min, record) { + return Math.min(min, record.displayTime); + }, Number.MAX_VALUE); + if (firstDataPoint < 1390000000000) firstDataPoint = 1390000000000; + var quarters = Math.floor((Date.now() - firstDataPoint) / period); + + var grid = $("#success-grid"); + grid.empty(); + var table = $("
'+translate('Time')+''+translate('Readings')+''+translate('Average')+''+translate('Min')+''+translate('Quartile')+' 25'+translate('Median')+''+translate('Quartile')+' 75'+translate('Max')+''+translate('Standard Deviation')+'
" + display + "" + pivotedByHour[hour].length + " (" + Math.floor(100 * pivotedByHour[hour].length / data.length) + "%)" + avg + "" + Math.min.apply(Math, pivotedByHour[hour].map(function(r) { return r.sgv; })) + "" + ((tmp=ss.quantile(pivotedByHour[hour].map(function(r) { return r.sgv; }), 0.25)) ? tmp.toFixed(1) : 0 ) + "" + ((tmp=ss.quantile(pivotedByHour[hour].map(function(r) { return r.sgv; }), 0.5)) ? tmp.toFixed(1) : 0 ) + "" + ((tmp=ss.quantile(pivotedByHour[hour].map(function(r) { return r.sgv; }), 0.75)) ? tmp.toFixed(1) : 0 ) + "" + Math.max.apply(Math, pivotedByHour[hour].map(function(r) { return r.sgv; })) + "" + Math.floor(dev*10)/10 + "
"); + + if (quarters == 0) { + // insufficent data + grid.append("

"+translate("There is not sufficient data to run this report. Select more days.")+"

"); + return; + } + + var dim = function(n) { + var a = []; + for (i = 0; i < n; i++) { + a[i]=0; + } + return a; + } + var sum = function(a) { + return a.reduce(function(sum,v) { + return sum+v; + }, 0); + } + var averages = { + percentLow: 0, + percentInRange: 0, + percentHigh: 0, + standardDeviation: 0, + lowerQuartile: 0, + upperQuartile: 0, + average: 0 + }; + try { + quarters = dim(quarters).map(function(blank, n) { + var starting = new Date(now - (n+1) * period), + ending = new Date(now - n * period); + return { + starting: starting, + ending: ending, + records: data.filter(function(record) { + return record.displayTime > starting && record.displayTime <= ending; + }) + }; + }).filter(function(quarter) { + return quarter.records.length > 0; + }).map(function(quarter, ix, all) { + var bgValues = quarter.records.map(function(record) { + return record.sgv; + }); + quarter.standardDeviation = ss.standard_deviation(bgValues); + quarter.average = bgValues.length > 0? (sum(bgValues) / bgValues.length): "N/A"; + quarter.lowerQuartile = ss.quantile(bgValues, 0.25); + quarter.upperQuartile = ss.quantile(bgValues, 0.75); + quarter.numberLow = bgValues.filter(function(bg) { + return bg < low; + }).length; + quarter.numberHigh = bgValues.filter(function(bg) { + return bg >= high; + }).length; + quarter.numberInRange = bgValues.length - (quarter.numberHigh + quarter.numberLow); + + quarter.percentLow = (quarter.numberLow / bgValues.length) * 100; + quarter.percentInRange = (quarter.numberInRange / bgValues.length) * 100; + quarter.percentHigh = (quarter.numberHigh / bgValues.length) * 100; + + averages.percentLow += quarter.percentLow / all.length; + averages.percentInRange += quarter.percentInRange / all.length; + averages.percentHigh += quarter.percentHigh / all.length; + averages.lowerQuartile += quarter.lowerQuartile / all.length; + averages.upperQuartile += quarter.upperQuartile / all.length; + averages.average += quarter.average / all.length; + averages.standardDeviation += quarter.standardDeviation / all.length; + return quarter; + }); + } catch (e) { + console.log(e); + } + + var lowComparison = function(quarter, averages, field, invert) { + if (quarter[field] < averages[field] * 0.8) { + return (invert? "bad": "good"); + } else if (quarter[field] > averages[field] * 1.2) { + return (invert? "good": "bad"); + } else { + return ""; + } + } + + var lowQuartileEvaluation = function(quarter, averages) { + if (quarter.lowerQuartile < low) { + return "bad"; + } else { + return lowComparison(quarter, averages, "lowerQuartile"); + } + } + + var upperQuartileEvaluation = function(quarter, averages) { + if (quarter.upperQuartile > high) { + return "bad"; + } else { + return lowComparison(quarter, averages, "upperQuartile"); + } + } + + var averageEvaluation = function(quarter, averages) { + if (quarter.average > high) { + return "bad"; + } else if (quarter.average < low) { + return "bad"; + } else { + return lowComparison(quarter, averages, "average", true); + } + } + + table.append(""); + table.append("" + quarters.filter(function(quarter) { + return quarter.records.length > 0; + }).map(function(quarter) { + var INVERT = true; + return "" + [ + quarter.starting.format("M d Y") + " - " + quarter.ending.format("M d Y"), + { + klass: lowComparison(quarter, averages, "percentLow"), + text: Math.round(quarter.percentLow) + "%" + }, + { + klass: lowComparison(quarter, averages, "percentInRange", INVERT), + text: Math.round(quarter.percentInRange) + "%" + }, + { + klass: lowComparison(quarter, averages, "percentHigh"), + text: Math.round(quarter.percentHigh) + "%" + }, + { + klass: lowComparison(quarter, averages, "standardDeviation"), + text: (quarter.standardDeviation > 10? Math.round(quarter.standardDeviation): quarter.standardDeviation.toFixed(1)) + }, + { + klass: lowQuartileEvaluation(quarter, averages), + text: quarter.lowerQuartile + }, + { + klass: lowComparison(quarter, averages, "average"), + text: quarter.average.toFixed(1) + }, + { + klass: upperQuartileEvaluation(quarter, averages), + text: quarter.upperQuartile + } + ].map(function(v) { + if (typeof v == "object") { + return ""; + } else { + return ""; + } + }).join("") + ""; + }).join("") + ""); + table.appendTo(grid); + +} \ No newline at end of file diff --git a/static/report/js/time.js b/static/report/js/time.js new file mode 100644 index 00000000000..0b34d7d47bf --- /dev/null +++ b/static/report/js/time.js @@ -0,0 +1,318 @@ +if (!("milliseconds" in Number.prototype)) + Number.prototype.milliseconds = function() { return this; }; +if (!("seconds" in Number.prototype)) + Number.prototype.seconds = function() { return this.milliseconds() * 1000; }; +if (!("minutes" in Number.prototype)) + Number.prototype.minutes = function() { return this.seconds() * 60; }; +if (!("hours" in Number.prototype)) + Number.prototype.hours = function() { return this.minutes() * 60; }; +if (!("days" in Number.prototype)) + Number.prototype.days = function() { return this.hours() * 24; }; +if (!("weeks" in Number.prototype)) + Number.prototype.weeks = function() { return this.days() * 7; }; +if (!("months" in Number.prototype)) + Number.prototype.months = function() { return this.days() * 30; }; + +if (!("toDays" in Number.prototype)) + Number.prototype.toDays = function() { return this.toHours() / 24; }; +if (!("toHours" in Number.prototype)) + Number.prototype.toHours = function() { return this.toMinutes() / 60; }; +if (!("toMinutes" in Number.prototype)) + Number.prototype.toMinutes = function() { return this.toSeconds() / 60; }; +if (!("toSeconds" in Number.prototype)) + Number.prototype.toSeconds = function() { return this.toMilliseconds() / 1000; }; +if (!("toMilliseconds" in Number.prototype)) + Number.prototype.toMilliseconds = function() { return this; }; + +Date.prototype.format = function(format) { + // discuss at: http://phpjs.org/functions/date/ + // original by: Carlos R. L. Rodrigues (http://www.jsfromhell.com) + // original by: gettimeofday + // parts by: Peter-Paul Koch (http://www.quirksmode.org/js/beat.html) + // improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // improved by: MeEtc (http://yass.meetcweb.com) + // improved by: Brad Touesnard + // improved by: Tim Wiel + // improved by: Bryan Elliott + // improved by: David Randall + // improved by: Theriault + // improved by: Theriault + // improved by: Brett Zamir (http://brett-zamir.me) + // improved by: Theriault + // improved by: Thomas Beaucourt (http://www.webapp.fr) + // improved by: JT + // improved by: Theriault + // improved by: Rafał Kukawski (http://blog.kukawski.pl) + // improved by: Theriault + // input by: Brett Zamir (http://brett-zamir.me) + // input by: majak + // input by: Alex + // input by: Martin + // input by: Alex Wilson + // input by: Haravikk + // bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // bugfixed by: majak + // bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // bugfixed by: Brett Zamir (http://brett-zamir.me) + // bugfixed by: omid (http://phpjs.org/functions/380:380#comment_137122) + // bugfixed by: Chris (http://www.devotis.nl/) + // note: Uses global: php_js to store the default timezone + // note: Although the function potentially allows timezone info (see notes), it currently does not set + // note: per a timezone specified by date_default_timezone_set(). Implementers might use + // note: this.php_js.currentTimezoneOffset and this.php_js.currentTimezoneDST set by that function + // note: in order to adjust the dates in this function (or our other date functions!) accordingly + // example 1: date('H:m:s \\m \\i\\s \\m\\o\\n\\t\\h', 1062402400); + // returns 1: '09:09:40 m is month' + // example 2: date('F j, Y, g:i a', 1062462400); + // returns 2: 'September 2, 2003, 2:26 am' + // example 3: date('Y W o', 1062462400); + // returns 3: '2003 36 2003' + // example 4: x = date('Y m d', (new Date()).getTime()/1000); + // example 4: (x+'').length == 10 // 2009 01 09 + // returns 4: true + // example 5: date('W', 1104534000); + // returns 5: '53' + // example 6: date('B t', 1104534000); + // returns 6: '999 31' + // example 7: date('W U', 1293750000.82); // 2010-12-31 + // returns 7: '52 1293750000' + // example 8: date('W', 1293836400); // 2011-01-01 + // returns 8: '52' + // example 9: date('W Y-m-d', 1293974054); // 2011-01-02 + // returns 9: '52 2011-01-02' + + var that = this, timestamp = this; + var jsdate, f; + // Keep this here (works, but for code commented-out below for file size reasons) + // var tal= []; + var txt_words = [ + 'Sun', 'Mon', 'Tues', 'Wednes', 'Thurs', 'Fri', 'Satur', + 'January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', 'November', 'December' + ]; + // trailing backslash -> (dropped) + // a backslash followed by any character (including backslash) -> the character + // empty string -> empty string + var formatChr = /\\?(.?)/gi; + var formatChrCb = function(t, s) { + return f[t] ? f[t]() : s; + }; + var _pad = function(n, c) { + n = String(n); + while (n.length < c) { + n = '0' + n; + } + return n; + }; + f = { + // Day + d: function() { // Day of month w/leading 0; 01..31 + return _pad(f.j(), 2); + }, + D: function() { // Shorthand day name; Mon...Sun + return f.l() + .slice(0, 3); + }, + j: function() { // Day of month; 1..31 + return jsdate.getDate(); + }, + l: function() { // Full day name; Monday...Sunday + return txt_words[f.w()] + 'day'; + }, + N: function() { // ISO-8601 day of week; 1[Mon]..7[Sun] + return f.w() || 7; + }, + S: function() { // Ordinal suffix for day of month; st, nd, rd, th + var j = f.j(); + var i = j % 10; + if (i <= 3 && parseInt((j % 100) / 10, 10) == 1) { + i = 0; + } + return ['st', 'nd', 'rd'][i - 1] || 'th'; + }, + w: function() { // Day of week; 0[Sun]..6[Sat] + return jsdate.getDay(); + }, + z: function() { // Day of year; 0..365 + var a = new Date(f.Y(), f.n() - 1, f.j()); + var b = new Date(f.Y(), 0, 1); + return Math.round((a - b) / 864e5); + }, + + // Week + W: function() { // ISO-8601 week number + var a = new Date(f.Y(), f.n() - 1, f.j() - f.N() + 3); + var b = new Date(a.getFullYear(), 0, 4); + return _pad(1 + Math.round((a - b) / 864e5 / 7), 2); + }, + + // Month + F: function() { // Full month name; January...December + return txt_words[6 + f.n()]; + }, + m: function() { // Month w/leading 0; 01...12 + return _pad(f.n(), 2); + }, + M: function() { // Shorthand month name; Jan...Dec + return f.F() + .slice(0, 3); + }, + n: function() { // Month; 1...12 + return jsdate.getMonth() + 1; + }, + t: function() { // Days in month; 28...31 + return (new Date(f.Y(), f.n(), 0)) + .getDate(); + }, + + // Year + L: function() { // Is leap year?; 0 or 1 + var j = f.Y(); + return j % 4 === 0 & j % 100 !== 0 | j % 400 === 0; + }, + o: function() { // ISO-8601 year + var n = f.n(); + var W = f.W(); + var Y = f.Y(); + return Y + (n === 12 && W < 9 ? 1 : n === 1 && W > 9 ? -1 : 0); + }, + Y: function() { // Full year; e.g. 1980...2010 + return jsdate.getFullYear(); + }, + y: function() { // Last two digits of year; 00...99 + return f.Y() + .toString() + .slice(-2); + }, + + // Time + a: function() { // am or pm + return jsdate.getHours() > 11 ? 'pm' : 'am'; + }, + A: function() { // AM or PM + return f.a() + .toUpperCase(); + }, + B: function() { // Swatch Internet time; 000..999 + var H = jsdate.getUTCHours() * 36e2; + // Hours + var i = jsdate.getUTCMinutes() * 60; + // Minutes + var s = jsdate.getUTCSeconds(); // Seconds + return _pad(Math.floor((H + i + s + 36e2) / 86.4) % 1e3, 3); + }, + g: function() { // 12-Hours; 1..12 + return f.G() % 12 || 12; + }, + G: function() { // 24-Hours; 0..23 + return jsdate.getHours(); + }, + h: function() { // 12-Hours w/leading 0; 01..12 + return _pad(f.g(), 2); + }, + H: function() { // 24-Hours w/leading 0; 00..23 + return _pad(f.G(), 2); + }, + i: function() { // Minutes w/leading 0; 00..59 + return _pad(jsdate.getMinutes(), 2); + }, + s: function() { // Seconds w/leading 0; 00..59 + return _pad(jsdate.getSeconds(), 2); + }, + u: function() { // Microseconds; 000000-999000 + return _pad(jsdate.getMilliseconds() * 1000, 6); + }, + + // Timezone + e: function() { // Timezone identifier; e.g. Atlantic/Azores, ... + // The following works, but requires inclusion of the very large + // timezone_abbreviations_list() function. + /* return that.date_default_timezone_get(); + */ + throw 'Not supported (see source code of date() for timezone on how to add support)'; + }, + I: function() { // DST observed?; 0 or 1 + // Compares Jan 1 minus Jan 1 UTC to Jul 1 minus Jul 1 UTC. + // If they are not equal, then DST is observed. + var a = new Date(f.Y(), 0); + // Jan 1 + var c = Date.UTC(f.Y(), 0); + // Jan 1 UTC + var b = new Date(f.Y(), 6); + // Jul 1 + var d = Date.UTC(f.Y(), 6); // Jul 1 UTC + return ((a - c) !== (b - d)) ? 1 : 0; + }, + O: function() { // Difference to GMT in hour format; e.g. +0200 + var tzo = jsdate.getTimezoneOffset(); + var a = Math.abs(tzo); + return (tzo > 0 ? '-' : '+') + _pad(Math.floor(a / 60) * 100 + a % 60, 4); + }, + P: function() { // Difference to GMT w/colon; e.g. +02:00 + var O = f.O(); + return (O.substr(0, 3) + ':' + O.substr(3, 2)); + }, + T: function() { // Timezone abbreviation; e.g. EST, MDT, ... + // The following works, but requires inclusion of the very + // large timezone_abbreviations_list() function. + /* var abbr, i, os, _default; + if (!tal.length) { + tal = that.timezone_abbreviations_list(); + } + if (that.php_js && that.php_js.default_timezone) { + _default = that.php_js.default_timezone; + for (abbr in tal) { + for (i = 0; i < tal[abbr].length; i++) { + if (tal[abbr][i].timezone_id === _default) { + return abbr.toUpperCase(); + } + } + } + } + for (abbr in tal) { + for (i = 0; i < tal[abbr].length; i++) { + os = -jsdate.getTimezoneOffset() * 60; + if (tal[abbr][i].offset === os) { + return abbr.toUpperCase(); + } + } + } + */ + return 'UTC'; + }, + Z: function() { // Timezone offset in seconds (-43200...50400) + return -jsdate.getTimezoneOffset() * 60; + }, + + // Full Date/Time + c: function() { // ISO-8601 date. + return 'Y-m-d\\TH:i:sP'.replace(formatChr, formatChrCb); + }, + r: function() { // RFC 2822 + return 'D, d M Y H:i:s O'.replace(formatChr, formatChrCb); + }, + U: function() { // Seconds since UNIX epoch + return jsdate / 1000 | 0; + } + }; + this.date = function(format, timestamp) { + that = this; + jsdate = (timestamp === undefined ? new Date() : // Not provided + (timestamp instanceof Date) ? new Date(timestamp) : // JS Date() + new Date(timestamp * 1000) // UNIX timestamp (auto-convert to int) + ); + return format.replace(formatChr, formatChrCb); + }; + return this.date(format, timestamp); +} + +// http://stackoverflow.com/questions/11887934/check-if-daylight-saving-time-is-in-effect-and-if-it-is-for-how-many-hours +Date.prototype.stdTimezoneOffset = function() { + var jan = new Date(this.getFullYear(), 0, 1); + var jul = new Date(this.getFullYear(), 6, 1); + return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset()); +}; + +Date.prototype.dst = function() { + return this.getTimezoneOffset() < this.stdTimezoneOffset(); +}; \ No newline at end of file diff --git a/static/report/js/treatments.js b/static/report/js/treatments.js new file mode 100644 index 00000000000..0f2f5ab0eef --- /dev/null +++ b/static/report/js/treatments.js @@ -0,0 +1,154 @@ + function report_treatments(datastorage,daystoshow,options) { + var icon_remove = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACrElEQVQ4T42Ty2sTQRzHv5tmk2yyjRNtpfZhL8V6s2KoUNC2XqwgaCsVQcGiFqpHi0c9iRdR/ANE9KR40FIQX4cueKoPaKFoLdSYNtE0abKT1+5s9iW7aUMiHtzTzO7v85md+c6PA4DrHbsPCKIgOWO1pA7dT6YXnXH949SE/F63pqwZtRrO+SCKgjQ5NUV+azpmHj2krMwaJC4c8Erj+/eRyloMMwWFKgbn1nC3ervlK1evkXBLGBZT8SOewotnTylTNLdgeg/pDgZDC2cPHSR8bB22DVC9hFe0SG/H0xFXcHlykjRHRDBWgJcZSCY38Xx2lhqMnRYE34Px/sN9vlQWeoHBAx2yXsRruVAVuFsIBaSJ8+eJGPaBqQV4NROJjTzez89jLBoFn6FgybQL54wS3uTyVDFQ3cL2IYpBv3RhdJSIIQ80tQyv7gEqJvS8AmUlBs7UXPhtjtZgh3UFNYngk86NHCfNAg9dMwHVBPu+CpsVkTXKeJeVG+AGgTOZ3tt6MSKKjy+NjEBjFrR4ElZmA4pdxstMFsyyJu6tZZ7Ux9vwB6EAL50ZGiRECEPPUOixVTRxHlicgSVWxEdZpuZWfNuS2hk48NjwMIkIYZglBnV5Cbqtws/5IaAJmsfCglrEl2y2QeKmEBJ80tixKmxrFpSVr0gV0viQoxho2YUuPohmeFD22PiklLC4ma5JuBvdrfLJI0dJd0s7bM0ES8aR/BXDXGaTskqlL+D3Lwy0tZEePoAd4EA5YF4tYymdonfjmQh3s6dTPjU4SHYGwjAKecSXFyGlM1TdytntE56T+ts7SC/vhw3gm6njc2Kd3vm5Ub1IwQAvnYhGiZpYw1wiWYPrIw7wnBTt7CLOOwdmut14kQQvqt24tfK/utGR6LaF+iRqMf4N/O/8D28HiiCRYqzAAAAAAElFTkSuQmCC"; + var icon_edit = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABEUlEQVQ4jZ3MMUsCYQDG8ee8IySQbNCLyyEKG/RLNAXicqvQcAeNLrcFLlE0+xHuNpt8wy04rrYm8Q4HQRE56BSC3lSqU1BwCoxM39dnffj9BWyxXvVeEzvtctBwHyRebNu2Nk2lzMlrgJB+qBEeTByiKYpihl+fIO8jTI9PDJEVF1+K2iw+M6PhDuyag4NkQi/c3FkCK5Z3ZbM76qLltpCbn+vXxq0FABsDy9hzPdBvqvtXvvXzrw1swmsDLPjfACteGeDBfwK8+FdgGwwAIgC0ncsjxGRSH/eiPBgAJADY2z8sJ4JBfNBsDqlADVYMANIzKalv/bHaefKsTH9iPFb8ISsGAJym0+Qinz3jQktbAHcxvx3559eSAAAAAElFTkSuQmCC"; + + var table = '
"+translate("Period")+""+translate("Low")+""+translate("In Range")+""+translate("High")+""+translate("Standard Deviation")+""+translate("Low Quartile")+""+translate("Average")+""+translate("Upper Quartile")+"
" + v.text + "" + v + "
'; + table += ''; + + Object.keys(daystoshow).forEach(function (day) { + table += ''; + var treatments = datastorage[day].treatments; + for (var t=0; t'; + table += ' '; + table += ''; + table += ''; + table += ''; + table += ''; + table += ''; + table += ''; + table += ''; + table += ''; + table += ''; + + table += ''; + } + }); + $('#treatments-report').html(table); + $('.deleteTreatment').click(deleteTreatment); + $('.editTreatment').click(editTreatment); + } + + function deleteTreatment(event) { + var data = JSON.parse($(this).attr('data')); + var day = $(this).attr('day'); + + var ok = window.confirm( + translate('Delete this treatment?')+'\n' + + '\n'+translate('Event Type')+': ' + data.eventType + + (data.glucose ? '\n'+translate('Blood Glucose')+': ' + data.glucose : '')+ + (data.glucoseType ? '\n'+translate('Method')+': ' + data.glucoseType : '')+ + (data.carbs ? '\n'+translate('Carbs Given')+': ' + data.carbs : '' )+ + (data.insulin ? '\n'+translate('Insulin Given')+': ' + data.insulin : '')+ + (data.preBolus ? '\n'+translate('Pre Bolus')+': ' + data.preBolus : '')+ + (data.notes ? '\n'+translate('Notes')+': ' + data.notes : '' )+ + (data.enteredBy ? '\n'+translate('Entered By')+': ' + data.enteredBy : '' )+ + ('\n'+translate('Event Time')+': ' + new Date(data.created_at).toLocaleString()) + ); + + if (ok) { + deleteTreatmentRecord(data._id); + delete datastorage[day]; + show(); + } + if (event) event.preventDefault(); + return false; + } + + function deleteTreatmentRecord(_id) { + if (!Nightscout.auth.isAuthenticated()) { + alert(translate('Your device is not authenticated yet')); + return false; + } + + var xhr = new XMLHttpRequest(); + xhr.open('DELETE', '/api/v1/treatments/'+_id, true); + xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); + xhr.setRequestHeader('api-secret', Nightscout.auth.hash()); + xhr.onload = function () { + if (xhr.statusText!='OK') { + alert(translate('Deleting record failed')); + } + } + xhr.send(null); + return true; + } + + function editTreatment(event) { + var data = JSON.parse($(this).attr('data')); + var day = $(this).attr('day'); + + $( '#rp_edittreatmentdialog' ).dialog({ + width: 350 + , height: 500 + , buttons: [ + { text: translate('Save'), + class: 'leftButton', + click: function() { + data.eventType = $('#rp_eventType').val(); + data.glucose = $('#rp_glucoseValue').val(); + data.glucoseType = $('#rp_edittreatmentdialog').find('input[name=rp_bginput]:checked').val(); + data.carbs = $('#rp_carbsGiven').val(); + data.insulin = $('#rp_insulinGiven').val(); + data.notes = $('#rp_adnotes').val(); + data.enteredBy = $('#rp_enteredBy').val(); + data.created_at = Nightscout.utils.mergeInputTime($('#rp_eventTimeValue').val(), $('#rp_eventDateValue').val()); + $( this ).dialog( "close" ); + saveTreatmentRecord(data); + delete datastorage[day]; + show(); + } + }, + { text: translate('Cancel'), + click: function () { $( this ).dialog( "close" ); } + } + ] + , open : function(ev, ui) { + $(this).parent().css('box-shadow', '20px 20px 20px 0px black'); + $(this).parent().find('.ui-dialog-buttonset' ).css({'width':'100%','text-align':'right'}) + $(this).parent().find('button:contains("'+translate('Save')+'")').css({'float':'left'}); + $('#rp_eventType').val(translate(data.eventType)); + $('#rp_glucoseValue').val(data.glucose ? data.glucose : '').attr('placeholder', translate('Value in') + ' ' + serverSettings.units); + $('#rp_bgfromsensor').prop('checked', data.glucoseType === 'Sensor'); + $('#rp_bgfrommeter').prop('checked', data.glucoseType === 'Finger'); + $('#rp_bgmanual').prop('checked', data.glucoseType === 'Manual'); + $('#rp_carbsGiven').val(data.carbs ? data.carbs : ''); + $('#rp_insulinGiven').val(data.insulin ? data.insulin : ''); + $('#rp_adnotes').val(data.notes ? data.notes : ''); + $('#rp_enteredBy').val(data.enteredBy ? data.enteredBy : ''); + $('#rp_eventTimeValue').val(moment(data.created_at).format('HH:mm')); + $('#rp_eventDateValue').val(moment(data.created_at).format('YYYY-MM-DD')); + $('#rp_eventType').focus(); + } + + }); + + if (event) event.preventDefault(); + return false; + } + + function saveTreatmentRecord(data) { + if (!Nightscout.auth.isAuthenticated()) { + alert(translate('Your device is not authenticated yet')); + return false; + } + + + var dataJson = JSON.stringify(data, null, ' '); + + var xhr = new XMLHttpRequest(); + xhr.open('PUT', '/api/v1/treatments/', true); + xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); + xhr.setRequestHeader('api-secret', Nightscout.auth.hash()); + xhr.onload = function () { + if (xhr.statusText!='OK') { + alert(translate('Saving record failed')); + } + } + xhr.send(dataJson); + return true; + } + From e94aa852db717ab86dfb953bce7a3858d011b910 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Thu, 27 Aug 2015 16:52:32 +0200 Subject: [PATCH 003/176] make it at least load without errors --- bower.json | 2 + static/css/report.css | 112 ++++++++++++++++++ static/report/index.html | 6 +- static/report/js/dailystats.js | 8 +- static/report/js/daytoday.js | 35 +++--- static/report/js/glucosedistribution.js | 4 + static/report/js/hourlystats.js | 4 + static/report/js/percentile.js | 10 +- static/report/js/report.js | 149 ++++++++++++++---------- static/report/js/success.js | 4 + static/report/js/treatments.js | 6 +- 11 files changed, 249 insertions(+), 91 deletions(-) create mode 100644 static/css/report.css diff --git a/bower.json b/bower.json index 09f505e7f2e..74e91242d6e 100644 --- a/bower.json +++ b/bower.json @@ -8,6 +8,8 @@ "jQuery-Storage-API": "~1.7.2", "tipsy-jmalonzo": "~1.0.1", "jquery-ui": "~1.11.3", + "jquery-flot": "0.8.3", + "simple-statistics": "0.7.0", "swagger-ui": "~2.1.2" }, "resolutions": { diff --git a/static/css/report.css b/static/css/report.css new file mode 100644 index 00000000000..d311c8d4b58 --- /dev/null +++ b/static/css/report.css @@ -0,0 +1,112 @@ +@import url("//fonts.googleapis.com/css?family=Ubuntu:300,400,500,700,300italic,400italic,500italic,700italic"); +@import url("//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,300,400,600,700,800"); +@import url("/glyphs/css/fontello.css"); + + +html, body { + height: 100%; + margin: 0; + padding: 0; +} +body { + font-family: 'Open Sans', Helvetica, Arial, sans-serif; + background: white; + color: black; +} +.inlinepiechart { + width: 2.0in; + height: 0.9in; +} + +#glucosedistribution-overviewchart { + width: 3.0in; + height: 3in; + float:left; +} +#percentile-chart { + width: 100%; + height: 100%; +} +#hourlystats-overviewchart { + width: 100%; + min-width: 6.5in; + height: 5in; +} +#success-placeholder table td { + border: 1px #ccc solid; + margin: 0; + padding: 1px; +} + +#success-placeholder td.bad { + background-color: #fcc; +} + +#success-placeholder td.good { + background-color: #cfc; +} + +#success-placeholder th:first-child { + width: 30%; +} +#success-placeholder th { + width: 10%; +} +#success-placeholder table { + width: 100%; +} + +table.centeraligned td{ + text-align:center; +} +table.centeraligned th{ + text-align:center; +} +#dailystats-placeholder td.tdborder { + width:80px; + border: 1px #ccc solid; + margin: 0; + padding: 1px; +} +#glucosedistribution-placeholder td.tdborder { + width:80px; + border: 1px #ccc solid; + margin: 0; + padding: 1px; +} + +ul#tabnav { /* general settings */ +text-align: left; /* set to left, right or center */ +margin: 1em 0 1em 0; /* set margins as desired */ +font: bold 11px verdana, arial, sans-serif; /* set font as desired */ +border-bottom: 1px solid #6c6; /* set border COLOR as desired */ +list-style-type: none; +padding: 3px 10px 3px 10px; /* THIRD number must change with respect to padding-top (X) below */ +} + +ul#tabnav li { /* do not change */ +display: inline; +} + +ul#tabnav li{ /* settings for all tab links */ +padding: 3px 4px; /* set padding (tab size) as desired; FIRST number must change with respect to padding-top (X) above */ +border: 1px solid #6c6; /* set border COLOR as desired; usually matches border color specified in #tabnav */ +background-color: #cfc; /* set unselected tab background color as desired */ +color: #666; /* set unselected tab link color as desired */ +margin-right: 0px; /* set additional spacing between tabs as desired */ +text-decoration: none; +border-bottom: none; +} + +ul#tabnav li.selected { /* settings selected tab */ +background: #fff; /* set desired selected color */ +} + +ul#tabnav li:hover { /* settings for hover effect */ +background: #9f9; /* set desired hover color */ +cursor:pointer; +} + +tr.border_bottom td { + border-bottom:1pt solid #eee; +} diff --git a/static/report/index.html b/static/report/index.html index d04be3aac72..76caed95fd7 100644 --- a/static/report/index.html +++ b/static/report/index.html @@ -217,8 +217,7 @@

Calibrations

- - + @@ -227,9 +226,6 @@

Calibrations

- - - diff --git a/static/report/js/dailystats.js b/static/report/js/dailystats.js index 18df7786ea0..ea34bf9cb93 100644 --- a/static/report/js/dailystats.js +++ b/static/report/js/dailystats.js @@ -1,4 +1,8 @@ function report_dailystats(datastorage,daystoshow,options) { + var Nightscout = window.Nightscout; + var client = Nightscout.client; + var translate = client.translate; + var todo = []; // var data = o[0]; // var days = 7; @@ -39,7 +43,7 @@ if (daysRecords.length == 0) { $("
").appendTo(tr); + $("").appendTo(tr); $('').appendTo(tr); table.append(tr); return;; @@ -67,7 +71,7 @@ var bgValues = daysRecords.map(function(r) { return r.sgv; }); $("").appendTo(tr); - $("").appendTo(tr); + $("").appendTo(tr); $("").appendTo(tr); $("").appendTo(tr); $("").appendTo(tr); diff --git a/static/report/js/daytoday.js b/static/report/js/daytoday.js index 371628d15dc..41ec2aaad64 100644 --- a/static/report/js/daytoday.js +++ b/static/report/js/daytoday.js @@ -1,6 +1,10 @@ function report_daytoday(datastorage,daystoshow,options) { - var translate = Nightscout.language.translate; - + var Nightscout = window.Nightscout; + var client = Nightscout.client; + var translate = client.translate; + var profile = client.sbx.data.profile; + var scaledTreatmentBG = Nightscout.reports.scaledTreatmentBG; + var padding = { top: 15, right: 15, bottom: 30, left: 35 }; var FORMAT_TIME_12 = '%I' @@ -12,7 +16,7 @@ function getTimeFormat() { var timeFormat = FORMAT_TIME_12; - if (serverSettings.defaults.timeFormat == '24') { + if (Nightscout.client.settings.timeFormat == '24') { timeFormat = FORMAT_TIME_24; } return timeFormat; @@ -29,8 +33,8 @@ , foodtexts = 0; // Tick Values - if (options.scale == SCALE_LOG) { - if (serverSettings.units == 'mmol') { + if (options.scale == Nightscout.reports.SCALE_LOG) { + if (client.settings.units == 'mmol') { tickValues = [ 2.0 , 3.0 @@ -54,7 +58,7 @@ ]; } } else { - if (serverSettings.units == 'mmol') { + if (client.settings.units == 'mmol') { tickValues = [ 2.0 , 4.0 @@ -85,9 +89,9 @@ } // create svg and g to contain the chart contents - charts = d3.select('#'+containerprefix+day).html( + charts = d3.select('#'+Nightscout.reports.containerprefix+day).html( ''+ - localeDate(day)+ + Nightscout.reports.localeDate(day)+ '
' ).append('svg'); @@ -102,12 +106,12 @@ xScale2 = d3.time.scale() .domain(d3.extent(data.sgv, function (d) { return d.date; })); - if (options.scale == SCALE_LOG) { + if (options.scale == Nightscout.reports.SCALE_LOG) { yScale2 = d3.scale.log() - .domain([scaleBg(36), scaleBg(420)]); + .domain([client.utils.scaleMgdl(36), client.utils.scaleMgdl(420)]); } else { yScale2 = d3.scale.linear() - .domain([scaleBg(36), scaleBg(420)]); + .domain([client.utils.scaleMgdl(36), client.utils.scaleMgdl(420)]); } yInsulinScale = d3.scale.linear() @@ -200,7 +204,7 @@ .attr('cy', function (d) { if (isNaN(d.sgv)) { badData.push(d); - return yScale2(scaleBg(450) + padding.top); + return yScale2(client.utils.scaleMgdl(450) + padding.top); } else { return yScale2(d.sgv) + padding.top; } @@ -233,15 +237,14 @@ var iobpolyline = '', cobpolyline = ''; for (var dt=from; dt < to; dt.add(5, 'minutes')) { if (options.iob) { - var iob = Nightscout.plugins('iob').calcTotal(data.treatments,Nightscout.profile,dt.toDate()).iob; + var iob = Nightscout.plugins('iob').calcTotal(data.treatments,profile,dt.toDate()).iob; if (dt!=from) { iobpolyline += ', '; } iobpolyline += (xScale2(dt) + padding.left) + ',' + (yInsulinScale(iob) + padding.top) + ' '; } if (options.cob) { - var cob = Nightscout.plugins('cob').cobTotal(data.treatments,Nightscout.profile,dt.toDate()).cob; -console.log(dt.toDate().toLocaleTimeString(),cob); + var cob = Nightscout.plugins('cob').cobTotal(data.treatments,profile,dt.toDate()).cob; if (dt!=from) { cobpolyline += ', '; } @@ -308,7 +311,7 @@ console.log(dt.toDate().toLocaleTimeString(),cob); } if (treatment.carbs && options.carbs) { - var ic = Nightscout.profile.getCarbRatio(new Date(treatment.mills)); + var ic = profile.getCarbRatio(new Date(treatment.mills)); context.append('rect') .attr('y',yCarbsScale(treatment.carbs)) .attr('height', chartHeight-yCarbsScale(treatment.carbs)) diff --git a/static/report/js/glucosedistribution.js b/static/report/js/glucosedistribution.js index 16ac13d5d0b..36addc1c5c1 100644 --- a/static/report/js/glucosedistribution.js +++ b/static/report/js/glucosedistribution.js @@ -1,4 +1,8 @@ function report_glucosedistribution(datastorage,daystoshow,options) { + var Nightscout = window.Nightscout; + var client = Nightscout.client; + var translate = client.translate; + var Statician = ss; var report = $("#glucosedistribution-report"); report.empty(); diff --git a/static/report/js/hourlystats.js b/static/report/js/hourlystats.js index 23dd1ce6949..4ad375d7805 100644 --- a/static/report/js/hourlystats.js +++ b/static/report/js/hourlystats.js @@ -1,4 +1,8 @@ function report_hourlystats(datastorage,daystoshow,options) { + var Nightscout = window.Nightscout; + var client = Nightscout.client; + var translate = client.translate; + var report = $("#hourlystats-report"); var stats = []; var pivotedByHour = {}; diff --git a/static/report/js/percentile.js b/static/report/js/percentile.js index 3a22cf19519..77e9374a4ef 100644 --- a/static/report/js/percentile.js +++ b/static/report/js/percentile.js @@ -1,6 +1,10 @@ function report_percentile(datastorage,daystoshow,options) { + var Nightscout = window.Nightscout; + var client = Nightscout.client; + var translate = client.translate; + var Statician = ss; - var window = 30; //minute-window should be a divisor of 60 + var minutewindow = 30; //minute-window should be a divisor of 60 var data = []; var days = 0; @@ -11,14 +15,14 @@ var bins = []; for (hour = 0; hour < 24; hour++) { - for (minute = 0; minute < 60; minute = minute + window) { + for (minute = 0; minute < 60; minute = minute + minutewindow) { var date = new Date(); date.setHours(hour); date.setMinutes(minute); var readings = data.filter(function(record) { var recdate = new Date(record.displayTime); return recdate.getHours() == hour && recdate.getMinutes() >= minute && - recdate.getMinutes() < minute + window;; + recdate.getMinutes() < minute + minutewindow; }); readings = readings.map(function(record) { return record.sgv; diff --git a/static/report/js/report.js b/static/report/js/report.js index b63828ab9aa..a6f9f17df63 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -1,10 +1,24 @@ +(function () { 'use strict'; - - var translate = Nightscout.language.translate; + //for the tests window isn't the global object + var $ = window.$; + var _ = window._; + var moment = window.moment; + var Nightscout = window.Nightscout; + var client = Nightscout.client; + + Nightscout.reports = Nightscout.reports || {}; + + if (serverSettings === undefined) { + console.error('server settings were not loaded, will not call init'); + } else { + client.init(serverSettings, Nightscout.plugins); + } + + var translate = client.translate; var maxInsulinValue = 0 ,maxCarbsValue = 0; - var containerprefix = 'chart-'; var maxdays = 3 * 31; var datastorage = {}; var daystoshow = {}; @@ -18,9 +32,9 @@ ONE_MIN_IN_MS = 60000 , SIX_MINS_IN_MS = 360000; - var - SCALE_LINEAR = 0 - , SCALE_LOG = 1; + Nightscout.reports.SCALE_LINEAR = 0; + Nightscout.reports.SCALE_LOG = 1; + Nightscout.reports.containerprefix = 'chart-'; var categories = []; @@ -60,44 +74,56 @@ return color; } - $('#info').html(''+translate('Loading profile')+' ...'); - $.ajax('/api/v1/profile', { - success: function (record) { - Nightscout.profile.loadData(record); + $('#info').html(''+translate('Loading food database')+' ...'); + $.ajax('/api/v1/food/regular.json', { + success: function foodLoadSuccess(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; + }); + fillForm(); } }).done(function() { - $('#info').html(''+translate('Loading food database')+' ...'); - $.ajax('/api/v1/food/regular.json', { - 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; - }); - fillForm(); - } - }).done(function() { - $('#info').html(''); - $('.presetdates').click(function(e) { var days = $(this).attr('days'); setDataRange(e,days); }); - - $('#rp_show').click(show); - $('#rp_food').change(function (event) { - event.preventDefault(); - $('#rp_enablefood').prop('checked',true); - }); - $('#rp_notes').change(function (event) { - event.preventDefault(); - $('#rp_enablenotes').prop('checked',true); - }); - - $('#rp_targetlow').val(targetBGdefault[serverSettings.units].low); - $('#rp_targethigh').val(targetBGdefault[serverSettings.units].high); - - $('.menutab').click(switchtab); + $('#info').html(''); + $('.presetdates').click(function(e) { var days = $(this).attr('days'); setDataRange(e,days); }); - setDataRange(null,7); - - }); + $('#rp_show').click(show); + $('#rp_food').change(function (event) { + event.preventDefault(); + $('#rp_enablefood').prop('checked',true); + }); + $('#rp_notes').change(function (event) { + event.preventDefault(); + $('#rp_enablenotes').prop('checked',true); + }); + + $('#rp_targetlow').val(targetBGdefault[client.settings.units].low); + $('#rp_targethigh').val(targetBGdefault[client.settings.units].high); + + $('.menutab').click(switchtab); + + setDataRange(null,7); + }).fail(function() { + $('#info').html(''); + $('.presetdates').click(function(e) { var days = $(this).attr('days'); setDataRange(e,days); }); + + $('#rp_show').click(show); + $('#rp_food').change(function (event) { + event.preventDefault(); + $('#rp_enablefood').prop('checked',true); + }); + $('#rp_notes').change(function (event) { + event.preventDefault(); + $('#rp_enablenotes').prop('checked',true); + }); + + $('#rp_targetlow').val(targetBGdefault[client.settings.units].low); + $('#rp_targethigh').val(targetBGdefault[client.settings.units].high); + + $('.menutab').click(switchtab); + + setDataRange(null,7); }); function show(event) { @@ -113,7 +139,7 @@ carbs: true, iob : true, cob : true, - scale: SCALE_LINEAR + scale: Nightscout.reports.SCALE_LINEAR }; options.targetLow = parseFloat($('#rp_targetlow').val().replace(',','.')); @@ -125,7 +151,7 @@ options.food = $('#rp_optionsfood').is(':checked'); options.insulin = $('#rp_optionsinsulin').is(':checked'); options.carbs = $('#rp_optionscarbs').is(':checked'); - options.scale = $('#rp_linear').is(':checked') ? SCALE_LINEAR : SCALE_LOG; + options.scale = $('#rp_linear').is(':checked') ? Nightscout.reports.SCALE_LINEAR : Nightscout.reports.SCALE_LOG; options.width = parseInt($('#rp_size :selected').attr('x')); options.height = parseInt($('#rp_size :selected').attr('y')); @@ -328,7 +354,7 @@ } - function localeDate(day) { + Nightscout.reports.localeDate = function localeDate(day) { var ret = [translate("Sunday"),translate("Monday"),translate("Tuesday"),translate("Wednesday"),translate("Thursday"),translate("Friday"),translate("Saturday")][new Date(day).getDay()]; ret += ' '; @@ -336,7 +362,7 @@ return ret; } - function localeDateTime(day) { + Nightscout.reports.localeDateTime = function localeDateTime(day) { var ret = new Date(day).toLocaleDateString() + ' ' + new Date(day).toLocaleTimeString(); return ret; } @@ -359,7 +385,7 @@ var to = from + 1000 * 60 * 60 * 24; var query = '?find[date][$gte]='+from+'&find[date][$lt]='+to+'&count=10000'; - $('#'+containerprefix+day).html(''+translate('Loading CGM data of')+' '+day+' ...'); + $('#'+Nightscout.reports.containerprefix+day).html(''+translate('Loading CGM data of')+' '+day+' ...'); $.ajax('/api/v1/entries.json'+query, { success: function (xhr) { xhr.forEach(function (element) { @@ -396,6 +422,7 @@ }); // sometimes cgm contains duplicates. uniq it. data.sgv = cgmData.slice(); +console.log(data.sgv); data.sgv.sort(function(a, b) { return a.x - b.x; }); var lastDate = 0; data.sgv = data.sgv.filter(function(d) { @@ -409,7 +436,7 @@ data.cal.sort(function(a, b) { return a.x - b.x; }); } }).done(function () { - $('#'+containerprefix+day).html(''+translate('Loading treatments data of')+' '+day+' ...'); + $('#'+Nightscout.reports.containerprefix+day).html(''+translate('Loading treatments data of')+' '+day+' ...'); var tquery = '?find[created_at][$gte]='+new Date(from).toISOString()+'&find[created_at][$lt]='+new Date(to).toISOString(); $.ajax('/api/v1/treatments.json'+tquery, { success: function (xhr) { @@ -422,7 +449,7 @@ data.treatments.sort(function(a, b) { return a.mills - b.mills; }); } }).done(function () { - $('#'+containerprefix+day).html(''+translate('Processing data of')+' '+day+' ...'); + $('#'+Nightscout.reports.containerprefix+day).html(''+translate('Processing data of')+' '+day+' ...'); processData(data,day,options); }); @@ -442,16 +469,16 @@ temp1 = data.sgv.map(function (entry) { var noise = entry.noise || 0; var rawBg = rawIsigToRawBg(entry, cal); - return { x: entry.x, date: new Date(entry.x - 2 * 1000), y: rawBg, sgv: scaleBg(rawBg), color: 'gray', type: 'rawbg', filtered: entry.filtered, unfiltered: entry.unfiltered } + return { x: entry.x, date: new Date(entry.x - 2 * 1000), y: rawBg, sgv: client.utils.scaleMgdl(rawBg), color: 'gray', type: 'rawbg', filtered: entry.filtered, unfiltered: entry.unfiltered } }).filter(function(entry) { return entry.y > 0}); } var temp2 = data.sgv.map(function (obj) { - return { x: obj.x, date: new Date(obj.x), y: obj.y, sgv: scaleBg(obj.y), color: sgvToColor(scaleBg(obj.y),options), type: 'sgv', noise: obj.noise, filtered: obj.filtered, unfiltered: obj.unfiltered} + return { x: obj.x, date: new Date(obj.x), y: obj.y, sgv: client.utils.scaleMgdl(obj.y), color: sgvToColor(client.utils.scaleMgdl(obj.y),options), type: 'sgv', noise: obj.noise, filtered: obj.filtered, unfiltered: obj.unfiltered} }); data.sgv = [].concat(temp1, temp2); //Add MBG's also, pretend they are SGV's - data.sgv = data.sgv.concat(data.mbg.map(function (obj) { return { date: new Date(obj.x), y: obj.y, sgv: scaleBg(obj.y), color: 'red', type: 'mbg', device: obj.device } })); + data.sgv = data.sgv.concat(data.mbg.map(function (obj) { return { date: new Date(obj.x), y: obj.y, sgv: client.utils.scaleMgdl(obj.y), color: 'red', type: 'mbg', device: obj.device } })); // make sure data range will be exactly 24h var from = new Date(new Date(day).getTime() + (new Date().getTimezoneOffset()*60*1000)); @@ -550,7 +577,7 @@ if (event) event.preventDefault(); } - function scaledTreatmentBG(treatment,data) { + Nightscout.reports.scaledTreatmentBG = function scaledTreatmentBG(treatment,data) { var SIX_MINS_IN_MS = 360000; @@ -576,15 +603,15 @@ if (treatment.glucose && isNaN(treatment.glucose)) { console.warn('found an invalid glucose value', treatment); } else { - if (treatment.glucose && treatment.units && serverSettings.units) { - if (treatment.units != serverSettings.units) { - console.info('found mismatched glucose units, converting ' + treatment.units + ' into ' + serverSettings.units, treatment); + if (treatment.glucose && treatment.units && client.settings.units) { + if (treatment.units != client.settings.units) { + console.info('found mismatched glucose units, converting ' + treatment.units + ' into ' + client.settings.units, treatment); if (treatment.units == 'mmol') { //BG is in mmol and display in mg/dl treatmentGlucose = Math.round(treatment.glucose * 18) } else { //BG is in mg/dl and display in mmol - treatmentGlucose = scaleBg(treatment.glucose); + treatmentGlucose = client.utils.scaleMgdl(treatment.glucose); } } else { treatmentGlucose = treatment.glucose; @@ -596,13 +623,7 @@ } } - return treatmentGlucose || scaleBg(calcBGByTime(treatment.mills)); + return treatmentGlucose || client.utils.scaleMgdl(calcBGByTime(treatment.mills)); } - function scaleBg(bg) { - if (serverSettings.units === 'mmol') { - return Nightscout.units.mgdlToMMOL(bg); - } else { - return bg; - } - } +})(); \ No newline at end of file diff --git a/static/report/js/success.js b/static/report/js/success.js index 85311b42624..20a120d892f 100644 --- a/static/report/js/success.js +++ b/static/report/js/success.js @@ -1,4 +1,8 @@ function report_success(datastorage,daystoshow,options) { + var Nightscout = window.Nightscout; + var client = Nightscout.client; + var translate = client.translate; + var low = parseInt(options.targetLow), high = parseInt(options.targetHigh); diff --git a/static/report/js/treatments.js b/static/report/js/treatments.js index 0f2f5ab0eef..91649ea01c7 100644 --- a/static/report/js/treatments.js +++ b/static/report/js/treatments.js @@ -1,4 +1,8 @@ function report_treatments(datastorage,daystoshow,options) { + var Nightscout = window.Nightscout; + var client = Nightscout.client; + var translate = client.translate; + var icon_remove = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACrElEQVQ4T42Ty2sTQRzHv5tmk2yyjRNtpfZhL8V6s2KoUNC2XqwgaCsVQcGiFqpHi0c9iRdR/ANE9KR40FIQX4cueKoPaKFoLdSYNtE0abKT1+5s9iW7aUMiHtzTzO7v85md+c6PA4DrHbsPCKIgOWO1pA7dT6YXnXH949SE/F63pqwZtRrO+SCKgjQ5NUV+azpmHj2krMwaJC4c8Erj+/eRyloMMwWFKgbn1nC3ervlK1evkXBLGBZT8SOewotnTylTNLdgeg/pDgZDC2cPHSR8bB22DVC9hFe0SG/H0xFXcHlykjRHRDBWgJcZSCY38Xx2lhqMnRYE34Px/sN9vlQWeoHBAx2yXsRruVAVuFsIBaSJ8+eJGPaBqQV4NROJjTzez89jLBoFn6FgybQL54wS3uTyVDFQ3cL2IYpBv3RhdJSIIQ80tQyv7gEqJvS8AmUlBs7UXPhtjtZgh3UFNYngk86NHCfNAg9dMwHVBPu+CpsVkTXKeJeVG+AGgTOZ3tt6MSKKjy+NjEBjFrR4ElZmA4pdxstMFsyyJu6tZZ7Ux9vwB6EAL50ZGiRECEPPUOixVTRxHlicgSVWxEdZpuZWfNuS2hk48NjwMIkIYZglBnV5Cbqtws/5IaAJmsfCglrEl2y2QeKmEBJ80tixKmxrFpSVr0gV0viQoxho2YUuPohmeFD22PiklLC4ma5JuBvdrfLJI0dJd0s7bM0ES8aR/BXDXGaTskqlL+D3Lwy0tZEePoAd4EA5YF4tYymdonfjmQh3s6dTPjU4SHYGwjAKecSXFyGlM1TdytntE56T+ts7SC/vhw3gm6njc2Kd3vm5Ub1IwQAvnYhGiZpYw1wiWYPrIw7wnBTt7CLOOwdmut14kQQvqt24tfK/utGR6LaF+iRqMf4N/O/8D28HiiCRYqzAAAAAAElFTkSuQmCC"; var icon_edit = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABEUlEQVQ4jZ3MMUsCYQDG8ee8IySQbNCLyyEKG/RLNAXicqvQcAeNLrcFLlE0+xHuNpt8wy04rrYm8Q4HQRE56BSC3lSqU1BwCoxM39dnffj9BWyxXvVeEzvtctBwHyRebNu2Nk2lzMlrgJB+qBEeTByiKYpihl+fIO8jTI9PDJEVF1+K2iw+M6PhDuyag4NkQi/c3FkCK5Z3ZbM76qLltpCbn+vXxq0FABsDy9hzPdBvqvtXvvXzrw1swmsDLPjfACteGeDBfwK8+FdgGwwAIgC0ncsjxGRSH/eiPBgAJADY2z8sJ4JBfNBsDqlADVYMANIzKalv/bHaefKsTH9iPFb8ISsGAJym0+Qinz3jQktbAHcxvx3559eSAAAAAElFTkSuQmCC"; @@ -6,7 +10,7 @@ table += ''; Object.keys(daystoshow).forEach(function (day) { - table += ''; + table += ''; var treatments = datastorage[day].treatments; for (var t=0; t Date: Fri, 28 Aug 2015 18:28:42 +0200 Subject: [PATCH 004/176] some renames --- static/report/index.html | 2 +- static/report/js/report.js | 64 ++++++++++++++++++++------------------ 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/static/report/index.html b/static/report/index.html index 76caed95fd7..e8442d93be0 100644 --- a/static/report/index.html +++ b/static/report/index.html @@ -6,7 +6,7 @@ -

Nightscout

+

Nightscout reporting

    diff --git a/static/report/js/report.js b/static/report/js/report.js index a6f9f17df63..a18f2b20c6d 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -14,7 +14,7 @@ } else { client.init(serverSettings, Nightscout.plugins); } - + var translate = client.translate; var maxInsulinValue = 0 @@ -37,8 +37,8 @@ Nightscout.reports.containerprefix = 'chart-'; - var categories = []; - var foodlist = []; + var food_categories = []; + var food_list = []; @@ -78,11 +78,11 @@ $.ajax('/api/v1/food/regular.json', { success: function foodLoadSuccess(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; + food_list.push(r); + if (r.category && !food_categories[r.category]) food_categories[r.category] = {}; + if (r.category && r.subcategory) food_categories[r.category][r.subcategory] = true; }); - fillForm(); + fillFoodForm(); } }).done(function() { $('#info').html(''); @@ -101,7 +101,7 @@ $('#rp_targetlow').val(targetBGdefault[client.settings.units].low); $('#rp_targethigh').val(targetBGdefault[client.settings.units].high); - $('.menutab').click(switchtab); + $('.menutab').click(switchreport_handler); setDataRange(null,7); }).fail(function() { @@ -121,7 +121,7 @@ $('#rp_targetlow').val(targetBGdefault[client.settings.units].low); $('#rp_targethigh').val(targetBGdefault[client.settings.units].high); - $('.menutab').click(switchtab); + $('.menutab').click(switchreport_handler); setDataRange(null,7); }); @@ -343,7 +343,7 @@ if (event) event.preventDefault(); } - function switchtab(event) { + function switchreport_handler(event) { var id = $(this).attr('id'); $('.menutab').removeClass('selected'); @@ -386,8 +386,10 @@ var query = '?find[date][$gte]='+from+'&find[date][$lt]='+to+'&count=10000'; $('#'+Nightscout.reports.containerprefix+day).html(''+translate('Loading CGM data of')+' '+day+' ...'); +console.log('/api/v1/entries.json'+query); $.ajax('/api/v1/entries.json'+query, { success: function (xhr) { +console.log(xhr); xhr.forEach(function (element) { if (element) { if (element.mbg) { @@ -516,31 +518,31 @@ console.log(data.sgv); // Filtering food code // ------------------- - var categories = []; - var foodlist = []; + var food_categories = []; + var food_list = []; var filter = { category: '' , subcategory: '' , name: '' }; - function fillForm(event) { + function fillFoodForm(event) { $('#rp_category').empty().append(new Option(translate('(none)'),'')); - for (var s in categories) { + for (var s in food_categories) { $('#rp_category').append(new Option(s,s)); } filter.category = ''; - fillSubcategories(); + fillFoodSubcategories(); - $('#rp_category').change(fillSubcategories); - $('#rp_subcategory').change(doFilter); - $('#rp_name').on('input',doFilter); + $('#rp_category').change(fillFoodSubcategories); + $('#rp_subcategory').change(doFoodFilter); + $('#rp_name').on('input',doFoodFilter); if (event) event.preventDefault(); return false; } - function fillSubcategories(event) { + function fillFoodSubcategories(event) { if (event) { event.preventDefault(); } @@ -548,30 +550,30 @@ console.log(data.sgv); filter.subcategory = ''; $('#rp_subcategory').empty().append(new Option(translate('(none)'),'')); if (filter.category != '') { - for (var s in categories[filter.category]) { + for (var s in food_categories[filter.category]) { $('#rp_subcategory').append(new Option(s,s)); } } - doFilter(); + doFoodFilter(); } - function doFilter(event) { + function doFoodFilter(event) { if (event) { filter.category = $('#rp_category').val(); filter.subcategory = $('#rp_subcategory').val(); filter.name = $('#rp_name').val(); } $('#rp_food').empty(); - for (var i=0; i Date: Fri, 28 Aug 2015 21:24:00 +0200 Subject: [PATCH 005/176] make reports plugins --- bundle/bundle.source.js | 1 + .../js => lib/report_plugins}/calibrations.js | 33 +- .../js => lib/report_plugins}/dailystats.js | 22 +- .../js => lib/report_plugins}/daytoday.js | 30 +- .../report_plugins}/glucosedistribution.js | 17 +- .../js => lib/report_plugins}/hourlystats.js | 17 +- lib/report_plugins/index.js | 45 +++ .../js => lib/report_plugins}/percentile.js | 35 +- .../js => lib/report_plugins}/success.js | 105 +++--- .../js => lib/report_plugins}/treatments.js | 89 +++-- lib/report_plugins/utils.js | 73 +++++ static/report/index.html | 8 - static/report/js/report.js | 310 +++++++----------- 13 files changed, 477 insertions(+), 308 deletions(-) rename {static/report/js => lib/report_plugins}/calibrations.js (94%) rename {static/report/js => lib/report_plugins}/dailystats.js (87%) rename {static/report/js => lib/report_plugins}/daytoday.js (95%) rename {static/report/js => lib/report_plugins}/glucosedistribution.js (93%) rename {static/report/js => lib/report_plugins}/hourlystats.js (93%) create mode 100644 lib/report_plugins/index.js rename {static/report/js => lib/report_plugins}/percentile.js (82%) rename {static/report/js => lib/report_plugins}/success.js (64%) rename {static/report/js => lib/report_plugins}/treatments.js (70%) create mode 100644 lib/report_plugins/utils.js diff --git a/bundle/bundle.source.js b/bundle/bundle.source.js index f9c9e195411..0a6eaee0058 100644 --- a/bundle/bundle.source.js +++ b/bundle/bundle.source.js @@ -8,6 +8,7 @@ window.Nightscout = { client: require('../lib/client') , plugins: require('../lib/plugins/')().registerClientDefaults() + , report_plugins: require('../lib/report_plugins/')() }; console.info('Nightscout bundle ready'); diff --git a/static/report/js/calibrations.js b/lib/report_plugins/calibrations.js similarity index 94% rename from static/report/js/calibrations.js rename to lib/report_plugins/calibrations.js index c66275e4968..02692de8236 100644 --- a/static/report/js/calibrations.js +++ b/lib/report_plugins/calibrations.js @@ -1,4 +1,19 @@ -function report_calibrations(datastorage,daystoshow,options) { +'use strict'; + +var calibrations = { + name: 'calibrations' + , label: 'Calibrations' + , pluginType: 'report' +}; + +function init() { + return calibrations; +} + +module.exports = init; + + +calibrations.report = function report_calibrations(datastorage,daystoshow,options) { var padding = { top: 15, right: 15, bottom: 30, left: 70 }; var treatments = []; Object.keys(daystoshow).forEach(function (day) { @@ -147,17 +162,13 @@ function report_calibrations(datastorage,daystoshow,options) { .domain([0,400000]); var xAxis2 = d3.svg.axis() - .scale(xScale2) -// .tickFormat(d3.time.format(getTimeFormat(true))) - .ticks(10) - .orient('bottom'); + .scale(xScale2) + .ticks(10) + .orient('bottom'); - yAxis2 = d3.svg.axis() - .scale(yScale2) -// .tickFormat(d3.format('d')) -// .tickValues(tickValues) -// .orient('right'); - .orient('left'); + var yAxis2 = d3.svg.axis() + .scale(yScale2) + .orient('left'); // get current data range var dataRange = [0,maxBG]; diff --git a/static/report/js/dailystats.js b/lib/report_plugins/dailystats.js similarity index 87% rename from static/report/js/dailystats.js rename to lib/report_plugins/dailystats.js index ea34bf9cb93..7fd3b48756e 100644 --- a/static/report/js/dailystats.js +++ b/lib/report_plugins/dailystats.js @@ -1,7 +1,23 @@ - function report_dailystats(datastorage,daystoshow,options) { +'use strict'; + +var dailystats = { + name: 'dailystats' + , label: 'Dailystats' + , pluginType: 'report' +}; + +function init() { + return dailystats; +} + +module.exports = init; + + +dailystats.report = function report_dailystats(datastorage,daystoshow,options) { var Nightscout = window.Nightscout; var client = Nightscout.client; var translate = client.translate; + var report_plugins = Nightscout.report_plugins; var todo = []; // var data = o[0]; @@ -43,7 +59,7 @@ if (daysRecords.length == 0) { $("
").appendTo(tr); + $("").appendTo(tr); $('').appendTo(tr); table.append(tr); return;; @@ -71,7 +87,7 @@ var bgValues = daysRecords.map(function(r) { return r.sgv; }); $("").appendTo(tr); - $("").appendTo(tr); + $("").appendTo(tr); $("").appendTo(tr); $("").appendTo(tr); $("").appendTo(tr); diff --git a/static/report/js/daytoday.js b/lib/report_plugins/daytoday.js similarity index 95% rename from static/report/js/daytoday.js rename to lib/report_plugins/daytoday.js index 41ec2aaad64..1ca56a6be8c 100644 --- a/static/report/js/daytoday.js +++ b/lib/report_plugins/daytoday.js @@ -1,16 +1,32 @@ - function report_daytoday(datastorage,daystoshow,options) { +'use strict'; + +var daytoday = { + name: 'daytoday' + , label: 'Daytoday' + , pluginType: 'report' +}; + +function init() { + return daytoday; +} + +module.exports = init; + + +daytoday.report = function report_daytoday(datastorage,daystoshow,options) { var Nightscout = window.Nightscout; var client = Nightscout.client; var translate = client.translate; var profile = client.sbx.data.profile; - var scaledTreatmentBG = Nightscout.reports.scaledTreatmentBG; + var report_plugins = Nightscout.report_plugins; + var scaledTreatmentBG = report_plugins.utils.scaledTreatmentBG; var padding = { top: 15, right: 15, bottom: 30, left: 35 }; var FORMAT_TIME_12 = '%I' , FORMAT_TIME_24 = '%H'; - for (day in daystoshow) { + for (var day in daystoshow) { drawChart(day,datastorage[day],options); } @@ -33,7 +49,7 @@ , foodtexts = 0; // Tick Values - if (options.scale == Nightscout.reports.SCALE_LOG) { + if (options.scale == report_plugins.getProperty('SCALE_LOG')) { if (client.settings.units == 'mmol') { tickValues = [ 2.0 @@ -89,9 +105,9 @@ } // create svg and g to contain the chart contents - charts = d3.select('#'+Nightscout.reports.containerprefix+day).html( + charts = d3.select('#'+report_plugins.getProperty('containerprefix')+day).html( ''+ - Nightscout.reports.localeDate(day)+ + report_plugins.utils.localeDate(day)+ '
' ).append('svg'); @@ -106,7 +122,7 @@ xScale2 = d3.time.scale() .domain(d3.extent(data.sgv, function (d) { return d.date; })); - if (options.scale == Nightscout.reports.SCALE_LOG) { + if (options.scale == report_plugins.getProperty('SCALE_LOG')) { yScale2 = d3.scale.log() .domain([client.utils.scaleMgdl(36), client.utils.scaleMgdl(420)]); } else { diff --git a/static/report/js/glucosedistribution.js b/lib/report_plugins/glucosedistribution.js similarity index 93% rename from static/report/js/glucosedistribution.js rename to lib/report_plugins/glucosedistribution.js index 36addc1c5c1..ab7fa77ef3a 100644 --- a/static/report/js/glucosedistribution.js +++ b/lib/report_plugins/glucosedistribution.js @@ -1,4 +1,19 @@ - function report_glucosedistribution(datastorage,daystoshow,options) { +'use strict'; + +var glucosedistribution = { + name: 'glucosedistribution' + , label: 'Glucose distribution' + , pluginType: 'report' +}; + +function init() { + return glucosedistribution; +} + +module.exports = init; + + +glucosedistribution.report = function report_glucosedistribution(datastorage,daystoshow,options) { var Nightscout = window.Nightscout; var client = Nightscout.client; var translate = client.translate; diff --git a/static/report/js/hourlystats.js b/lib/report_plugins/hourlystats.js similarity index 93% rename from static/report/js/hourlystats.js rename to lib/report_plugins/hourlystats.js index 4ad375d7805..3a9cc33434d 100644 --- a/static/report/js/hourlystats.js +++ b/lib/report_plugins/hourlystats.js @@ -1,4 +1,19 @@ - function report_hourlystats(datastorage,daystoshow,options) { +'use strict'; + +var hourlystats = { + name: 'hourlystats' + , label: 'Hourly stats' + , pluginType: 'report' +}; + +function init() { + return hourlystats; +} + +module.exports = init; + + +hourlystats.report = function report_hourlystats(datastorage,daystoshow,options) { var Nightscout = window.Nightscout; var client = Nightscout.client; var translate = client.translate; diff --git a/lib/report_plugins/index.js b/lib/report_plugins/index.js new file mode 100644 index 00000000000..f7ff151e9ab --- /dev/null +++ b/lib/report_plugins/index.js @@ -0,0 +1,45 @@ +'use strict'; + +var _ = require('lodash'); + +function init() { + + var properties = {} + , allPlugins = [ + require('./daytoday')() + , require('./dailystats')() + , require('./glucosedistribution')() + , require('./hourlystats')() + , require('./percentile')() + , require('./success')() + , require('./calibrations')() + , require('./treatments')() + ]; + + function plugins(name) { + if (name) { + return _.find(allPlugins, {name: name}); + } else { + return plugins; + } + } + + plugins.eachPlugin = function eachPlugin(f) { + _.each(allPlugins, f); + }; + + plugins.setProperty = function setProperty(p, val) { + properties[p] = val; + }; + + plugins.getProperty = function getProperty(p) { + return properties[p]; + }; + + plugins.utils = require('./utils')(); + + return plugins(); + +} + +module.exports = init; \ No newline at end of file diff --git a/static/report/js/percentile.js b/lib/report_plugins/percentile.js similarity index 82% rename from static/report/js/percentile.js rename to lib/report_plugins/percentile.js index 77e9374a4ef..d0f781bb741 100644 --- a/static/report/js/percentile.js +++ b/lib/report_plugins/percentile.js @@ -1,4 +1,19 @@ - function report_percentile(datastorage,daystoshow,options) { +'use strict'; + +var percentile = { + name: 'percentile' + , label: 'Percentile' + , pluginType: 'report' +}; + +function init() { + return percentile; +} + +module.exports = init; + + +percentile.report = function report_percentile(datastorage,daystoshow,options) { var Nightscout = window.Nightscout; var client = Nightscout.client; var translate = client.translate; @@ -14,8 +29,8 @@ }); var bins = []; - for (hour = 0; hour < 24; hour++) { - for (minute = 0; minute < 60; minute = minute + minutewindow) { + for (var hour = 0; hour < 24; hour++) { + for (var minute = 0; minute < 60; minute = minute + minutewindow) { var date = new Date(); date.setHours(hour); date.setMinutes(minute); @@ -32,23 +47,23 @@ //readings.forEach(function(x){console.log(x)}); } } - dat10 = bins.map(function(bin) { + var dat10 = bins.map(function(bin) { return [bin[0], ss.quantile(bin[1], 0.1)]; }); - dat25 = bins.map(function(bin) { + var dat25 = bins.map(function(bin) { return [bin[0], ss.quantile(bin[1], 0.25)]; }); - dat50 = bins.map(function(bin) { + var dat50 = bins.map(function(bin) { return [bin[0], ss.quantile(bin[1], 0.5)]; }); - dat75 = bins.map(function(bin) { + var dat75 = bins.map(function(bin) { return [bin[0], ss.quantile(bin[1], 0.75)]; }); - dat90 = bins.map(function(bin) { + var dat90 = bins.map(function(bin) { return [bin[0], ss.quantile(bin[1], 0.9)]; }); - high = options.targetHigh; - low = options.targetLow; + var high = options.targetHigh; + var low = options.targetLow; //dat50.forEach(function(x){console.log(x[0] + " - " + x[1])}); $.plot( "#percentile-chart", [{ diff --git a/static/report/js/success.js b/lib/report_plugins/success.js similarity index 64% rename from static/report/js/success.js rename to lib/report_plugins/success.js index 20a120d892f..6e0d9ec037e 100644 --- a/static/report/js/success.js +++ b/lib/report_plugins/success.js @@ -1,4 +1,19 @@ -function report_success(datastorage,daystoshow,options) { +'use strict'; + +var success = { + name: 'success' + , label: 'Success' + , pluginType: 'report' +}; + +function init() { + return success; +} + +module.exports = init; + + +success.report = function report_success(datastorage,daystoshow,options) { var Nightscout = window.Nightscout; var client = Nightscout.client; var translate = client.translate; @@ -33,7 +48,7 @@ function report_success(datastorage,daystoshow,options) { var dim = function(n) { var a = []; - for (i = 0; i < n; i++) { + for (var i = 0; i < n; i++) { a[i]=0; } return a; @@ -52,51 +67,47 @@ function report_success(datastorage,daystoshow,options) { upperQuartile: 0, average: 0 }; - try { - quarters = dim(quarters).map(function(blank, n) { - var starting = new Date(now - (n+1) * period), - ending = new Date(now - n * period); - return { - starting: starting, - ending: ending, - records: data.filter(function(record) { - return record.displayTime > starting && record.displayTime <= ending; - }) - }; - }).filter(function(quarter) { - return quarter.records.length > 0; - }).map(function(quarter, ix, all) { - var bgValues = quarter.records.map(function(record) { - return record.sgv; - }); - quarter.standardDeviation = ss.standard_deviation(bgValues); - quarter.average = bgValues.length > 0? (sum(bgValues) / bgValues.length): "N/A"; - quarter.lowerQuartile = ss.quantile(bgValues, 0.25); - quarter.upperQuartile = ss.quantile(bgValues, 0.75); - quarter.numberLow = bgValues.filter(function(bg) { - return bg < low; - }).length; - quarter.numberHigh = bgValues.filter(function(bg) { - return bg >= high; - }).length; - quarter.numberInRange = bgValues.length - (quarter.numberHigh + quarter.numberLow); - - quarter.percentLow = (quarter.numberLow / bgValues.length) * 100; - quarter.percentInRange = (quarter.numberInRange / bgValues.length) * 100; - quarter.percentHigh = (quarter.numberHigh / bgValues.length) * 100; - - averages.percentLow += quarter.percentLow / all.length; - averages.percentInRange += quarter.percentInRange / all.length; - averages.percentHigh += quarter.percentHigh / all.length; - averages.lowerQuartile += quarter.lowerQuartile / all.length; - averages.upperQuartile += quarter.upperQuartile / all.length; - averages.average += quarter.average / all.length; - averages.standardDeviation += quarter.standardDeviation / all.length; - return quarter; - }); - } catch (e) { - console.log(e); - } + quarters = dim(quarters).map(function(blank, n) { + var starting = new Date(now - (n+1) * period), + ending = new Date(now - n * period); + return { + starting: starting, + ending: ending, + records: data.filter(function(record) { + return record.displayTime > starting && record.displayTime <= ending; + }) + }; + }).filter(function(quarter) { + return quarter.records.length > 0; + }).map(function(quarter, ix, all) { + var bgValues = quarter.records.map(function(record) { + return record.sgv; + }); + quarter.standardDeviation = ss.standard_deviation(bgValues); + quarter.average = bgValues.length > 0? (sum(bgValues) / bgValues.length): "N/A"; + quarter.lowerQuartile = ss.quantile(bgValues, 0.25); + quarter.upperQuartile = ss.quantile(bgValues, 0.75); + quarter.numberLow = bgValues.filter(function(bg) { + return bg < low; + }).length; + quarter.numberHigh = bgValues.filter(function(bg) { + return bg >= high; + }).length; + quarter.numberInRange = bgValues.length - (quarter.numberHigh + quarter.numberLow); + + quarter.percentLow = (quarter.numberLow / bgValues.length) * 100; + quarter.percentInRange = (quarter.numberInRange / bgValues.length) * 100; + quarter.percentHigh = (quarter.numberHigh / bgValues.length) * 100; + + averages.percentLow += quarter.percentLow / all.length; + averages.percentInRange += quarter.percentInRange / all.length; + averages.percentHigh += quarter.percentHigh / all.length; + averages.lowerQuartile += quarter.lowerQuartile / all.length; + averages.upperQuartile += quarter.upperQuartile / all.length; + averages.average += quarter.average / all.length; + averages.standardDeviation += quarter.standardDeviation / all.length; + return quarter; + }); var lowComparison = function(quarter, averages, field, invert) { if (quarter[field] < averages[field] * 0.8) { diff --git a/static/report/js/treatments.js b/lib/report_plugins/treatments.js similarity index 70% rename from static/report/js/treatments.js rename to lib/report_plugins/treatments.js index 91649ea01c7..dcef65abb22 100644 --- a/static/report/js/treatments.js +++ b/lib/report_plugins/treatments.js @@ -1,41 +1,20 @@ - function report_treatments(datastorage,daystoshow,options) { - var Nightscout = window.Nightscout; - var client = Nightscout.client; - var translate = client.translate; +'use strict'; - var icon_remove = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACrElEQVQ4T42Ty2sTQRzHv5tmk2yyjRNtpfZhL8V6s2KoUNC2XqwgaCsVQcGiFqpHi0c9iRdR/ANE9KR40FIQX4cueKoPaKFoLdSYNtE0abKT1+5s9iW7aUMiHtzTzO7v85md+c6PA4DrHbsPCKIgOWO1pA7dT6YXnXH949SE/F63pqwZtRrO+SCKgjQ5NUV+azpmHj2krMwaJC4c8Erj+/eRyloMMwWFKgbn1nC3ervlK1evkXBLGBZT8SOewotnTylTNLdgeg/pDgZDC2cPHSR8bB22DVC9hFe0SG/H0xFXcHlykjRHRDBWgJcZSCY38Xx2lhqMnRYE34Px/sN9vlQWeoHBAx2yXsRruVAVuFsIBaSJ8+eJGPaBqQV4NROJjTzez89jLBoFn6FgybQL54wS3uTyVDFQ3cL2IYpBv3RhdJSIIQ80tQyv7gEqJvS8AmUlBs7UXPhtjtZgh3UFNYngk86NHCfNAg9dMwHVBPu+CpsVkTXKeJeVG+AGgTOZ3tt6MSKKjy+NjEBjFrR4ElZmA4pdxstMFsyyJu6tZZ7Ux9vwB6EAL50ZGiRECEPPUOixVTRxHlicgSVWxEdZpuZWfNuS2hk48NjwMIkIYZglBnV5Cbqtws/5IaAJmsfCglrEl2y2QeKmEBJ80tixKmxrFpSVr0gV0viQoxho2YUuPohmeFD22PiklLC4ma5JuBvdrfLJI0dJd0s7bM0ES8aR/BXDXGaTskqlL+D3Lwy0tZEePoAd4EA5YF4tYymdonfjmQh3s6dTPjU4SHYGwjAKecSXFyGlM1TdytntE56T+ts7SC/vhw3gm6njc2Kd3vm5Ub1IwQAvnYhGiZpYw1wiWYPrIw7wnBTt7CLOOwdmut14kQQvqt24tfK/utGR6LaF+iRqMf4N/O/8D28HiiCRYqzAAAAAAElFTkSuQmCC"; - var icon_edit = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABEUlEQVQ4jZ3MMUsCYQDG8ee8IySQbNCLyyEKG/RLNAXicqvQcAeNLrcFLlE0+xHuNpt8wy04rrYm8Q4HQRE56BSC3lSqU1BwCoxM39dnffj9BWyxXvVeEzvtctBwHyRebNu2Nk2lzMlrgJB+qBEeTByiKYpihl+fIO8jTI9PDJEVF1+K2iw+M6PhDuyag4NkQi/c3FkCK5Z3ZbM76qLltpCbn+vXxq0FABsDy9hzPdBvqvtXvvXzrw1swmsDLPjfACteGeDBfwK8+FdgGwwAIgC0ncsjxGRSH/eiPBgAJADY2z8sJ4JBfNBsDqlADVYMANIzKalv/bHaefKsTH9iPFb8ISsGAJym0+Qinz3jQktbAHcxvx3559eSAAAAAElFTkSuQmCC"; +var treatments = { + name: 'treatments' + , label: 'Treatments' + , pluginType: 'report' +}; - var table = '
'+translate('Time')+''+translate('Event Type')+''+translate('Blood Glucose')+''+translate('Insulin')+''+translate('Carbs')+''+translate('Entered By')+''+translate('Notes')+'
'+localeDate(day)+'
'+(new Date(tr.created_at).toLocaleTimeString().replace(/([\d]+:[\d]{2})(:[\d]{2})(.*)/, "$1$3"))+''+(tr.eventType ? tr.eventType : '')+''+(tr.glucose ? tr.glucose + ' ('+translate(tr.glucoseType)+')' : '')+''+(tr.insulin ? tr.insulin : '')+''+(tr.carbs ? tr.carbs : '')+''+(tr.enteredBy ? tr.enteredBy : '')+''+(tr.notes ? tr.notes : '')+'
").appendTo(tr); - $("" + localeDate(dayInQuestion) + "" + Nightscout.reports.localeDate(dayInQuestion) + "'+translate('No data available')+'
" + localeDate(dayInQuestion) + "" + Nightscout.reports.localeDate(dayInQuestion) + "" + Math.floor((100 * stats.lows) / daysRecords.length) + "%" + Math.floor((100 * stats.normal) / daysRecords.length) + "%" + Math.floor((100 * stats.highs) / daysRecords.length) + "%
'+translate('Time')+''+translate('Event Type')+''+translate('Blood Glucose')+''+translate('Insulin')+''+translate('Carbs')+''+translate('Entered By')+''+translate('Notes')+'
'+localeDate(day)+'
'+Nightscout.reports.localeDate(day)+'
").appendTo(tr); - $("" + Nightscout.reports.localeDate(dayInQuestion) + "" + report_plugins.utils.localeDate(dayInQuestion) + "'+translate('No data available')+'
" + Nightscout.reports.localeDate(dayInQuestion) + "" + report_plugins.utils.localeDate(dayInQuestion) + "" + Math.floor((100 * stats.lows) / daysRecords.length) + "%" + Math.floor((100 * stats.normal) / daysRecords.length) + "%" + Math.floor((100 * stats.highs) / daysRecords.length) + "%
'; - table += ''; - - Object.keys(daystoshow).forEach(function (day) { - table += ''; - var treatments = datastorage[day].treatments; - for (var t=0; t'; - table += ' '; - table += ''; - table += ''; - table += ''; - table += ''; - table += ''; - table += ''; - table += ''; - table += ''; - table += ''; - - table += ''; - } - }); - $('#treatments-report').html(table); - $('.deleteTreatment').click(deleteTreatment); - $('.editTreatment').click(editTreatment); - } - +function init() { + return treatments; +} + +module.exports = init; + + +treatments.report = function report_treatments(datastorage,daystoshow,options) { + function deleteTreatment(event) { var data = JSON.parse($(this).attr('data')); var day = $(this).attr('day'); @@ -156,3 +135,41 @@ return true; } + var Nightscout = window.Nightscout; + var client = Nightscout.client; + var translate = client.translate; + var report_plugins = Nightscout.report_plugins; + + var icon_remove = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACrElEQVQ4T42Ty2sTQRzHv5tmk2yyjRNtpfZhL8V6s2KoUNC2XqwgaCsVQcGiFqpHi0c9iRdR/ANE9KR40FIQX4cueKoPaKFoLdSYNtE0abKT1+5s9iW7aUMiHtzTzO7v85md+c6PA4DrHbsPCKIgOWO1pA7dT6YXnXH949SE/F63pqwZtRrO+SCKgjQ5NUV+azpmHj2krMwaJC4c8Erj+/eRyloMMwWFKgbn1nC3ervlK1evkXBLGBZT8SOewotnTylTNLdgeg/pDgZDC2cPHSR8bB22DVC9hFe0SG/H0xFXcHlykjRHRDBWgJcZSCY38Xx2lhqMnRYE34Px/sN9vlQWeoHBAx2yXsRruVAVuFsIBaSJ8+eJGPaBqQV4NROJjTzez89jLBoFn6FgybQL54wS3uTyVDFQ3cL2IYpBv3RhdJSIIQ80tQyv7gEqJvS8AmUlBs7UXPhtjtZgh3UFNYngk86NHCfNAg9dMwHVBPu+CpsVkTXKeJeVG+AGgTOZ3tt6MSKKjy+NjEBjFrR4ElZmA4pdxstMFsyyJu6tZZ7Ux9vwB6EAL50ZGiRECEPPUOixVTRxHlicgSVWxEdZpuZWfNuS2hk48NjwMIkIYZglBnV5Cbqtws/5IaAJmsfCglrEl2y2QeKmEBJ80tixKmxrFpSVr0gV0viQoxho2YUuPohmeFD22PiklLC4ma5JuBvdrfLJI0dJd0s7bM0ES8aR/BXDXGaTskqlL+D3Lwy0tZEePoAd4EA5YF4tYymdonfjmQh3s6dTPjU4SHYGwjAKecSXFyGlM1TdytntE56T+ts7SC/vhw3gm6njc2Kd3vm5Ub1IwQAvnYhGiZpYw1wiWYPrIw7wnBTt7CLOOwdmut14kQQvqt24tfK/utGR6LaF+iRqMf4N/O/8D28HiiCRYqzAAAAAAElFTkSuQmCC"; + var icon_edit = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABEUlEQVQ4jZ3MMUsCYQDG8ee8IySQbNCLyyEKG/RLNAXicqvQcAeNLrcFLlE0+xHuNpt8wy04rrYm8Q4HQRE56BSC3lSqU1BwCoxM39dnffj9BWyxXvVeEzvtctBwHyRebNu2Nk2lzMlrgJB+qBEeTByiKYpihl+fIO8jTI9PDJEVF1+K2iw+M6PhDuyag4NkQi/c3FkCK5Z3ZbM76qLltpCbn+vXxq0FABsDy9hzPdBvqvtXvvXzrw1swmsDLPjfACteGeDBfwK8+FdgGwwAIgC0ncsjxGRSH/eiPBgAJADY2z8sJ4JBfNBsDqlADVYMANIzKalv/bHaefKsTH9iPFb8ISsGAJym0+Qinz3jQktbAHcxvx3559eSAAAAAElFTkSuQmCC"; + + var table = '
'+translate('Time')+''+translate('Event Type')+''+translate('Blood Glucose')+''+translate('Insulin')+''+translate('Carbs')+''+translate('Entered By')+''+translate('Notes')+'
'+Nightscout.reports.localeDate(day)+'
'+(new Date(tr.created_at).toLocaleTimeString().replace(/([\d]+:[\d]{2})(:[\d]{2})(.*)/, "$1$3"))+''+(tr.eventType ? tr.eventType : '')+''+(tr.glucose ? tr.glucose + ' ('+translate(tr.glucoseType)+')' : '')+''+(tr.insulin ? tr.insulin : '')+''+(tr.carbs ? tr.carbs : '')+''+(tr.enteredBy ? tr.enteredBy : '')+''+(tr.notes ? tr.notes : '')+'
'; + table += ''; + + Object.keys(daystoshow).forEach(function (day) { + table += ''; + var treatments = datastorage[day].treatments; + for (var t=0; t'; + table += ' '; + table += ''; + table += ''; + table += ''; + table += ''; + table += ''; + table += ''; + table += ''; + table += ''; + table += ''; + + table += ''; + } + }); + $('#treatments-report').html(table); + $('.deleteTreatment').click(deleteTreatment); + $('.editTreatment').click(editTreatment); +} + diff --git a/lib/report_plugins/utils.js b/lib/report_plugins/utils.js new file mode 100644 index 00000000000..b4235fcbce5 --- /dev/null +++ b/lib/report_plugins/utils.js @@ -0,0 +1,73 @@ +'use strict'; + +var utils = { }; + +function init( ) { + return utils; +} + +module.exports = init; + +utils.localeDate = function localeDate(day) { + var translate = Nightscout.client.translate; + var ret = + [translate("Sunday"),translate("Monday"),translate("Tuesday"),translate("Wednesday"),translate("Thursday"),translate("Friday"),translate("Saturday")][new Date(day).getDay()]; + ret += ' '; + ret += new Date(day).toLocaleDateString(); + return ret; +} + +utils.localeDateTime = function localeDateTime(day) { + var ret = new Date(day).toLocaleDateString() + ' ' + new Date(day).toLocaleTimeString(); + return ret; +} + +utils.scaledTreatmentBG = function scaledTreatmentBG(treatment,data) { + var client = Nightscout.client; + + var SIX_MINS_IN_MS = 360000; + + function calcBGByTime(time) { + var closeBGs = data.filter(function(d) { + if (!d.y) { + return false; + } else { + return Math.abs((new Date(d.date)).getTime() - time) <= SIX_MINS_IN_MS; + } + }); + + var totalBG = 0; + closeBGs.forEach(function(d) { + totalBG += Number(d.y); + }); + + return totalBG > 0 ? (totalBG / closeBGs.length) : 450; + } + + var treatmentGlucose = null; + + if (treatment.glucose && isNaN(treatment.glucose)) { + console.warn('found an invalid glucose value', treatment); + } else { + if (treatment.glucose && treatment.units && client.settings.units) { + if (treatment.units != client.settings.units) { + console.info('found mismatched glucose units, converting ' + treatment.units + ' into ' + client.settings.units, treatment); + if (treatment.units == 'mmol') { + //BG is in mmol and display in mg/dl + treatmentGlucose = Math.round(treatment.glucose * 18) + } else { + //BG is in mg/dl and display in mmol + treatmentGlucose = client.utils.scaleMgdl(treatment.glucose); + } + } else { + treatmentGlucose = treatment.glucose; + } + } else if (treatment.glucose) { + //no units, assume everything is the same + console.warn('found an glucose value with any units, maybe from an old version?', treatment); + treatmentGlucose = treatment.glucose; + } + } + + return treatmentGlucose || client.utils.scaleMgdl(calcBGByTime(treatment.mills)); +} diff --git a/static/report/index.html b/static/report/index.html index e8442d93be0..2ab71406553 100644 --- a/static/report/index.html +++ b/static/report/index.html @@ -228,14 +228,6 @@

Calibrations

- - - - - - - - diff --git a/static/report/js/report.js b/static/report/js/report.js index a18f2b20c6d..fd4d41195ca 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -6,15 +6,14 @@ var moment = window.moment; var Nightscout = window.Nightscout; var client = Nightscout.client; + var report_plugins = Nightscout.report_plugins; - Nightscout.reports = Nightscout.reports || {}; - if (serverSettings === undefined) { console.error('server settings were not loaded, will not call init'); } else { client.init(serverSettings, Nightscout.plugins); } - + var translate = client.translate; var maxInsulinValue = 0 @@ -32,14 +31,74 @@ ONE_MIN_IN_MS = 60000 , SIX_MINS_IN_MS = 360000; - Nightscout.reports.SCALE_LINEAR = 0; - Nightscout.reports.SCALE_LOG = 1; - Nightscout.reports.containerprefix = 'chart-'; + report_plugins.setProperty('SCALE_LINEAR', 0); + report_plugins.setProperty('SCALE_LOG', 1); + report_plugins.setProperty('containerprefix', 'chart-'); - + // ****** FOOD CODE START ****** var food_categories = []; var food_list = []; + var filter = { + category: '' + , subcategory: '' + , name: '' + }; + + function fillFoodForm(event) { + $('#rp_category').empty().append(new Option(translate('(none)'),'')); + for (var s in food_categories) { + $('#rp_category').append(new Option(s,s)); + } + filter.category = ''; + fillFoodSubcategories(); + + $('#rp_category').change(fillFoodSubcategories); + $('#rp_subcategory').change(doFoodFilter); + $('#rp_name').on('input',doFoodFilter); + + if (event) event.preventDefault(); + return false; + } + + function fillFoodSubcategories(event) { + if (event) { + event.preventDefault(); + } + filter.category = $('#rp_category').val(); + filter.subcategory = ''; + $('#rp_subcategory').empty().append(new Option(translate('(none)'),'')); + if (filter.category != '') { + for (var s in food_categories[filter.category]) { + $('#rp_subcategory').append(new Option(s,s)); + } + } + doFoodFilter(); + } + + function doFoodFilter(event) { + if (event) { + filter.category = $('#rp_category').val(); + filter.subcategory = $('#rp_subcategory').val(); + filter.name = $('#rp_name').val(); + } + $('#rp_food').empty(); + for (var i=0; i'+translate('Loading food database')+' ...'); - $.ajax('/api/v1/food/regular.json', { - success: function foodLoadSuccess(records) { - records.forEach(function (r) { - food_list.push(r); - if (r.category && !food_categories[r.category]) food_categories[r.category] = {}; - if (r.category && r.subcategory) food_categories[r.category][r.subcategory] = true; - }); - fillFoodForm(); - } - }).done(function() { - $('#info').html(''); - $('.presetdates').click(function(e) { var days = $(this).attr('days'); setDataRange(e,days); }); - - $('#rp_show').click(show); - $('#rp_food').change(function (event) { - event.preventDefault(); - $('#rp_enablefood').prop('checked',true); + $('#info').html(''+translate('Loading food database')+' ...'); + $.ajax('/api/v1/food/regular.json', { + success: function foodLoadSuccess(records) { + records.forEach(function (r) { + food_list.push(r); + if (r.category && !food_categories[r.category]) food_categories[r.category] = {}; + if (r.category && r.subcategory) food_categories[r.category][r.subcategory] = true; }); - $('#rp_notes').change(function (event) { - event.preventDefault(); - $('#rp_enablenotes').prop('checked',true); - }); - - $('#rp_targetlow').val(targetBGdefault[client.settings.units].low); - $('#rp_targethigh').val(targetBGdefault[client.settings.units].high); - - $('.menutab').click(switchreport_handler); + fillFoodForm(); + } + }).done(function() { + $('#info').html(''); + $('.presetdates').click(function(e) { var days = $(this).attr('days'); setDataRange(e,days); }); - setDataRange(null,7); - }).fail(function() { - $('#info').html(''); - $('.presetdates').click(function(e) { var days = $(this).attr('days'); setDataRange(e,days); }); + $('#rp_show').click(show); + $('#rp_food').change(function (event) { + event.preventDefault(); + $('#rp_enablefood').prop('checked',true); + }); + $('#rp_notes').change(function (event) { + event.preventDefault(); + $('#rp_enablenotes').prop('checked',true); + }); + + $('#rp_targetlow').val(targetBGdefault[client.settings.units].low); + $('#rp_targethigh').val(targetBGdefault[client.settings.units].high); + + $('.menutab').click(switchreport_handler); - $('#rp_show').click(show); - $('#rp_food').change(function (event) { - event.preventDefault(); - $('#rp_enablefood').prop('checked',true); - }); - $('#rp_notes').change(function (event) { - event.preventDefault(); - $('#rp_enablenotes').prop('checked',true); - }); - - $('#rp_targetlow').val(targetBGdefault[client.settings.units].low); - $('#rp_targethigh').val(targetBGdefault[client.settings.units].high); - - $('.menutab').click(switchreport_handler); + setDataRange(null,7); + }).fail(function() { + $('#info').html(''); + $('.presetdates').click(function(e) { var days = $(this).attr('days'); setDataRange(e,days); }); - setDataRange(null,7); + $('#rp_show').click(show); + $('#rp_food').change(function (event) { + event.preventDefault(); + $('#rp_enablefood').prop('checked',true); + }); + $('#rp_notes').change(function (event) { + event.preventDefault(); + $('#rp_enablenotes').prop('checked',true); }); + + $('#rp_targetlow').val(targetBGdefault[client.settings.units].low); + $('#rp_targethigh').val(targetBGdefault[client.settings.units].high); + + $('.menutab').click(switchreport_handler); + + setDataRange(null,7); + }); function show(event) { var options = { @@ -139,7 +198,7 @@ carbs: true, iob : true, cob : true, - scale: Nightscout.reports.SCALE_LINEAR + scale: report_plugins.getProperty('SCALE_LINEAR') }; options.targetLow = parseFloat($('#rp_targetlow').val().replace(',','.')); @@ -151,7 +210,7 @@ options.food = $('#rp_optionsfood').is(':checked'); options.insulin = $('#rp_optionsinsulin').is(':checked'); options.carbs = $('#rp_optionscarbs').is(':checked'); - options.scale = $('#rp_linear').is(':checked') ? Nightscout.reports.SCALE_LINEAR : Nightscout.reports.SCALE_LOG; + options.scale = $('#rp_linear').is(':checked') ? report_plugins.getProperty('SCALE_LINEAR') : report_plugins.getProperty('SCALE_LOG'); options.width = parseInt($('#rp_size :selected').attr('x')); options.height = parseInt($('#rp_size :selected').attr('y')); @@ -323,7 +382,7 @@ for (var d in daystoshow) { if (!datastorage[d]) return; // all data not loaded yet } - +/* ['daytoday','dailystats','percentile','glucosedistribution','hourlystats','success','treatments','calibrations'].forEach(function (chart) { // jquery plot doesn't draw to hidden div $('#'+chart+'-placeholder').css('display',''); @@ -331,6 +390,14 @@ if (!$('#'+chart).hasClass('selected')) $('#'+chart+'-placeholder').css('display','none'); }); +*/ + report_plugins.eachPlugin(function (plugin) { + // jquery plot doesn't draw to hidden div + $('#'+plugin.name+'-placeholder').css('display',''); + plugin.report(datastorage,daystoshow,options); + if (!$('#'+plugin.name).hasClass('selected')) + $('#'+plugin.name+'-placeholder').css('display','none'); + }); $('#info').html(''); $('#rp_show').css('display',''); @@ -354,19 +421,6 @@ } - Nightscout.reports.localeDate = function localeDate(day) { - var ret = - [translate("Sunday"),translate("Monday"),translate("Tuesday"),translate("Wednesday"),translate("Thursday"),translate("Friday"),translate("Saturday")][new Date(day).getDay()]; - ret += ' '; - ret += new Date(day).toLocaleDateString(); - return ret; - } - - Nightscout.reports.localeDateTime = function localeDateTime(day) { - var ret = new Date(day).toLocaleDateString() + ' ' + new Date(day).toLocaleTimeString(); - return ret; - } - function loadData(day,options) { // check for loaded data if (datastorage[day] && day != moment().format('YYYY-MM-DD')) { @@ -385,7 +439,7 @@ var to = from + 1000 * 60 * 60 * 24; var query = '?find[date][$gte]='+from+'&find[date][$lt]='+to+'&count=10000'; - $('#'+Nightscout.reports.containerprefix+day).html(''+translate('Loading CGM data of')+' '+day+' ...'); + $('#'+report_plugins.getProperty('containerprefix')+day).html(''+translate('Loading CGM data of')+' '+day+' ...'); console.log('/api/v1/entries.json'+query); $.ajax('/api/v1/entries.json'+query, { success: function (xhr) { @@ -438,7 +492,7 @@ console.log(data.sgv); data.cal.sort(function(a, b) { return a.x - b.x; }); } }).done(function () { - $('#'+Nightscout.reports.containerprefix+day).html(''+translate('Loading treatments data of')+' '+day+' ...'); + $('#'+report_plugins.getProperty('containerprefix')+day).html(''+translate('Loading treatments data of')+' '+day+' ...'); var tquery = '?find[created_at][$gte]='+new Date(from).toISOString()+'&find[created_at][$lt]='+new Date(to).toISOString(); $.ajax('/api/v1/treatments.json'+tquery, { success: function (xhr) { @@ -451,7 +505,7 @@ console.log(data.sgv); data.treatments.sort(function(a, b) { return a.mills - b.mills; }); } }).done(function () { - $('#'+Nightscout.reports.containerprefix+day).html(''+translate('Processing data of')+' '+day+' ...'); + $('#'+report_plugins.getProperty('containerprefix')+day).html(''+translate('Processing data of')+' '+day+' ...'); processData(data,day,options); }); @@ -516,116 +570,4 @@ console.log(data.sgv); showreports(options); } - // Filtering food code - // ------------------- - var food_categories = []; - var food_list = []; - var filter = { - category: '' - , subcategory: '' - , name: '' - }; - - function fillFoodForm(event) { - $('#rp_category').empty().append(new Option(translate('(none)'),'')); - for (var s in food_categories) { - $('#rp_category').append(new Option(s,s)); - } - filter.category = ''; - fillFoodSubcategories(); - - $('#rp_category').change(fillFoodSubcategories); - $('#rp_subcategory').change(doFoodFilter); - $('#rp_name').on('input',doFoodFilter); - - if (event) event.preventDefault(); - return false; - } - - function fillFoodSubcategories(event) { - if (event) { - event.preventDefault(); - } - filter.category = $('#rp_category').val(); - filter.subcategory = ''; - $('#rp_subcategory').empty().append(new Option(translate('(none)'),'')); - if (filter.category != '') { - for (var s in food_categories[filter.category]) { - $('#rp_subcategory').append(new Option(s,s)); - } - } - doFoodFilter(); - } - - function doFoodFilter(event) { - if (event) { - filter.category = $('#rp_category').val(); - filter.subcategory = $('#rp_subcategory').val(); - filter.name = $('#rp_name').val(); - } - $('#rp_food').empty(); - for (var i=0; i 0 ? (totalBG / closeBGs.length) : 450; - } - - var treatmentGlucose = null; - - if (treatment.glucose && isNaN(treatment.glucose)) { - console.warn('found an invalid glucose value', treatment); - } else { - if (treatment.glucose && treatment.units && client.settings.units) { - if (treatment.units != client.settings.units) { - console.info('found mismatched glucose units, converting ' + treatment.units + ' into ' + client.settings.units, treatment); - if (treatment.units == 'mmol') { - //BG is in mmol and display in mg/dl - treatmentGlucose = Math.round(treatment.glucose * 18) - } else { - //BG is in mg/dl and display in mmol - treatmentGlucose = client.utils.scaleMgdl(treatment.glucose); - } - } else { - treatmentGlucose = treatment.glucose; - } - } else if (treatment.glucose) { - //no units, assume everything is the same - console.warn('found an glucose value with any units, maybe from an old version?', treatment); - treatmentGlucose = treatment.glucose; - } - } - - return treatmentGlucose || client.utils.scaleMgdl(calcBGByTime(treatment.mills)); - } - })(); \ No newline at end of file From a837f2262f25ed836033ab0f382489735a0395aa Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 28 Aug 2015 21:52:52 +0200 Subject: [PATCH 006/176] removed tabulators, fixed idents --- lib/report_plugins/calibrations.js | 492 ++++++++--------- lib/report_plugins/dailystats.js | 216 ++++---- lib/report_plugins/daytoday.js | 645 +++++++++++----------- lib/report_plugins/glucosedistribution.js | 192 +++---- lib/report_plugins/hourlystats.js | 198 ++++--- lib/report_plugins/percentile.js | 308 +++++------ lib/report_plugins/success.js | 260 ++++----- lib/report_plugins/treatments.js | 148 ++--- 8 files changed, 1203 insertions(+), 1256 deletions(-) diff --git a/lib/report_plugins/calibrations.js b/lib/report_plugins/calibrations.js index 02692de8236..bdb14f9c7a1 100644 --- a/lib/report_plugins/calibrations.js +++ b/lib/report_plugins/calibrations.js @@ -15,153 +15,121 @@ module.exports = init; calibrations.report = function report_calibrations(datastorage,daystoshow,options) { var padding = { top: 15, right: 15, bottom: 30, left: 70 }; - var treatments = []; - Object.keys(daystoshow).forEach(function (day) { - treatments = treatments.concat(datastorage[day].treatments.filter(function (t) { - if (t.eventType == "Sensor Start") return true; - if (t.eventType == "Sensor Change") return true; - return false; - })); - }); - - var cals = []; - Object.keys(daystoshow).forEach(function (day) { - cals = cals.concat(datastorage[day].cal); - }); - - var sgvs = []; - Object.keys(daystoshow).forEach(function (day) { - sgvs = sgvs.concat(datastorage[day].sgv); - }); - - var mbgs = []; - Object.keys(daystoshow).forEach(function (day) { - mbgs = mbgs.concat(datastorage[day].mbg); - }); - mbgs.forEach(function (mbg) { calibrations_calcmbg(mbg); }); - - - var events = treatments.concat(cals).concat(mbgs).sort(function(a, b) { return a.x - b.x; }); - - var colors = ['Aqua','Blue','Brown','Chartreuse','Coral','CornflowerBlue','DarkCyan','DarkMagenta','DarkOrange','Fuchsia','Green','Yellow']; - var colorindex = 0; - var html = '
'+translate('Time')+''+translate('Event Type')+''+translate('Blood Glucose')+''+translate('Insulin')+''+translate('Carbs')+''+translate('Entered By')+''+translate('Notes')+'
'+report_plugins.utils.localeDate(day)+'
'+(new Date(tr.created_at).toLocaleTimeString().replace(/([\d]+:[\d]{2})(:[\d]{2})(.*)/, "$1$3"))+''+(tr.eventType ? tr.eventType : '')+''+(tr.glucose ? tr.glucose + ' ('+translate(tr.glucoseType)+')' : '')+''+(tr.insulin ? tr.insulin : '')+''+(tr.carbs ? tr.carbs : '')+''+(tr.enteredBy ? tr.enteredBy : '')+''+(tr.notes ? tr.notes : '')+'
'; - var lastmbg = null; - for (var i=0; i'; - }; - - html += '
'; - e.bgcolor = colors[colorindex]; - if (e.eventType) - html += ''+translate(e.eventType)+':
'; - else if (typeof e.device !== 'undefined') { - html += ' '; - html += 'MBG: ' + e.y + ' Raw: '+e.raw+'
'; - lastmbg = e; - e.cals = []; - e.checked = false; - } else if (typeof e.scale !== 'undefined') { - html += 'CAL: ' + ' Scale: ' + e.scale.toFixed(2) + ' Intercept: ' + e.intercept.toFixed(0) + ' Slope: ' + e.slope.toFixed(2) + '
'; - if (lastmbg) lastmbg.cals.push(e); - } else html += JSON.stringify(e); - html += '
'; - - $('#calibrations-list').html(html); - - // select last 3 mbgs - var maxcals = 3; - for (var i=events.length-1; i>0; i--) { - if (typeof events[i].device !== 'undefined') { - events[i].checked = true; - $('#calibrations-'+i).prop('checked',true); - if (--maxcals<1) break; - } - } - calibrations_drawelements(); - - $('.calibrations-checkbox').change(calibrations_checkboxevent); - - function calibrations_checkboxevent(event) { - var index = $(this).attr('index'); - events[index].checked = $(this).is(':checked'); - calibrations_drawelements(); - event.preventDefault(); - } - - function calibrations_drawelements() { - calibrations_drawChart(); - for (var i=0; i'; + e.bgcolor = colors[colorindex]; + if (e.eventType) + html += ''+translate(e.eventType)+':
'; + else if (typeof e.device !== 'undefined') { + html += ' '; + html += 'MBG: ' + e.y + ' Raw: '+e.raw+'
'; + lastmbg = e; + e.cals = []; + e.checked = false; + } else if (typeof e.scale !== 'undefined') { + html += 'CAL: ' + ' Scale: ' + e.scale.toFixed(2) + ' Intercept: ' + e.intercept.toFixed(0) + ' Slope: ' + e.slope.toFixed(2) + '
'; + if (lastmbg) lastmbg.cals.push(e); + } else html += JSON.stringify(e); + html += ''; + }; + + html += ''; + + $('#calibrations-list').html(html); + + // select last 3 mbgs + var maxcals = 3; + for (var i=events.length-1; i>0; i--) { + if (typeof events[i].device !== 'undefined') { + events[i].checked = true; + $('#calibrations-'+i).prop('checked',true); + if (--maxcals<1) break; + } + } + calibrations_drawelements(); + + $('.calibrations-checkbox').change(calibrations_checkboxevent); + + function calibrations_checkboxevent(event) { + var index = $(this).attr('index'); + events[index].checked = $(this).is(':checked'); + calibrations_drawelements(); + event.preventDefault(); + } + + function calibrations_drawelements() { + calibrations_drawChart(); + for (var i=0; i5*60*1000) { - console.log('Last SGV too old for MBG. Time diff: '+((mbg.x-lastsgv.x)/1000/60).toFixed(1)+' min',mbg); - } else { - mbg.raw = lastsgv.filtered || lastsgv.unfiltered; - } - } else { - console.log('Last entry not found for MBG ',mbg); - } - } - - function calibrations_drawmbg(mbg,color) { - if (mbg.raw) { - calibration_context.append('circle') - .attr('cx', xScale2(mbg.y) + padding.left) - .attr('cy', yScale2(mbg.raw) + padding.top) - .attr('fill', color) - .style('opacity', 1) - .attr('stroke-width', 1) - .attr('stroke', 'black') - .attr('r', 5); - } - } - - function calibrations_findlatest(date,storage) { - var last = null; - var time = date.getTime(); - for (var i=0; i time) - return last; - last = storage[i]; - } - return last; - } - + // get current data range + var dataRange = [0,maxBG]; + var width = 600; + var height = 500; + + // get the entire container height and width subtracting the padding + var chartWidth = width - padding.left - padding.right; + var chartHeight = height - padding.top - padding.bottom; + + //set the width and height of the SVG element + charts.attr('width', width) + .attr('height', height) + + // ranges are based on the width and height available so reset + xScale2.range([0, chartWidth]); + yScale2.range([chartHeight,0]); + + // create the x axis container + calibration_context.append('g') + .attr('class', 'x axis'); + + // create the y axis container + calibration_context.append('g') + .attr('class', 'y axis'); + + calibration_context.select('.y') + .attr('transform', 'translate(' + (/*chartWidth + */ padding.left) + ',' + padding.top + ')') + .style('stroke', 'black') + .style('shape-rendering', 'crispEdges') + .style('fill', 'none') + .call(yAxis2); + + // if first run then just display axis with no transition + calibration_context.select('.x') + .attr('transform', 'translate(' + padding.left + ',' + (chartHeight + padding.top) + ')') + .style('stroke', 'black') + .style('shape-rendering', 'crispEdges') + .style('fill', 'none') + .call(xAxis2); + + [50000,100000,150000,200000,250000,300000,350000,400000].forEach(function (li) { + calibration_context.append('line') + .attr('class', 'high-line') + .attr('x1', xScale2(dataRange[0])+padding.left) + .attr('y1', yScale2(li)+padding.top) + .attr('x2', xScale2(dataRange[1])+padding.left) + .attr('y2', yScale2(li)+padding.top) + .style('stroke-dasharray', ('3, 3')) + .attr('stroke', 'grey'); + }); + [50,100,150,200,250,300,350,400,450,500].forEach(function (li) { + calibration_context.append('line') + .attr('class', 'high-line') + .attr('x1', xScale2(li)+padding.left) + .attr('y1', padding.top) + .attr('x2', xScale2(li)+padding.left) + .attr('y2', chartHeight+padding.top) + .style('stroke-dasharray', ('3, 3')) + .attr('stroke', 'grey'); + }); + } + + function calibrations_drawcal(cal,color) { + var y1 = 50000; + var x1 = cal.scale * (y1 - cal.intercept) / cal.slope; + var y2 = 400000; + var x2 = cal.scale * (y2 - cal.intercept) / cal.slope; + calibration_context.append('line') + .attr('x1', xScale2(x1)+padding.left) + .attr('y1', yScale2(y1)+padding.top) + .attr('x2', xScale2(x2)+padding.left) + .attr('y2', yScale2(y2)+padding.top) + .style('stroke-width', 3) + .attr('stroke', color); + } + + function calibrations_calcmbg(mbg) { + var lastsgv = calibrations_findlatest(new Date(mbg.x),sgvs); + + if (lastsgv) { + if (mbg.x-lastsgv.x>5*60*1000) { + console.log('Last SGV too old for MBG. Time diff: '+((mbg.x-lastsgv.x)/1000/60).toFixed(1)+' min',mbg); + } else { + mbg.raw = lastsgv.filtered || lastsgv.unfiltered; + } + } else { + console.log('Last entry not found for MBG ',mbg); + } + } + + function calibrations_drawmbg(mbg,color) { + if (mbg.raw) { + calibration_context.append('circle') + .attr('cx', xScale2(mbg.y) + padding.left) + .attr('cy', yScale2(mbg.raw) + padding.top) + .attr('fill', color) + .style('opacity', 1) + .attr('stroke-width', 1) + .attr('stroke', 'black') + .attr('r', 5); + } + } + + function calibrations_findlatest(date,storage) { + var last = null; + var time = date.getTime(); + for (var i=0; i time) + return last; + last = storage[i]; + } + return last; + } } diff --git a/lib/report_plugins/dailystats.js b/lib/report_plugins/dailystats.js index 7fd3b48756e..58f9010e1b9 100644 --- a/lib/report_plugins/dailystats.js +++ b/lib/report_plugins/dailystats.js @@ -12,125 +12,115 @@ function init() { module.exports = init; - dailystats.report = function report_dailystats(datastorage,daystoshow,options) { - var Nightscout = window.Nightscout; - var client = Nightscout.client; - var translate = client.translate; - var report_plugins = Nightscout.report_plugins; + var Nightscout = window.Nightscout; + var client = Nightscout.client; + var translate = client.translate; + var report_plugins = Nightscout.report_plugins; - var todo = []; -// var data = o[0]; -// var days = 7; -// var config = { low: convertBg(low), high: convertBg(high) }; // options.targetLow options.targetHigh -// var sevendaysago = Date.now() - days.days(); - var report = $("#dailystats-report"); - var minForDay, maxForDay; - var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"]; + var todo = []; + var report = $("#dailystats-report"); + var minForDay, maxForDay; + var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"]; -// data = data.filter(function(record) { -// return "bgValue" in record && /\d+/.test(record.bgValue.toString()); -// }).filter(function(record) { -// return record.displayTime > sevendaysago; -// }); - report.empty(); - var table = $(''); - report.append(table); - var thead = $(""); - $("").appendTo(thead); - $('').appendTo(thead); - $('').appendTo(thead); - $('').appendTo(thead); - $('').appendTo(thead); - $('').appendTo(thead); - $('').appendTo(thead); - $('').appendTo(thead); - $('').appendTo(thead); - $('').appendTo(thead); - $('').appendTo(thead); - $('').appendTo(thead); - thead.appendTo(table); + report.empty(); + var table = $('
'+translate('Date')+''+translate('Low')+''+translate('Normal')+''+translate('High')+''+translate('Readings')+''+translate('Min')+''+translate('Max')+''+translate('StDev')+''+translate('25%')+''+translate('Median')+''+translate('75%')+'
'); + report.append(table); + var thead = $(""); + $("").appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + thead.appendTo(table); - Object.keys(daystoshow).forEach(function (day) { - var tr = $(""); - var dayInQuestion = new Date(day); + Object.keys(daystoshow).forEach(function (day) { + var tr = $(""); + var dayInQuestion = new Date(day); - var daysRecords = datastorage[day].statsrecords; - - if (daysRecords.length == 0) { - $("").appendTo(tr); - $('').appendTo(tr); - table.append(tr); - return;; - } + var daysRecords = datastorage[day].statsrecords; + + if (daysRecords.length == 0) { + $("").appendTo(tr); + $('').appendTo(tr); + table.append(tr); + return;; + } - minForDay = daysRecords[0].sgv; - maxForDay = daysRecords[0].sgv; - var stats = daysRecords.reduce(function(out, record) { - record.sgv = parseFloat(record.sgv); - if (record.sgv < options.targetLow) { - out.lows++; - } else if (record.sgv < options.targetHigh) { - out.normal++; - } else { - out.highs++; - } - if (minForDay > record.sgv) minForDay = record.sgv; - if (maxForDay < record.sgv) maxForDay = record.sgv; - return out; - }, { - lows: 0, - normal: 0, - highs: 0 - }); - var bgValues = daysRecords.map(function(r) { return r.sgv; }); - $("").appendTo(tr); + minForDay = daysRecords[0].sgv; + maxForDay = daysRecords[0].sgv; + var stats = daysRecords.reduce(function(out, record) { + record.sgv = parseFloat(record.sgv); + if (record.sgv < options.targetLow) { + out.lows++; + } else if (record.sgv < options.targetHigh) { + out.normal++; + } else { + out.highs++; + } + if (minForDay > record.sgv) minForDay = record.sgv; + if (maxForDay < record.sgv) maxForDay = record.sgv; + return out; + }, { + lows: 0, + normal: 0, + highs: 0 + }); + var bgValues = daysRecords.map(function(r) { return r.sgv; }); + $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); - table.append(tr); - var inrange = [ - { - label: translate('Low'), - data: Math.floor(stats.lows * 1000 / daysRecords.length) / 10 - }, - { - label: translate('In range'), - data: Math.floor(stats.normal * 1000 / daysRecords.length) / 10 - }, - { - label: translate('High'), - data: Math.floor(stats.highs * 1000 / daysRecords.length) / 10 - } - ]; - $.plot( - "#dailystat-chart-" + day.toString(), - inrange, - { - series: { - pie: { - show: true - } - }, - colors: ["#f88", "#8f8", "#ff8"] - } - ); - }); + table.append(tr); + var inrange = [ + { + label: translate('Low'), + data: Math.floor(stats.lows * 1000 / daysRecords.length) / 10 + }, + { + label: translate('In range'), + data: Math.floor(stats.normal * 1000 / daysRecords.length) / 10 + }, + { + label: translate('High'), + data: Math.floor(stats.highs * 1000 / daysRecords.length) / 10 + } + ]; + $.plot( + "#dailystat-chart-" + day.toString(), + inrange, + { + series: { + pie: { + show: true + } + }, + colors: ["#f88", "#8f8", "#ff8"] + } + ); + }); - setTimeout(function() { - todo.forEach(function(fn) { - fn(); - }); - }, 50); - } \ No newline at end of file + setTimeout(function() { + todo.forEach(function(fn) { + fn(); + }); + }, 50); +} diff --git a/lib/report_plugins/daytoday.js b/lib/report_plugins/daytoday.js index 1ca56a6be8c..8f5e41f84f9 100644 --- a/lib/report_plugins/daytoday.js +++ b/lib/report_plugins/daytoday.js @@ -14,373 +14,372 @@ module.exports = init; daytoday.report = function report_daytoday(datastorage,daystoshow,options) { - var Nightscout = window.Nightscout; - var client = Nightscout.client; - var translate = client.translate; - var profile = client.sbx.data.profile; - var report_plugins = Nightscout.report_plugins; - var scaledTreatmentBG = report_plugins.utils.scaledTreatmentBG; + var Nightscout = window.Nightscout; + var client = Nightscout.client; + var translate = client.translate; + var profile = client.sbx.data.profile; + var report_plugins = Nightscout.report_plugins; + var scaledTreatmentBG = report_plugins.utils.scaledTreatmentBG; + + var padding = { top: 15, right: 15, bottom: 30, left: 35 }; + var + FORMAT_TIME_12 = '%I' + , FORMAT_TIME_24 = '%H'; - var padding = { top: 15, right: 15, bottom: 30, left: 35 }; - var - FORMAT_TIME_12 = '%I' - , FORMAT_TIME_24 = '%H'; - - for (var day in daystoshow) { - drawChart(day,datastorage[day],options); - } - - function getTimeFormat() { - var timeFormat = FORMAT_TIME_12; - if (Nightscout.client.settings.timeFormat == '24') { - timeFormat = FORMAT_TIME_24; - } - return timeFormat; - } + for (var day in daystoshow) { + drawChart(day,datastorage[day],options); + } - function drawChart(day,data,options) { - var tickValues - , charts - , context - , xScale2, yScale2 - , yInsulinScale, yCarbsScale - , xAxis2, yAxis2 - , dateFn = function (d) { return new Date(d.date) } - , foodtexts = 0; + function getTimeFormat() { + var timeFormat = FORMAT_TIME_12; + if (Nightscout.client.settings.timeFormat == '24') { + timeFormat = FORMAT_TIME_24; + } + return timeFormat; + } + + function drawChart(day,data,options) { + var tickValues + , charts + , context + , xScale2, yScale2 + , yInsulinScale, yCarbsScale + , xAxis2, yAxis2 + , dateFn = function (d) { return new Date(d.date) } + , foodtexts = 0; - // Tick Values - if (options.scale == report_plugins.getProperty('SCALE_LOG')) { - if (client.settings.units == 'mmol') { - tickValues = [ - 2.0 - , 3.0 - , options.targetLow - , 6.0 - , 8.0 - , options.targetHigh - , 16.0 - , 22.0 - ]; - } else { - tickValues = [ - 40 - , 60 - , options.targetLow - , 120 - , 160 - , options.targetHigh - , 250 - , 400 - ]; - } + // Tick Values + if (options.scale == report_plugins.getProperty('SCALE_LOG')) { + if (client.settings.units == 'mmol') { + tickValues = [ + 2.0 + , 3.0 + , options.targetLow + , 6.0 + , 8.0 + , options.targetHigh + , 16.0 + , 22.0 + ]; } else { - if (client.settings.units == 'mmol') { - tickValues = [ - 2.0 - , 4.0 - , 6.0 - , 8.0 - , 10.0 - , 12.0 - , 14.0 - , 16.0 - , 18.0 - , 20.0 - , 22.0 - ]; - } else { - tickValues = [ - 40 - , 80 - , 120 - , 160 - , 200 - , 240 - , 280 - , 320 - , 360 - , 400 - ]; - } + tickValues = [ + 40 + , 60 + , options.targetLow + , 120 + , 160 + , options.targetHigh + , 250 + , 400 + ]; } + } else { + if (client.settings.units == 'mmol') { + tickValues = [ + 2.0 + , 4.0 + , 6.0 + , 8.0 + , 10.0 + , 12.0 + , 14.0 + , 16.0 + , 18.0 + , 20.0 + , 22.0 + ]; + } else { + tickValues = [ + 40 + , 80 + , 120 + , 160 + , 200 + , 240 + , 280 + , 320 + , 360 + , 400 + ]; + } + } - // create svg and g to contain the chart contents - charts = d3.select('#'+report_plugins.getProperty('containerprefix')+day).html( - ''+ - report_plugins.utils.localeDate(day)+ - '
' - ).append('svg'); + // create svg and g to contain the chart contents + charts = d3.select('#'+report_plugins.getProperty('containerprefix')+day).html( + ''+ + report_plugins.utils.localeDate(day)+ + '
' + ).append('svg'); - charts.append("rect") - .attr("width", "100%") - .attr("height", "100%") - .attr("fill", "WhiteSmoke"); - - context = charts.append('g'); + charts.append("rect") + .attr("width", "100%") + .attr("height", "100%") + .attr("fill", "WhiteSmoke"); + + context = charts.append('g'); - // define the parts of the axis that aren't dependent on width or height - xScale2 = d3.time.scale() - .domain(d3.extent(data.sgv, function (d) { return d.date; })); + // define the parts of the axis that aren't dependent on width or height + xScale2 = d3.time.scale() + .domain(d3.extent(data.sgv, function (d) { return d.date; })); - if (options.scale == report_plugins.getProperty('SCALE_LOG')) { - yScale2 = d3.scale.log() - .domain([client.utils.scaleMgdl(36), client.utils.scaleMgdl(420)]); - } else { - yScale2 = d3.scale.linear() - .domain([client.utils.scaleMgdl(36), client.utils.scaleMgdl(420)]); - } + if (options.scale == report_plugins.getProperty('SCALE_LOG')) { + yScale2 = d3.scale.log() + .domain([client.utils.scaleMgdl(36), client.utils.scaleMgdl(420)]); + } else { + yScale2 = d3.scale.linear() + .domain([client.utils.scaleMgdl(36), client.utils.scaleMgdl(420)]); + } - yInsulinScale = d3.scale.linear() - .domain([0, options.maxInsulinValue*2]); + yInsulinScale = d3.scale.linear() + .domain([0, options.maxInsulinValue*2]); - yCarbsScale = d3.scale.linear() - .domain([0, options.maxCarbsValue*1.25]); + yCarbsScale = d3.scale.linear() + .domain([0, options.maxCarbsValue*1.25]); - xAxis2 = d3.svg.axis() - .scale(xScale2) - .tickFormat(d3.time.format(getTimeFormat(true))) - .ticks(24) - .orient('bottom'); + xAxis2 = d3.svg.axis() + .scale(xScale2) + .tickFormat(d3.time.format(getTimeFormat(true))) + .ticks(24) + .orient('bottom'); - yAxis2 = d3.svg.axis() - .scale(yScale2) - .tickFormat(d3.format('d')) - .tickValues(tickValues) - .orient('left'); + yAxis2 = d3.svg.axis() + .scale(yScale2) + .tickFormat(d3.format('d')) + .tickValues(tickValues) + .orient('left'); - // get current data range - var dataRange = d3.extent(data.sgv, dateFn); + // get current data range + var dataRange = d3.extent(data.sgv, dateFn); - // get the entire container height and width subtracting the padding - var chartWidth = options.width - padding.left - padding.right; - var chartHeight = options.height - padding.top - padding.bottom; - - //set the width and height of the SVG element - charts.attr('width', options.width) - .attr('height', options.height); - - // ranges are based on the width and height available so reset - xScale2.range([0, chartWidth]); - yScale2.range([chartHeight,0]); - yInsulinScale.range([chartHeight,0]); - yCarbsScale.range([chartHeight,0]); + // get the entire container height and width subtracting the padding + var chartWidth = options.width - padding.left - padding.right; + var chartHeight = options.height - padding.top - padding.bottom; - // add target BG rect - context.append('rect') - .attr('x', xScale2(dataRange[0])+padding.left) - .attr('y', yScale2(options.targetHigh)+padding.top) - .attr('width', xScale2(dataRange[1]- xScale2(dataRange[0]))) - .attr('height', yScale2(options.targetLow)-yScale2(options.targetHigh)) - .style('fill', '#D6FFD6') - .attr('stroke', 'grey'); + //set the width and height of the SVG element + charts.attr('width', options.width) + .attr('height', options.height); + + // ranges are based on the width and height available so reset + xScale2.range([0, chartWidth]); + yScale2.range([chartHeight,0]); + yInsulinScale.range([chartHeight,0]); + yCarbsScale.range([chartHeight,0]); - // create the x axis container - context.append('g') - .attr('class', 'x axis'); + // add target BG rect + context.append('rect') + .attr('x', xScale2(dataRange[0])+padding.left) + .attr('y', yScale2(options.targetHigh)+padding.top) + .attr('width', xScale2(dataRange[1]- xScale2(dataRange[0]))) + .attr('height', yScale2(options.targetLow)-yScale2(options.targetHigh)) + .style('fill', '#D6FFD6') + .attr('stroke', 'grey'); - // create the y axis container - context.append('g') - .attr('class', 'y axis'); + // create the x axis container + context.append('g') + .attr('class', 'x axis'); - context.select('.y') - .attr('transform', 'translate(' + (/*chartWidth + */ padding.left) + ',' + padding.top + ')') - .style('stroke', 'black') - .style('shape-rendering', 'crispEdges') - .style('fill', 'none') - .call(yAxis2); + // create the y axis container + context.append('g') + .attr('class', 'y axis'); - // if first run then just display axis with no transition - context.select('.x') - .attr('transform', 'translate(' + padding.left + ',' + (chartHeight + padding.top) + ')') - .style('stroke', 'black') - .style('shape-rendering', 'crispEdges') - .style('fill', 'none') - .call(xAxis2); + context.select('.y') + .attr('transform', 'translate(' + (/*chartWidth + */ padding.left) + ',' + padding.top + ')') + .style('stroke', 'black') + .style('shape-rendering', 'crispEdges') + .style('fill', 'none') + .call(yAxis2); - for (var li in tickValues) { - context.append('line') - .attr('class', 'high-line') - .attr('x1', xScale2(dataRange[0])+padding.left) - .attr('y1', yScale2(tickValues[li])+padding.top) - .attr('x2', xScale2(dataRange[1])+padding.left) - .attr('y2', yScale2(tickValues[li])+padding.top) - .style('stroke-dasharray', ('3, 3')) - .attr('stroke', 'grey'); - } + // if first run then just display axis with no transition + context.select('.x') + .attr('transform', 'translate(' + padding.left + ',' + (chartHeight + padding.top) + ')') + .style('stroke', 'black') + .style('shape-rendering', 'crispEdges') + .style('fill', 'none') + .call(xAxis2); - // bind up the context chart data to an array of circles - var contextCircles = context.selectAll('circle') - .data(data.sgv); + for (var li in tickValues) { + context.append('line') + .attr('class', 'high-line') + .attr('x1', xScale2(dataRange[0])+padding.left) + .attr('y1', yScale2(tickValues[li])+padding.top) + .attr('x2', xScale2(dataRange[1])+padding.left) + .attr('y2', yScale2(tickValues[li])+padding.top) + .style('stroke-dasharray', ('3, 3')) + .attr('stroke', 'grey'); + } - function prepareContextCircles(sel) { - var badData = []; - sel.attr('cx', function (d) { - return xScale2(d.date) + padding.left; - }) - .attr('cy', function (d) { - if (isNaN(d.sgv)) { - badData.push(d); - return yScale2(client.utils.scaleMgdl(450) + padding.top); - } else { - return yScale2(d.sgv) + padding.top; - } - }) - .attr('fill', function (d) { - if (d.color == 'gray' && !options.raw) { - return 'transparent'; - } - return d.color; - }) - .style('opacity', function (d) { 0.5 }) - .attr('stroke-width', function (d) {if (d.type == 'mbg') return 2; else return 0; }) - .attr('stroke', function (d) { return 'black'; }) - .attr('r', function(d) { if (d.type == 'mbg') { return 4; } else { return 2; }}); + // bind up the context chart data to an array of circles + var contextCircles = context.selectAll('circle') + .data(data.sgv); - if (badData.length > 0) { - console.warn("Bad Data: isNaN(sgv)", badData); + function prepareContextCircles(sel) { + var badData = []; + sel.attr('cx', function (d) { + return xScale2(d.date) + padding.left; + }) + .attr('cy', function (d) { + if (isNaN(d.sgv)) { + badData.push(d); + return yScale2(client.utils.scaleMgdl(450) + padding.top); + } else { + return yScale2(d.sgv) + padding.top; } - return sel; - } + }) + .attr('fill', function (d) { + if (d.color == 'gray' && !options.raw) { + return 'transparent'; + } + return d.color; + }) + .style('opacity', function (d) { 0.5 }) + .attr('stroke-width', function (d) {if (d.type == 'mbg') return 2; else return 0; }) + .attr('stroke', function (d) { return 'black'; }) + .attr('r', function(d) { if (d.type == 'mbg') { return 4; } else { return 2; }}); - // if new circle then just display - prepareContextCircles(contextCircles.enter().append('circle')); + if (badData.length > 0) { + console.warn("Bad Data: isNaN(sgv)", badData); + } + return sel; + } - contextCircles.exit() - .remove(); + // if new circle then just display + prepareContextCircles(contextCircles.enter().append('circle')); - var to = moment(day).add(1, 'days') //.add(new Date().getTimezoneOffset(), 'minutes'); - var from = moment(day); //.add(new Date().getTimezoneOffset(), 'minutes'); - var iobpolyline = '', cobpolyline = ''; - for (var dt=from; dt < to; dt.add(5, 'minutes')) { - if (options.iob) { - var iob = Nightscout.plugins('iob').calcTotal(data.treatments,profile,dt.toDate()).iob; - if (dt!=from) { - iobpolyline += ', '; - } - iobpolyline += (xScale2(dt) + padding.left) + ',' + (yInsulinScale(iob) + padding.top) + ' '; - } - if (options.cob) { - var cob = Nightscout.plugins('cob').cobTotal(data.treatments,profile,dt.toDate()).cob; - if (dt!=from) { - cobpolyline += ', '; - } - cobpolyline += (xScale2(dt.toDate()) + padding.left) + ',' + (yCarbsScale(cob) + padding.top) + ' '; + contextCircles.exit() + .remove(); + + var to = moment(day).add(1, 'days') //.add(new Date().getTimezoneOffset(), 'minutes'); + var from = moment(day); //.add(new Date().getTimezoneOffset(), 'minutes'); + var iobpolyline = '', cobpolyline = ''; + for (var dt=from; dt < to; dt.add(5, 'minutes')) { + if (options.iob) { + var iob = Nightscout.plugins('iob').calcTotal(data.treatments,profile,dt.toDate()).iob; + if (dt!=from) { + iobpolyline += ', '; } + iobpolyline += (xScale2(dt) + padding.left) + ',' + (yInsulinScale(iob) + padding.top) + ' '; } - if (options.iob) { - context.append('polyline') - .attr('stroke', 'blue') - .attr('opacity', '0.5') - .attr('fill-opacity', '0.1') - .attr('points',iobpolyline); - } if (options.cob) { - context.append('polyline') - .attr('stroke', 'red') - .attr('opacity', '0.5') - .attr('fill-opacity', '0.1') - .attr('points',cobpolyline); - } + var cob = Nightscout.plugins('cob').cobTotal(data.treatments,profile,dt.toDate()).cob; + if (dt!=from) { + cobpolyline += ', '; + } + cobpolyline += (xScale2(dt.toDate()) + padding.left) + ',' + (yCarbsScale(cob) + padding.top) + ' '; + } + } + if (options.iob) { + context.append('polyline') + .attr('stroke', 'blue') + .attr('opacity', '0.5') + .attr('fill-opacity', '0.1') + .attr('points',iobpolyline); + } + if (options.cob) { + context.append('polyline') + .attr('stroke', 'red') + .attr('opacity', '0.5') + .attr('fill-opacity', '0.1') + .attr('points',cobpolyline); + } - data.treatments.forEach(function (treatment) { - if (treatment.boluscalc && treatment.boluscalc.foods && treatment.boluscalc.foods.length > 0 || treatment.notes) { - var lastfoodtext = foodtexts; - var drawpointer = false; - if (treatment.boluscalc && treatment.boluscalc.foods && treatment.boluscalc.foods.length > 0 && options.food) { - var foods = treatment.boluscalc.foods; - for (var fi=0; fi 0 || treatment.notes) { + var lastfoodtext = foodtexts; + var drawpointer = false; + if (treatment.boluscalc && treatment.boluscalc.foods && treatment.boluscalc.foods.length > 0 && options.food) { + var foods = treatment.boluscalc.foods; + for (var fi=0; fi'); - var thead = $(""); - $('').appendTo(thead); - $('').appendTo(thead); - $('').appendTo(thead); - $('').appendTo(thead); - $('').appendTo(thead); - $('').appendTo(thead); - $('').appendTo(thead); - thead.appendTo(table); + var Statician = ss; + var report = $("#glucosedistribution-report"); + report.empty(); + var minForDay, maxForDay; + var stats = []; + var table = $('
'+translate('Date')+''+translate('Low')+''+translate('Normal')+''+translate('High')+''+translate('Readings')+''+translate('Min')+''+translate('Max')+''+translate('StDev')+''+translate('25%')+''+translate('Median')+''+translate('75%')+'
").appendTo(tr); - $("" + report_plugins.utils.localeDate(dayInQuestion) + "'+translate('No data available')+'").appendTo(tr); + $("" + report_plugins.utils.localeDate(dayInQuestion) + "'+translate('No data available')+'
" + report_plugins.utils.localeDate(dayInQuestion) + "" + Math.floor((100 * stats.lows) / daysRecords.length) + "%" + Math.floor((100 * stats.normal) / daysRecords.length) + "%" + Math.floor((100 * stats.highs) / daysRecords.length) + "%" + daysRecords.length +"" + minForDay +"" + maxForDay +"" + Math.floor(ss.standard_deviation(bgValues)) + "" + ss.quantile(bgValues, 0.25) + "" + ss.quantile(bgValues, 0.5) + "" + ss.quantile(bgValues, 0.75) + "" + report_plugins.utils.localeDate(dayInQuestion) + "" + Math.floor((100 * stats.lows) / daysRecords.length) + "%" + Math.floor((100 * stats.normal) / daysRecords.length) + "%" + Math.floor((100 * stats.highs) / daysRecords.length) + "%" + daysRecords.length +"" + minForDay +"" + maxForDay +"" + Math.floor(ss.standard_deviation(bgValues)) + "" + ss.quantile(bgValues, 0.25) + "" + ss.quantile(bgValues, 0.5) + "" + ss.quantile(bgValues, 0.75) + "
'+translate('Range')+''+translate('% of Readings')+''+translate('# of Readings')+''+translate('Mean')+''+translate('Median')+''+translate('Standard Deviation')+''+translate('A1c estimation*')+'
'); + var thead = $(""); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + thead.appendTo(table); - var data = []; - var days = 0; - Object.keys(daystoshow).forEach(function (day) { - data = data.concat(datastorage[day].statsrecords); - days++; - }); - - $('#glucosedistribution-days').text(days+' '+translate('days total')); - - ['Low', 'Normal', 'High'].forEach(function(range) { - var tr = $(""); - var rangeRecords = data.filter(function(r) { - if (range == "Low") { - return r.sgv > 0 && r.sgv < options.targetLow; - } else if (range == "Normal") { - return r.sgv >= options.targetLow && r.sgv < options.targetHigh; - } else { - return r.sgv >= options.targetHigh; - } - }); - stats.push(rangeRecords.length); - rangeRecords.sort(function(a,b) { - return a.sgv - b.sgv; - }); - var localBgs = rangeRecords.map(function(r) { return r.sgv; }).filter(function(bg) { return !!bg; }); + var data = []; + var days = 0; + Object.keys(daystoshow).forEach(function (day) { + data = data.concat(datastorage[day].statsrecords); + days++; + }); + + $('#glucosedistribution-days').text(days+' '+translate('days total')); + + ['Low', 'Normal', 'High'].forEach(function(range) { + var tr = $(""); + var rangeRecords = data.filter(function(r) { + if (range == "Low") { + return r.sgv > 0 && r.sgv < options.targetLow; + } else if (range == "Normal") { + return r.sgv >= options.targetLow && r.sgv < options.targetHigh; + } else { + return r.sgv >= options.targetHigh; + } + }); + stats.push(rangeRecords.length); + rangeRecords.sort(function(a,b) { + return a.sgv - b.sgv; + }); + var localBgs = rangeRecords.map(function(r) { return r.sgv; }).filter(function(bg) { return !!bg; }); - var midpoint = Math.floor(rangeRecords.length / 2); - //var statistics = ss.(new Statician(rangeRecords.map(function(r) { return r.sgv; }))).stats; + var midpoint = Math.floor(rangeRecords.length / 2); + //var statistics = ss.(new Statician(rangeRecords.map(function(r) { return r.sgv; }))).stats; - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - if (rangeRecords.length > 0) { - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - } else { - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - } + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + if (rangeRecords.length > 0) { + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + } else { + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + } - table.append(tr); - }); - - var tr = $(""); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - if (data.length > 0) { - var localBgs = data.map(function(r) { return r.sgv; }).filter(function(bg) { return !!bg; }); - var mgDlBgs = data.map(function(r) { return r.bgValue; }).filter(function(bg) { return !!bg; }); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - } else { - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - } - table.append(tr); - report.append(table); + table.append(tr); + }); + + var tr = $(""); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + if (data.length > 0) { + var localBgs = data.map(function(r) { return r.sgv; }).filter(function(bg) { return !!bg; }); + var mgDlBgs = data.map(function(r) { return r.bgValue; }).filter(function(bg) { return !!bg; }); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + } else { + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + } + table.append(tr); + report.append(table); - setTimeout(function() { - $.plot( - "#glucosedistribution-overviewchart", - stats, - { - series: { - pie: { - show: true - } - }, - colors: ["#f88", "#8f8", "#ff8"] - } - ); - }); - } + setTimeout(function() { + $.plot( + "#glucosedistribution-overviewchart", + stats, + { + series: { + pie: { + show: true + } + }, + colors: ["#f88", "#8f8", "#ff8"] + } + ); + }); +} diff --git a/lib/report_plugins/hourlystats.js b/lib/report_plugins/hourlystats.js index 3a9cc33434d..ee3c536bd22 100644 --- a/lib/report_plugins/hourlystats.js +++ b/lib/report_plugins/hourlystats.js @@ -14,112 +14,106 @@ module.exports = init; hourlystats.report = function report_hourlystats(datastorage,daystoshow,options) { - var Nightscout = window.Nightscout; - var client = Nightscout.client; - var translate = client.translate; + var Nightscout = window.Nightscout; + var client = Nightscout.client; + var translate = client.translate; - var report = $("#hourlystats-report"); - var stats = []; - var pivotedByHour = {}; + var report = $("#hourlystats-report"); + var stats = []; + var pivotedByHour = {}; - var data = []; - var days = 0; - Object.keys(daystoshow).forEach(function (day) { - data = data.concat(datastorage[day].statsrecords); - days++; - }); - - for (var i = 0; i < 24; i++) { - pivotedByHour[i] = []; - } - data.forEach(function(record) { - var d = new Date(record.displayTime); - pivotedByHour[d.getHours()].push(record); - }); - var table = $("
'+translate('Range')+''+translate('% of Readings')+''+translate('# of Readings')+''+translate('Mean')+''+translate('Median')+''+translate('Standard Deviation')+''+translate('A1c estimation*')+'
" + translate(range) + ": " + Math.floor(100 * rangeRecords.length / data.length) + "%" + rangeRecords.length + "" + Math.floor(10*Statician.mean(localBgs))/10 + "" + rangeRecords[midpoint].sgv + "" + Math.floor(Statician.standard_deviation(localBgs)*10)/10 + " N/AN/AN/A " + translate(range) + ": " + Math.floor(100 * rangeRecords.length / data.length) + "%" + rangeRecords.length + "" + Math.floor(10*Statician.mean(localBgs))/10 + "" + rangeRecords[midpoint].sgv + "" + Math.floor(Statician.standard_deviation(localBgs)*10)/10 + " N/AN/AN/A
"+translate("Overall")+": " + data.length + "" + Math.round(10*ss.mean(localBgs))/10 + "" + Math.round(10*ss.quantile(localBgs, 0.5))/10+ "" + Math.round(ss.standard_deviation(localBgs)*10)/10 + "
" + Math.round(10*(ss.mean(mgDlBgs)+46.7)/28.7)/10 + "%DCCT | " +Math.round(((ss.mean(mgDlBgs)+46.7)/28.7 - 2.15)*10.929) + "IFCC
N/AN/AN/AN/A
"+translate("Overall")+": " + data.length + "" + Math.round(10*ss.mean(localBgs))/10 + "" + Math.round(10*ss.quantile(localBgs, 0.5))/10+ "" + Math.round(ss.standard_deviation(localBgs)*10)/10 + "
" + Math.round(10*(ss.mean(mgDlBgs)+46.7)/28.7)/10 + "%DCCT | " +Math.round(((ss.mean(mgDlBgs)+46.7)/28.7 - 2.15)*10.929) + "IFCC
N/AN/AN/AN/A
"); - var thead = $(""); - $('').appendTo(thead); - $('').appendTo(thead); - $('').appendTo(thead); - $('').appendTo(thead); - $('').appendTo(thead); - $('').appendTo(thead); - $('').appendTo(thead); - $('').appendTo(thead); - $('').appendTo(thead); - thead.appendTo(table); + var data = []; + var days = 0; + Object.keys(daystoshow).forEach(function (day) { + data = data.concat(datastorage[day].statsrecords); + days++; + }); + + for (var i = 0; i < 24; i++) { + pivotedByHour[i] = []; + } + data.forEach(function(record) { + var d = new Date(record.displayTime); + pivotedByHour[d.getHours()].push(record); + }); + var table = $("
'+translate('Time')+''+translate('Readings')+''+translate('Average')+''+translate('Min')+''+translate('Quartile')+' 25'+translate('Median')+''+translate('Quartile')+' 75'+translate('Max')+''+translate('Standard Deviation')+'
"); + var thead = $(""); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + $('').appendTo(thead); + thead.appendTo(table); - [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23].forEach(function(hour) { - var tr = $(""); - var display = hour % 12; - if (hour === 0) { - display = "12"; - } - display += ":00 "; - if (hour >= 12) { - display += "PM"; - } else { - display += "AM"; - } + [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23].forEach(function(hour) { + var tr = $(""); + var display = hour % 12; + if (hour === 0) { + display = "12"; + } + display += ":00 "; + if (hour >= 12) { + display += "PM"; + } else { + display += "AM"; + } - var avg = Math.floor(pivotedByHour[hour].map(function(r) { return r.sgv; }).reduce(function(o,v){ return o+v; }, 0) / pivotedByHour[hour].length); - var d = new Date(hour.hours()); - // d.setHours(hour); - // d.setMinutes(0); - // d.setSeconds(0); - // d.setMilliseconds(0); + var avg = Math.floor(pivotedByHour[hour].map(function(r) { return r.sgv; }).reduce(function(o,v){ return o+v; }, 0) / pivotedByHour[hour].length); + var d = new Date(hour.hours()); - var dev = ss.standard_deviation(pivotedByHour[hour].map(function(r) { return r.sgv; })); - stats.push([ - new Date(d), - ss.quantile(pivotedByHour[hour].map(function(r) { return r.sgv; }), 0.25), - ss.quantile(pivotedByHour[hour].map(function(r) { return r.sgv; }), 0.75), - avg - dev, - avg + dev - // Math.min.apply(Math, pivotedByHour[hour].map(function(r) { return r.sgv; })), - // Math.max.apply(Math, pivotedByHour[hour].map(function(r) { return r.sgv; })) - ]); - var tmp; - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - table.append(tr); - }); + var dev = ss.standard_deviation(pivotedByHour[hour].map(function(r) { return r.sgv; })); + stats.push([ + new Date(d), + ss.quantile(pivotedByHour[hour].map(function(r) { return r.sgv; }), 0.25), + ss.quantile(pivotedByHour[hour].map(function(r) { return r.sgv; }), 0.75), + avg - dev, + avg + dev + ]); + var tmp; + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + $("").appendTo(tr); + table.append(tr); + }); - report.empty(); - report.append(table); + report.empty(); + report.append(table); - $.plot( - "#hourlystats-overviewchart", - [{ - data:stats, - candle:true - }], - { - series: { - candle: true, - lines: false //Somehow it draws lines if you dont disable this. Should investigate and fix this ;) - }, - xaxis: { - mode: "time", - timeFormat: "%h:00", - min: 0, - max: (24).hours()-(1).seconds() - }, - yaxis: { - min: 0, - max: serverSettings.units == 'mmol' ? 22: 400, - show: true - }, - grid: { - show: true - } - } - ); - } \ No newline at end of file + $.plot( + "#hourlystats-overviewchart", + [{ + data:stats, + candle:true + }], + { + series: { + candle: true, + lines: false //Somehow it draws lines if you dont disable this. Should investigate and fix this ;) + }, + xaxis: { + mode: "time", + timeFormat: "%h:00", + min: 0, + max: (24).hours()-(1).seconds() + }, + yaxis: { + min: 0, + max: serverSettings.units == 'mmol' ? 22: 400, + show: true + }, + grid: { + show: true + } + } + ); +} \ No newline at end of file diff --git a/lib/report_plugins/percentile.js b/lib/report_plugins/percentile.js index d0f781bb741..ec71828116c 100644 --- a/lib/report_plugins/percentile.js +++ b/lib/report_plugins/percentile.js @@ -14,158 +14,158 @@ module.exports = init; percentile.report = function report_percentile(datastorage,daystoshow,options) { - var Nightscout = window.Nightscout; - var client = Nightscout.client; - var translate = client.translate; + var Nightscout = window.Nightscout; + var client = Nightscout.client; + var translate = client.translate; - var Statician = ss; - var minutewindow = 30; //minute-window should be a divisor of 60 - - var data = []; - var days = 0; - Object.keys(daystoshow).forEach(function (day) { - data = data.concat(datastorage[day].statsrecords); - days++; - }); - - var bins = []; - for (var hour = 0; hour < 24; hour++) { - for (var minute = 0; minute < 60; minute = minute + minutewindow) { - var date = new Date(); - date.setHours(hour); - date.setMinutes(minute); - var readings = data.filter(function(record) { - var recdate = new Date(record.displayTime); - return recdate.getHours() == hour && recdate.getMinutes() >= minute && - recdate.getMinutes() < minute + minutewindow; - }); - readings = readings.map(function(record) { - return record.sgv; - }); - bins.push([date, readings]); - //console.log(date + " - " + readings.length); - //readings.forEach(function(x){console.log(x)}); - } - } - var dat10 = bins.map(function(bin) { - return [bin[0], ss.quantile(bin[1], 0.1)]; - }); - var dat25 = bins.map(function(bin) { - return [bin[0], ss.quantile(bin[1], 0.25)]; - }); - var dat50 = bins.map(function(bin) { - return [bin[0], ss.quantile(bin[1], 0.5)]; - }); - var dat75 = bins.map(function(bin) { - return [bin[0], ss.quantile(bin[1], 0.75)]; - }); - var dat90 = bins.map(function(bin) { - return [bin[0], ss.quantile(bin[1], 0.9)]; - }); - var high = options.targetHigh; - var low = options.targetLow; - //dat50.forEach(function(x){console.log(x[0] + " - " + x[1])}); - $.plot( - "#percentile-chart", [{ - label: translate("Median"), - data: dat50, - id: 'c50', - color: "#000000", - points: { - show: false - }, - lines: { - show: true, - //fill: true - } - }, { - label: "25%/75% "+translate("percentile"), - data: dat25, - id: 'c25', - color: "#000055", - points: { - show: false - }, - lines: { - show: true, - fill: true - }, - fillBetween: 'c50' - }, { - data: dat75, - id: 'c75', - color: "#000055", - points: { - show: false - }, - lines: { - show: true, - fill: true - }, - fillBetween: 'c50' - }, { - label: "10%/90% "+translate("percentile"), - data: dat10, - id: 'c10', - color: "#a0a0FF", - points: { - show: false - }, - lines: { - show: true, - fill: true - }, - fillBetween: 'c25' - }, { - data: dat90, - id: 'c90', - color: "#a0a0FF", - points: { - show: false - }, - lines: { - show: true, - fill: true - }, - fillBetween: 'c75' - }, { - label: translate("High"), - data: [], - color: '#FFFF00', - }, { - label: translate("Low"), - data: [], - color: '#FF0000', - }], { - xaxis: { - mode: "time", - timezone: "browser", - timeformat: "%H:%M", - tickColor: "#555", - }, - yaxis: { - min: 0, - max: serverSettings.units == 'mmol' ? 22: 400, - tickColor: "#555", - }, - grid: { - markings: [{ - color: '#FF0000', - lineWidth: 2, - yaxis: { - from: low, - to: low - } - }, { - color: '#FFFF00', - lineWidth: 2, - yaxis: { - from: high, - to: high - } - }], - //hoverable: true - } - } - ); - } + var Statician = ss; + var minutewindow = 30; //minute-window should be a divisor of 60 + + var data = []; + var days = 0; + Object.keys(daystoshow).forEach(function (day) { + data = data.concat(datastorage[day].statsrecords); + days++; + }); + + var bins = []; + for (var hour = 0; hour < 24; hour++) { + for (var minute = 0; minute < 60; minute = minute + minutewindow) { + var date = new Date(); + date.setHours(hour); + date.setMinutes(minute); + var readings = data.filter(function(record) { + var recdate = new Date(record.displayTime); + return recdate.getHours() == hour && recdate.getMinutes() >= minute && + recdate.getMinutes() < minute + minutewindow; + }); + readings = readings.map(function(record) { + return record.sgv; + }); + bins.push([date, readings]); + //console.log(date + " - " + readings.length); + //readings.forEach(function(x){console.log(x)}); + } + } + var dat10 = bins.map(function(bin) { + return [bin[0], ss.quantile(bin[1], 0.1)]; + }); + var dat25 = bins.map(function(bin) { + return [bin[0], ss.quantile(bin[1], 0.25)]; + }); + var dat50 = bins.map(function(bin) { + return [bin[0], ss.quantile(bin[1], 0.5)]; + }); + var dat75 = bins.map(function(bin) { + return [bin[0], ss.quantile(bin[1], 0.75)]; + }); + var dat90 = bins.map(function(bin) { + return [bin[0], ss.quantile(bin[1], 0.9)]; + }); + var high = options.targetHigh; + var low = options.targetLow; + //dat50.forEach(function(x){console.log(x[0] + " - " + x[1])}); + $.plot( + "#percentile-chart", [{ + label: translate("Median"), + data: dat50, + id: 'c50', + color: "#000000", + points: { + show: false + }, + lines: { + show: true, + //fill: true + } + }, { + label: "25%/75% "+translate("percentile"), + data: dat25, + id: 'c25', + color: "#000055", + points: { + show: false + }, + lines: { + show: true, + fill: true + }, + fillBetween: 'c50' + }, { + data: dat75, + id: 'c75', + color: "#000055", + points: { + show: false + }, + lines: { + show: true, + fill: true + }, + fillBetween: 'c50' + }, { + label: "10%/90% "+translate("percentile"), + data: dat10, + id: 'c10', + color: "#a0a0FF", + points: { + show: false + }, + lines: { + show: true, + fill: true + }, + fillBetween: 'c25' + }, { + data: dat90, + id: 'c90', + color: "#a0a0FF", + points: { + show: false + }, + lines: { + show: true, + fill: true + }, + fillBetween: 'c75' + }, { + label: translate("High"), + data: [], + color: '#FFFF00', + }, { + label: translate("Low"), + data: [], + color: '#FF0000', + }], { + xaxis: { + mode: "time", + timezone: "browser", + timeformat: "%H:%M", + tickColor: "#555", + }, + yaxis: { + min: 0, + max: serverSettings.units == 'mmol' ? 22: 400, + tickColor: "#555", + }, + grid: { + markings: [{ + color: '#FF0000', + lineWidth: 2, + yaxis: { + from: low, + to: low + } + }, { + color: '#FFFF00', + lineWidth: 2, + yaxis: { + from: high, + to: high + } + }], + //hoverable: true + } + } + ); +} diff --git a/lib/report_plugins/success.js b/lib/report_plugins/success.js index 6e0d9ec037e..c9c50ff3dba 100644 --- a/lib/report_plugins/success.js +++ b/lib/report_plugins/success.js @@ -18,55 +18,55 @@ success.report = function report_success(datastorage,daystoshow,options) { var client = Nightscout.client; var translate = client.translate; - var low = parseInt(options.targetLow), - high = parseInt(options.targetHigh); - - var data = []; - var days = 0; - Object.keys(daystoshow).forEach(function (day) { - data = data.concat(datastorage[day].statsrecords); - days++; - }); - - var now = Date.now(); - var period = (7).days(); - var firstDataPoint = data.reduce(function(min, record) { - return Math.min(min, record.displayTime); - }, Number.MAX_VALUE); - if (firstDataPoint < 1390000000000) firstDataPoint = 1390000000000; - var quarters = Math.floor((Date.now() - firstDataPoint) / period); - - var grid = $("#success-grid"); - grid.empty(); - var table = $("
'+translate('Time')+''+translate('Readings')+''+translate('Average')+''+translate('Min')+''+translate('Quartile')+' 25'+translate('Median')+''+translate('Quartile')+' 75'+translate('Max')+''+translate('Standard Deviation')+'
" + display + "" + pivotedByHour[hour].length + " (" + Math.floor(100 * pivotedByHour[hour].length / data.length) + "%)" + avg + "" + Math.min.apply(Math, pivotedByHour[hour].map(function(r) { return r.sgv; })) + "" + ((tmp=ss.quantile(pivotedByHour[hour].map(function(r) { return r.sgv; }), 0.25)) ? tmp.toFixed(1) : 0 ) + "" + ((tmp=ss.quantile(pivotedByHour[hour].map(function(r) { return r.sgv; }), 0.5)) ? tmp.toFixed(1) : 0 ) + "" + ((tmp=ss.quantile(pivotedByHour[hour].map(function(r) { return r.sgv; }), 0.75)) ? tmp.toFixed(1) : 0 ) + "" + Math.max.apply(Math, pivotedByHour[hour].map(function(r) { return r.sgv; })) + "" + Math.floor(dev*10)/10 + "" + display + "" + pivotedByHour[hour].length + " (" + Math.floor(100 * pivotedByHour[hour].length / data.length) + "%)" + avg + "" + Math.min.apply(Math, pivotedByHour[hour].map(function(r) { return r.sgv; })) + "" + ((tmp=ss.quantile(pivotedByHour[hour].map(function(r) { return r.sgv; }), 0.25)) ? tmp.toFixed(1) : 0 ) + "" + ((tmp=ss.quantile(pivotedByHour[hour].map(function(r) { return r.sgv; }), 0.5)) ? tmp.toFixed(1) : 0 ) + "" + ((tmp=ss.quantile(pivotedByHour[hour].map(function(r) { return r.sgv; }), 0.75)) ? tmp.toFixed(1) : 0 ) + "" + Math.max.apply(Math, pivotedByHour[hour].map(function(r) { return r.sgv; })) + "" + Math.floor(dev*10)/10 + "
"); - - if (quarters == 0) { - // insufficent data - grid.append("

"+translate("There is not sufficient data to run this report. Select more days.")+"

"); - return; - } - - var dim = function(n) { - var a = []; - for (var i = 0; i < n; i++) { - a[i]=0; - } - return a; - } - var sum = function(a) { - return a.reduce(function(sum,v) { - return sum+v; - }, 0); - } - var averages = { - percentLow: 0, - percentInRange: 0, - percentHigh: 0, - standardDeviation: 0, - lowerQuartile: 0, - upperQuartile: 0, - average: 0 - }; + var low = parseInt(options.targetLow), + high = parseInt(options.targetHigh); + + var data = []; + var days = 0; + Object.keys(daystoshow).forEach(function (day) { + data = data.concat(datastorage[day].statsrecords); + days++; + }); + + var now = Date.now(); + var period = (7).days(); + var firstDataPoint = data.reduce(function(min, record) { + return Math.min(min, record.displayTime); + }, Number.MAX_VALUE); + if (firstDataPoint < 1390000000000) firstDataPoint = 1390000000000; + var quarters = Math.floor((Date.now() - firstDataPoint) / period); + + var grid = $("#success-grid"); + grid.empty(); + var table = $("
"); + + if (quarters == 0) { + // insufficent data + grid.append("

"+translate("There is not sufficient data to run this report. Select more days.")+"

"); + return; + } + + var dim = function(n) { + var a = []; + for (var i = 0; i < n; i++) { + a[i]=0; + } + return a; + } + var sum = function(a) { + return a.reduce(function(sum,v) { + return sum+v; + }, 0); + } + var averages = { + percentLow: 0, + percentInRange: 0, + percentHigh: 0, + standardDeviation: 0, + lowerQuartile: 0, + upperQuartile: 0, + average: 0 + }; quarters = dim(quarters).map(function(blank, n) { var starting = new Date(now - (n+1) * period), ending = new Date(now - n * period); @@ -74,7 +74,7 @@ success.report = function report_success(datastorage,daystoshow,options) { starting: starting, ending: ending, records: data.filter(function(record) { - return record.displayTime > starting && record.displayTime <= ending; + return record.displayTime > starting && record.displayTime <= ending; }) }; }).filter(function(quarter) { @@ -109,85 +109,85 @@ success.report = function report_success(datastorage,daystoshow,options) { return quarter; }); - var lowComparison = function(quarter, averages, field, invert) { - if (quarter[field] < averages[field] * 0.8) { - return (invert? "bad": "good"); - } else if (quarter[field] > averages[field] * 1.2) { - return (invert? "good": "bad"); - } else { - return ""; - } - } - - var lowQuartileEvaluation = function(quarter, averages) { - if (quarter.lowerQuartile < low) { - return "bad"; - } else { - return lowComparison(quarter, averages, "lowerQuartile"); - } - } - - var upperQuartileEvaluation = function(quarter, averages) { - if (quarter.upperQuartile > high) { - return "bad"; - } else { - return lowComparison(quarter, averages, "upperQuartile"); - } - } - - var averageEvaluation = function(quarter, averages) { - if (quarter.average > high) { - return "bad"; - } else if (quarter.average < low) { - return "bad"; - } else { - return lowComparison(quarter, averages, "average", true); - } - } - - table.append(""); - table.append("" + quarters.filter(function(quarter) { - return quarter.records.length > 0; - }).map(function(quarter) { - var INVERT = true; - return "" + [ - quarter.starting.format("M d Y") + " - " + quarter.ending.format("M d Y"), - { - klass: lowComparison(quarter, averages, "percentLow"), - text: Math.round(quarter.percentLow) + "%" - }, - { - klass: lowComparison(quarter, averages, "percentInRange", INVERT), - text: Math.round(quarter.percentInRange) + "%" - }, - { - klass: lowComparison(quarter, averages, "percentHigh"), - text: Math.round(quarter.percentHigh) + "%" - }, - { - klass: lowComparison(quarter, averages, "standardDeviation"), - text: (quarter.standardDeviation > 10? Math.round(quarter.standardDeviation): quarter.standardDeviation.toFixed(1)) - }, - { - klass: lowQuartileEvaluation(quarter, averages), - text: quarter.lowerQuartile - }, - { - klass: lowComparison(quarter, averages, "average"), - text: quarter.average.toFixed(1) - }, - { - klass: upperQuartileEvaluation(quarter, averages), - text: quarter.upperQuartile - } - ].map(function(v) { - if (typeof v == "object") { - return ""; - } else { - return ""; - } - }).join("") + ""; - }).join("") + ""); - table.appendTo(grid); + var lowComparison = function(quarter, averages, field, invert) { + if (quarter[field] < averages[field] * 0.8) { + return (invert? "bad": "good"); + } else if (quarter[field] > averages[field] * 1.2) { + return (invert? "good": "bad"); + } else { + return ""; + } + } + + var lowQuartileEvaluation = function(quarter, averages) { + if (quarter.lowerQuartile < low) { + return "bad"; + } else { + return lowComparison(quarter, averages, "lowerQuartile"); + } + } + + var upperQuartileEvaluation = function(quarter, averages) { + if (quarter.upperQuartile > high) { + return "bad"; + } else { + return lowComparison(quarter, averages, "upperQuartile"); + } + } + + var averageEvaluation = function(quarter, averages) { + if (quarter.average > high) { + return "bad"; + } else if (quarter.average < low) { + return "bad"; + } else { + return lowComparison(quarter, averages, "average", true); + } + } + + table.append(""); + table.append("" + quarters.filter(function(quarter) { + return quarter.records.length > 0; + }).map(function(quarter) { + var INVERT = true; + return "" + [ + quarter.starting.format("M d Y") + " - " + quarter.ending.format("M d Y"), + { + klass: lowComparison(quarter, averages, "percentLow"), + text: Math.round(quarter.percentLow) + "%" + }, + { + klass: lowComparison(quarter, averages, "percentInRange", INVERT), + text: Math.round(quarter.percentInRange) + "%" + }, + { + klass: lowComparison(quarter, averages, "percentHigh"), + text: Math.round(quarter.percentHigh) + "%" + }, + { + klass: lowComparison(quarter, averages, "standardDeviation"), + text: (quarter.standardDeviation > 10? Math.round(quarter.standardDeviation): quarter.standardDeviation.toFixed(1)) + }, + { + klass: lowQuartileEvaluation(quarter, averages), + text: quarter.lowerQuartile + }, + { + klass: lowComparison(quarter, averages, "average"), + text: quarter.average.toFixed(1) + }, + { + klass: upperQuartileEvaluation(quarter, averages), + text: quarter.upperQuartile + } + ].map(function(v) { + if (typeof v == "object") { + return ""; + } else { + return ""; + } + }).join("") + ""; + }).join("") + ""); + table.appendTo(grid); } \ No newline at end of file diff --git a/lib/report_plugins/treatments.js b/lib/report_plugins/treatments.js index dcef65abb22..f462a39286a 100644 --- a/lib/report_plugins/treatments.js +++ b/lib/report_plugins/treatments.js @@ -15,54 +15,54 @@ module.exports = init; treatments.report = function report_treatments(datastorage,daystoshow,options) { - function deleteTreatment(event) { - var data = JSON.parse($(this).attr('data')); - var day = $(this).attr('day'); - - var ok = window.confirm( - translate('Delete this treatment?')+'\n' + - '\n'+translate('Event Type')+': ' + data.eventType + - (data.glucose ? '\n'+translate('Blood Glucose')+': ' + data.glucose : '')+ - (data.glucoseType ? '\n'+translate('Method')+': ' + data.glucoseType : '')+ - (data.carbs ? '\n'+translate('Carbs Given')+': ' + data.carbs : '' )+ - (data.insulin ? '\n'+translate('Insulin Given')+': ' + data.insulin : '')+ - (data.preBolus ? '\n'+translate('Pre Bolus')+': ' + data.preBolus : '')+ - (data.notes ? '\n'+translate('Notes')+': ' + data.notes : '' )+ - (data.enteredBy ? '\n'+translate('Entered By')+': ' + data.enteredBy : '' )+ - ('\n'+translate('Event Time')+': ' + new Date(data.created_at).toLocaleString()) - ); - - if (ok) { - deleteTreatmentRecord(data._id); - delete datastorage[day]; - show(); - } - if (event) event.preventDefault(); - return false; - } - - function deleteTreatmentRecord(_id) { - if (!Nightscout.auth.isAuthenticated()) { - alert(translate('Your device is not authenticated yet')); - return false; - } - - var xhr = new XMLHttpRequest(); - xhr.open('DELETE', '/api/v1/treatments/'+_id, true); - xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); - xhr.setRequestHeader('api-secret', Nightscout.auth.hash()); - xhr.onload = function () { - if (xhr.statusText!='OK') { - alert(translate('Deleting record failed')); - } - } - xhr.send(null); - return true; - } - - function editTreatment(event) { - var data = JSON.parse($(this).attr('data')); - var day = $(this).attr('day'); + function deleteTreatment(event) { + var data = JSON.parse($(this).attr('data')); + var day = $(this).attr('day'); + + var ok = window.confirm( + translate('Delete this treatment?')+'\n' + + '\n'+translate('Event Type')+': ' + data.eventType + + (data.glucose ? '\n'+translate('Blood Glucose')+': ' + data.glucose : '')+ + (data.glucoseType ? '\n'+translate('Method')+': ' + data.glucoseType : '')+ + (data.carbs ? '\n'+translate('Carbs Given')+': ' + data.carbs : '' )+ + (data.insulin ? '\n'+translate('Insulin Given')+': ' + data.insulin : '')+ + (data.preBolus ? '\n'+translate('Pre Bolus')+': ' + data.preBolus : '')+ + (data.notes ? '\n'+translate('Notes')+': ' + data.notes : '' )+ + (data.enteredBy ? '\n'+translate('Entered By')+': ' + data.enteredBy : '' )+ + ('\n'+translate('Event Time')+': ' + new Date(data.created_at).toLocaleString()) + ); + + if (ok) { + deleteTreatmentRecord(data._id); + delete datastorage[day]; + show(); + } + if (event) event.preventDefault(); + return false; + } + + function deleteTreatmentRecord(_id) { + if (!Nightscout.auth.isAuthenticated()) { + alert(translate('Your device is not authenticated yet')); + return false; + } + + var xhr = new XMLHttpRequest(); + xhr.open('DELETE', '/api/v1/treatments/'+_id, true); + xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); + xhr.setRequestHeader('api-secret', Nightscout.auth.hash()); + xhr.onload = function () { + if (xhr.statusText!='OK') { + alert(translate('Deleting record failed')); + } + } + xhr.send(null); + return true; + } + + function editTreatment(event) { + var data = JSON.parse($(this).attr('data')); + var day = $(this).attr('day'); $( '#rp_edittreatmentdialog' ).dialog({ width: 350 @@ -88,7 +88,7 @@ treatments.report = function report_treatments(datastorage,daystoshow,options) { { text: translate('Cancel'), click: function () { $( this ).dialog( "close" ); } } - ] + ] , open : function(ev, ui) { $(this).parent().css('box-shadow', '20px 20px 20px 0px black'); $(this).parent().find('.ui-dialog-buttonset' ).css({'width':'100%','text-align':'right'}) @@ -110,30 +110,30 @@ treatments.report = function report_treatments(datastorage,daystoshow,options) { }); if (event) event.preventDefault(); - return false; - } - - function saveTreatmentRecord(data) { - if (!Nightscout.auth.isAuthenticated()) { - alert(translate('Your device is not authenticated yet')); - return false; - } - - - var dataJson = JSON.stringify(data, null, ' '); - - var xhr = new XMLHttpRequest(); - xhr.open('PUT', '/api/v1/treatments/', true); - xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); - xhr.setRequestHeader('api-secret', Nightscout.auth.hash()); - xhr.onload = function () { - if (xhr.statusText!='OK') { - alert(translate('Saving record failed')); - } - } - xhr.send(dataJson); - return true; - } + return false; + } + + function saveTreatmentRecord(data) { + if (!Nightscout.auth.isAuthenticated()) { + alert(translate('Your device is not authenticated yet')); + return false; + } + + + var dataJson = JSON.stringify(data, null, ' '); + + var xhr = new XMLHttpRequest(); + xhr.open('PUT', '/api/v1/treatments/', true); + xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); + xhr.setRequestHeader('api-secret', Nightscout.auth.hash()); + xhr.onload = function () { + if (xhr.statusText!='OK') { + alert(translate('Saving record failed')); + } + } + xhr.send(dataJson); + return true; + } var Nightscout = window.Nightscout; var client = Nightscout.client; @@ -172,4 +172,4 @@ treatments.report = function report_treatments(datastorage,daystoshow,options) { $('.deleteTreatment').click(deleteTreatment); $('.editTreatment').click(editTreatment); } - + From f61a7720098a73b056f731eb90231ae12b27b6bf Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 28 Aug 2015 22:10:10 +0200 Subject: [PATCH 007/176] doublequotes to quotes --- lib/report_plugins/calibrations.js | 12 ++--- lib/report_plugins/dailystats.js | 42 +++++++-------- lib/report_plugins/daytoday.js | 10 ++-- lib/report_plugins/glucosedistribution.js | 60 +++++++++++----------- lib/report_plugins/hourlystats.js | 40 +++++++-------- lib/report_plugins/percentile.js | 32 ++++++------ lib/report_plugins/success.js | 62 +++++++++++------------ lib/report_plugins/treatments.js | 4 +- lib/report_plugins/utils.js | 2 +- static/report/js/report.js | 4 +- 10 files changed, 134 insertions(+), 134 deletions(-) diff --git a/lib/report_plugins/calibrations.js b/lib/report_plugins/calibrations.js index bdb14f9c7a1..70bb9dd54e8 100644 --- a/lib/report_plugins/calibrations.js +++ b/lib/report_plugins/calibrations.js @@ -18,8 +18,8 @@ calibrations.report = function report_calibrations(datastorage,daystoshow,option var treatments = []; Object.keys(daystoshow).forEach(function (day) { treatments = treatments.concat(datastorage[day].treatments.filter(function (t) { - if (t.eventType == "Sensor Start") return true; - if (t.eventType == "Sensor Change") return true; + if (t.eventType == 'Sensor Start') return true; + if (t.eventType == 'Sensor Change') return true; return false; })); }); @@ -115,10 +115,10 @@ calibrations.report = function report_calibrations(datastorage,daystoshow,option $('#calibrations-chart').empty(); var charts = d3.select('#calibrations-chart').append('svg'); - charts.append("rect") - .attr("width", "100%") - .attr("height", "100%") - .attr("fill", "WhiteSmoke"); + charts.append('rect') + .attr('width', '100%') + .attr('height', '100%') + .attr('fill', 'WhiteSmoke'); calibration_context = charts.append('g'); diff --git a/lib/report_plugins/dailystats.js b/lib/report_plugins/dailystats.js index 58f9010e1b9..3511ae763e9 100644 --- a/lib/report_plugins/dailystats.js +++ b/lib/report_plugins/dailystats.js @@ -19,15 +19,15 @@ dailystats.report = function report_dailystats(datastorage,daystoshow,options) { var report_plugins = Nightscout.report_plugins; var todo = []; - var report = $("#dailystats-report"); + var report = $('#dailystats-report'); var minForDay, maxForDay; - var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"]; + var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec']; report.empty(); var table = $('
"+translate("Period")+""+translate("Low")+""+translate("In Range")+""+translate("High")+""+translate("Standard Deviation")+""+translate("Low Quartile")+""+translate("Average")+""+translate("Upper Quartile")+"
" + v.text + "" + v + "
"+translate("Period")+""+translate("Low")+""+translate("In Range")+""+translate("High")+""+translate("Standard Deviation")+""+translate("Low Quartile")+""+translate("Average")+""+translate("Upper Quartile")+"
" + v.text + "" + v + "
'); report.append(table); - var thead = $(""); - $("").appendTo(thead); + var thead = $(''); + $('').appendTo(thead); $('').appendTo(thead); $('').appendTo(thead); $('').appendTo(thead); @@ -42,14 +42,14 @@ dailystats.report = function report_dailystats(datastorage,daystoshow,options) { thead.appendTo(table); Object.keys(daystoshow).forEach(function (day) { - var tr = $(""); + var tr = $(''); var dayInQuestion = new Date(day); var daysRecords = datastorage[day].statsrecords; if (daysRecords.length == 0) { - $("").appendTo(tr); + $('').appendTo(tr); $('').appendTo(tr); table.append(tr); return;; @@ -75,19 +75,19 @@ dailystats.report = function report_dailystats(datastorage,daystoshow,options) { highs: 0 }); var bgValues = daysRecords.map(function(r) { return r.sgv; }); - $("").appendTo(tr); + $('').appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); table.append(tr); var inrange = [ @@ -105,7 +105,7 @@ dailystats.report = function report_dailystats(datastorage,daystoshow,options) { } ]; $.plot( - "#dailystat-chart-" + day.toString(), + '#dailystat-chart-' + day.toString(), inrange, { series: { @@ -113,7 +113,7 @@ dailystats.report = function report_dailystats(datastorage,daystoshow,options) { show: true } }, - colors: ["#f88", "#8f8", "#ff8"] + colors: ['#f88', '#8f8', '#ff8'] } ); }); diff --git a/lib/report_plugins/daytoday.js b/lib/report_plugins/daytoday.js index 8f5e41f84f9..ef62099c52c 100644 --- a/lib/report_plugins/daytoday.js +++ b/lib/report_plugins/daytoday.js @@ -111,10 +111,10 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { '
' ).append('svg'); - charts.append("rect") - .attr("width", "100%") - .attr("height", "100%") - .attr("fill", "WhiteSmoke"); + charts.append('rect') + .attr('width', '100%') + .attr('height', '100%') + .attr('fill', 'WhiteSmoke'); context = charts.append('g'); @@ -237,7 +237,7 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { .attr('r', function(d) { if (d.type == 'mbg') { return 4; } else { return 2; }}); if (badData.length > 0) { - console.warn("Bad Data: isNaN(sgv)", badData); + console.warn('Bad Data: isNaN(sgv)', badData); } return sel; } diff --git a/lib/report_plugins/glucosedistribution.js b/lib/report_plugins/glucosedistribution.js index 5b0f278c5b1..332916fcf44 100644 --- a/lib/report_plugins/glucosedistribution.js +++ b/lib/report_plugins/glucosedistribution.js @@ -19,12 +19,12 @@ glucosedistribution.report = function report_glucosedistribution(datastorage,day var translate = client.translate; var Statician = ss; - var report = $("#glucosedistribution-report"); + var report = $('#glucosedistribution-report'); report.empty(); var minForDay, maxForDay; var stats = []; var table = $('
'+translate('Date')+''+translate('Low')+''+translate('Normal')+'
").appendTo(tr); - $("" + report_plugins.utils.localeDate(dayInQuestion) + "').appendTo(tr); + $('' + report_plugins.utils.localeDate(dayInQuestion) + ''+translate('No data available')+'
" + report_plugins.utils.localeDate(dayInQuestion) + "" + Math.floor((100 * stats.lows) / daysRecords.length) + "%" + Math.floor((100 * stats.normal) / daysRecords.length) + "%" + Math.floor((100 * stats.highs) / daysRecords.length) + "%" + daysRecords.length +"" + minForDay +"" + maxForDay +"" + Math.floor(ss.standard_deviation(bgValues)) + "" + ss.quantile(bgValues, 0.25) + "" + ss.quantile(bgValues, 0.5) + "" + ss.quantile(bgValues, 0.75) + "' + report_plugins.utils.localeDate(dayInQuestion) + '' + Math.floor((100 * stats.lows) / daysRecords.length) + '%' + Math.floor((100 * stats.normal) / daysRecords.length) + '%' + Math.floor((100 * stats.highs) / daysRecords.length) + '%' + daysRecords.length +'' + minForDay +'' + maxForDay +'' + Math.floor(ss.standard_deviation(bgValues)) + '' + ss.quantile(bgValues, 0.25) + '' + ss.quantile(bgValues, 0.5) + '' + ss.quantile(bgValues, 0.75) + '
'); - var thead = $(""); + var thead = $(''); $('').appendTo(thead); $('').appendTo(thead); $('').appendTo(thead); @@ -44,11 +44,11 @@ glucosedistribution.report = function report_glucosedistribution(datastorage,day $('#glucosedistribution-days').text(days+' '+translate('days total')); ['Low', 'Normal', 'High'].forEach(function(range) { - var tr = $(""); + var tr = $(''); var rangeRecords = data.filter(function(r) { - if (range == "Low") { + if (range == 'Low') { return r.sgv > 0 && r.sgv < options.targetLow; - } else if (range == "Normal") { + } else if (range == 'Normal') { return r.sgv >= options.targetLow && r.sgv < options.targetHigh; } else { return r.sgv >= options.targetHigh; @@ -63,47 +63,47 @@ glucosedistribution.report = function report_glucosedistribution(datastorage,day var midpoint = Math.floor(rangeRecords.length / 2); //var statistics = ss.(new Statician(rangeRecords.map(function(r) { return r.sgv; }))).stats; - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); if (rangeRecords.length > 0) { - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); } else { - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); } table.append(tr); }); - var tr = $(""); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); + var tr = $(''); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); if (data.length > 0) { var localBgs = data.map(function(r) { return r.sgv; }).filter(function(bg) { return !!bg; }); var mgDlBgs = data.map(function(r) { return r.bgValue; }).filter(function(bg) { return !!bg; }); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); } else { - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); } table.append(tr); report.append(table); setTimeout(function() { $.plot( - "#glucosedistribution-overviewchart", + '#glucosedistribution-overviewchart', stats, { series: { @@ -111,7 +111,7 @@ glucosedistribution.report = function report_glucosedistribution(datastorage,day show: true } }, - colors: ["#f88", "#8f8", "#ff8"] + colors: ['#f88', '#8f8', '#ff8'] } ); }); diff --git a/lib/report_plugins/hourlystats.js b/lib/report_plugins/hourlystats.js index ee3c536bd22..4fa8929aaaf 100644 --- a/lib/report_plugins/hourlystats.js +++ b/lib/report_plugins/hourlystats.js @@ -18,7 +18,7 @@ hourlystats.report = function report_hourlystats(datastorage,daystoshow,options) var client = Nightscout.client; var translate = client.translate; - var report = $("#hourlystats-report"); + var report = $('#hourlystats-report'); var stats = []; var pivotedByHour = {}; @@ -36,8 +36,8 @@ hourlystats.report = function report_hourlystats(datastorage,daystoshow,options) var d = new Date(record.displayTime); pivotedByHour[d.getHours()].push(record); }); - var table = $("
'+translate('Range')+''+translate('% of Readings')+''+translate('# of Readings')+'
" + translate(range) + ": " + Math.floor(100 * rangeRecords.length / data.length) + "%" + rangeRecords.length + "' + translate(range) + ': ' + Math.floor(100 * rangeRecords.length / data.length) + '%' + rangeRecords.length + '" + Math.floor(10*Statician.mean(localBgs))/10 + "" + rangeRecords[midpoint].sgv + "" + Math.floor(Statician.standard_deviation(localBgs)*10)/10 + " ' + Math.floor(10*Statician.mean(localBgs))/10 + '' + rangeRecords[midpoint].sgv + '' + Math.floor(Statician.standard_deviation(localBgs)*10)/10 + ' N/AN/AN/A N/AN/AN/A
"+translate("Overall")+": " + data.length + "
'+translate('Overall')+': ' + data.length + '" + Math.round(10*ss.mean(localBgs))/10 + "" + Math.round(10*ss.quantile(localBgs, 0.5))/10+ "" + Math.round(ss.standard_deviation(localBgs)*10)/10 + "
" + Math.round(10*(ss.mean(mgDlBgs)+46.7)/28.7)/10 + "%DCCT | " +Math.round(((ss.mean(mgDlBgs)+46.7)/28.7 - 2.15)*10.929) + "IFCC
' + Math.round(10*ss.mean(localBgs))/10 + '' + Math.round(10*ss.quantile(localBgs, 0.5))/10+ '' + Math.round(ss.standard_deviation(localBgs)*10)/10 + '
' + Math.round(10*(ss.mean(mgDlBgs)+46.7)/28.7)/10 + '%DCCT | ' +Math.round(((ss.mean(mgDlBgs)+46.7)/28.7 - 2.15)*10.929) + 'IFCC
N/AN/AN/AN/AN/AN/AN/AN/A
"); - var thead = $(""); + var table = $('
'); + var thead = $(''); $('').appendTo(thead); $('').appendTo(thead); $('').appendTo(thead); @@ -50,16 +50,16 @@ hourlystats.report = function report_hourlystats(datastorage,daystoshow,options) thead.appendTo(table); [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23].forEach(function(hour) { - var tr = $(""); + var tr = $(''); var display = hour % 12; if (hour === 0) { - display = "12"; + display = '12'; } - display += ":00 "; + display += ':00 '; if (hour >= 12) { - display += "PM"; + display += 'PM'; } else { - display += "AM"; + display += 'AM'; } var avg = Math.floor(pivotedByHour[hour].map(function(r) { return r.sgv; }).reduce(function(o,v){ return o+v; }, 0) / pivotedByHour[hour].length); @@ -74,15 +74,15 @@ hourlystats.report = function report_hourlystats(datastorage,daystoshow,options) avg + dev ]); var tmp; - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); - $("").appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); + $('').appendTo(tr); table.append(tr); }); @@ -90,7 +90,7 @@ hourlystats.report = function report_hourlystats(datastorage,daystoshow,options) report.append(table); $.plot( - "#hourlystats-overviewchart", + '#hourlystats-overviewchart', [{ data:stats, candle:true @@ -101,8 +101,8 @@ hourlystats.report = function report_hourlystats(datastorage,daystoshow,options) lines: false //Somehow it draws lines if you dont disable this. Should investigate and fix this ;) }, xaxis: { - mode: "time", - timeFormat: "%h:00", + mode: 'time', + timeFormat: '%h:00', min: 0, max: (24).hours()-(1).seconds() }, diff --git a/lib/report_plugins/percentile.js b/lib/report_plugins/percentile.js index ec71828116c..cd107433ceb 100644 --- a/lib/report_plugins/percentile.js +++ b/lib/report_plugins/percentile.js @@ -66,11 +66,11 @@ percentile.report = function report_percentile(datastorage,daystoshow,options) { var low = options.targetLow; //dat50.forEach(function(x){console.log(x[0] + " - " + x[1])}); $.plot( - "#percentile-chart", [{ - label: translate("Median"), + '#percentile-chart', [{ + label: translate('Median'), data: dat50, id: 'c50', - color: "#000000", + color: '#000000', points: { show: false }, @@ -79,10 +79,10 @@ percentile.report = function report_percentile(datastorage,daystoshow,options) { //fill: true } }, { - label: "25%/75% "+translate("percentile"), + label: '25%/75% '+translate('percentile'), data: dat25, id: 'c25', - color: "#000055", + color: '#000055', points: { show: false }, @@ -94,7 +94,7 @@ percentile.report = function report_percentile(datastorage,daystoshow,options) { }, { data: dat75, id: 'c75', - color: "#000055", + color: '#000055', points: { show: false }, @@ -104,10 +104,10 @@ percentile.report = function report_percentile(datastorage,daystoshow,options) { }, fillBetween: 'c50' }, { - label: "10%/90% "+translate("percentile"), + label: '10%/90% '+translate('percentile'), data: dat10, id: 'c10', - color: "#a0a0FF", + color: '#a0a0FF', points: { show: false }, @@ -119,7 +119,7 @@ percentile.report = function report_percentile(datastorage,daystoshow,options) { }, { data: dat90, id: 'c90', - color: "#a0a0FF", + color: '#a0a0FF', points: { show: false }, @@ -129,24 +129,24 @@ percentile.report = function report_percentile(datastorage,daystoshow,options) { }, fillBetween: 'c75' }, { - label: translate("High"), + label: translate('High'), data: [], color: '#FFFF00', }, { - label: translate("Low"), + label: translate('Low'), data: [], color: '#FF0000', }], { xaxis: { - mode: "time", - timezone: "browser", - timeformat: "%H:%M", - tickColor: "#555", + mode: 'time', + timezone: 'browser', + timeformat: '%H:%M', + tickColor: '#555', }, yaxis: { min: 0, max: serverSettings.units == 'mmol' ? 22: 400, - tickColor: "#555", + tickColor: '#555', }, grid: { markings: [{ diff --git a/lib/report_plugins/success.js b/lib/report_plugins/success.js index c9c50ff3dba..b693d7459e7 100644 --- a/lib/report_plugins/success.js +++ b/lib/report_plugins/success.js @@ -36,13 +36,13 @@ success.report = function report_success(datastorage,daystoshow,options) { if (firstDataPoint < 1390000000000) firstDataPoint = 1390000000000; var quarters = Math.floor((Date.now() - firstDataPoint) / period); - var grid = $("#success-grid"); + var grid = $('#success-grid'); grid.empty(); - var table = $("
'+translate('Time')+''+translate('Readings')+''+translate('Average')+'
" + display + "" + pivotedByHour[hour].length + " (" + Math.floor(100 * pivotedByHour[hour].length / data.length) + "%)" + avg + "" + Math.min.apply(Math, pivotedByHour[hour].map(function(r) { return r.sgv; })) + "" + ((tmp=ss.quantile(pivotedByHour[hour].map(function(r) { return r.sgv; }), 0.25)) ? tmp.toFixed(1) : 0 ) + "" + ((tmp=ss.quantile(pivotedByHour[hour].map(function(r) { return r.sgv; }), 0.5)) ? tmp.toFixed(1) : 0 ) + "" + ((tmp=ss.quantile(pivotedByHour[hour].map(function(r) { return r.sgv; }), 0.75)) ? tmp.toFixed(1) : 0 ) + "" + Math.max.apply(Math, pivotedByHour[hour].map(function(r) { return r.sgv; })) + "" + Math.floor(dev*10)/10 + "' + display + '' + pivotedByHour[hour].length + ' (' + Math.floor(100 * pivotedByHour[hour].length / data.length) + '%)' + avg + '' + Math.min.apply(Math, pivotedByHour[hour].map(function(r) { return r.sgv; })) + '' + ((tmp=ss.quantile(pivotedByHour[hour].map(function(r) { return r.sgv; }), 0.25)) ? tmp.toFixed(1) : 0 ) + '' + ((tmp=ss.quantile(pivotedByHour[hour].map(function(r) { return r.sgv; }), 0.5)) ? tmp.toFixed(1) : 0 ) + '' + ((tmp=ss.quantile(pivotedByHour[hour].map(function(r) { return r.sgv; }), 0.75)) ? tmp.toFixed(1) : 0 ) + '' + Math.max.apply(Math, pivotedByHour[hour].map(function(r) { return r.sgv; })) + '' + Math.floor(dev*10)/10 + '
"); + var table = $('
'); if (quarters == 0) { // insufficent data - grid.append("

"+translate("There is not sufficient data to run this report. Select more days.")+"

"); + grid.append('

'+translate('There is not sufficient data to run this report. Select more days.')+'

'); return; } @@ -84,7 +84,7 @@ success.report = function report_success(datastorage,daystoshow,options) { return record.sgv; }); quarter.standardDeviation = ss.standard_deviation(bgValues); - quarter.average = bgValues.length > 0? (sum(bgValues) / bgValues.length): "N/A"; + quarter.average = bgValues.length > 0? (sum(bgValues) / bgValues.length): 'N/A'; quarter.lowerQuartile = ss.quantile(bgValues, 0.25); quarter.upperQuartile = ss.quantile(bgValues, 0.75); quarter.numberLow = bgValues.filter(function(bg) { @@ -111,61 +111,61 @@ success.report = function report_success(datastorage,daystoshow,options) { var lowComparison = function(quarter, averages, field, invert) { if (quarter[field] < averages[field] * 0.8) { - return (invert? "bad": "good"); + return (invert? 'bad': 'good'); } else if (quarter[field] > averages[field] * 1.2) { - return (invert? "good": "bad"); + return (invert? 'good': 'bad'); } else { - return ""; + return ''; } } var lowQuartileEvaluation = function(quarter, averages) { if (quarter.lowerQuartile < low) { - return "bad"; + return 'bad'; } else { - return lowComparison(quarter, averages, "lowerQuartile"); + return lowComparison(quarter, averages, 'lowerQuartile'); } } var upperQuartileEvaluation = function(quarter, averages) { if (quarter.upperQuartile > high) { - return "bad"; + return 'bad'; } else { - return lowComparison(quarter, averages, "upperQuartile"); + return lowComparison(quarter, averages, 'upperQuartile'); } } var averageEvaluation = function(quarter, averages) { if (quarter.average > high) { - return "bad"; + return 'bad'; } else if (quarter.average < low) { - return "bad"; + return 'bad'; } else { - return lowComparison(quarter, averages, "average", true); + return lowComparison(quarter, averages, 'average', true); } } - table.append(""); - table.append("" + quarters.filter(function(quarter) { + table.append(''); + table.append('' + quarters.filter(function(quarter) { return quarter.records.length > 0; }).map(function(quarter) { var INVERT = true; - return "" + [ - quarter.starting.format("M d Y") + " - " + quarter.ending.format("M d Y"), + return '' + [ + quarter.starting.format('M d Y') + ' - ' + quarter.ending.format('M d Y'), { - klass: lowComparison(quarter, averages, "percentLow"), - text: Math.round(quarter.percentLow) + "%" + klass: lowComparison(quarter, averages, 'percentLow'), + text: Math.round(quarter.percentLow) + '%' }, { - klass: lowComparison(quarter, averages, "percentInRange", INVERT), - text: Math.round(quarter.percentInRange) + "%" + klass: lowComparison(quarter, averages, 'percentInRange', INVERT), + text: Math.round(quarter.percentInRange) + '%' }, { - klass: lowComparison(quarter, averages, "percentHigh"), - text: Math.round(quarter.percentHigh) + "%" + klass: lowComparison(quarter, averages, 'percentHigh'), + text: Math.round(quarter.percentHigh) + '%' }, { - klass: lowComparison(quarter, averages, "standardDeviation"), + klass: lowComparison(quarter, averages, 'standardDeviation'), text: (quarter.standardDeviation > 10? Math.round(quarter.standardDeviation): quarter.standardDeviation.toFixed(1)) }, { @@ -173,7 +173,7 @@ success.report = function report_success(datastorage,daystoshow,options) { text: quarter.lowerQuartile }, { - klass: lowComparison(quarter, averages, "average"), + klass: lowComparison(quarter, averages, 'average'), text: quarter.average.toFixed(1) }, { @@ -181,13 +181,13 @@ success.report = function report_success(datastorage,daystoshow,options) { text: quarter.upperQuartile } ].map(function(v) { - if (typeof v == "object") { - return ""; + if (typeof v == 'object') { + return ''; } else { - return ""; + return ''; } - }).join("") + ""; - }).join("") + ""); + }).join('') + ''; + }).join('') + ''); table.appendTo(grid); } \ No newline at end of file diff --git a/lib/report_plugins/treatments.js b/lib/report_plugins/treatments.js index f462a39286a..992955ad743 100644 --- a/lib/report_plugins/treatments.js +++ b/lib/report_plugins/treatments.js @@ -140,8 +140,8 @@ treatments.report = function report_treatments(datastorage,daystoshow,options) { var translate = client.translate; var report_plugins = Nightscout.report_plugins; - var icon_remove = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACrElEQVQ4T42Ty2sTQRzHv5tmk2yyjRNtpfZhL8V6s2KoUNC2XqwgaCsVQcGiFqpHi0c9iRdR/ANE9KR40FIQX4cueKoPaKFoLdSYNtE0abKT1+5s9iW7aUMiHtzTzO7v85md+c6PA4DrHbsPCKIgOWO1pA7dT6YXnXH949SE/F63pqwZtRrO+SCKgjQ5NUV+azpmHj2krMwaJC4c8Erj+/eRyloMMwWFKgbn1nC3ervlK1evkXBLGBZT8SOewotnTylTNLdgeg/pDgZDC2cPHSR8bB22DVC9hFe0SG/H0xFXcHlykjRHRDBWgJcZSCY38Xx2lhqMnRYE34Px/sN9vlQWeoHBAx2yXsRruVAVuFsIBaSJ8+eJGPaBqQV4NROJjTzez89jLBoFn6FgybQL54wS3uTyVDFQ3cL2IYpBv3RhdJSIIQ80tQyv7gEqJvS8AmUlBs7UXPhtjtZgh3UFNYngk86NHCfNAg9dMwHVBPu+CpsVkTXKeJeVG+AGgTOZ3tt6MSKKjy+NjEBjFrR4ElZmA4pdxstMFsyyJu6tZZ7Ux9vwB6EAL50ZGiRECEPPUOixVTRxHlicgSVWxEdZpuZWfNuS2hk48NjwMIkIYZglBnV5Cbqtws/5IaAJmsfCglrEl2y2QeKmEBJ80tixKmxrFpSVr0gV0viQoxho2YUuPohmeFD22PiklLC4ma5JuBvdrfLJI0dJd0s7bM0ES8aR/BXDXGaTskqlL+D3Lwy0tZEePoAd4EA5YF4tYymdonfjmQh3s6dTPjU4SHYGwjAKecSXFyGlM1TdytntE56T+ts7SC/vhw3gm6njc2Kd3vm5Ub1IwQAvnYhGiZpYw1wiWYPrIw7wnBTt7CLOOwdmut14kQQvqt24tfK/utGR6LaF+iRqMf4N/O/8D28HiiCRYqzAAAAAAElFTkSuQmCC"; - var icon_edit = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABEUlEQVQ4jZ3MMUsCYQDG8ee8IySQbNCLyyEKG/RLNAXicqvQcAeNLrcFLlE0+xHuNpt8wy04rrYm8Q4HQRE56BSC3lSqU1BwCoxM39dnffj9BWyxXvVeEzvtctBwHyRebNu2Nk2lzMlrgJB+qBEeTByiKYpihl+fIO8jTI9PDJEVF1+K2iw+M6PhDuyag4NkQi/c3FkCK5Z3ZbM76qLltpCbn+vXxq0FABsDy9hzPdBvqvtXvvXzrw1swmsDLPjfACteGeDBfwK8+FdgGwwAIgC0ncsjxGRSH/eiPBgAJADY2z8sJ4JBfNBsDqlADVYMANIzKalv/bHaefKsTH9iPFb8ISsGAJym0+Qinz3jQktbAHcxvx3559eSAAAAAElFTkSuQmCC"; + var icon_remove = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACrElEQVQ4T42Ty2sTQRzHv5tmk2yyjRNtpfZhL8V6s2KoUNC2XqwgaCsVQcGiFqpHi0c9iRdR/ANE9KR40FIQX4cueKoPaKFoLdSYNtE0abKT1+5s9iW7aUMiHtzTzO7v85md+c6PA4DrHbsPCKIgOWO1pA7dT6YXnXH949SE/F63pqwZtRrO+SCKgjQ5NUV+azpmHj2krMwaJC4c8Erj+/eRyloMMwWFKgbn1nC3ervlK1evkXBLGBZT8SOewotnTylTNLdgeg/pDgZDC2cPHSR8bB22DVC9hFe0SG/H0xFXcHlykjRHRDBWgJcZSCY38Xx2lhqMnRYE34Px/sN9vlQWeoHBAx2yXsRruVAVuFsIBaSJ8+eJGPaBqQV4NROJjTzez89jLBoFn6FgybQL54wS3uTyVDFQ3cL2IYpBv3RhdJSIIQ80tQyv7gEqJvS8AmUlBs7UXPhtjtZgh3UFNYngk86NHCfNAg9dMwHVBPu+CpsVkTXKeJeVG+AGgTOZ3tt6MSKKjy+NjEBjFrR4ElZmA4pdxstMFsyyJu6tZZ7Ux9vwB6EAL50ZGiRECEPPUOixVTRxHlicgSVWxEdZpuZWfNuS2hk48NjwMIkIYZglBnV5Cbqtws/5IaAJmsfCglrEl2y2QeKmEBJ80tixKmxrFpSVr0gV0viQoxho2YUuPohmeFD22PiklLC4ma5JuBvdrfLJI0dJd0s7bM0ES8aR/BXDXGaTskqlL+D3Lwy0tZEePoAd4EA5YF4tYymdonfjmQh3s6dTPjU4SHYGwjAKecSXFyGlM1TdytntE56T+ts7SC/vhw3gm6njc2Kd3vm5Ub1IwQAvnYhGiZpYw1wiWYPrIw7wnBTt7CLOOwdmut14kQQvqt24tfK/utGR6LaF+iRqMf4N/O/8D28HiiCRYqzAAAAAAElFTkSuQmCC'; + var icon_edit = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABEUlEQVQ4jZ3MMUsCYQDG8ee8IySQbNCLyyEKG/RLNAXicqvQcAeNLrcFLlE0+xHuNpt8wy04rrYm8Q4HQRE56BSC3lSqU1BwCoxM39dnffj9BWyxXvVeEzvtctBwHyRebNu2Nk2lzMlrgJB+qBEeTByiKYpihl+fIO8jTI9PDJEVF1+K2iw+M6PhDuyag4NkQi/c3FkCK5Z3ZbM76qLltpCbn+vXxq0FABsDy9hzPdBvqvtXvvXzrw1swmsDLPjfACteGeDBfwK8+FdgGwwAIgC0ncsjxGRSH/eiPBgAJADY2z8sJ4JBfNBsDqlADVYMANIzKalv/bHaefKsTH9iPFb8ISsGAJym0+Qinz3jQktbAHcxvx3559eSAAAAAElFTkSuQmCC'; var table = '
"+translate("Period")+""+translate("Low")+""+translate("In Range")+""+translate("High")+""+translate("Standard Deviation")+""+translate("Low Quartile")+""+translate("Average")+""+translate("Upper Quartile")+"
'+translate('Period')+''+translate('Low')+''+translate('In Range')+''+translate('High')+''+translate('Standard Deviation')+''+translate('Low Quartile')+''+translate('Average')+''+translate('Upper Quartile')+'
" + v.text + "' + v.text + '" + v + "' + v + '
'; table += ''; diff --git a/lib/report_plugins/utils.js b/lib/report_plugins/utils.js index b4235fcbce5..4cd5d5d68dd 100644 --- a/lib/report_plugins/utils.js +++ b/lib/report_plugins/utils.js @@ -11,7 +11,7 @@ module.exports = init; utils.localeDate = function localeDate(day) { var translate = Nightscout.client.translate; var ret = - [translate("Sunday"),translate("Monday"),translate("Tuesday"),translate("Wednesday"),translate("Thursday"),translate("Friday"),translate("Saturday")][new Date(day).getDay()]; + [translate('Sunday'),translate('Monday'),translate('Tuesday'),translate('Wednesday'),translate('Thursday'),translate('Friday'),translate('Saturday')][new Date(day).getDay()]; ret += ' '; ret += new Date(day).toLocaleDateString(); return ret; diff --git a/static/report/js/report.js b/static/report/js/report.js index fd4d41195ca..5726cffcb19 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -23,8 +23,8 @@ var daystoshow = {}; var targetBGdefault = { - "mg/dl": { low: 72, high: 180 }, - "mmol": { low: 4, high: 10 } + 'mg/dl': { low: 72, high: 180 }, + 'mmol': { low: 4, high: 10 } }; var From e3cb1dad810810105ef04783c01f0fe61124a07c Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 28 Aug 2015 22:26:33 +0200 Subject: [PATCH 008/176] === and !== --- lib/report_plugins/calibrations.js | 6 ++-- lib/report_plugins/dailystats.js | 2 +- lib/report_plugins/daytoday.js | 20 ++++++------- lib/report_plugins/glucosedistribution.js | 4 +-- lib/report_plugins/hourlystats.js | 4 +-- lib/report_plugins/percentile.js | 4 +-- lib/report_plugins/success.js | 4 +-- lib/report_plugins/treatments.js | 4 +-- lib/report_plugins/utils.js | 4 +-- static/report/js/report.js | 36 +++++++++++------------ 10 files changed, 44 insertions(+), 44 deletions(-) diff --git a/lib/report_plugins/calibrations.js b/lib/report_plugins/calibrations.js index 70bb9dd54e8..9dda3c1dc34 100644 --- a/lib/report_plugins/calibrations.js +++ b/lib/report_plugins/calibrations.js @@ -18,8 +18,8 @@ calibrations.report = function report_calibrations(datastorage,daystoshow,option var treatments = []; Object.keys(daystoshow).forEach(function (day) { treatments = treatments.concat(datastorage[day].treatments.filter(function (t) { - if (t.eventType == 'Sensor Start') return true; - if (t.eventType == 'Sensor Change') return true; + if (t.eventType === 'Sensor Start') return true; + if (t.eventType === 'Sensor Change') return true; return false; })); }); @@ -149,7 +149,7 @@ calibrations.report = function report_calibrations(datastorage,daystoshow,option //set the width and height of the SVG element charts.attr('width', width) - .attr('height', height) + .attr('height', height); // ranges are based on the width and height available so reset xScale2.range([0, chartWidth]); diff --git a/lib/report_plugins/dailystats.js b/lib/report_plugins/dailystats.js index 3511ae763e9..6367bebd6c2 100644 --- a/lib/report_plugins/dailystats.js +++ b/lib/report_plugins/dailystats.js @@ -47,7 +47,7 @@ dailystats.report = function report_dailystats(datastorage,daystoshow,options) { var daysRecords = datastorage[day].statsrecords; - if (daysRecords.length == 0) { + if (daysRecords.length === 0) { $('').appendTo(tr); $('').appendTo(tr); diff --git a/lib/report_plugins/daytoday.js b/lib/report_plugins/daytoday.js index ef62099c52c..bb2ff4bf03a 100644 --- a/lib/report_plugins/daytoday.js +++ b/lib/report_plugins/daytoday.js @@ -32,7 +32,7 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { function getTimeFormat() { var timeFormat = FORMAT_TIME_12; - if (Nightscout.client.settings.timeFormat == '24') { + if (Nightscout.client.settings.timeFormat === '24') { timeFormat = FORMAT_TIME_24; } return timeFormat; @@ -49,8 +49,8 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { , foodtexts = 0; // Tick Values - if (options.scale == report_plugins.getProperty('SCALE_LOG')) { - if (client.settings.units == 'mmol') { + if (options.scale === report_plugins.getProperty('SCALE_LOG')) { + if (client.settings.units === 'mmol') { tickValues = [ 2.0 , 3.0 @@ -74,7 +74,7 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { ]; } } else { - if (client.settings.units == 'mmol') { + if (client.settings.units === 'mmol') { tickValues = [ 2.0 , 4.0 @@ -122,7 +122,7 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { xScale2 = d3.time.scale() .domain(d3.extent(data.sgv, function (d) { return d.date; })); - if (options.scale == report_plugins.getProperty('SCALE_LOG')) { + if (options.scale === report_plugins.getProperty('SCALE_LOG')) { yScale2 = d3.scale.log() .domain([client.utils.scaleMgdl(36), client.utils.scaleMgdl(420)]); } else { @@ -226,15 +226,15 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { } }) .attr('fill', function (d) { - if (d.color == 'gray' && !options.raw) { + if (d.color === 'gray' && !options.raw) { return 'transparent'; } return d.color; }) .style('opacity', function (d) { 0.5 }) - .attr('stroke-width', function (d) {if (d.type == 'mbg') return 2; else return 0; }) + .attr('stroke-width', function (d) {if (d.type === 'mbg') return 2; else return 0; }) .attr('stroke', function (d) { return 'black'; }) - .attr('r', function(d) { if (d.type == 'mbg') { return 4; } else { return 2; }}); + .attr('r', function(d) { if (d.type === 'mbg') { return 4; } else { return 2; }}); if (badData.length > 0) { console.warn('Bad Data: isNaN(sgv)', badData); @@ -254,14 +254,14 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { for (var dt=from; dt < to; dt.add(5, 'minutes')) { if (options.iob) { var iob = Nightscout.plugins('iob').calcTotal(data.treatments,profile,dt.toDate()).iob; - if (dt!=from) { + if (dt!==from) { iobpolyline += ', '; } iobpolyline += (xScale2(dt) + padding.left) + ',' + (yInsulinScale(iob) + padding.top) + ' '; } if (options.cob) { var cob = Nightscout.plugins('cob').cobTotal(data.treatments,profile,dt.toDate()).cob; - if (dt!=from) { + if (dt!==from) { cobpolyline += ', '; } cobpolyline += (xScale2(dt.toDate()) + padding.left) + ',' + (yCarbsScale(cob) + padding.top) + ' '; diff --git a/lib/report_plugins/glucosedistribution.js b/lib/report_plugins/glucosedistribution.js index 332916fcf44..7511e1d1a8e 100644 --- a/lib/report_plugins/glucosedistribution.js +++ b/lib/report_plugins/glucosedistribution.js @@ -46,9 +46,9 @@ glucosedistribution.report = function report_glucosedistribution(datastorage,day ['Low', 'Normal', 'High'].forEach(function(range) { var tr = $(''); var rangeRecords = data.filter(function(r) { - if (range == 'Low') { + if (range === 'Low') { return r.sgv > 0 && r.sgv < options.targetLow; - } else if (range == 'Normal') { + } else if (range === 'Normal') { return r.sgv >= options.targetLow && r.sgv < options.targetHigh; } else { return r.sgv >= options.targetHigh; diff --git a/lib/report_plugins/hourlystats.js b/lib/report_plugins/hourlystats.js index 4fa8929aaaf..a4fff3b1d8e 100644 --- a/lib/report_plugins/hourlystats.js +++ b/lib/report_plugins/hourlystats.js @@ -13,7 +13,7 @@ function init() { module.exports = init; -hourlystats.report = function report_hourlystats(datastorage,daystoshow,options) { +hourlystats.report = function report_hourlystats(datastorage,daystoshow) { var Nightscout = window.Nightscout; var client = Nightscout.client; var translate = client.translate; @@ -108,7 +108,7 @@ hourlystats.report = function report_hourlystats(datastorage,daystoshow,options) }, yaxis: { min: 0, - max: serverSettings.units == 'mmol' ? 22: 400, + max: serverSettings.units === 'mmol' ? 22: 400, show: true }, grid: { diff --git a/lib/report_plugins/percentile.js b/lib/report_plugins/percentile.js index cd107433ceb..c405c762997 100644 --- a/lib/report_plugins/percentile.js +++ b/lib/report_plugins/percentile.js @@ -36,7 +36,7 @@ percentile.report = function report_percentile(datastorage,daystoshow,options) { date.setMinutes(minute); var readings = data.filter(function(record) { var recdate = new Date(record.displayTime); - return recdate.getHours() == hour && recdate.getMinutes() >= minute && + return recdate.getHours() === hour && recdate.getMinutes() >= minute && recdate.getMinutes() < minute + minutewindow; }); readings = readings.map(function(record) { @@ -145,7 +145,7 @@ percentile.report = function report_percentile(datastorage,daystoshow,options) { }, yaxis: { min: 0, - max: serverSettings.units == 'mmol' ? 22: 400, + max: serverSettings.units === 'mmol' ? 22: 400, tickColor: '#555', }, grid: { diff --git a/lib/report_plugins/success.js b/lib/report_plugins/success.js index b693d7459e7..1f20b0f0231 100644 --- a/lib/report_plugins/success.js +++ b/lib/report_plugins/success.js @@ -40,7 +40,7 @@ success.report = function report_success(datastorage,daystoshow,options) { grid.empty(); var table = $('
'+translate('Time')+''+translate('Event Type')+''+translate('Blood Glucose')+''+translate('Insulin')+''+translate('Carbs')+''+translate('Entered By')+''+translate('Notes')+'
').appendTo(tr); $('' + report_plugins.utils.localeDate(dayInQuestion) + ''+translate('No data available')+'
'); - if (quarters == 0) { + if (quarters === 0) { // insufficent data grid.append('

'+translate('There is not sufficient data to run this report. Select more days.')+'

'); return; @@ -181,7 +181,7 @@ success.report = function report_success(datastorage,daystoshow,options) { text: quarter.upperQuartile } ].map(function(v) { - if (typeof v == 'object') { + if (typeof v === 'object') { return ''; } else { return ''; diff --git a/lib/report_plugins/treatments.js b/lib/report_plugins/treatments.js index 992955ad743..c10b53dc048 100644 --- a/lib/report_plugins/treatments.js +++ b/lib/report_plugins/treatments.js @@ -52,7 +52,7 @@ treatments.report = function report_treatments(datastorage,daystoshow,options) { xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); xhr.setRequestHeader('api-secret', Nightscout.auth.hash()); xhr.onload = function () { - if (xhr.statusText!='OK') { + if (xhr.statusText!=='OK') { alert(translate('Deleting record failed')); } } @@ -127,7 +127,7 @@ treatments.report = function report_treatments(datastorage,daystoshow,options) { xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); xhr.setRequestHeader('api-secret', Nightscout.auth.hash()); xhr.onload = function () { - if (xhr.statusText!='OK') { + if (xhr.statusText!=='OK') { alert(translate('Saving record failed')); } } diff --git a/lib/report_plugins/utils.js b/lib/report_plugins/utils.js index 4cd5d5d68dd..1f240fbf220 100644 --- a/lib/report_plugins/utils.js +++ b/lib/report_plugins/utils.js @@ -50,9 +50,9 @@ utils.scaledTreatmentBG = function scaledTreatmentBG(treatment,data) { console.warn('found an invalid glucose value', treatment); } else { if (treatment.glucose && treatment.units && client.settings.units) { - if (treatment.units != client.settings.units) { + if (treatment.units !== client.settings.units) { console.info('found mismatched glucose units, converting ' + treatment.units + ' into ' + client.settings.units, treatment); - if (treatment.units == 'mmol') { + if (treatment.units === 'mmol') { //BG is in mmol and display in mg/dl treatmentGlucose = Math.round(treatment.glucose * 18) } else { diff --git a/static/report/js/report.js b/static/report/js/report.js index 5726cffcb19..1d9b9c61387 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -68,7 +68,7 @@ filter.category = $('#rp_category').val(); filter.subcategory = ''; $('#rp_subcategory').empty().append(new Option(translate('(none)'),'')); - if (filter.category != '') { + if (filter.category !== '') { for (var s in food_categories[filter.category]) { $('#rp_subcategory').append(new Option(s,s)); } @@ -84,9 +84,9 @@ } $('#rp_food').empty(); for (var i=0; i'+translate('Loading')+' ...'); $('#charts').html(''); for (var d in daystoshow) { - if (daystoshow[d]==matchesneeded) { + if (daystoshow[d]===matchesneeded) { if (displayeddays < maxdays) { $('#charts').append($('
')); loadData(d,options); @@ -365,7 +365,7 @@ delete daystoshow[d]; } } - if (displayeddays==0) { + if (displayeddays===0) { $('#charts').html(''+translate('Result is empty')+''); $('#info').empty(); } @@ -423,7 +423,7 @@ function loadData(day,options) { // check for loaded data - if (datastorage[day] && day != moment().format('YYYY-MM-DD')) { + if (datastorage[day] && day !== moment().format('YYYY-MM-DD')) { showreports(options); return; } @@ -465,7 +465,7 @@ console.log(xhr); , rssi: element.rssi , sgv: element.sgv }); - } else if (element.type == 'cal') { + } else if (element.type === 'cal') { calData.push({ x: element.date , d: element.dateString @@ -553,7 +553,7 @@ console.log(data.sgv); // for other reports data.statsrecords = data.sgv.filter(function(r) { - if (r.type) return r.type == 'sgv'; + if (r.type) return r.type === 'sgv'; else return true; }).map(function (r) { var ret = {}; From 1e16946399d87eec027b6669daae8cb53673c2c6 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 28 Aug 2015 22:42:05 +0200 Subject: [PATCH 009/176] maybePreventDefault --- static/report/js/report.js | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/static/report/js/report.js b/static/report/js/report.js index 1d9b9c61387..9ffbc6d4fde 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -1,3 +1,6 @@ +// TODO: +// - bypass nightmode in reports + (function () { 'use strict'; //for the tests window isn't the global object @@ -57,14 +60,10 @@ $('#rp_subcategory').change(doFoodFilter); $('#rp_name').on('input',doFoodFilter); - if (event) event.preventDefault(); - return false; + return maybePreventDefault(event); } function fillFoodSubcategories(event) { - if (event) { - event.preventDefault(); - } filter.category = $('#rp_category').val(); filter.subcategory = ''; $('#rp_subcategory').empty().append(new Option(translate('(none)'),'')); @@ -74,6 +73,7 @@ } } doFoodFilter(); + return maybePreventDefault(event); } function doFoodFilter(event) { @@ -95,7 +95,7 @@ $('#rp_food').append(new Option(o,food_list[i]._id)); } - if (event) event.preventDefault(); + return maybePreventDefault(event); } // ****** FOOD CODE END ****** @@ -149,12 +149,12 @@ $('#rp_show').click(show); $('#rp_food').change(function (event) { - event.preventDefault(); $('#rp_enablefood').prop('checked',true); + return maybePreventDefault(event); }); - $('#rp_notes').change(function (event) { - event.preventDefault(); + $('#rp_notes').change(function (event) { $('#rp_enablenotes').prop('checked',true); + return maybePreventDefault(event); }); $('#rp_targetlow').val(targetBGdefault[client.settings.units].low); @@ -169,12 +169,12 @@ $('#rp_show').click(show); $('#rp_food').change(function (event) { - event.preventDefault(); $('#rp_enablefood').prop('checked',true); + return maybePreventDefault(event); }); $('#rp_notes').change(function (event) { - event.preventDefault(); $('#rp_enablenotes').prop('checked',true); + return maybePreventDefault(event); }); $('#rp_targetlow').val(targetBGdefault[client.settings.units].low); @@ -374,7 +374,7 @@ $('#rp_show').css('display','none'); daystoshow = {}; datefilter(); - if (event) event.preventDefault(); + return maybePreventDefault(event); } function showreports(options) { @@ -406,8 +406,7 @@ function setDataRange(event,days) { $('#rp_to').val(moment().format('YYYY-MM-DD')); $('#rp_from').val(moment().add(-days+1, 'days').format('YYYY-MM-DD')); - - if (event) event.preventDefault(); + return maybePreventDefault(event); } function switchreport_handler(event) { @@ -418,7 +417,7 @@ $('.tabplaceholder').css('display','none'); $('#'+id+'-placeholder').css('display',''); - + return maybePreventDefault(event); } function loadData(day,options) { @@ -570,4 +569,10 @@ console.log(data.sgv); showreports(options); } + function maybePreventDefault(event) { + if (event) { + event.preventDefault(); + } + return false; + } })(); \ No newline at end of file From 643cf0032bbbd3a0661d4ad2c91f5b6684871c56 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 28 Aug 2015 22:56:56 +0200 Subject: [PATCH 010/176] if brackets --- lib/report_plugins/calibrations.js | 31 +++++++---- lib/report_plugins/dailystats.js | 8 ++- lib/report_plugins/success.js | 4 +- static/report/js/report.js | 87 +++++++++++++++++------------- 4 files changed, 82 insertions(+), 48 deletions(-) diff --git a/lib/report_plugins/calibrations.js b/lib/report_plugins/calibrations.js index 9dda3c1dc34..547c788a2f7 100644 --- a/lib/report_plugins/calibrations.js +++ b/lib/report_plugins/calibrations.js @@ -18,8 +18,12 @@ calibrations.report = function report_calibrations(datastorage,daystoshow,option var treatments = []; Object.keys(daystoshow).forEach(function (day) { treatments = treatments.concat(datastorage[day].treatments.filter(function (t) { - if (t.eventType === 'Sensor Start') return true; - if (t.eventType === 'Sensor Change') return true; + if (t.eventType === 'Sensor Start') { + return true; + } + if (t.eventType === 'Sensor Change') { + return true; + } return false; })); }); @@ -50,14 +54,18 @@ calibrations.report = function report_calibrations(datastorage,daystoshow,option for (var i=0; i
'; }; @@ -80,7 +90,9 @@ calibrations.report = function report_calibrations(datastorage,daystoshow,option if (typeof events[i].device !== 'undefined') { events[i].checked = true; $('#calibrations-'+i).prop('checked',true); - if (--maxcals<1) break; + if (--maxcals<1) { + break; + } } } calibrations_drawelements(); @@ -245,8 +257,9 @@ calibrations.report = function report_calibrations(datastorage,daystoshow,option var last = null; var time = date.getTime(); for (var i=0; i time) + if (storage[i].x > time) { return last; + } last = storage[i]; } return last; diff --git a/lib/report_plugins/dailystats.js b/lib/report_plugins/dailystats.js index 6367bebd6c2..b998064cea1 100644 --- a/lib/report_plugins/dailystats.js +++ b/lib/report_plugins/dailystats.js @@ -66,8 +66,12 @@ dailystats.report = function report_dailystats(datastorage,daystoshow,options) { } else { out.highs++; } - if (minForDay > record.sgv) minForDay = record.sgv; - if (maxForDay < record.sgv) maxForDay = record.sgv; + if (minForDay > record.sgv) { + minForDay = record.sgv; + } + if (maxForDay < record.sgv) { + maxForDay = record.sgv; + } return out; }, { lows: 0, diff --git a/lib/report_plugins/success.js b/lib/report_plugins/success.js index 1f20b0f0231..18e7c03a3fb 100644 --- a/lib/report_plugins/success.js +++ b/lib/report_plugins/success.js @@ -33,7 +33,9 @@ success.report = function report_success(datastorage,daystoshow,options) { var firstDataPoint = data.reduce(function(min, record) { return Math.min(min, record.displayTime); }, Number.MAX_VALUE); - if (firstDataPoint < 1390000000000) firstDataPoint = 1390000000000; + if (firstDataPoint < 1390000000000) { + firstDataPoint = 1390000000000; + } var quarters = Math.floor((Date.now() - firstDataPoint) / period); var grid = $('#success-grid'); diff --git a/static/report/js/report.js b/static/report/js/report.js index 9ffbc6d4fde..c8b20da8086 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -84,9 +84,9 @@ } $('#rp_food').empty(); for (var i=0; i
' + v.text + '' + v + ''; e.bgcolor = colors[colorindex]; - if (e.eventType) + if (e.eventType) { html += ''+translate(e.eventType)+':
'; - else if (typeof e.device !== 'undefined') { + } else if (typeof e.device !== 'undefined') { html += ' '; html += 'MBG: ' + e.y + ' Raw: '+e.raw+'
'; lastmbg = e; @@ -66,7 +74,9 @@ calibrations.report = function report_calibrations(datastorage,daystoshow,option } else if (typeof e.scale !== 'undefined') { html += 'CAL: ' + ' Scale: ' + e.scale.toFixed(2) + ' Intercept: ' + e.intercept.toFixed(0) + ' Slope: ' + e.slope.toFixed(2) + '
'; if (lastmbg) lastmbg.cals.push(e); - } else html += JSON.stringify(e); + } else { + html += JSON.stringify(e); + } html += '
'; var lastmbg = null; for (var i=0; i0; i--) { + for (i=events.length-1; i>0; i--) { if (typeof events[i].device !== 'undefined') { events[i].checked = true; $('#calibrations-'+i).prop('checked',true); @@ -264,4 +264,4 @@ calibrations.report = function report_calibrations(datastorage,daystoshow,option } return last; } -} +}; diff --git a/lib/report_plugins/dailystats.js b/lib/report_plugins/dailystats.js index b998064cea1..24e118dfdc8 100644 --- a/lib/report_plugins/dailystats.js +++ b/lib/report_plugins/dailystats.js @@ -21,7 +21,6 @@ dailystats.report = function report_dailystats(datastorage,daystoshow,options) { var todo = []; var report = $('#dailystats-report'); var minForDay, maxForDay; - var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec']; report.empty(); var table = $('
'); @@ -127,4 +126,4 @@ dailystats.report = function report_dailystats(datastorage,daystoshow,options) { fn(); }); }, 50); -} +}; diff --git a/lib/report_plugins/daytoday.js b/lib/report_plugins/daytoday.js index bb2ff4bf03a..3c2503eca4f 100644 --- a/lib/report_plugins/daytoday.js +++ b/lib/report_plugins/daytoday.js @@ -16,7 +16,6 @@ module.exports = init; daytoday.report = function report_daytoday(datastorage,daystoshow,options) { var Nightscout = window.Nightscout; var client = Nightscout.client; - var translate = client.translate; var profile = client.sbx.data.profile; var report_plugins = Nightscout.report_plugins; var scaledTreatmentBG = report_plugins.utils.scaledTreatmentBG; @@ -231,9 +230,9 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { } return d.color; }) - .style('opacity', function (d) { 0.5 }) + .style('opacity', function () { return 0.5 }) .attr('stroke-width', function (d) {if (d.type === 'mbg') return 2; else return 0; }) - .attr('stroke', function (d) { return 'black'; }) + .attr('stroke', function () { return 'black'; }) .attr('r', function(d) { if (d.type === 'mbg') { return 4; } else { return 2; }}); if (badData.length > 0) { @@ -248,7 +247,7 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { contextCircles.exit() .remove(); - var to = moment(day).add(1, 'days') //.add(new Date().getTimezoneOffset(), 'minutes'); + var to = moment(day).add(1, 'days'); //.add(new Date().getTimezoneOffset(), 'minutes'); var from = moment(day); //.add(new Date().getTimezoneOffset(), 'minutes'); var iobpolyline = '', cobpolyline = ''; for (var dt=from; dt < to; dt.add(5, 'minutes')) { @@ -382,4 +381,4 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { } }); } -} +}; diff --git a/lib/report_plugins/glucosedistribution.js b/lib/report_plugins/glucosedistribution.js index 7511e1d1a8e..52806f08399 100644 --- a/lib/report_plugins/glucosedistribution.js +++ b/lib/report_plugins/glucosedistribution.js @@ -21,7 +21,6 @@ glucosedistribution.report = function report_glucosedistribution(datastorage,day var Statician = ss; var report = $('#glucosedistribution-report'); report.empty(); - var minForDay, maxForDay; var stats = []; var table = $('
'); var thead = $(''); @@ -115,4 +114,4 @@ glucosedistribution.report = function report_glucosedistribution(datastorage,day } ); }); -} +}; diff --git a/lib/report_plugins/hourlystats.js b/lib/report_plugins/hourlystats.js index a4fff3b1d8e..69321abccff 100644 --- a/lib/report_plugins/hourlystats.js +++ b/lib/report_plugins/hourlystats.js @@ -116,4 +116,4 @@ hourlystats.report = function report_hourlystats(datastorage,daystoshow) { } } ); -} \ No newline at end of file +}; \ No newline at end of file diff --git a/lib/report_plugins/percentile.js b/lib/report_plugins/percentile.js index c405c762997..bf38d68f62d 100644 --- a/lib/report_plugins/percentile.js +++ b/lib/report_plugins/percentile.js @@ -18,7 +18,6 @@ percentile.report = function report_percentile(datastorage,daystoshow,options) { var client = Nightscout.client; var translate = client.translate; - var Statician = ss; var minutewindow = 30; //minute-window should be a divisor of 60 var data = []; @@ -168,4 +167,4 @@ percentile.report = function report_percentile(datastorage,daystoshow,options) { } } ); -} +}; diff --git a/lib/report_plugins/success.js b/lib/report_plugins/success.js index 18e7c03a3fb..b02afa48747 100644 --- a/lib/report_plugins/success.js +++ b/lib/report_plugins/success.js @@ -54,12 +54,12 @@ success.report = function report_success(datastorage,daystoshow,options) { a[i]=0; } return a; - } + }; var sum = function(a) { return a.reduce(function(sum,v) { return sum+v; }, 0); - } + }; var averages = { percentLow: 0, percentInRange: 0, @@ -119,7 +119,7 @@ success.report = function report_success(datastorage,daystoshow,options) { } else { return ''; } - } + }; var lowQuartileEvaluation = function(quarter, averages) { if (quarter.lowerQuartile < low) { @@ -127,7 +127,7 @@ success.report = function report_success(datastorage,daystoshow,options) { } else { return lowComparison(quarter, averages, 'lowerQuartile'); } - } + }; var upperQuartileEvaluation = function(quarter, averages) { if (quarter.upperQuartile > high) { @@ -135,17 +135,7 @@ success.report = function report_success(datastorage,daystoshow,options) { } else { return lowComparison(quarter, averages, 'upperQuartile'); } - } - - var averageEvaluation = function(quarter, averages) { - if (quarter.average > high) { - return 'bad'; - } else if (quarter.average < low) { - return 'bad'; - } else { - return lowComparison(quarter, averages, 'average', true); - } - } + }; table.append(''); table.append('' + quarters.filter(function(quarter) { diff --git a/lib/report_plugins/treatments.js b/lib/report_plugins/treatments.js index c10b53dc048..df911e4944d 100644 --- a/lib/report_plugins/treatments.js +++ b/lib/report_plugins/treatments.js @@ -13,7 +13,7 @@ function init() { module.exports = init; -treatments.report = function report_treatments(datastorage,daystoshow,options) { +treatments.report = function report_treatments(datastorage,daystoshow) { function deleteTreatment(event) { var data = JSON.parse($(this).attr('data')); @@ -55,7 +55,7 @@ treatments.report = function report_treatments(datastorage,daystoshow,options) { if (xhr.statusText!=='OK') { alert(translate('Deleting record failed')); } - } + }; xhr.send(null); return true; } @@ -86,12 +86,12 @@ treatments.report = function report_treatments(datastorage,daystoshow,options) { } }, { text: translate('Cancel'), - click: function () { $( this ).dialog( "close" ); } + click: function () { $( this ).dialog( 'close' ); } } ] - , open : function(ev, ui) { + , open : function() { $(this).parent().css('box-shadow', '20px 20px 20px 0px black'); - $(this).parent().find('.ui-dialog-buttonset' ).css({'width':'100%','text-align':'right'}) + $(this).parent().find('.ui-dialog-buttonset' ).css({'width':'100%','text-align':'right'}); $(this).parent().find('button:contains("'+translate('Save')+'")').css({'float':'left'}); $('#rp_eventType').val(translate(data.eventType)); $('#rp_glucoseValue').val(data.glucose ? data.glucose : '').attr('placeholder', translate('Value in') + ' ' + serverSettings.units); @@ -157,7 +157,7 @@ treatments.report = function report_treatments(datastorage,daystoshow,options) { table += ' '; table += ''; table += ''; - table += ''; + table += ''; table += ''; table += ''; table += ''; diff --git a/lib/report_plugins/utils.js b/lib/report_plugins/utils.js index 1f240fbf220..98fac2c7f57 100644 --- a/lib/report_plugins/utils.js +++ b/lib/report_plugins/utils.js @@ -15,12 +15,12 @@ utils.localeDate = function localeDate(day) { ret += ' '; ret += new Date(day).toLocaleDateString(); return ret; -} +}; utils.localeDateTime = function localeDateTime(day) { var ret = new Date(day).toLocaleDateString() + ' ' + new Date(day).toLocaleTimeString(); return ret; -} +}; utils.scaledTreatmentBG = function scaledTreatmentBG(treatment,data) { var client = Nightscout.client; @@ -70,4 +70,4 @@ utils.scaledTreatmentBG = function scaledTreatmentBG(treatment,data) { } return treatmentGlucose || client.utils.scaleMgdl(calcBGByTime(treatment.mills)); -} +}; From 91469499c39446bf0d77d1fd44f7f84b8bb55585 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 28 Aug 2015 23:29:57 +0200 Subject: [PATCH 012/176] codacy pass 2 --- lib/api/treatments/index.js | 5 +++-- lib/report_plugins/success.js | 2 +- lib/report_plugins/treatments.js | 4 +++- lib/treatments.js | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/api/treatments/index.js b/lib/api/treatments/index.js index cec3a375fab..30aaf48b76e 100644 --- a/lib/api/treatments/index.js +++ b/lib/api/treatments/index.js @@ -27,10 +27,11 @@ function configure (app, wares, ctx) { function post_response(req, res) { var treatment = req.body; ctx.treatments.create(treatment, function (err, created) { - if (err) + if (err) { res.sendJSONStatus(res, consts.HTTP_INTERNAL_ERROR, 'Mongo Error', err); - else + } else { res.json(created); + } }); } if (app.treatments_auth) diff --git a/lib/report_plugins/success.js b/lib/report_plugins/success.js index b02afa48747..45f98cc8d69 100644 --- a/lib/report_plugins/success.js +++ b/lib/report_plugins/success.js @@ -182,4 +182,4 @@ success.report = function report_success(datastorage,daystoshow,options) { }).join('') + ''); table.appendTo(grid); -} \ No newline at end of file +}; \ No newline at end of file diff --git a/lib/report_plugins/treatments.js b/lib/report_plugins/treatments.js index df911e4944d..f367f7535f9 100644 --- a/lib/report_plugins/treatments.js +++ b/lib/report_plugins/treatments.js @@ -37,7 +37,9 @@ treatments.report = function report_treatments(datastorage,daystoshow) { delete datastorage[day]; show(); } - if (event) event.preventDefault(); + if (event) { + event.preventDefault(); + } return false; } diff --git a/lib/treatments.js b/lib/treatments.js index 94d7c3cba92..2e9e23f85ef 100644 --- a/lib/treatments.js +++ b/lib/treatments.js @@ -55,7 +55,7 @@ function storage (env, ctx) { } function remove (_id, fn) { - return api( ).remove({ "_id": new ObjectID(_id) }, fn); + return api( ).remove({ '_id': new ObjectID(_id) }, fn); } function save (obj, fn) { From 2fdb03bece3c936c60e01c6d2670b4331594b208 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sat, 29 Aug 2015 00:20:16 +0200 Subject: [PATCH 013/176] codacy pass 3 --- lib/api/treatments/index.js | 6 +++--- lib/report_plugins/calibrations.js | 6 ++++-- lib/report_plugins/daytoday.js | 10 +++++----- lib/report_plugins/treatments.js | 8 +++++--- lib/report_plugins/utils.js | 2 +- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/api/treatments/index.js b/lib/api/treatments/index.js index 30aaf48b76e..c6fd36f4c8b 100644 --- a/lib/api/treatments/index.js +++ b/lib/api/treatments/index.js @@ -34,11 +34,11 @@ function configure (app, wares, ctx) { } }); } - if (app.treatments_auth) + if (app.treatments_auth) { api.post('/treatments/', wares.verifyAuthorization, post_response); - else + } else { api.post('/treatments/', post_response); - + } api.delete('/treatments/:_id', wares.verifyAuthorization, function(req, res) { ctx.treatments.remove(req.params._id, function ( ) { res.json({ }); diff --git a/lib/report_plugins/calibrations.js b/lib/report_plugins/calibrations.js index 4613cef5dac..49e8632c159 100644 --- a/lib/report_plugins/calibrations.js +++ b/lib/report_plugins/calibrations.js @@ -13,7 +13,7 @@ function init() { module.exports = init; -calibrations.report = function report_calibrations(datastorage,daystoshow,options) { +calibrations.report = function report_calibrations(datastorage,daystoshow) { var padding = { top: 15, right: 15, bottom: 30, left: 70 }; var treatments = []; Object.keys(daystoshow).forEach(function (day) { @@ -73,7 +73,9 @@ calibrations.report = function report_calibrations(datastorage,daystoshow,option e.checked = false; } else if (typeof e.scale !== 'undefined') { html += 'CAL: ' + ' Scale: ' + e.scale.toFixed(2) + ' Intercept: ' + e.intercept.toFixed(0) + ' Slope: ' + e.slope.toFixed(2) + '
'; - if (lastmbg) lastmbg.cals.push(e); + if (lastmbg) { + lastmbg.cals.push(e); + } } else { html += JSON.stringify(e); } diff --git a/lib/report_plugins/daytoday.js b/lib/report_plugins/daytoday.js index 3c2503eca4f..9a8b52da7b4 100644 --- a/lib/report_plugins/daytoday.js +++ b/lib/report_plugins/daytoday.js @@ -25,9 +25,9 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { FORMAT_TIME_12 = '%I' , FORMAT_TIME_24 = '%H'; - for (var day in daystoshow) { + _.each(daystoshow, function (n, day) { drawChart(day,datastorage[day],options); - } + }); function getTimeFormat() { var timeFormat = FORMAT_TIME_12; @@ -196,7 +196,7 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { .style('fill', 'none') .call(xAxis2); - for (var li in tickValues) { + _.each(tickValues, function (n, li) { context.append('line') .attr('class', 'high-line') .attr('x1', xScale2(dataRange[0])+padding.left) @@ -205,7 +205,7 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { .attr('y2', yScale2(tickValues[li])+padding.top) .style('stroke-dasharray', ('3, 3')) .attr('stroke', 'grey'); - } + }); // bind up the context chart data to an array of circles var contextCircles = context.selectAll('circle') @@ -231,7 +231,7 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { return d.color; }) .style('opacity', function () { return 0.5 }) - .attr('stroke-width', function (d) {if (d.type === 'mbg') return 2; else return 0; }) + .attr('stroke-width', function (d) {if (d.type === 'mbg') { return 2; } else { return 0; }}) .attr('stroke', function () { return 'black'; }) .attr('r', function(d) { if (d.type === 'mbg') { return 4; } else { return 2; }}); diff --git a/lib/report_plugins/treatments.js b/lib/report_plugins/treatments.js index f367f7535f9..8e24f9a6ed2 100644 --- a/lib/report_plugins/treatments.js +++ b/lib/report_plugins/treatments.js @@ -111,7 +111,9 @@ treatments.report = function report_treatments(datastorage,daystoshow) { }); - if (event) event.preventDefault(); + if (event) { + event.preventDefault(); + } return false; } @@ -132,7 +134,7 @@ treatments.report = function report_treatments(datastorage,daystoshow) { if (xhr.statusText!=='OK') { alert(translate('Saving record failed')); } - } + }; xhr.send(dataJson); return true; } @@ -173,5 +175,5 @@ treatments.report = function report_treatments(datastorage,daystoshow) { $('#treatments-report').html(table); $('.deleteTreatment').click(deleteTreatment); $('.editTreatment').click(editTreatment); -} +}; diff --git a/lib/report_plugins/utils.js b/lib/report_plugins/utils.js index 98fac2c7f57..d5e00cc3f1d 100644 --- a/lib/report_plugins/utils.js +++ b/lib/report_plugins/utils.js @@ -54,7 +54,7 @@ utils.scaledTreatmentBG = function scaledTreatmentBG(treatment,data) { console.info('found mismatched glucose units, converting ' + treatment.units + ' into ' + client.settings.units, treatment); if (treatment.units === 'mmol') { //BG is in mmol and display in mg/dl - treatmentGlucose = Math.round(treatment.glucose * 18) + treatmentGlucose = Math.round(treatment.glucose * 18); } else { //BG is in mg/dl and display in mmol treatmentGlucose = client.utils.scaleMgdl(treatment.glucose); From 03e165293d959db65c7a27e2a4a76b446986ea5c Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sat, 29 Aug 2015 22:11:44 +0200 Subject: [PATCH 014/176] make html plugin's code dymnamicaly injected on load --- lib/report_plugins/calibrations.js | 18 +- lib/report_plugins/dailystats.js | 8 +- lib/report_plugins/daytoday.js | 45 +++- lib/report_plugins/glucosedistribution.js | 16 +- lib/report_plugins/hourlystats.js | 6 + lib/report_plugins/index.js | 32 ++- lib/report_plugins/percentile.js | 9 +- lib/report_plugins/success.js | 7 +- lib/report_plugins/treatments.js | 7 +- static/report/index.html | 237 ++++++++-------------- static/report/js/report.js | 26 ++- 11 files changed, 217 insertions(+), 194 deletions(-) diff --git a/lib/report_plugins/calibrations.js b/lib/report_plugins/calibrations.js index 49e8632c159..8310b920d9a 100644 --- a/lib/report_plugins/calibrations.js +++ b/lib/report_plugins/calibrations.js @@ -1,4 +1,5 @@ 'use strict'; +var translate = require('../language')().translate; var calibrations = { name: 'calibrations' @@ -12,6 +13,11 @@ function init() { module.exports = init; +calibrations.html = + '

' + translate('Calibrations') + '

' + + '
' + + '
' + ; calibrations.report = function report_calibrations(datastorage,daystoshow) { var padding = { top: 15, right: 15, bottom: 30, left: 70 }; @@ -113,10 +119,8 @@ calibrations.report = function report_calibrations(datastorage,daystoshow) { for (var i=0; i' + translate('Daily stats report') + '' + + '
' + ; + dailystats.report = function report_dailystats(datastorage,daystoshow,options) { var Nightscout = window.Nightscout; var client = Nightscout.client; diff --git a/lib/report_plugins/daytoday.js b/lib/report_plugins/daytoday.js index 9a8b52da7b4..cb86dc38e30 100644 --- a/lib/report_plugins/daytoday.js +++ b/lib/report_plugins/daytoday.js @@ -1,8 +1,9 @@ 'use strict'; +var translate = require('../language')().translate; var daytoday = { name: 'daytoday' - , label: 'Daytoday' + , label: 'Day to day' , pluginType: 'report' }; @@ -12,6 +13,39 @@ function init() { module.exports = init; +daytoday.html = + translate('Display') + + ''+translate('Insulin')+'' + + ''+translate('Carbs')+'' + + ''+translate('Notes') + + ''+translate('Food') + + ''+translate('Raw')+'' + + ''+translate('IOB')+'' + + ''+translate('COB')+'' + + ' '+translate('Size') + + '' + + '
' + + translate('Scale') + + '' + + translate('Linear') + + '' + + translate('Logarithmic') + + '
' + + '
' + + '
' + ; + +daytoday.prepareHtml = function daytodayPrepareHtml(daystoshow) { + $('#daytodaycharts').empty(); + for (var d in daystoshow) { + $('#daytodaycharts').append($('
')); + } +}; daytoday.report = function report_daytoday(datastorage,daystoshow,options) { var Nightscout = window.Nightscout; @@ -24,7 +58,8 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { var FORMAT_TIME_12 = '%I' , FORMAT_TIME_24 = '%H'; - + + daytoday.prepareHtml(daystoshow) ; _.each(daystoshow, function (n, day) { drawChart(day,datastorage[day],options); }); @@ -48,7 +83,7 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { , foodtexts = 0; // Tick Values - if (options.scale === report_plugins.getProperty('SCALE_LOG')) { + if (options.scale === report_plugins.consts.SCALE_LOG) { if (client.settings.units === 'mmol') { tickValues = [ 2.0 @@ -104,7 +139,7 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { } // create svg and g to contain the chart contents - charts = d3.select('#'+report_plugins.getProperty('containerprefix')+day).html( + charts = d3.select('#daytodaychart-' + day).html( ''+ report_plugins.utils.localeDate(day)+ '
' @@ -121,7 +156,7 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { xScale2 = d3.time.scale() .domain(d3.extent(data.sgv, function (d) { return d.date; })); - if (options.scale === report_plugins.getProperty('SCALE_LOG')) { + if (options.scale === report_plugins.consts.SCALE_LOG) { yScale2 = d3.scale.log() .domain([client.utils.scaleMgdl(36), client.utils.scaleMgdl(420)]); } else { diff --git a/lib/report_plugins/glucosedistribution.js b/lib/report_plugins/glucosedistribution.js index 52806f08399..004cd17b3b4 100644 --- a/lib/report_plugins/glucosedistribution.js +++ b/lib/report_plugins/glucosedistribution.js @@ -1,8 +1,9 @@ 'use strict'; +var translate = require('../language')().translate; var glucosedistribution = { name: 'glucosedistribution' - , label: 'Glucose distribution' + , label: 'Distribution' , pluginType: 'report' }; @@ -12,6 +13,19 @@ function init() { module.exports = init; +glucosedistribution.html = + '

' + + translate('Glucose distribution') + + ' (' + + ' ' + + ' )' + + '

' + + '
' + + '
' + + '
' + + '
' + + translate('* This is only a rough estimation that can be very inaccurate and does not replace actual blood testing. The formula used is taken from: Nathan, David M., et al. "Translating the A1C assay into estimated average glucose values." Diabetes care 31.8 (2008): 1473-1478.') + ; glucosedistribution.report = function report_glucosedistribution(datastorage,daystoshow,options) { var Nightscout = window.Nightscout; diff --git a/lib/report_plugins/hourlystats.js b/lib/report_plugins/hourlystats.js index 69321abccff..aa1c13c8190 100644 --- a/lib/report_plugins/hourlystats.js +++ b/lib/report_plugins/hourlystats.js @@ -1,4 +1,5 @@ 'use strict'; +var translate = require('../language')().translate; var hourlystats = { name: 'hourlystats' @@ -12,6 +13,11 @@ function init() { module.exports = init; +hourlystats.html = + '

' + translate('Hourly stats') + '

' + + '
' + + '
' + ; hourlystats.report = function report_hourlystats(datastorage,daystoshow) { var Nightscout = window.Nightscout; diff --git a/lib/report_plugins/index.js b/lib/report_plugins/index.js index f7ff151e9ab..98d04e8901a 100644 --- a/lib/report_plugins/index.js +++ b/lib/report_plugins/index.js @@ -1,10 +1,13 @@ 'use strict'; var _ = require('lodash'); +var translate = require('../language')().translate; function init() { - - var properties = {} + var consts = { + SCALE_LINEAR: 0 + , SCALE_LOG: 1 + } , allPlugins = [ require('./daytoday')() , require('./dailystats')() @@ -28,15 +31,26 @@ function init() { _.each(allPlugins, f); }; - plugins.setProperty = function setProperty(p, val) { - properties[p] = val; - }; - - plugins.getProperty = function getProperty(p) { - return properties[p]; - }; + plugins.consts = consts; plugins.utils = require('./utils')(); + + plugins.addHtmlFromPlugins = function addHtmlFromPlugins(client) { + plugins.eachPlugin(function addHtml(p) { + // add main plugin html + if (p.html && ! $('#' + p.name + '-placeholder').length) { + $('#pluginchartplaceholders').append($('
').attr('id',p.name + '-placeholder').addClass('tabplaceholder').css('display','none').append(p.html)); + } + // add menu item + if (p.html && ! $('#' + p.name).length) { + $('#tabnav').append($('
  • ').attr('id',p.name).addClass('menutab').append(client.translate(p.label))); + } + // select 1st tab + $('#tabnav > li:first').addClass('selected'); + // show 1st report + $('#pluginchartplaceholders > div:first').css('display',''); + }); + }; return plugins(); diff --git a/lib/report_plugins/percentile.js b/lib/report_plugins/percentile.js index bf38d68f62d..ecbcfda6b7e 100644 --- a/lib/report_plugins/percentile.js +++ b/lib/report_plugins/percentile.js @@ -1,8 +1,9 @@ 'use strict'; +var translate = require('../language')().translate; var percentile = { name: 'percentile' - , label: 'Percentile' + , label: 'Percentile Chart' , pluginType: 'report' }; @@ -12,6 +13,12 @@ function init() { module.exports = init; +percentile.html = + '

    ' + translate('Glucose Percentile report') + '

    ' + + '
    ' + + '
    ' + + '
    ' + ; percentile.report = function report_percentile(datastorage,daystoshow,options) { var Nightscout = window.Nightscout; diff --git a/lib/report_plugins/success.js b/lib/report_plugins/success.js index 45f98cc8d69..c6155eea27e 100644 --- a/lib/report_plugins/success.js +++ b/lib/report_plugins/success.js @@ -1,8 +1,9 @@ 'use strict'; +var translate = require('../language')().translate; var success = { name: 'success' - , label: 'Success' + , label: 'Weekly success' , pluginType: 'report' }; @@ -12,6 +13,10 @@ function init() { module.exports = init; +success.html = + '

    ' + translate('Weekly Success') + '

    ' + + '
    ' + ; success.report = function report_success(datastorage,daystoshow,options) { var Nightscout = window.Nightscout; diff --git a/lib/report_plugins/treatments.js b/lib/report_plugins/treatments.js index 8e24f9a6ed2..038bb414afd 100644 --- a/lib/report_plugins/treatments.js +++ b/lib/report_plugins/treatments.js @@ -1,4 +1,5 @@ 'use strict'; +var translate = require('../language')().translate; var treatments = { name: 'treatments' @@ -12,7 +13,11 @@ function init() { module.exports = init; - +treatments.html = + '

    ' + translate('Treatments') + '

    ' + + '
    ' + ; + treatments.report = function report_treatments(datastorage,daystoshow) { function deleteTreatment(event) { diff --git a/static/report/index.html b/static/report/index.html index 2ab71406553..eecabd778e8 100644 --- a/static/report/index.html +++ b/static/report/index.html @@ -7,158 +7,85 @@

    Nightscout reporting

    -
      - - - - - - - - -
    -
  • '+translate('Period')+''+translate('Low')+''+translate('In Range')+''+translate('High')+''+translate('Standard Deviation')+''+translate('Low Quartile')+''+translate('Average')+''+translate('Upper Quartile')+'
    '+(new Date(tr.created_at).toLocaleTimeString().replace(/([\d]+:[\d]{2})(:[\d]{2})(.*)/, "$1$3"))+''+(new Date(tr.created_at).toLocaleTimeString().replace(/([\d]+:[\d]{2})(:[\d]{2})(.*)/, '$1$3'))+''+(tr.eventType ? tr.eventType : '')+''+(tr.glucose ? tr.glucose + ' ('+translate(tr.glucoseType)+')' : '')+''+(tr.insulin ? tr.insulin : '')+'
    - - - - - - - +
      +
    +
    - From: - To: - Today - Last 2 days - Last 3 days - Last week - Last 2 weeks - Last month - Last 3 months -
    - Category: - Subcategory: - Name: -
    + + + + + + + - - - - + + + + - - - - - - - - - - - - - - - - - - -
    + From: + To: + Today + Last 2 days + Last 3 days + Last week + Last 2 weeks + Last month + Last 3 months +
    + Category: + Subcategory: + Name: +
    - - - Food: -
    + + + Food: +
    - Notes contain: -
    - Event type contains: -
    - Mo - Tu - We - Th - Fr - Sa - Su -
    - Target bg range bottom: - - top: - -
    - -
    -
    -
    - Display: - Insulin - Carbs - Notes - Food - Raw - IOB - COB -  Size: - -
    - Scale: - - Linear - - Logarithmic -
    -
    -
    -
    - - - - - - - + + + + + Notes contain: + + + + + + + Event type contains: + + + + + Mo + Tu + We + Th + Fr + Sa + Su + + + + + + Target bg range bottom: + + top: + + + + + + +
    +
    +
    - - - + + + @@ -224,10 +151,10 @@

    Calibrations

    - + - - + + diff --git a/static/report/js/report.js b/static/report/js/report.js index c8b20da8086..bafacb31e90 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -16,8 +16,12 @@ } else { client.init(serverSettings, Nightscout.plugins); } + + // init HTML code + report_plugins.addHtmlFromPlugins( client ); var translate = client.translate; + //language.set(client.settings.language); var maxInsulinValue = 0 ,maxCarbsValue = 0; @@ -34,10 +38,6 @@ ONE_MIN_IN_MS = 60000 , SIX_MINS_IN_MS = 360000; - report_plugins.setProperty('SCALE_LINEAR', 0); - report_plugins.setProperty('SCALE_LOG', 1); - report_plugins.setProperty('containerprefix', 'chart-'); - // ****** FOOD CODE START ****** var food_categories = []; var food_list = []; @@ -198,7 +198,7 @@ carbs: true, iob : true, cob : true, - scale: report_plugins.getProperty('SCALE_LINEAR') + scale: report_plugins.consts.SCALE_LINEAR }; options.targetLow = parseFloat($('#rp_targetlow').val().replace(',','.')); @@ -210,7 +210,7 @@ options.food = $('#rp_optionsfood').is(':checked'); options.insulin = $('#rp_optionsinsulin').is(':checked'); options.carbs = $('#rp_optionscarbs').is(':checked'); - options.scale = $('#rp_linear').is(':checked') ? report_plugins.getProperty('SCALE_LINEAR') : report_plugins.getProperty('SCALE_LOG'); + options.scale = ( $('#rp_linear').is(':checked') ? report_plugins.consts.SCALE_LINEAR : report_plugins.consts.SCALE_LOG ); options.width = parseInt($('#rp_size :selected').attr('x')); options.height = parseInt($('#rp_size :selected').attr('y')); @@ -363,23 +363,21 @@ console.log('Total: ',daystoshow,'Needed: ',matchesneeded); var displayeddays = 0; $('#info').html(''+translate('Loading')+' ...'); - $('#charts').html(''); for (var d in daystoshow) { if (daystoshow[d]===matchesneeded) { if (displayeddays < maxdays) { - $('#charts').append($('
    ')); + $('#info').append($('
    ')); loadData(d,options); displayeddays++; } else { - $('#charts').append($('
    '+d+' '+translate('not displayed')+'.
    ')); + $('#info').append($('
    '+d+' '+translate('not displayed')+'.
    ')); } } else { delete daystoshow[d]; } } if (displayeddays===0) { - $('#charts').html(''+translate('Result is empty')+''); - $('#info').empty(); + $('#info').html(''+translate('Result is empty')+''); } } @@ -444,7 +442,7 @@ var to = from + 1000 * 60 * 60 * 24; var query = '?find[date][$gte]='+from+'&find[date][$lt]='+to+'&count=10000'; - $('#'+report_plugins.getProperty('containerprefix')+day).html(''+translate('Loading CGM data of')+' '+day+' ...'); + $('#info-' + day).html(''+translate('Loading CGM data of')+' '+day+' ...'); console.log('/api/v1/entries.json'+query); $.ajax('/api/v1/entries.json'+query, { success: function (xhr) { @@ -497,7 +495,7 @@ console.log(data.sgv); data.cal.sort(function(a, b) { return a.x - b.x; }); } }).done(function () { - $('#'+report_plugins.getProperty('containerprefix')+day).html(''+translate('Loading treatments data of')+' '+day+' ...'); + $('#info-' + day).html(''+translate('Loading treatments data of')+' '+day+' ...'); var tquery = '?find[created_at][$gte]='+new Date(from).toISOString()+'&find[created_at][$lt]='+new Date(to).toISOString(); $.ajax('/api/v1/treatments.json'+tquery, { success: function (xhr) { @@ -510,7 +508,7 @@ console.log(data.sgv); data.treatments.sort(function(a, b) { return a.mills - b.mills; }); } }).done(function () { - $('#'+report_plugins.getProperty('containerprefix')+day).html(''+translate('Processing data of')+' '+day+' ...'); + $('#info-' + day).html(''+translate('Processing data of')+' '+day+' ...'); processData(data,day,options); }); From 4129a2934ab841d5cfa6cf2a15b60db9e7ee6914 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sat, 29 Aug 2015 22:45:42 +0200 Subject: [PATCH 015/176] codacy pass 4 --- lib/report_plugins/daytoday.js | 2 +- lib/report_plugins/index.js | 9 ++++----- static/report/js/report.js | 14 +++++++++----- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/report_plugins/daytoday.js b/lib/report_plugins/daytoday.js index cb86dc38e30..58839df741d 100644 --- a/lib/report_plugins/daytoday.js +++ b/lib/report_plugins/daytoday.js @@ -23,7 +23,7 @@ daytoday.html = + ''+translate('IOB')+'' + ''+translate('COB')+'' + ' '+translate('Size') - + '' + ' ' + ' ' + ' ' diff --git a/lib/report_plugins/index.js b/lib/report_plugins/index.js index 98d04e8901a..48b9bd08ae0 100644 --- a/lib/report_plugins/index.js +++ b/lib/report_plugins/index.js @@ -1,7 +1,6 @@ 'use strict'; var _ = require('lodash'); -var translate = require('../language')().translate; function init() { var consts = { @@ -45,11 +44,11 @@ function init() { if (p.html && ! $('#' + p.name).length) { $('#tabnav').append($('
  • ').attr('id',p.name).addClass('menutab').append(client.translate(p.label))); } - // select 1st tab - $('#tabnav > li:first').addClass('selected'); - // show 1st report - $('#pluginchartplaceholders > div:first').css('display',''); }); + // select 1st tab + $('#tabnav > li:first').addClass('selected'); + // show 1st report + $('#pluginchartplaceholders > div:first').css('display',''); }; return plugins(); diff --git a/static/report/js/report.js b/static/report/js/report.js index bafacb31e90..72d9ef57434 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -1,5 +1,13 @@ // TODO: // - bypass nightmode in reports +// - optimize .done() on food load +// - hiding food html +// - make axis on daytoday better working with thresholds +// - get rid of /static/report/js/time.js +// - load css dynamic + optimize +// - move rp_edittreatmentdialog html to plugin +// - check if everything is translated +// - add tests (function () { 'use strict'; @@ -21,7 +29,6 @@ report_plugins.addHtmlFromPlugins( client ); var translate = client.translate; - //language.set(client.settings.language); var maxInsulinValue = 0 ,maxCarbsValue = 0; @@ -34,9 +41,7 @@ 'mmol': { low: 4, high: 10 } }; - var - ONE_MIN_IN_MS = 60000 - , SIX_MINS_IN_MS = 360000; + var ONE_MIN_IN_MS = 60000; // ****** FOOD CODE START ****** var food_categories = []; @@ -530,7 +535,6 @@ console.log(data.sgv); var temp1 = [ ]; if (cal) { temp1 = data.sgv.map(function (entry) { - var noise = entry.noise || 0; var rawBg = rawIsigToRawBg(entry, cal); return { x: entry.x, date: new Date(entry.x - 2 * 1000), y: rawBg, sgv: client.utils.scaleMgdl(rawBg), color: 'gray', type: 'rawbg', filtered: entry.filtered, unfiltered: entry.unfiltered } }).filter(function(entry) { return entry.y > 0}); From bd4b72e94b135a9fa1ffc192ef7722f7f39cd318 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sat, 29 Aug 2015 23:10:02 +0200 Subject: [PATCH 016/176] restore replaced new code in treatments.js --- lib/treatments.js | 7 ++++++- static/report/js/report.js | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/treatments.js b/lib/treatments.js index 2e9e23f85ef..d9d5309b437 100644 --- a/lib/treatments.js +++ b/lib/treatments.js @@ -84,6 +84,11 @@ function prepareData(obj) { , preBolusCarbs: '' }; + obj.glucose = Number(obj.glucose); + obj.carbs = Number(obj.carbs); + obj.insulin = Number(obj.insulin); + obj.preBolus = Number(obj.preBolus); + var eventTime; if (obj.eventTime) { eventTime = new Date(obj.eventTime); @@ -114,7 +119,7 @@ function prepareData(obj) { deleteIfEmpty('notes'); deleteIfEmpty('preBolus'); - if (!obj.glucose || obj.glucose === 0) { + if (obj.glucose === 0 || isNaN(obj.glucose)) { delete obj.glucose; delete obj.glucoseType; delete obj.units; diff --git a/static/report/js/report.js b/static/report/js/report.js index 72d9ef57434..37c752ec245 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -8,6 +8,9 @@ // - move rp_edittreatmentdialog html to plugin // - check if everything is translated // - add tests +// - optimize merging data inside every plugin +// - auto check checkbox to enable filter when data changed + (function () { 'use strict'; From 56ae37cda2d99c7a15933b5511d71b84adf5da29 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sun, 30 Aug 2015 09:35:20 +0200 Subject: [PATCH 017/176] rebase changes --- lib/treatments.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/treatments.js b/lib/treatments.js index d9d5309b437..c7b08c4e818 100644 --- a/lib/treatments.js +++ b/lib/treatments.js @@ -133,7 +133,8 @@ storage.queryOpts = { insulin: parseInt , carbs: parseInt , glucose: parseInt - , notes: find_options.parseRegEx + , notes: find_options.parseRegEx + , eventType: find_options.parseRegEx } , dateField: 'created_at' }; From 2a24bc4041815ec8ee2a7a0ff6740b5a1bcc85a9 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sun, 30 Aug 2015 09:56:10 +0200 Subject: [PATCH 018/176] allow regex in query --- lib/query.js | 6 +++++- lib/treatments.js | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/query.js b/lib/query.js index c322919cb57..989a0faa832 100644 --- a/lib/query.js +++ b/lib/query.js @@ -174,7 +174,11 @@ function walk_prop (prop, typer) { } function parseRegEx (str) { - return new RegExp(str); + var regtest = /\/(.*)\/(.*)/.exec(str); + if (regtest) { + return new RegExp(regtest[1],regtest[2]); + } + return str; } // attach helpers and utilities to main function for testing diff --git a/lib/treatments.js b/lib/treatments.js index c7b08c4e818..ed8eb77ac01 100644 --- a/lib/treatments.js +++ b/lib/treatments.js @@ -70,7 +70,7 @@ function storage (env, ctx) { api.list = list; api.create = create; - api.indexedFields = ['created_at', 'eventType', 'insulin', 'carbs', 'glucose', 'boluscalc.foods._id', 'notes']; + api.indexedFields = ['created_at', 'eventType', 'insulin', 'carbs', 'glucose', 'enteredBy', 'boluscalc.foods._id', 'notes']; api.remove = remove; api.save = save; return api; @@ -135,6 +135,7 @@ storage.queryOpts = { , glucose: parseInt , notes: find_options.parseRegEx , eventType: find_options.parseRegEx + , enteredBy: find_options.parseRegEx } , dateField: 'created_at' }; From 11283bee1dc259e55b34315aff5d565eb9859e99 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sun, 30 Aug 2015 11:16:27 +0200 Subject: [PATCH 019/176] .x -> .mills everywhere to make calibration.js work --- lib/report_plugins/calibrations.js | 19 ++++++++++-------- lib/report_plugins/treatments.js | 2 +- static/report/js/report.js | 31 +++++++++++++----------------- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/lib/report_plugins/calibrations.js b/lib/report_plugins/calibrations.js index 8310b920d9a..919669d7825 100644 --- a/lib/report_plugins/calibrations.js +++ b/lib/report_plugins/calibrations.js @@ -20,6 +20,9 @@ calibrations.html = ; calibrations.report = function report_calibrations(datastorage,daystoshow) { + var Nightscout = window.Nightscout; + var report_plugins = Nightscout.report_plugins; + var padding = { top: 15, right: 15, bottom: 30, left: 70 }; var treatments = []; Object.keys(daystoshow).forEach(function (day) { @@ -51,7 +54,7 @@ calibrations.report = function report_calibrations(datastorage,daystoshow) { mbgs.forEach(function (mbg) { calibrations_calcmbg(mbg); }); - var events = treatments.concat(cals).concat(mbgs).sort(function(a, b) { return a.x - b.x; }); + var events = treatments.concat(cals).concat(mbgs).sort(function(a, b) { return a.mills - b.mills; }); var colors = ['Aqua','Blue','Brown','Chartreuse','Coral','CornflowerBlue','DarkCyan','DarkMagenta','DarkOrange','Fuchsia','Green','Yellow']; var colorindex = 0; @@ -67,7 +70,7 @@ calibrations.report = function report_calibrations(datastorage,daystoshow) { currentcolor = colors[colorindex]; } html += ''; - html += '' + localeDateTime(new Date(e.x)) + ''; + html += '' + report_plugins.utils.localeDateTime(new Date(e.mills)) + ''; e.bgcolor = colors[colorindex]; if (e.eventType) { html += ''+translate(e.eventType)+':
    '; @@ -219,7 +222,7 @@ calibrations.report = function report_calibrations(datastorage,daystoshow) { } function calibrations_drawcal(cal) { - var color = cal.color; + var color = cal.bgcolor; var y1 = 50000; var x1 = cal.scale * (y1 - cal.intercept) / cal.slope; var y2 = 400000; @@ -234,11 +237,11 @@ calibrations.report = function report_calibrations(datastorage,daystoshow) { } function calibrations_calcmbg(mbg) { - var lastsgv = calibrations_findlatest(new Date(mbg.x),sgvs); + var lastsgv = calibrations_findlatest(new Date(mbg.mills),sgvs); if (lastsgv) { - if (mbg.x-lastsgv.x>5*60*1000) { - console.log('Last SGV too old for MBG. Time diff: '+((mbg.x-lastsgv.x)/1000/60).toFixed(1)+' min',mbg); + if (mbg.mills-lastsgv.mills>5*60*1000) { + console.log('Last SGV too old for MBG. Time diff: '+((mbg.mills-lastsgv.mills)/1000/60).toFixed(1)+' min',mbg); } else { mbg.raw = lastsgv.filtered || lastsgv.unfiltered; } @@ -248,7 +251,7 @@ calibrations.report = function report_calibrations(datastorage,daystoshow) { } function calibrations_drawmbg(mbg) { - var color = mbg.color; + var color = mbg.bgcolor; if (mbg.raw) { calibration_context.append('circle') .attr('cx', xScale2(mbg.y) + padding.left) @@ -265,7 +268,7 @@ calibrations.report = function report_calibrations(datastorage,daystoshow) { var last = null; var time = date.getTime(); for (var i=0; i time) { + if (storage[i].mills > time) { return last; } last = storage[i]; diff --git a/lib/report_plugins/treatments.js b/lib/report_plugins/treatments.js index 038bb414afd..22516ebdae8 100644 --- a/lib/report_plugins/treatments.js +++ b/lib/report_plugins/treatments.js @@ -167,7 +167,7 @@ treatments.report = function report_treatments(datastorage,daystoshow) { table += ''; table += ''; table += ''+(new Date(tr.created_at).toLocaleTimeString().replace(/([\d]+:[\d]{2})(:[\d]{2})(.*)/, '$1$3'))+''; - table += ''+(tr.eventType ? tr.eventType : '')+''; + table += ''+(tr.eventType ? translate(tr.eventType) : '')+''; table += ''+(tr.glucose ? tr.glucose + ' ('+translate(tr.glucoseType)+')' : '')+''; table += ''+(tr.insulin ? tr.insulin : '')+''; table += ''+(tr.carbs ? tr.carbs : '')+''; diff --git a/static/report/js/report.js b/static/report/js/report.js index 37c752ec245..219ba3ef415 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -6,10 +6,11 @@ // - get rid of /static/report/js/time.js // - load css dynamic + optimize // - move rp_edittreatmentdialog html to plugin -// - check if everything is translated +// - check everything is translated // - add tests // - optimize merging data inside every plugin // - auto check checkbox to enable filter when data changed +// - Insuling Change vs Insulin Cartridge Change in translations (function () { @@ -451,23 +452,21 @@ var query = '?find[date][$gte]='+from+'&find[date][$lt]='+to+'&count=10000'; $('#info-' + day).html(''+translate('Loading CGM data of')+' '+day+' ...'); -console.log('/api/v1/entries.json'+query); $.ajax('/api/v1/entries.json'+query, { success: function (xhr) { -console.log(xhr); xhr.forEach(function (element) { if (element) { if (element.mbg) { mbgData.push({ y: element.mbg - , x: element.date + , mills: element.date , d: element.dateString , device: element.device }); } else if (element.sgv) { cgmData.push({ y: element.sgv - , x: element.date + , mills: element.date , d: element.dateString , device: element.device , filtered: element.filtered @@ -478,7 +477,7 @@ console.log(xhr); }); } else if (element.type === 'cal') { calData.push({ - x: element.date + mills: element.date , d: element.dateString , scale: element.scale , intercept: element.intercept @@ -489,18 +488,17 @@ console.log(xhr); }); // sometimes cgm contains duplicates. uniq it. data.sgv = cgmData.slice(); -console.log(data.sgv); - data.sgv.sort(function(a, b) { return a.x - b.x; }); + data.sgv.sort(function(a, b) { return a.mills - b.mills; }); var lastDate = 0; data.sgv = data.sgv.filter(function(d) { - var ok = (lastDate + ONE_MIN_IN_MS) < d.x; - lastDate = d.x; + var ok = (lastDate + ONE_MIN_IN_MS) < d.mills; + lastDate = d.mills; return ok; }); data.mbg = mbgData.slice(); - data.mbg.sort(function(a, b) { return a.x - b.x; }); + data.mbg.sort(function(a, b) { return a.mills - b.mills; }); data.cal = calData.slice(); - data.cal.sort(function(a, b) { return a.x - b.x; }); + data.cal.sort(function(a, b) { return a.mills - b.mills; }); } }).done(function () { $('#info-' + day).html(''+translate('Loading treatments data of')+' '+day+' ...'); @@ -539,16 +537,16 @@ console.log(data.sgv); if (cal) { temp1 = data.sgv.map(function (entry) { var rawBg = rawIsigToRawBg(entry, cal); - return { x: entry.x, date: new Date(entry.x - 2 * 1000), y: rawBg, sgv: client.utils.scaleMgdl(rawBg), color: 'gray', type: 'rawbg', filtered: entry.filtered, unfiltered: entry.unfiltered } + return { mills: entry.mills, date: new Date(entry.mills - 2 * 1000), y: rawBg, sgv: client.utils.scaleMgdl(rawBg), color: 'gray', type: 'rawbg', filtered: entry.filtered, unfiltered: entry.unfiltered } }).filter(function(entry) { return entry.y > 0}); } var temp2 = data.sgv.map(function (obj) { - return { x: obj.x, date: new Date(obj.x), y: obj.y, sgv: client.utils.scaleMgdl(obj.y), color: sgvToColor(client.utils.scaleMgdl(obj.y),options), type: 'sgv', noise: obj.noise, filtered: obj.filtered, unfiltered: obj.unfiltered} + return { mills: obj.mills, date: new Date(obj.mills), y: obj.y, sgv: client.utils.scaleMgdl(obj.y), color: sgvToColor(client.utils.scaleMgdl(obj.y),options), type: 'sgv', noise: obj.noise, filtered: obj.filtered, unfiltered: obj.unfiltered} }); data.sgv = [].concat(temp1, temp2); //Add MBG's also, pretend they are SGV's - data.sgv = data.sgv.concat(data.mbg.map(function (obj) { return { date: new Date(obj.x), y: obj.y, sgv: client.utils.scaleMgdl(obj.y), color: 'red', type: 'mbg', device: obj.device } })); + data.sgv = data.sgv.concat(data.mbg.map(function (obj) { return { date: new Date(obj.mills), y: obj.y, sgv: client.utils.scaleMgdl(obj.y), color: 'red', type: 'mbg', device: obj.device } })); // make sure data range will be exactly 24h var from = new Date(new Date(day).getTime() + (new Date().getTimezoneOffset()*60*1000)); @@ -564,9 +562,6 @@ console.log(data.sgv); return true; }); - //delete data.cal; - //delete data.mbg; - // for other reports data.statsrecords = data.sgv.filter(function(r) { if (r.type) { From b1cc6b1a8b029417beb75b232099a9b20fb5d97d Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sun, 30 Aug 2015 11:37:52 +0200 Subject: [PATCH 020/176] units passed with options --- lib/report_plugins/hourlystats.js | 4 ++-- lib/report_plugins/percentile.js | 2 +- static/report/js/report.js | 25 +++++++++++++------------ 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/report_plugins/hourlystats.js b/lib/report_plugins/hourlystats.js index aa1c13c8190..6587169e835 100644 --- a/lib/report_plugins/hourlystats.js +++ b/lib/report_plugins/hourlystats.js @@ -19,7 +19,7 @@ hourlystats.html = + '
    ' ; -hourlystats.report = function report_hourlystats(datastorage,daystoshow) { +hourlystats.report = function report_hourlystats(datastorage, daystoshow, options) { var Nightscout = window.Nightscout; var client = Nightscout.client; var translate = client.translate; @@ -114,7 +114,7 @@ hourlystats.report = function report_hourlystats(datastorage,daystoshow) { }, yaxis: { min: 0, - max: serverSettings.units === 'mmol' ? 22: 400, + max: options.units === 'mmol' ? 22: 400, show: true }, grid: { diff --git a/lib/report_plugins/percentile.js b/lib/report_plugins/percentile.js index ecbcfda6b7e..cdce8e9c736 100644 --- a/lib/report_plugins/percentile.js +++ b/lib/report_plugins/percentile.js @@ -151,7 +151,7 @@ percentile.report = function report_percentile(datastorage,daystoshow,options) { }, yaxis: { min: 0, - max: serverSettings.units === 'mmol' ? 22: 400, + max: options.units === 'mmol' ? 22: 400, tickColor: '#555', }, grid: { diff --git a/static/report/js/report.js b/static/report/js/report.js index 219ba3ef415..fa24934dd61 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -196,18 +196,19 @@ function show(event) { var options = { - width: 1000, - height: 300, - targetLow: 3.5, - targetHigh: 10, - raw: true, - notes: true, - food: true, - insulin: true, - carbs: true, - iob : true, - cob : true, - scale: report_plugins.consts.SCALE_LINEAR + width: 1000 + , height: 300 + , targetLow: 3.5 + , targetHigh: 10 + , raw: true + , notes: true + , food: true + , insulin: true + , carbs: true + , iob : true + , cob : true + , scale: report_plugins.consts.SCALE_LINEAR + , units: client.settings.units }; options.targetLow = parseFloat($('#rp_targetlow').val().replace(',','.')); From c78e9b05eca749c1253e20448510d5fce07b3ad6 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sun, 30 Aug 2015 12:09:18 +0200 Subject: [PATCH 021/176] plugin.html must be a function(client) to be correctly translated with initialized language module --- lib/report_plugins/calibrations.js | 6 ++- lib/report_plugins/dailystats.js | 6 ++- lib/report_plugins/daytoday.js | 56 ++++++++++++----------- lib/report_plugins/glucosedistribution.js | 6 ++- lib/report_plugins/hourlystats.js | 6 ++- lib/report_plugins/index.js | 2 +- lib/report_plugins/percentile.js | 6 ++- lib/report_plugins/success.js | 6 ++- lib/report_plugins/treatments.js | 6 ++- 9 files changed, 66 insertions(+), 34 deletions(-) diff --git a/lib/report_plugins/calibrations.js b/lib/report_plugins/calibrations.js index 919669d7825..b283f59b3e3 100644 --- a/lib/report_plugins/calibrations.js +++ b/lib/report_plugins/calibrations.js @@ -13,11 +13,15 @@ function init() { module.exports = init; -calibrations.html = +calibrations.html = function html(client) { + var translate = client.translate; + var ret = '

    ' + translate('Calibrations') + '

    ' + '
    ' + '
    ' ; + return ret; +} calibrations.report = function report_calibrations(datastorage,daystoshow) { var Nightscout = window.Nightscout; diff --git a/lib/report_plugins/dailystats.js b/lib/report_plugins/dailystats.js index 6f38c01f6e6..6e16cd25827 100644 --- a/lib/report_plugins/dailystats.js +++ b/lib/report_plugins/dailystats.js @@ -13,10 +13,14 @@ function init() { module.exports = init; -dailystats.html = +dailystats.html = function html(client) { + var translate = client.translate; + var ret = '

    ' + translate('Daily stats report') + '

    ' + '
    ' ; + return ret; +} dailystats.report = function report_dailystats(datastorage,daystoshow,options) { var Nightscout = window.Nightscout; diff --git a/lib/report_plugins/daytoday.js b/lib/report_plugins/daytoday.js index 58839df741d..76ae4b61dea 100644 --- a/lib/report_plugins/daytoday.js +++ b/lib/report_plugins/daytoday.js @@ -13,32 +13,36 @@ function init() { module.exports = init; -daytoday.html = - translate('Display') - + ''+translate('Insulin')+'' - + ''+translate('Carbs')+'' - + ''+translate('Notes') - + ''+translate('Food') - + ''+translate('Raw')+'' - + ''+translate('IOB')+'' - + ''+translate('COB')+'' - + ' '+translate('Size') - + ' ' - + '
    ' - + translate('Scale') - + '' - + translate('Linear') - + '' - + translate('Logarithmic') - + '
    ' - + '
    ' - + '
    ' - ; +daytoday.html = function html(client) { + var translate = client.translate; + var ret = + translate('Display') + ': ' + + ''+translate('Insulin')+'' + + ''+translate('Carbs')+'' + + ''+translate('Notes') + + ''+translate('Food') + + ''+translate('Raw')+'' + + ''+translate('IOB')+'' + + ''+translate('COB')+'' + + ' '+translate('Size') + + ' ' + + '
    ' + + translate('Scale') + + '' + + translate('Linear') + + '' + + translate('Logarithmic') + + '
    ' + + '
    ' + + '
    ' + ; + return ret; +} daytoday.prepareHtml = function daytodayPrepareHtml(daystoshow) { $('#daytodaycharts').empty(); diff --git a/lib/report_plugins/glucosedistribution.js b/lib/report_plugins/glucosedistribution.js index 004cd17b3b4..aef141ceacb 100644 --- a/lib/report_plugins/glucosedistribution.js +++ b/lib/report_plugins/glucosedistribution.js @@ -13,7 +13,9 @@ function init() { module.exports = init; -glucosedistribution.html = +glucosedistribution.html = function html(client) { + var translate = client.translate; + var ret = '

    ' + translate('Glucose distribution') + ' (' @@ -26,6 +28,8 @@ glucosedistribution.html = + '
    ' + translate('* This is only a rough estimation that can be very inaccurate and does not replace actual blood testing. The formula used is taken from: Nathan, David M., et al. "Translating the A1C assay into estimated average glucose values." Diabetes care 31.8 (2008): 1473-1478.') ; + return ret; +} glucosedistribution.report = function report_glucosedistribution(datastorage,daystoshow,options) { var Nightscout = window.Nightscout; diff --git a/lib/report_plugins/hourlystats.js b/lib/report_plugins/hourlystats.js index 6587169e835..c43470b79c2 100644 --- a/lib/report_plugins/hourlystats.js +++ b/lib/report_plugins/hourlystats.js @@ -13,11 +13,15 @@ function init() { module.exports = init; -hourlystats.html = +hourlystats.html = function html(client) { + var translate = client.translate; + var ret = '

    ' + translate('Hourly stats') + '

    ' + '
    ' + '
    ' ; + return ret; +} hourlystats.report = function report_hourlystats(datastorage, daystoshow, options) { var Nightscout = window.Nightscout; diff --git a/lib/report_plugins/index.js b/lib/report_plugins/index.js index 48b9bd08ae0..f8470a4b6be 100644 --- a/lib/report_plugins/index.js +++ b/lib/report_plugins/index.js @@ -38,7 +38,7 @@ function init() { plugins.eachPlugin(function addHtml(p) { // add main plugin html if (p.html && ! $('#' + p.name + '-placeholder').length) { - $('#pluginchartplaceholders').append($('
    ').attr('id',p.name + '-placeholder').addClass('tabplaceholder').css('display','none').append(p.html)); + $('#pluginchartplaceholders').append($('
    ').attr('id',p.name + '-placeholder').addClass('tabplaceholder').css('display','none').append(p.html(client))); } // add menu item if (p.html && ! $('#' + p.name).length) { diff --git a/lib/report_plugins/percentile.js b/lib/report_plugins/percentile.js index cdce8e9c736..715379ddf8f 100644 --- a/lib/report_plugins/percentile.js +++ b/lib/report_plugins/percentile.js @@ -13,12 +13,16 @@ function init() { module.exports = init; -percentile.html = +percentile.html = function html(client) { + var translate = client.translate; + var ret = '

    ' + translate('Glucose Percentile report') + '

    ' + '
    ' + '
    ' + '
    ' ; + return ret; +} percentile.report = function report_percentile(datastorage,daystoshow,options) { var Nightscout = window.Nightscout; diff --git a/lib/report_plugins/success.js b/lib/report_plugins/success.js index c6155eea27e..87990b5ce3d 100644 --- a/lib/report_plugins/success.js +++ b/lib/report_plugins/success.js @@ -13,10 +13,14 @@ function init() { module.exports = init; -success.html = +success.html = function html(client) { + var translate = client.translate; + var ret = '

    ' + translate('Weekly Success') + '

    ' + '
    ' ; + return ret; +} success.report = function report_success(datastorage,daystoshow,options) { var Nightscout = window.Nightscout; diff --git a/lib/report_plugins/treatments.js b/lib/report_plugins/treatments.js index 22516ebdae8..a87e74a0676 100644 --- a/lib/report_plugins/treatments.js +++ b/lib/report_plugins/treatments.js @@ -13,10 +13,14 @@ function init() { module.exports = init; -treatments.html = +treatments.html = function html(client) { + var translate = client.translate; + var ret = '

    ' + translate('Treatments') + '

    ' + '
    ' ; + return ret; +} treatments.report = function report_treatments(datastorage,daystoshow) { From f8079d4175475c0193521750a9c5b3da10bbb622 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sun, 30 Aug 2015 12:17:29 +0200 Subject: [PATCH 022/176] require not needed anymore --- lib/report_plugins/dailystats.js | 1 - lib/report_plugins/daytoday.js | 1 - lib/report_plugins/glucosedistribution.js | 1 - lib/report_plugins/hourlystats.js | 1 - lib/report_plugins/percentile.js | 1 - lib/report_plugins/success.js | 1 - 6 files changed, 6 deletions(-) diff --git a/lib/report_plugins/dailystats.js b/lib/report_plugins/dailystats.js index 6e16cd25827..ae56fdced00 100644 --- a/lib/report_plugins/dailystats.js +++ b/lib/report_plugins/dailystats.js @@ -1,5 +1,4 @@ 'use strict'; -var translate = require('../language')().translate; var dailystats = { name: 'dailystats' diff --git a/lib/report_plugins/daytoday.js b/lib/report_plugins/daytoday.js index 76ae4b61dea..5d8bc40c5b8 100644 --- a/lib/report_plugins/daytoday.js +++ b/lib/report_plugins/daytoday.js @@ -1,5 +1,4 @@ 'use strict'; -var translate = require('../language')().translate; var daytoday = { name: 'daytoday' diff --git a/lib/report_plugins/glucosedistribution.js b/lib/report_plugins/glucosedistribution.js index aef141ceacb..c674661330a 100644 --- a/lib/report_plugins/glucosedistribution.js +++ b/lib/report_plugins/glucosedistribution.js @@ -1,5 +1,4 @@ 'use strict'; -var translate = require('../language')().translate; var glucosedistribution = { name: 'glucosedistribution' diff --git a/lib/report_plugins/hourlystats.js b/lib/report_plugins/hourlystats.js index c43470b79c2..6e3125c7609 100644 --- a/lib/report_plugins/hourlystats.js +++ b/lib/report_plugins/hourlystats.js @@ -1,5 +1,4 @@ 'use strict'; -var translate = require('../language')().translate; var hourlystats = { name: 'hourlystats' diff --git a/lib/report_plugins/percentile.js b/lib/report_plugins/percentile.js index 715379ddf8f..9658b6ed20b 100644 --- a/lib/report_plugins/percentile.js +++ b/lib/report_plugins/percentile.js @@ -1,5 +1,4 @@ 'use strict'; -var translate = require('../language')().translate; var percentile = { name: 'percentile' diff --git a/lib/report_plugins/success.js b/lib/report_plugins/success.js index 87990b5ce3d..60d259608c3 100644 --- a/lib/report_plugins/success.js +++ b/lib/report_plugins/success.js @@ -1,5 +1,4 @@ 'use strict'; -var translate = require('../language')().translate; var success = { name: 'success' From 549933aacc65322fef6968965c99a0644ae63809 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sun, 30 Aug 2015 13:56:58 +0200 Subject: [PATCH 023/176] codacy pass 5 --- lib/report_plugins/calibrations.js | 2 +- lib/report_plugins/dailystats.js | 2 +- lib/report_plugins/daytoday.js | 2 +- lib/report_plugins/glucosedistribution.js | 2 +- lib/report_plugins/hourlystats.js | 2 +- lib/report_plugins/percentile.js | 2 +- lib/report_plugins/success.js | 2 +- lib/report_plugins/treatments.js | 6 +++--- lib/treatments.js | 12 ------------ static/report/js/report.js | 5 ++--- 10 files changed, 12 insertions(+), 25 deletions(-) diff --git a/lib/report_plugins/calibrations.js b/lib/report_plugins/calibrations.js index b283f59b3e3..cb57903cbf5 100644 --- a/lib/report_plugins/calibrations.js +++ b/lib/report_plugins/calibrations.js @@ -21,7 +21,7 @@ calibrations.html = function html(client) { + '
    ' ; return ret; -} +}; calibrations.report = function report_calibrations(datastorage,daystoshow) { var Nightscout = window.Nightscout; diff --git a/lib/report_plugins/dailystats.js b/lib/report_plugins/dailystats.js index ae56fdced00..838fed41692 100644 --- a/lib/report_plugins/dailystats.js +++ b/lib/report_plugins/dailystats.js @@ -19,7 +19,7 @@ dailystats.html = function html(client) { + '
    ' ; return ret; -} +}; dailystats.report = function report_dailystats(datastorage,daystoshow,options) { var Nightscout = window.Nightscout; diff --git a/lib/report_plugins/daytoday.js b/lib/report_plugins/daytoday.js index 5d8bc40c5b8..91f30659919 100644 --- a/lib/report_plugins/daytoday.js +++ b/lib/report_plugins/daytoday.js @@ -41,7 +41,7 @@ daytoday.html = function html(client) { + '
    ' ; return ret; -} +}; daytoday.prepareHtml = function daytodayPrepareHtml(daystoshow) { $('#daytodaycharts').empty(); diff --git a/lib/report_plugins/glucosedistribution.js b/lib/report_plugins/glucosedistribution.js index c674661330a..68c6bd173d7 100644 --- a/lib/report_plugins/glucosedistribution.js +++ b/lib/report_plugins/glucosedistribution.js @@ -28,7 +28,7 @@ glucosedistribution.html = function html(client) { + translate('* This is only a rough estimation that can be very inaccurate and does not replace actual blood testing. The formula used is taken from: Nathan, David M., et al. "Translating the A1C assay into estimated average glucose values." Diabetes care 31.8 (2008): 1473-1478.') ; return ret; -} +}; glucosedistribution.report = function report_glucosedistribution(datastorage,daystoshow,options) { var Nightscout = window.Nightscout; diff --git a/lib/report_plugins/hourlystats.js b/lib/report_plugins/hourlystats.js index 6e3125c7609..353a0ba4ec9 100644 --- a/lib/report_plugins/hourlystats.js +++ b/lib/report_plugins/hourlystats.js @@ -20,7 +20,7 @@ hourlystats.html = function html(client) { + '
    ' ; return ret; -} +}; hourlystats.report = function report_hourlystats(datastorage, daystoshow, options) { var Nightscout = window.Nightscout; diff --git a/lib/report_plugins/percentile.js b/lib/report_plugins/percentile.js index 9658b6ed20b..fa52cefcffc 100644 --- a/lib/report_plugins/percentile.js +++ b/lib/report_plugins/percentile.js @@ -21,7 +21,7 @@ percentile.html = function html(client) { + '
    ' ; return ret; -} +}; percentile.report = function report_percentile(datastorage,daystoshow,options) { var Nightscout = window.Nightscout; diff --git a/lib/report_plugins/success.js b/lib/report_plugins/success.js index 60d259608c3..bdd079600bc 100644 --- a/lib/report_plugins/success.js +++ b/lib/report_plugins/success.js @@ -19,7 +19,7 @@ success.html = function html(client) { + '
    ' ; return ret; -} +}; success.report = function report_success(datastorage,daystoshow,options) { var Nightscout = window.Nightscout; diff --git a/lib/report_plugins/treatments.js b/lib/report_plugins/treatments.js index a87e74a0676..54c6910f97c 100644 --- a/lib/report_plugins/treatments.js +++ b/lib/report_plugins/treatments.js @@ -20,7 +20,7 @@ treatments.html = function html(client) { + '
    ' ; return ret; -} +}; treatments.report = function report_treatments(datastorage,daystoshow) { @@ -90,14 +90,14 @@ treatments.report = function report_treatments(datastorage,daystoshow) { data.notes = $('#rp_adnotes').val(); data.enteredBy = $('#rp_enteredBy').val(); data.created_at = Nightscout.utils.mergeInputTime($('#rp_eventTimeValue').val(), $('#rp_eventDateValue').val()); - $( this ).dialog( "close" ); + $( this ).dialog('close'); saveTreatmentRecord(data); delete datastorage[day]; show(); } }, { text: translate('Cancel'), - click: function () { $( this ).dialog( 'close' ); } + click: function () { $( this ).dialog('close'); } } ] , open : function() { diff --git a/lib/treatments.js b/lib/treatments.js index ed8eb77ac01..000645ad361 100644 --- a/lib/treatments.js +++ b/lib/treatments.js @@ -5,18 +5,6 @@ var find_options = require('./query'); function storage (env, ctx) { var ObjectID = require('mongodb').ObjectID; - // allow regexp search - // /api/v1/treatments.json?find[notes]=/sometext/i - function find_query (opts) { - var reg; - ['notes','eventType'].forEach(function(d) { - if (opts && opts.find && opts.find[d] && (reg=/\/(.*)\/(.*)/.exec(opts.find[d]))) { - opts.find[d] = new RegExp(reg[1],reg[2]); - } - }); - return opts; - } - function create (obj, fn) { var results = prepareData(obj); diff --git a/static/report/js/report.js b/static/report/js/report.js index fa24934dd61..15399ad8493 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -17,7 +17,6 @@ 'use strict'; //for the tests window isn't the global object var $ = window.$; - var _ = window._; var moment = window.moment; var Nightscout = window.Nightscout; var client = Nightscout.client; @@ -538,11 +537,11 @@ if (cal) { temp1 = data.sgv.map(function (entry) { var rawBg = rawIsigToRawBg(entry, cal); - return { mills: entry.mills, date: new Date(entry.mills - 2 * 1000), y: rawBg, sgv: client.utils.scaleMgdl(rawBg), color: 'gray', type: 'rawbg', filtered: entry.filtered, unfiltered: entry.unfiltered } + return { mills: entry.mills, date: new Date(entry.mills - 2 * 1000), y: rawBg, sgv: client.utils.scaleMgdl(rawBg), color: 'gray', type: 'rawbg', filtered: entry.filtered, unfiltered: entry.unfiltered }; }).filter(function(entry) { return entry.y > 0}); } var temp2 = data.sgv.map(function (obj) { - return { mills: obj.mills, date: new Date(obj.mills), y: obj.y, sgv: client.utils.scaleMgdl(obj.y), color: sgvToColor(client.utils.scaleMgdl(obj.y),options), type: 'sgv', noise: obj.noise, filtered: obj.filtered, unfiltered: obj.unfiltered} + return { mills: obj.mills, date: new Date(obj.mills), y: obj.y, sgv: client.utils.scaleMgdl(obj.y), color: sgvToColor(client.utils.scaleMgdl(obj.y),options), type: 'sgv', noise: obj.noise, filtered: obj.filtered, unfiltered: obj.unfiltered}; }); data.sgv = [].concat(temp1, temp2); From 89f184a70aa91de7ca12530d5e5c56d8af29b9b8 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sun, 30 Aug 2015 14:24:36 +0200 Subject: [PATCH 024/176] gui improvements --- lib/report_plugins/daytoday.js | 2 +- static/report/index.html | 5 +- static/report/js/report.js | 116 +++++++++++++++++---------------- 3 files changed, 64 insertions(+), 59 deletions(-) diff --git a/lib/report_plugins/daytoday.js b/lib/report_plugins/daytoday.js index 91f30659919..214c85436c0 100644 --- a/lib/report_plugins/daytoday.js +++ b/lib/report_plugins/daytoday.js @@ -31,7 +31,7 @@ daytoday.html = function html(client) { + ' ' + '' + '
    ' - + translate('Scale') + + translate('Scale') + ': ' + '' + translate('Linear') + '' diff --git a/static/report/index.html b/static/report/index.html index eecabd778e8..bc34df627df 100644 --- a/static/report/index.html +++ b/static/report/index.html @@ -33,15 +33,14 @@

    Nightscout reporting

    - + Food: - - + diff --git a/static/report/js/report.js b/static/report/js/report.js index 15399ad8493..be99d5ad7ed 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -1,7 +1,5 @@ // TODO: // - bypass nightmode in reports -// - optimize .done() on food load -// - hiding food html // - make axis on daytoday better working with thresholds // - get rid of /static/report/js/time.js // - load css dynamic + optimize @@ -9,7 +7,6 @@ // - check everything is translated // - add tests // - optimize merging data inside every plugin -// - auto check checkbox to enable filter when data changed // - Insuling Change vs Insulin Cartridge Change in translations @@ -45,6 +42,8 @@ }; var ONE_MIN_IN_MS = 60000; + + prepareGUI(); // ****** FOOD CODE START ****** var food_categories = []; @@ -106,9 +105,68 @@ return maybePreventDefault(event); } + $('#info').html(''+translate('Loading food database')+' ...'); + $.ajax('/api/v1/food/regular.json', { + success: function foodLoadSuccess(records) { + records.forEach(function (r) { + food_list.push(r); + if (r.category && !food_categories[r.category]) { food_categories[r.category] = {}; } + if (r.category && r.subcategory) { food_categories[r.category][r.subcategory] = true; } + }); + fillFoodForm(); + } + }).done(function() { + if (food_list.length) { + enableFoodGUI(); + } else { + disableFoodGUI(); + } + }).fail(function() { + disableFoodGUI(); + }); + + function enableFoodGUI( ) { + $('#info').html(''); + + $('#rp_foodgui').css('display',''); + $('#rp_food').change(function (event) { + $('#rp_enablefood').prop('checked',true); + return maybePreventDefault(event); + }); + } + + function disableFoodGUI(){ + $('#info').html(''); + $('#rp_foodgui').css('display','none'); + } + // ****** FOOD CODE END ****** + function prepareGUI() { + $('.presetdates').click(function(event) { + var days = $(this).attr('days'); + $('#rp_enabledate').prop('checked',true); + return setDataRange(event,days); + }); + $('#rp_show').click(show); + $('#rp_notes').bind('input', function (event) { + $('#rp_enablenotes').prop('checked',true); + return maybePreventDefault(event); + }); + $('#rp_eventtype').bind('input', function (event) { + $('#rp_enableeventtype').prop('checked',true); + return maybePreventDefault(event); + }); + + $('#rp_targetlow').val(targetBGdefault[client.settings.units].low); + $('#rp_targethigh').val(targetBGdefault[client.settings.units].high); + + $('.menutab').click(switchreport_handler); + + setDataRange(null,7); + } + function rawIsigToRawBg(entry, cal) { var raw = 0 , unfiltered = parseInt(entry.unfiltered) || 0 @@ -141,58 +199,6 @@ return color; } - $('#info').html(''+translate('Loading food database')+' ...'); - $.ajax('/api/v1/food/regular.json', { - success: function foodLoadSuccess(records) { - records.forEach(function (r) { - food_list.push(r); - if (r.category && !food_categories[r.category]) { food_categories[r.category] = {}; } - if (r.category && r.subcategory) { food_categories[r.category][r.subcategory] = true; } - }); - fillFoodForm(); - } - }).done(function() { - $('#info').html(''); - $('.presetdates').click(function(e) { var days = $(this).attr('days'); setDataRange(e,days); }); - - $('#rp_show').click(show); - $('#rp_food').change(function (event) { - $('#rp_enablefood').prop('checked',true); - return maybePreventDefault(event); - }); - $('#rp_notes').change(function (event) { - $('#rp_enablenotes').prop('checked',true); - return maybePreventDefault(event); - }); - - $('#rp_targetlow').val(targetBGdefault[client.settings.units].low); - $('#rp_targethigh').val(targetBGdefault[client.settings.units].high); - - $('.menutab').click(switchreport_handler); - - setDataRange(null,7); - }).fail(function() { - $('#info').html(''); - $('.presetdates').click(function(e) { var days = $(this).attr('days'); setDataRange(e,days); }); - - $('#rp_show').click(show); - $('#rp_food').change(function (event) { - $('#rp_enablefood').prop('checked',true); - return maybePreventDefault(event); - }); - $('#rp_notes').change(function (event) { - $('#rp_enablenotes').prop('checked',true); - return maybePreventDefault(event); - }); - - $('#rp_targetlow').val(targetBGdefault[client.settings.units].low); - $('#rp_targethigh').val(targetBGdefault[client.settings.units].high); - - $('.menutab').click(switchreport_handler); - - setDataRange(null,7); - }); - function show(event) { var options = { width: 1000 From e1c5977460790c569a80dff08a05b2c7876c3300 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sun, 30 Aug 2015 14:47:24 +0200 Subject: [PATCH 025/176] make careportal events dynamic --- lib/client/careportal.js | 26 ++++++++++++++++++++++++++ static/index.html | 17 +---------------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/lib/client/careportal.js b/lib/client/careportal.js index 9c055d83e84..872f0ead697 100644 --- a/lib/client/careportal.js +++ b/lib/client/careportal.js @@ -8,6 +8,23 @@ function init (client, $) { var translate = client.translate; var storage = $.localStorage; + careportal.events = [ + { val: "BG Check", name: 'BG Check' } + , { val: "Snack Bolus", name: 'Snack Bolus' } + , { val: "Meal Bolus", name: 'Meal Bolus' } + , { val: "Correction Bolus", name: 'Correction Bolus' } + , { val: "Carb Correction", name: 'Carb Correction' } + , { val: "Announcement", name: 'Announcement' } + , { val: "Note", name: 'Note' } + , { val: "Question", name: 'Question' } + , { val: "Exercise", name: 'Exercise' } + , { val: "Site Change", name: 'Pump Site Change' } + , { val: "Sensor Start", name: 'Dexcom Sensor Start' } + , { val: "Sensor Change", name: 'Dexcom Sensor Change' } + , { val: "Insulin Change", name: 'Insulin Cartridge Change' } + , { val: "D.A.D. Alert", name: 'D.A.D. Alert' } + ]; + var eventTime = $('#eventTimeValue'); var eventDate = $('#eventDateValue'); @@ -32,7 +49,16 @@ function init (client, $) { } } + careportal.prepareEvents = function prepareEvents ( ) { + $('#eventType').empty(); + _.each(careportal.events, function eachEvent(event) { + $('#eventType').append(''); + }); + + }; + careportal.prepare = function prepare ( ) { + careportal.prepareEvents(); $('#eventType').val('BG Check'); $('#glucoseValue').val('').attr('placeholder', translate('Value in') + ' ' + client.settings.units); $('#meter').prop('checked', true); diff --git a/static/index.html b/static/index.html index 4574917292d..ab6d97b6c89 100644 --- a/static/index.html +++ b/static/index.html @@ -176,22 +176,7 @@ Log a Treatment
    From db784e520b18ca993b9e456e78164570937561c4 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sun, 30 Aug 2015 15:22:27 +0200 Subject: [PATCH 026/176] careportal test fix --- lib/client/careportal.js | 1 + tests/careportal.test.js | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/client/careportal.js b/lib/client/careportal.js index 872f0ead697..a9522c1a9c0 100644 --- a/lib/client/careportal.js +++ b/lib/client/careportal.js @@ -1,6 +1,7 @@ 'use strict'; var moment = require('moment-timezone'); +var _ = require('lodash'); function init (client, $) { var careportal = { }; diff --git a/tests/careportal.test.js b/tests/careportal.test.js index 2f877503d68..e71251ae9da 100644 --- a/tests/careportal.test.js +++ b/tests/careportal.test.js @@ -72,6 +72,7 @@ describe('client', function ( ) { client.init(serverSettings, plugins); client.dataUpdate(nowData); + client.careportal.prepareEvents(); client.careportal.toggleDrawer(); $('#eventType').val('Snack Bolus'); From 69c01214a7f45770cbf3f1f83cff32c5a64fb6b5 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sun, 30 Aug 2015 15:43:20 +0200 Subject: [PATCH 027/176] careportal codacy fix --- lib/client/careportal.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/client/careportal.js b/lib/client/careportal.js index a9522c1a9c0..3ac738dd3f0 100644 --- a/lib/client/careportal.js +++ b/lib/client/careportal.js @@ -10,20 +10,20 @@ function init (client, $) { var storage = $.localStorage; careportal.events = [ - { val: "BG Check", name: 'BG Check' } - , { val: "Snack Bolus", name: 'Snack Bolus' } - , { val: "Meal Bolus", name: 'Meal Bolus' } - , { val: "Correction Bolus", name: 'Correction Bolus' } - , { val: "Carb Correction", name: 'Carb Correction' } - , { val: "Announcement", name: 'Announcement' } - , { val: "Note", name: 'Note' } - , { val: "Question", name: 'Question' } - , { val: "Exercise", name: 'Exercise' } - , { val: "Site Change", name: 'Pump Site Change' } - , { val: "Sensor Start", name: 'Dexcom Sensor Start' } - , { val: "Sensor Change", name: 'Dexcom Sensor Change' } - , { val: "Insulin Change", name: 'Insulin Cartridge Change' } - , { val: "D.A.D. Alert", name: 'D.A.D. Alert' } + { val: 'BG Check', name: 'BG Check' } + , { val: 'Snack Bolus', name: 'Snack Bolus' } + , { val: 'Meal Bolus', name: 'Meal Bolus' } + , { val: 'Correction Bolus', name: 'Correction Bolus' } + , { val: 'Carb Correction', name: 'Carb Correction' } + , { val: 'Announcement', name: 'Announcement' } + , { val: 'Note', name: 'Note' } + , { val: 'Question', name: 'Question' } + , { val: 'Exercise', name: 'Exercise' } + , { val: 'Site Change', name: 'Pump Site Change' } + , { val: 'Sensor Start', name: 'Dexcom Sensor Start' } + , { val: 'Sensor Change', name: 'Dexcom Sensor Change' } + , { val: 'Insulin Change', name: 'Insulin Cartridge Change' } + , { val: 'D.A.D. Alert', name: 'D.A.D. Alert' } ]; var eventTime = $('#eventTimeValue'); From 3ac1c71c773f1c3fd9774357ddd96a634df0dc85 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sun, 30 Aug 2015 16:01:53 +0200 Subject: [PATCH 028/176] reuse careportal's event list in reports --- lib/client/careportal.js | 1 - lib/language.js | 17 +++-------------- static/report/index.html | 2 +- static/report/js/report.js | 8 ++++++++ 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/lib/client/careportal.js b/lib/client/careportal.js index 3ac738dd3f0..fa766497590 100644 --- a/lib/client/careportal.js +++ b/lib/client/careportal.js @@ -55,7 +55,6 @@ function init (client, $) { _.each(careportal.events, function eachEvent(event) { $('#eventType').append(''); }); - }; careportal.prepare = function prepare ( ) { diff --git a/lib/language.js b/lib/language.js index 4fc95d7cbd7..0c348155a85 100644 --- a/lib/language.js +++ b/lib/language.js @@ -473,20 +473,6 @@ function init() { ,dk: 'Noter indeholder' ,nb: 'Notater inneholder' } - ,'Event type contains' : { - cs: 'Typ události obsahuje' - ,de: 'Ereignis-Typ beinhaltet' - ,es: 'Contenido del tipo de evento' - ,fr: 'Type d\'événement contient' - ,pt: 'Tipo de evento contém' - ,ro: 'Conținut tip de eveniment' - ,bg: 'Типа събитие включва' - ,hr: 'Sadržaj vrste događaja' - ,sv: 'Händelsen innehåller' - ,it: 'Contiene evento' - ,dk: 'Hændelsen indeholder' - ,nb: 'Hendelsen inneholder' - } ,'Target bg range bottom' : { cs: 'Cílová glykémie spodní' ,de: 'Untergrenze des Blutzuckerzielbereiches' @@ -3659,6 +3645,9 @@ function init() { ,'Update' : { // Update button cs: 'Aktualizovat' } + ,'All sensor events' : { // 'Sensor Start' + 'Sensor Change' events + cs: 'Všechny události senzoru' + } }; diff --git a/static/report/index.html b/static/report/index.html index bc34df627df..111092ed4e7 100644 --- a/static/report/index.html +++ b/static/report/index.html @@ -51,7 +51,7 @@

    Nightscout reporting

    - Event type contains: + Event Type: diff --git a/static/report/js/report.js b/static/report/js/report.js index be99d5ad7ed..cee00c5ab11 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -159,6 +159,13 @@ return maybePreventDefault(event); }); + // fill careportal events + $('#rp_eventtype').empty(); + _.each(client.careportal.events, function eachEvent(event) { + $('#rp_eventtype').append(''); + }); + $('#rp_eventtype').append(''); + $('#rp_targetlow').val(targetBGdefault[client.settings.units].low); $('#rp_targethigh').val(targetBGdefault[client.settings.units].high); @@ -393,6 +400,7 @@ } if (displayeddays===0) { $('#info').html(''+translate('Result is empty')+''); + $('#rp_show').css('display',''); } } From 907f22db8e9fcaa750e749c24448e8e234e2785d Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sun, 30 Aug 2015 16:50:23 +0200 Subject: [PATCH 029/176] fixed bug in processing request response --- lib/report_plugins/daytoday.js | 6 +++--- static/report/js/report.js | 23 ++++++++++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/report_plugins/daytoday.js b/lib/report_plugins/daytoday.js index 214c85436c0..797e141c7a0 100644 --- a/lib/report_plugins/daytoday.js +++ b/lib/report_plugins/daytoday.js @@ -44,7 +44,7 @@ daytoday.html = function html(client) { }; daytoday.prepareHtml = function daytodayPrepareHtml(daystoshow) { - $('#daytodaycharts').empty(); + $('#daytodaycharts').html(''); for (var d in daystoshow) { $('#daytodaycharts').append($('
    ')); } @@ -140,8 +140,8 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { ]; } } - - // create svg and g to contain the chart contents + + // create svg and g to contain the chart contents charts = d3.select('#daytodaychart-' + day).html( ''+ report_plugins.utils.localeDate(day)+ diff --git a/static/report/js/report.js b/static/report/js/report.js index cee00c5ab11..554431576c6 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -8,6 +8,7 @@ // - add tests // - optimize merging data inside every plugin // - Insuling Change vs Insulin Cartridge Change in translations +// - pressing Show 2nd time generates d3 errors, previous graphs are not removed (function () { @@ -222,6 +223,9 @@ , scale: report_plugins.consts.SCALE_LINEAR , units: client.settings.units }; + + // default time range if no time range specified in GUI + var timerange = '&find[created_at][$gte]='+new Date('1970-01-01').toISOString(); options.targetLow = parseFloat($('#rp_targetlow').val().replace(',','.')); options.targetHigh = parseFloat($('#rp_targethigh').val().replace(',','.')); @@ -244,7 +248,7 @@ matchesneeded++; var from = moment($('#rp_from').val()); var to = moment($('#rp_to').val()); - + timerange = '&find[created_at][$gte]='+new Date(from).toISOString()+'&find[created_at][$lt]='+new Date(to).toISOString(); while (from <= to) { if (daystoshow[from.format('YYYY-MM-DD')]) { daystoshow[from.format('YYYY-MM-DD')]++; @@ -265,11 +269,11 @@ var _id = $('#rp_food').val(); if (_id) { var treatmentData; - var tquery = '?find[boluscalc.foods._id]='+_id; + var tquery = '?find[boluscalc.foods._id]=' + _id + timerange; $.ajax('/api/v1/treatments.json'+tquery, { success: function (xhr) { treatmentData = xhr.map(function (treatment) { - return moment(treatment.mills).format('YYYY-MM-DD'); + return moment(treatment.created_at).format('YYYY-MM-DD'); }); // unique it treatmentData = $.grep(treatmentData, function(v, k){ @@ -301,11 +305,11 @@ var notes = $('#rp_notes').val(); if (notes) { var treatmentData; - var tquery = '?find[notes]=/'+notes+'/i'; - $.ajax('/api/v1/treatments.json'+tquery, { + var tquery = '?find[notes]=/' + notes + '/i'; + $.ajax('/api/v1/treatments.json' + tquery + timerange, { success: function (xhr) { treatmentData = xhr.map(function (treatment) { - return moment(treatment.mills).format('YYYY-MM-DD'); + return moment(treatment.created_at).format('YYYY-MM-DD'); }); // unique it treatmentData = $.grep(treatmentData, function(v, k){ @@ -337,11 +341,11 @@ var eventtype = $('#rp_eventtype').val(); if (eventtype) { var treatmentData; - var tquery = '?find[eventType]=/'+eventtype+'/i'; - $.ajax('/api/v1/treatments.json'+tquery, { + var tquery = '?find[eventType]=/' + eventtype + '/i'; + $.ajax('/api/v1/treatments.json' + tquery + timerange, { success: function (xhr) { treatmentData = xhr.map(function (treatment) { - return moment(treatment.mills).format('YYYY-MM-DD'); + return moment(treatment.created_at).format('YYYY-MM-DD'); }); // unique it treatmentData = $.grep(treatmentData, function(v, k){ @@ -406,6 +410,7 @@ $('#rp_show').css('display','none'); daystoshow = {}; + datefilter(); return maybePreventDefault(event); } From 555fdca8120b55a79c1082c7ec51194bd4169303 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sun, 30 Aug 2015 17:21:00 +0200 Subject: [PATCH 030/176] resolved translation issue between eventType value and text in dropdownbox --- lib/report_plugins/treatments.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/report_plugins/treatments.js b/lib/report_plugins/treatments.js index 54c6910f97c..36dadd02d01 100644 --- a/lib/report_plugins/treatments.js +++ b/lib/report_plugins/treatments.js @@ -131,8 +131,7 @@ treatments.report = function report_treatments(datastorage,daystoshow) { alert(translate('Your device is not authenticated yet')); return false; } - - + var dataJson = JSON.stringify(data, null, ' '); var xhr = new XMLHttpRequest(); @@ -148,6 +147,15 @@ treatments.report = function report_treatments(datastorage,daystoshow) { return true; } + function resolveEventName(value) { + _.each(Nightscout.client.careportal.events, function eachEvent(e) { + if (e.val === value) { + value = e.name; + } + }); + return value; + } + var Nightscout = window.Nightscout; var client = Nightscout.client; var translate = client.translate; @@ -171,7 +179,7 @@ treatments.report = function report_treatments(datastorage,daystoshow) { table += ''; table += ''; table += ''+(new Date(tr.created_at).toLocaleTimeString().replace(/([\d]+:[\d]{2})(:[\d]{2})(.*)/, '$1$3'))+''; - table += ''+(tr.eventType ? translate(tr.eventType) : '')+''; + table += ''+(tr.eventType ? translate(resolveEventName(tr.eventType)) : '')+''; table += ''+(tr.glucose ? tr.glucose + ' ('+translate(tr.glucoseType)+')' : '')+''; table += ''+(tr.insulin ? tr.insulin : '')+''; table += ''+(tr.carbs ? tr.carbs : '')+''; From d995465cabc65a5aacb83b82d6103c7c385c933e Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sun, 30 Aug 2015 17:22:29 +0200 Subject: [PATCH 031/176] ... and removed from todo --- static/report/js/report.js | 1 - 1 file changed, 1 deletion(-) diff --git a/static/report/js/report.js b/static/report/js/report.js index 554431576c6..7b018866684 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -7,7 +7,6 @@ // - check everything is translated // - add tests // - optimize merging data inside every plugin -// - Insuling Change vs Insulin Cartridge Change in translations // - pressing Show 2nd time generates d3 errors, previous graphs are not removed From a765c042ee2292be72ba3b53f2ecb67a2c5ea342 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sun, 30 Aug 2015 18:24:02 +0200 Subject: [PATCH 032/176] updated fontello icons --- static/glyphs/config.json | 24 +++++++ static/glyphs/css/fontello-codes.css | 6 +- static/glyphs/css/fontello-embedded.css | 18 +++-- static/glyphs/css/fontello-ie7-codes.css | 6 +- static/glyphs/css/fontello-ie7.css | 6 +- static/glyphs/css/fontello.css | 24 ++++--- static/glyphs/demo.html | 82 ++++++++++++++++++----- static/glyphs/font/fontello.eot | Bin 7304 -> 8364 bytes static/glyphs/font/fontello.svg | 4 ++ static/glyphs/font/fontello.ttf | Bin 7136 -> 8196 bytes static/glyphs/font/fontello.woff | Bin 4064 -> 4780 bytes 11 files changed, 137 insertions(+), 33 deletions(-) diff --git a/static/glyphs/config.json b/static/glyphs/config.json index e72e5aff933..d8524e5c26b 100644 --- a/static/glyphs/config.json +++ b/static/glyphs/config.json @@ -18,6 +18,24 @@ "code": 59394, "src": "fontawesome" }, + { + "uid": "83458acd9f38d03ec0226ce82a83c0f4", + "css": "tint", + "code": 59406, + "src": "fontawesome" + }, + { + "uid": "ea2d9a8c51ca42b38ef0d2a07f16d9a7", + "css": "chart-line", + "code": 59407, + "src": "fontawesome" + }, + { + "uid": "1ee2aeb352153a403df4b441a8bc9bda", + "css": "calc", + "code": 59405, + "src": "fontawesome" + }, { "uid": "c759418c008e9562944080fee617fc76", "css": "cancel-circled", @@ -60,6 +78,12 @@ "code": 59400, "src": "typicons" }, + { + "uid": "2d220a22480861b15878d1632e31ab47", + "css": "sort-numeric", + "code": 59408, + "src": "typicons" + }, { "uid": "3e02a8849305ac80a0e36302f461f265", "css": "help-circled", diff --git a/static/glyphs/css/fontello-codes.css b/static/glyphs/css/fontello-codes.css index d06e8a87fa7..014c5ddd4fd 100644 --- a/static/glyphs/css/fontello-codes.css +++ b/static/glyphs/css/fontello-codes.css @@ -11,4 +11,8 @@ .icon-cancel-circled:before { content: '\e809'; } /* '' */ .icon-volume:before { content: '\e80a'; } /* '' */ .icon-plus:before { content: '\e80b'; } /* '' */ -.icon-hourglass:before { content: '\e80c'; } /* '' */ \ No newline at end of file +.icon-hourglass:before { content: '\e80c'; } /* '' */ +.icon-calc:before { content: '\e80d'; } /* '' */ +.icon-tint:before { content: '\e80e'; } /* '' */ +.icon-chart-line:before { content: '\e80f'; } /* '' */ +.icon-sort-numeric:before { content: '\e810'; } /* '' */ \ No newline at end of file diff --git a/static/glyphs/css/fontello-embedded.css b/static/glyphs/css/fontello-embedded.css index 2f21144d71d..a41d4de3298 100644 --- a/static/glyphs/css/fontello-embedded.css +++ b/static/glyphs/css/fontello-embedded.css @@ -1,15 +1,15 @@ @font-face { font-family: 'fontello'; - src: url('../font/fontello.eot?94033511'); - src: url('../font/fontello.eot?94033511#iefix') format('embedded-opentype'), - url('../font/fontello.svg?94033511#fontello') format('svg'); + src: url('../font/fontello.eot?87658047'); + src: url('../font/fontello.eot?87658047#iefix') format('embedded-opentype'), + url('../font/fontello.svg?87658047#fontello') format('svg'); font-weight: normal; font-style: normal; } @font-face { font-family: 'fontello'; - src: url('data:application/octet-stream;base64,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') format('woff'), - url('data:application/octet-stream;base64,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JSAuRyNHI2EgsAQjQrAJQysgsGBQWCCwQFFYswIgAyAbswImAxpZQkIjIEewBEOwAmIgsABQWLBAYFlmsAFjYCCwASsgiophILACQ2BkI7ADQ2FkUFiwAkNhG7ADQ2BZsAMlsAJiILAAUFiwQGBZZrABY2GwAiVGYTgjIDwjOBshICBGI0ewASsjYTghWbErARQrLbBCLLA1Ky6xKwEUKy2wQyywNishIyAgPLAEI0IjOLErARQrsARDLrArKy2wRCywABUgR7AAI0KyAAEBFRQTLrAxKi2wRSywABUgR7AAI0KyAAEBFRQTLrAxKi2wRiyxAAEUE7AyKi2wRyywNCotsEgssAAWRSMgLiBGiiNhOLErARQrLbBJLLAII0KwSCstsEossgAAQSstsEsssgABQSstsEwssgEAQSstsE0ssgEBQSstsE4ssgAAQistsE8ssgABQistsFAssgEAQistsFEssgEBQistsFIssgAAPistsFMssgABPistsFQssgEAPistsFUssgEBPistsFYssgAAQCstsFcssgABQCstsFgssgEAQCstsFkssgEBQCstsFossgAAQystsFsssgABQystsFwssgEAQystsF0ssgEBQystsF4ssgAAPystsF8ssgABPystsGAssgEAPystsGEssgEBPystsGIssDcrLrErARQrLbBjLLA3K7A7Ky2wZCywNyuwPCstsGUssAAWsDcrsD0rLbBmLLA4Ky6xKwEUKy2wZyywOCuwOystsGgssDgrsDwrLbBpLLA4K7A9Ky2waiywOSsusSsBFCstsGsssDkrsDsrLbBsLLA5K7A8Ky2wbSywOSuwPSstsG4ssDorLrErARQrLbBvLLA6K7A7Ky2wcCywOiuwPCstsHEssDorsD0rLbByLLMJBAIDRVghGyMhWUIrsAhlsAMkUHiwARUwLQBLuADIUlixAQGOWbABuQgACABjcLEABUKxAAAqsQAFQrEACCqxAAVCsQAIKrEABUK5AAAACSqxAAVCuQAAAAkqsQMARLEkAYhRWLBAiFixA2REsSYBiFFYugiAAAEEQIhjVFixAwBEWVlZWbEADCq4Af+FsASNsQIARAA=') format('truetype'); + src: url('data:application/octet-stream;base64,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') format('woff'), + url('data:application/octet-stream;base64,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') format('truetype'); } /* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */ /* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */ @@ -17,7 +17,7 @@ @media screen and (-webkit-min-device-pixel-ratio:0) { @font-face { font-family: 'fontello'; - src: url('../font/fontello.svg?94033511#fontello') format('svg'); + src: url('../font/fontello.svg?87658047#fontello') format('svg'); } } */ @@ -64,4 +64,8 @@ .icon-cancel-circled:before { content: '\e809'; } /* '' */ .icon-volume:before { content: '\e80a'; } /* '' */ .icon-plus:before { content: '\e80b'; } /* '' */ -.icon-hourglass:before { content: '\e80c'; } /* '' */ \ No newline at end of file +.icon-hourglass:before { content: '\e80c'; } /* '' */ +.icon-calc:before { content: '\e80d'; } /* '' */ +.icon-tint:before { content: '\e80e'; } /* '' */ +.icon-chart-line:before { content: '\e80f'; } /* '' */ +.icon-sort-numeric:before { content: '\e810'; } /* '' */ \ No newline at end of file diff --git a/static/glyphs/css/fontello-ie7-codes.css b/static/glyphs/css/fontello-ie7-codes.css index f12e517b8fe..6cc26c1385a 100644 --- a/static/glyphs/css/fontello-ie7-codes.css +++ b/static/glyphs/css/fontello-ie7-codes.css @@ -11,4 +11,8 @@ .icon-cancel-circled { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-volume { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-plus { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } -.icon-hourglass { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } \ No newline at end of file +.icon-hourglass { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } +.icon-calc { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } +.icon-tint { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } +.icon-chart-line { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } +.icon-sort-numeric { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } \ No newline at end of file diff --git a/static/glyphs/css/fontello-ie7.css b/static/glyphs/css/fontello-ie7.css index f57862786bf..4770e782110 100644 --- a/static/glyphs/css/fontello-ie7.css +++ b/static/glyphs/css/fontello-ie7.css @@ -22,4 +22,8 @@ .icon-cancel-circled { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-volume { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } .icon-plus { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } -.icon-hourglass { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } \ No newline at end of file +.icon-hourglass { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } +.icon-calc { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } +.icon-tint { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } +.icon-chart-line { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } +.icon-sort-numeric { *zoom: expression( this.runtimeStyle['zoom'] = '1', this.innerHTML = ' '); } \ No newline at end of file diff --git a/static/glyphs/css/fontello.css b/static/glyphs/css/fontello.css index dcef60596fe..1bdd8aedcc4 100644 --- a/static/glyphs/css/fontello.css +++ b/static/glyphs/css/fontello.css @@ -1,10 +1,10 @@ @font-face { font-family: 'fontello'; - src: url('../font/fontello.eot?46427953'); - src: url('../font/fontello.eot?46427953#iefix') format('embedded-opentype'), - url('../font/fontello.woff?46427953') format('woff'), - url('../font/fontello.ttf?46427953') format('truetype'), - url('../font/fontello.svg?46427953#fontello') format('svg'); + src: url('../font/fontello.eot?87142642'); + src: url('../font/fontello.eot?87142642#iefix') format('embedded-opentype'), + url('../font/fontello.woff?87142642') format('woff'), + url('../font/fontello.ttf?87142642') format('truetype'), + url('../font/fontello.svg?87142642#fontello') format('svg'); font-weight: normal; font-style: normal; } @@ -14,7 +14,7 @@ @media screen and (-webkit-min-device-pixel-ratio:0) { @font-face { font-family: 'fontello'; - src: url('../font/fontello.svg?46427953#fontello') format('svg'); + src: url('../font/fontello.svg?87142642#fontello') format('svg'); } } */ @@ -35,7 +35,7 @@ /* For safety - reset parent styles, that can break glyph codes*/ font-variant: normal; text-transform: none; - + /* fix buttons height, for twitter bootstrap */ line-height: 1em; @@ -46,6 +46,10 @@ /* you can be more comfortable with increased icons size */ /* font-size: 120%; */ + /* Font smoothing. That was taken from TWBS */ + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + /* Uncomment for 3D effect */ /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */ } @@ -62,4 +66,8 @@ .icon-cancel-circled:before { content: '\e809'; } /* '' */ .icon-volume:before { content: '\e80a'; } /* '' */ .icon-plus:before { content: '\e80b'; } /* '' */ -.icon-hourglass:before { content: '\e80c'; } /* '' */ \ No newline at end of file +.icon-hourglass:before { content: '\e80c'; } /* '' */ +.icon-calc:before { content: '\e80d'; } /* '' */ +.icon-tint:before { content: '\e80e'; } /* '' */ +.icon-chart-line:before { content: '\e80f'; } /* '' */ +.icon-sort-numeric:before { content: '\e810'; } /* '' */ \ No newline at end of file diff --git a/static/glyphs/demo.html b/static/glyphs/demo.html index e8078fcc615..3ba8dbc7164 100644 --- a/static/glyphs/demo.html +++ b/static/glyphs/demo.html @@ -227,8 +227,54 @@ .i-code { display: none; } - - +@font-face { + font-family: 'fontello'; + src: url('./font/fontello.eot?65044999'); + src: url('./font/fontello.eot?65044999#iefix') format('embedded-opentype'), + url('./font/fontello.woff?65044999') format('woff'), + url('./font/fontello.ttf?65044999') format('truetype'), + url('./font/fontello.svg?65044999#fontello') format('svg'); + font-weight: normal; + font-style: normal; + } + + + .demo-icon + { + font-family: "fontello"; + font-style: normal; + font-weight: normal; + speak: none; + + display: inline-block; + text-decoration: inherit; + width: 1em; + margin-right: .2em; + text-align: center; + /* opacity: .8; */ + + /* For safety - reset parent styles, that can break glyph codes*/ + font-variant: normal; + text-transform: none; + + /* fix buttons height, for twitter bootstrap */ + line-height: 1em; + + /* Animation center compensation - margins should be symmetric */ + /* remove if not needed */ + margin-left: .2em; + + /* You can be more comfortable with increased icons size */ + /* font-size: 120%; */ + + /* Font smoothing. That was taken from TWBS */ + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + + /* Uncomment for 3D effect */ + /* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */ + } + diff --git a/static/report/js/report.js b/static/report/js/report.js index 7b018866684..9008380972c 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -3,11 +3,12 @@ // - make axis on daytoday better working with thresholds // - get rid of /static/report/js/time.js // - load css dynamic + optimize -// - move rp_edittreatmentdialog html to plugin // - check everything is translated // - add tests // - optimize merging data inside every plugin // - pressing Show 2nd time generates d3 errors, previous graphs are not removed +// - XMLHttpRequest - > $.ajax in treatments.js +// - finish TREATMENT_AUTH in careportal (function () { @@ -27,6 +28,8 @@ // init HTML code report_plugins.addHtmlFromPlugins( client ); + // make show() accessible outside for treatments.js + report_plugins.show = show; var translate = client.translate; From 3702e551be2b04f74d26cbf764acf100fea9a044 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Mon, 31 Aug 2015 08:15:23 +0200 Subject: [PATCH 034/176] food html code not hidden properly fix --- static/report/index.html | 4 ++-- static/report/js/report.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/static/report/index.html b/static/report/index.html index cfd3a330438..eb7ba373ba9 100644 --- a/static/report/index.html +++ b/static/report/index.html @@ -24,7 +24,7 @@

    Nightscout reporting

    Last 3 months - + Category: @@ -33,7 +33,7 @@

    Nightscout reporting

    - + diff --git a/static/report/js/report.js b/static/report/js/report.js index 9008380972c..4bbe43258ce 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -131,7 +131,7 @@ function enableFoodGUI( ) { $('#info').html(''); - $('#rp_foodgui').css('display',''); + $('.rp_foodgui').css('display',''); $('#rp_food').change(function (event) { $('#rp_enablefood').prop('checked',true); return maybePreventDefault(event); @@ -140,7 +140,7 @@ function disableFoodGUI(){ $('#info').html(''); - $('#rp_foodgui').css('display','none'); + $('.rp_foodgui').css('display','none'); } // ****** FOOD CODE END ****** From 72d66e576149d2cc9e2a8476c6dfff6d1f3939e3 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Mon, 31 Aug 2015 11:07:24 +0200 Subject: [PATCH 035/176] Fixed bug drawing was called multiple times --- static/report/js/report.js | 45 ++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/static/report/js/report.js b/static/report/js/report.js index 4bbe43258ce..6e0face8541 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -6,7 +6,6 @@ // - check everything is translated // - add tests // - optimize merging data inside every plugin -// - pressing Show 2nd time generates d3 errors, previous graphs are not removed // - XMLHttpRequest - > $.ajax in treatments.js // - finish TREATMENT_AUTH in careportal @@ -384,19 +383,19 @@ if (day===5 && $('#rp_fr').is(':checked')) { daystoshow[d]++; } if (day===6 && $('#rp_sa').is(':checked')) { daystoshow[d]++; } } + countDays(); display(); } function display() { - console.log('Total: ',daystoshow,'Needed: ',matchesneeded); - var displayeddays = 0; + var count = 0; $('#info').html(''+translate('Loading')+' ...'); for (var d in daystoshow) { if (daystoshow[d]===matchesneeded) { - if (displayeddays < maxdays) { + if (count < maxdays) { $('#info').append($('
    ')); - loadData(d,options); - displayeddays++; + count++; + loadData(d, options, dataLoadedCallback); } else { $('#info').append($('
    '+d+' '+translate('not displayed')+'.
    ')); } @@ -404,12 +403,33 @@ delete daystoshow[d]; } } - if (displayeddays===0) { + if (count===0) { $('#info').html(''+translate('Result is empty')+''); $('#rp_show').css('display',''); } } + var dayscount = 0; + var loadeddays = 0; + + function countDays() { + for (var d in daystoshow) { + if (daystoshow[d]===matchesneeded) { + if (dayscount < maxdays) { + dayscount++; + } + } + } + console.log('Total: ', daystoshow, 'Matches needed: ', matchesneeded, 'Will be loaded: ', dayscount); + } + + function dataLoadedCallback () { + loadeddays++; + if (loadeddays === dayscount) { + showreports(options); + } + } + $('#rp_show').css('display','none'); daystoshow = {}; @@ -427,6 +447,7 @@ report_plugins.eachPlugin(function (plugin) { // jquery plot doesn't draw to hidden div $('#'+plugin.name+'-placeholder').css('display',''); + //console.log('Drawing ',plugin.name); plugin.report(datastorage,daystoshow,options); if (!$('#'+plugin.name).hasClass('selected')) { $('#'+plugin.name+'-placeholder').css('display','none'); @@ -454,10 +475,10 @@ return maybePreventDefault(event); } - function loadData(day,options) { + function loadData(day, options, callback) { // check for loaded data if (datastorage[day] && day !== moment().format('YYYY-MM-DD')) { - showreports(options); + callback(); return; } // patientData = [actual, predicted, mbg, treatment, cal, devicestatusData]; @@ -536,13 +557,13 @@ } }).done(function () { $('#info-' + day).html(''+translate('Processing data of')+' '+day+' ...'); - processData(data,day,options); + processData(data, day, options, callback); }); }); } - function processData(data,day,options) { + function processData(data, day, options, callback) { // treatments data.treatments.forEach(function (d) { if (parseFloat(d.insulin) > maxInsulinValue) { @@ -602,7 +623,7 @@ datastorage[day] = data; options.maxInsulinValue = maxInsulinValue; options.maxCarbsValue = maxCarbsValue; - showreports(options); + callback(); } function maybePreventDefault(event) { From 55e8d92ad95b2d12a34d02b245f13c2b45c589e7 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Mon, 31 Aug 2015 11:31:03 +0200 Subject: [PATCH 036/176] translation fix in dailystats --- lib/report_plugins/dailystats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/report_plugins/dailystats.js b/lib/report_plugins/dailystats.js index 838fed41692..7f72e0997e9 100644 --- a/lib/report_plugins/dailystats.js +++ b/lib/report_plugins/dailystats.js @@ -108,7 +108,7 @@ dailystats.report = function report_dailystats(datastorage,daystoshow,options) { data: Math.floor(stats.lows * 1000 / daysRecords.length) / 10 }, { - label: translate('In range'), + label: translate('In Range'), data: Math.floor(stats.normal * 1000 / daysRecords.length) / 10 }, { From f2e047f73b6da1a18e0158ed581875cefa66f305 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Mon, 31 Aug 2015 13:36:12 +0200 Subject: [PATCH 037/176] optimized merging data in reports --- lib/report_plugins/glucosedistribution.js | 8 ++------ lib/report_plugins/hourlystats.js | 8 ++------ lib/report_plugins/percentile.js | 8 ++------ lib/report_plugins/success.js | 8 ++------ static/report/js/report.js | 15 ++++++++------- 5 files changed, 16 insertions(+), 31 deletions(-) diff --git a/lib/report_plugins/glucosedistribution.js b/lib/report_plugins/glucosedistribution.js index 68c6bd173d7..27a226c27bb 100644 --- a/lib/report_plugins/glucosedistribution.js +++ b/lib/report_plugins/glucosedistribution.js @@ -50,12 +50,8 @@ glucosedistribution.report = function report_glucosedistribution(datastorage,day $(''+translate('A1c estimation*')+'').appendTo(thead); thead.appendTo(table); - var data = []; - var days = 0; - Object.keys(daystoshow).forEach(function (day) { - data = data.concat(datastorage[day].statsrecords); - days++; - }); + var data = datastorage.allstatsrecords; + var days = datastorage.alldays; $('#glucosedistribution-days').text(days+' '+translate('days total')); diff --git a/lib/report_plugins/hourlystats.js b/lib/report_plugins/hourlystats.js index 353a0ba4ec9..0fbe1d2b655 100644 --- a/lib/report_plugins/hourlystats.js +++ b/lib/report_plugins/hourlystats.js @@ -31,12 +31,8 @@ hourlystats.report = function report_hourlystats(datastorage, daystoshow, option var stats = []; var pivotedByHour = {}; - var data = []; - var days = 0; - Object.keys(daystoshow).forEach(function (day) { - data = data.concat(datastorage[day].statsrecords); - days++; - }); + var data = datastorage.allstatsrecords; + var days = datastorage.alldays; for (var i = 0; i < 24; i++) { pivotedByHour[i] = []; diff --git a/lib/report_plugins/percentile.js b/lib/report_plugins/percentile.js index fa52cefcffc..5fb748a0eb8 100644 --- a/lib/report_plugins/percentile.js +++ b/lib/report_plugins/percentile.js @@ -30,12 +30,8 @@ percentile.report = function report_percentile(datastorage,daystoshow,options) { var minutewindow = 30; //minute-window should be a divisor of 60 - var data = []; - var days = 0; - Object.keys(daystoshow).forEach(function (day) { - data = data.concat(datastorage[day].statsrecords); - days++; - }); + var data = datastorage.allstatsrecords; + var days = datastorage.alldays; var bins = []; for (var hour = 0; hour < 24; hour++) { diff --git a/lib/report_plugins/success.js b/lib/report_plugins/success.js index bdd079600bc..748898906b7 100644 --- a/lib/report_plugins/success.js +++ b/lib/report_plugins/success.js @@ -29,12 +29,8 @@ success.report = function report_success(datastorage,daystoshow,options) { var low = parseInt(options.targetLow), high = parseInt(options.targetHigh); - var data = []; - var days = 0; - Object.keys(daystoshow).forEach(function (day) { - data = data.concat(datastorage[day].statsrecords); - days++; - }); + var data = datastorage.allstatsrecords; + var days = datastorage.alldays; var now = Date.now(); var period = (7).days(); diff --git a/static/report/js/report.js b/static/report/js/report.js index 6e0face8541..a117a14ba2a 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -5,7 +5,6 @@ // - load css dynamic + optimize // - check everything is translated // - add tests -// - optimize merging data inside every plugin // - XMLHttpRequest - > $.ajax in treatments.js // - finish TREATMENT_AUTH in careportal @@ -438,12 +437,14 @@ } function showreports(options) { - // wait for all loads - for (var d in daystoshow) { - if (!datastorage[d]) { - return; // all data not loaded yet - } - } + // prepare some data used in more reports + datastorage.allstatsrecords = []; + datastorage.alldays = 0; + Object.keys(daystoshow).forEach(function (day) { + datastorage.allstatsrecords = datastorage.allstatsrecords.concat(datastorage[day].statsrecords); + datastorage.alldays++; + }); + report_plugins.eachPlugin(function (plugin) { // jquery plot doesn't draw to hidden div $('#'+plugin.name+'-placeholder').css('display',''); From 0cbdf57aa9e92d8d37df909b9823926e960241f2 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Mon, 31 Aug 2015 13:45:38 +0200 Subject: [PATCH 038/176] added missing translation --- lib/language.js | 3 +++ lib/report_plugins/glucosedistribution.js | 2 +- static/report/js/report.js | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/language.js b/lib/language.js index 157e3575c57..05d713c2bc5 100644 --- a/lib/language.js +++ b/lib/language.js @@ -3654,6 +3654,9 @@ function init() { ,'Edit treatment' : { cs: 'Upravit ošetření' } + ,'This is only a rough estimation that can be very inaccurate and does not replace actual blood testing. The formula used is taken from: Nathan, David M., et al. "Translating the A1C assay into estimated average glucose values." Diabetes care 31.8 (2008): 1473-1478.' : { + cs: 'Toto je pouze hrubý odhad, který může být velmi nepřesný a nenahrazuje měření z krve. Vzorec je převzatý z: Nathan, David M., et al. "Translating the A1C assay into estimated average glucose values." Diabetes care 31.8 (2008): 1473-1478.' + } }; diff --git a/lib/report_plugins/glucosedistribution.js b/lib/report_plugins/glucosedistribution.js index 27a226c27bb..ce03b12d791 100644 --- a/lib/report_plugins/glucosedistribution.js +++ b/lib/report_plugins/glucosedistribution.js @@ -25,7 +25,7 @@ glucosedistribution.html = function html(client) { + '
    ' + '
    ' + '
    ' - + translate('* This is only a rough estimation that can be very inaccurate and does not replace actual blood testing. The formula used is taken from: Nathan, David M., et al. "Translating the A1C assay into estimated average glucose values." Diabetes care 31.8 (2008): 1473-1478.') + + '* ' + translate('This is only a rough estimation that can be very inaccurate and does not replace actual blood testing. The formula used is taken from: Nathan, David M., et al. "Translating the A1C assay into estimated average glucose values." Diabetes care 31.8 (2008): 1473-1478.') ; return ret; }; diff --git a/static/report/js/report.js b/static/report/js/report.js index a117a14ba2a..25d26c79137 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -3,7 +3,6 @@ // - make axis on daytoday better working with thresholds // - get rid of /static/report/js/time.js // - load css dynamic + optimize -// - check everything is translated // - add tests // - XMLHttpRequest - > $.ajax in treatments.js // - finish TREATMENT_AUTH in careportal From 57fe7dc9c3ef7b98ddfd675159f1653677b1a269 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Mon, 31 Aug 2015 15:13:58 +0200 Subject: [PATCH 039/176] TREATMENT_AUTH handling, added authentication status to careportal --- lib/api/treatments/index.js | 4 +++- lib/client/careportal.js | 10 ++++++++-- lib/report_plugins/treatments.js | 12 ++++++------ static/index.html | 3 +++ static/report/js/report.js | 2 -- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/lib/api/treatments/index.js b/lib/api/treatments/index.js index c6fd36f4c8b..69a6087b368 100644 --- a/lib/api/treatments/index.js +++ b/lib/api/treatments/index.js @@ -28,13 +28,15 @@ function configure (app, wares, ctx) { var treatment = req.body; ctx.treatments.create(treatment, function (err, created) { if (err) { + console.log('Error adding treatment'); res.sendJSONStatus(res, consts.HTTP_INTERNAL_ERROR, 'Mongo Error', err); } else { + console.log('Treatment created'); res.json(created); } }); } - if (app.treatments_auth) { + if (app.settings.treatments_auth) { api.post('/treatments/', wares.verifyAuthorization, post_response); } else { api.post('/treatments/', post_response); diff --git a/lib/client/careportal.js b/lib/client/careportal.js index fa766497590..29a32fc6dad 100644 --- a/lib/client/careportal.js +++ b/lib/client/careportal.js @@ -126,10 +126,16 @@ function init (client, $) { if (window.confirm(buildConfirmText(data))) { $.ajax({ method: 'POST', - url: '/api/v1/treatments/', - data: data + url: '/api/v1/treatments/' + , headers: { + 'api-secret': client.hashauth.hash() + } + , data: data }).done(function treatmentSaved (response) { console.info('treatment saved', response); + }).fail(function treatmentSaveFail (response) { + console.info('treatment saved', response); + alert(translate('Entering record failed') + '. ' + translate('Status') + ': ' + response.status); }); storage.set('enteredBy', data.enteredBy); diff --git a/lib/report_plugins/treatments.js b/lib/report_plugins/treatments.js index 9f058a01fc1..a583d63cb4e 100644 --- a/lib/report_plugins/treatments.js +++ b/lib/report_plugins/treatments.js @@ -69,12 +69,17 @@ treatments.report = function report_treatments(datastorage, daystoshow, options) var report_plugins = Nightscout.report_plugins; function deleteTreatment(event) { + if (!client.hashauth.isAuthenticated()) { + alert(translate('Your device is not authenticated yet')); + return false; + } + var data = JSON.parse($(this).attr('data')); var day = $(this).attr('day'); var ok = window.confirm( translate('Delete this treatment?')+'\n' + - '\n'+translate('Event Type')+': ' + data.eventType + + '\n'+translate('Event Type')+': ' + translate(resolveEventName(data.eventType)) + (data.glucose ? '\n'+translate('Blood Glucose')+': ' + data.glucose : '')+ (data.glucoseType ? '\n'+translate('Method')+': ' + data.glucoseType : '')+ (data.carbs ? '\n'+translate('Carbs Given')+': ' + data.carbs : '' )+ @@ -97,11 +102,6 @@ treatments.report = function report_treatments(datastorage, daystoshow, options) } function deleteTreatmentRecord(_id) { - if (!client.hashauth.isAuthenticated()) { - alert(translate('Your device is not authenticated yet')); - return false; - } - var xhr = new XMLHttpRequest(); xhr.open('DELETE', '/api/v1/treatments/'+_id, true); xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); diff --git a/static/index.html b/static/index.html index ab6d97b6c89..3b607b054dc 100644 --- a/static/index.html +++ b/static/index.html @@ -243,6 +243,9 @@
    View all treatments +
    + Authentication status:
    + diff --git a/static/report/js/report.js b/static/report/js/report.js index 25d26c79137..2d3d4a774c1 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -5,8 +5,6 @@ // - load css dynamic + optimize // - add tests // - XMLHttpRequest - > $.ajax in treatments.js -// - finish TREATMENT_AUTH in careportal - (function () { 'use strict'; From 2d5e8f3ba8a3285b6403757d3222fc798508d5c2 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Mon, 31 Aug 2015 21:38:21 +0200 Subject: [PATCH 040/176] fixed mock func in test --- tests/careportal.test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/careportal.test.js b/tests/careportal.test.js index e71251ae9da..34539eb2aec 100644 --- a/tests/careportal.test.js +++ b/tests/careportal.test.js @@ -57,6 +57,10 @@ describe('client', function ( ) { done: function mockDone (fn) { fn(); done(); + return self.$.ajax(); + } + , fail: function mockFail (fn) { + return self.$.ajax(); } }; }; From 8728f0bba60b6fcc614490543841a9296374cd85 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Mon, 31 Aug 2015 23:20:51 +0200 Subject: [PATCH 041/176] treatments edit/save needed changes, XMLHttp -> $.ajax --- lib/api/treatments/index.js | 2 +- lib/language.js | 3 ++ lib/report_plugins/treatments.js | 50 ++++++++++++++++++-------------- lib/treatments.js | 9 ++++-- static/report/js/report.js | 3 +- 5 files changed, 40 insertions(+), 27 deletions(-) diff --git a/lib/api/treatments/index.js b/lib/api/treatments/index.js index 69a6087b368..65a7cccdba6 100644 --- a/lib/api/treatments/index.js +++ b/lib/api/treatments/index.js @@ -57,7 +57,7 @@ function configure (app, wares, ctx) { console.log(err); } else { res.json(created); - console.log('Treatment saved'); + console.log('Treatment saved', data); } }); }); diff --git a/lib/language.js b/lib/language.js index 05d713c2bc5..57b59a11898 100644 --- a/lib/language.js +++ b/lib/language.js @@ -3657,6 +3657,9 @@ function init() { ,'This is only a rough estimation that can be very inaccurate and does not replace actual blood testing. The formula used is taken from: Nathan, David M., et al. "Translating the A1C assay into estimated average glucose values." Diabetes care 31.8 (2008): 1473-1478.' : { cs: 'Toto je pouze hrubý odhad, který může být velmi nepřesný a nenahrazuje měření z krve. Vzorec je převzatý z: Nathan, David M., et al. "Translating the A1C assay into estimated average glucose values." Diabetes care 31.8 (2008): 1473-1478.' } + ,'Saving record failed' : { + cs: 'Uložení záznamu selhalo' + } }; diff --git a/lib/report_plugins/treatments.js b/lib/report_plugins/treatments.js index a583d63cb4e..c1b3e8fcf06 100644 --- a/lib/report_plugins/treatments.js +++ b/lib/report_plugins/treatments.js @@ -102,16 +102,18 @@ treatments.report = function report_treatments(datastorage, daystoshow, options) } function deleteTreatmentRecord(_id) { - var xhr = new XMLHttpRequest(); - xhr.open('DELETE', '/api/v1/treatments/'+_id, true); - xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); - xhr.setRequestHeader('api-secret', client.hashauth.hash()); - xhr.onload = function () { - if (xhr.statusText!=='OK') { - alert(translate('Deleting record failed')); + $.ajax({ + method: 'DELETE' + , url: '/api/v1/treatments/' + _id + , headers: { + 'api-secret': client.hashauth.hash() } - }; - xhr.send(null); + }).done(function treatmentDeleted (response) { + console.info('treatment deleted', response); + }).fail(function treatmentDeleteFail (response) { + console.info('treatment delete failed', response); + alert(translate('Deleting record failed') + '. ' + translate('Status') + ': ' + response.status); + }); return true; } @@ -139,8 +141,10 @@ treatments.report = function report_treatments(datastorage, daystoshow, options) data.insulin = $('#rped_insulinGiven').val(); data.notes = $('#rped_adnotes').val(); data.enteredBy = $('#rped_enteredBy').val(); - data.created_at = client.utils.mergeInputTime($('#rped_eventTimeValue').val(), $('#rped_eventDateValue').val()); + data.eventTime = new Date(client.utils.mergeInputTime($('#rped_eventTimeValue').val(), $('#rped_eventDateValue').val())).toISOString(); data.units = options.units; + delete data.mills; + delete data.created_at; $( this ).dialog('close'); saveTreatmentRecord(data); delete datastorage[day]; @@ -183,18 +187,20 @@ treatments.report = function report_treatments(datastorage, daystoshow, options) return false; } - var dataJson = JSON.stringify(data, null, ' '); - - var xhr = new XMLHttpRequest(); - xhr.open('PUT', '/api/v1/treatments/', true); - xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); - xhr.setRequestHeader('api-secret', client.hashauth.hash()); - xhr.onload = function () { - if (xhr.statusText!=='OK') { - alert(translate('Saving record failed')); - } - }; - xhr.send(dataJson); + $.ajax({ + method: 'PUT' + , url: '/api/v1/treatments/' + , headers: { + 'api-secret': client.hashauth.hash() + } + , data: data + }).done(function treatmentSaved (response) { + console.info('treatment saved', response); + }).fail(function treatmentSaveFail (response) { + console.info('treatment save failed', response); + alert(translate('Saving record failed') + '. ' + translate('Status') + ': ' + response.status); + }); + return true; } diff --git a/lib/treatments.js b/lib/treatments.js index 000645ad361..623deae33e4 100644 --- a/lib/treatments.js +++ b/lib/treatments.js @@ -43,12 +43,17 @@ function storage (env, ctx) { } function remove (_id, fn) { - return api( ).remove({ '_id': new ObjectID(_id) }, fn); + api( ).remove({ '_id': new ObjectID(_id) }, fn); + + ctx.bus.emit('data-received'); } function save (obj, fn) { obj._id = new ObjectID(obj._id); + prepareData(obj); api().save(obj, fn); + + ctx.bus.emit('data-received'); } @@ -84,7 +89,7 @@ function prepareData(obj) { } obj.created_at = results.created_at.toISOString(); - if (obj.preBolus !== 0 && obj.carbs) { + if (obj.preBolus && obj.preBolus !== 0 && obj.carbs) { results.preBolusCarbs = obj.carbs; delete obj.carbs; } diff --git a/static/report/js/report.js b/static/report/js/report.js index 2d3d4a774c1..c8db0cedf94 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -1,10 +1,9 @@ // TODO: // - bypass nightmode in reports -// - make axis on daytoday better working with thresholds // - get rid of /static/report/js/time.js // - load css dynamic + optimize // - add tests -// - XMLHttpRequest - > $.ajax in treatments.js +// - on save/delete treatment ctx.bus.emit('data-received'); is not enough. we must add something like 'data-updated' (function () { 'use strict'; From e7967669f0644302e440849a6203eebee99ce5ba Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 3 Sep 2015 21:26:08 +0200 Subject: [PATCH 042/176] Fix rolling minutes over hours --- lib/client/careportal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/careportal.js b/lib/client/careportal.js index 9c055d83e84..38ef086f628 100644 --- a/lib/client/careportal.js +++ b/lib/client/careportal.js @@ -123,7 +123,7 @@ function init (client, $) { var ele = $(this); var merged = mergeDateAndTime(); - if (ele.attr('oldminutes') === ' 59' && merged.minutes() === 0) { + if (ele.attr('oldminutes') === '59' && merged.minutes() === 0) { merged.add(1, 'hours'); } if (ele.attr('oldminutes') === '0' && merged.minutes() === 59) { From 344b0692fb1cbb063c0cef83cf1c1138b13ac3c5 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 4 Sep 2015 10:22:56 +0200 Subject: [PATCH 043/176] codacy pass 6 --- lib/report_plugins/hourlystats.js | 1 - lib/report_plugins/percentile.js | 1 - lib/report_plugins/success.js | 1 - lib/report_plugins/treatments.js | 7 ++----- tests/careportal.test.js | 2 +- 5 files changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/report_plugins/hourlystats.js b/lib/report_plugins/hourlystats.js index 0fbe1d2b655..4031ed607a9 100644 --- a/lib/report_plugins/hourlystats.js +++ b/lib/report_plugins/hourlystats.js @@ -32,7 +32,6 @@ hourlystats.report = function report_hourlystats(datastorage, daystoshow, option var pivotedByHour = {}; var data = datastorage.allstatsrecords; - var days = datastorage.alldays; for (var i = 0; i < 24; i++) { pivotedByHour[i] = []; diff --git a/lib/report_plugins/percentile.js b/lib/report_plugins/percentile.js index 5fb748a0eb8..9518a757e30 100644 --- a/lib/report_plugins/percentile.js +++ b/lib/report_plugins/percentile.js @@ -31,7 +31,6 @@ percentile.report = function report_percentile(datastorage,daystoshow,options) { var minutewindow = 30; //minute-window should be a divisor of 60 var data = datastorage.allstatsrecords; - var days = datastorage.alldays; var bins = []; for (var hour = 0; hour < 24; hour++) { diff --git a/lib/report_plugins/success.js b/lib/report_plugins/success.js index 748898906b7..5a53a2892d7 100644 --- a/lib/report_plugins/success.js +++ b/lib/report_plugins/success.js @@ -30,7 +30,6 @@ success.report = function report_success(datastorage,daystoshow,options) { high = parseInt(options.targetHigh); var data = datastorage.allstatsrecords; - var days = datastorage.alldays; var now = Date.now(); var period = (7).days(); diff --git a/lib/report_plugins/treatments.js b/lib/report_plugins/treatments.js index c1b3e8fcf06..586ef4bbb7b 100644 --- a/lib/report_plugins/treatments.js +++ b/lib/report_plugins/treatments.js @@ -66,6 +66,8 @@ treatments.html = function html(client) { treatments.report = function report_treatments(datastorage, daystoshow, options) { var Nightscout = window.Nightscout; + var client = Nightscout.client; + var translate = client.translate; var report_plugins = Nightscout.report_plugins; function deleteTreatment(event) { @@ -213,11 +215,6 @@ treatments.report = function report_treatments(datastorage, daystoshow, options) return value; } - var Nightscout = window.Nightscout; - var client = Nightscout.client; - var translate = client.translate; - var report_plugins = Nightscout.report_plugins; - var icon_remove = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACrElEQVQ4T42Ty2sTQRzHv5tmk2yyjRNtpfZhL8V6s2KoUNC2XqwgaCsVQcGiFqpHi0c9iRdR/ANE9KR40FIQX4cueKoPaKFoLdSYNtE0abKT1+5s9iW7aUMiHtzTzO7v85md+c6PA4DrHbsPCKIgOWO1pA7dT6YXnXH949SE/F63pqwZtRrO+SCKgjQ5NUV+azpmHj2krMwaJC4c8Erj+/eRyloMMwWFKgbn1nC3ervlK1evkXBLGBZT8SOewotnTylTNLdgeg/pDgZDC2cPHSR8bB22DVC9hFe0SG/H0xFXcHlykjRHRDBWgJcZSCY38Xx2lhqMnRYE34Px/sN9vlQWeoHBAx2yXsRruVAVuFsIBaSJ8+eJGPaBqQV4NROJjTzez89jLBoFn6FgybQL54wS3uTyVDFQ3cL2IYpBv3RhdJSIIQ80tQyv7gEqJvS8AmUlBs7UXPhtjtZgh3UFNYngk86NHCfNAg9dMwHVBPu+CpsVkTXKeJeVG+AGgTOZ3tt6MSKKjy+NjEBjFrR4ElZmA4pdxstMFsyyJu6tZZ7Ux9vwB6EAL50ZGiRECEPPUOixVTRxHlicgSVWxEdZpuZWfNuS2hk48NjwMIkIYZglBnV5Cbqtws/5IaAJmsfCglrEl2y2QeKmEBJ80tixKmxrFpSVr0gV0viQoxho2YUuPohmeFD22PiklLC4ma5JuBvdrfLJI0dJd0s7bM0ES8aR/BXDXGaTskqlL+D3Lwy0tZEePoAd4EA5YF4tYymdonfjmQh3s6dTPjU4SHYGwjAKecSXFyGlM1TdytntE56T+ts7SC/vhw3gm6njc2Kd3vm5Ub1IwQAvnYhGiZpYw1wiWYPrIw7wnBTt7CLOOwdmut14kQQvqt24tfK/utGR6LaF+iRqMf4N/O/8D28HiiCRYqzAAAAAAElFTkSuQmCC'; var icon_edit = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABEUlEQVQ4jZ3MMUsCYQDG8ee8IySQbNCLyyEKG/RLNAXicqvQcAeNLrcFLlE0+xHuNpt8wy04rrYm8Q4HQRE56BSC3lSqU1BwCoxM39dnffj9BWyxXvVeEzvtctBwHyRebNu2Nk2lzMlrgJB+qBEeTByiKYpihl+fIO8jTI9PDJEVF1+K2iw+M6PhDuyag4NkQi/c3FkCK5Z3ZbM76qLltpCbn+vXxq0FABsDy9hzPdBvqvtXvvXzrw1swmsDLPjfACteGeDBfwK8+FdgGwwAIgC0ncsjxGRSH/eiPBgAJADY2z8sJ4JBfNBsDqlADVYMANIzKalv/bHaefKsTH9iPFb8ISsGAJym0+Qinz3jQktbAHcxvx3559eSAAAAAElFTkSuQmCC'; diff --git a/tests/careportal.test.js b/tests/careportal.test.js index 34539eb2aec..11821fd3ffe 100644 --- a/tests/careportal.test.js +++ b/tests/careportal.test.js @@ -59,7 +59,7 @@ describe('client', function ( ) { done(); return self.$.ajax(); } - , fail: function mockFail (fn) { + , fail: function mockFail ( ) { return self.$.ajax(); } }; From f42df1703e98588001b7cbd4929855e6431dcec5 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 4 Sep 2015 10:41:44 +0200 Subject: [PATCH 044/176] treatments.js refactoring --- lib/report_plugins/calibrations.js | 61 +++++++++++++++--------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/lib/report_plugins/calibrations.js b/lib/report_plugins/calibrations.js index cb57903cbf5..c771a6452f1 100644 --- a/lib/report_plugins/calibrations.js +++ b/lib/report_plugins/calibrations.js @@ -55,7 +55,7 @@ calibrations.report = function report_calibrations(datastorage,daystoshow) { Object.keys(daystoshow).forEach(function (day) { mbgs = mbgs.concat(datastorage[day].mbg); }); - mbgs.forEach(function (mbg) { calibrations_calcmbg(mbg); }); + mbgs.forEach(function (mbg) { calcmbg(mbg); }); var events = treatments.concat(cals).concat(mbgs).sort(function(a, b) { return a.mills - b.mills; }); @@ -66,13 +66,9 @@ calibrations.report = function report_calibrations(datastorage,daystoshow) { var lastmbg = null; for (var i=0; i'; e.bgcolor = colors[colorindex]; @@ -100,41 +96,44 @@ calibrations.report = function report_calibrations(datastorage,daystoshow) { $('#calibrations-list').html(html); // select last 3 mbgs - var maxcals = 3; - for (i=events.length-1; i>0; i--) { - if (typeof events[i].device !== 'undefined') { - events[i].checked = true; - $('#calibrations-'+i).prop('checked',true); - if (--maxcals<1) { - break; + checkLastCheckboxes(3); + drawelements(); + + $('.calibrations-checkbox').change(checkboxevent); + + function checkLastCheckboxes (maxcals) { + for (i=events.length-1; i>0; i--) { + if (typeof events[i].device !== 'undefined') { + events[i].checked = true; + $('#calibrations-'+i).prop('checked',true); + if (--maxcals<1) { + break; + } } } } - calibrations_drawelements(); - - $('.calibrations-checkbox').change(calibrations_checkboxevent); - - function calibrations_checkboxevent(event) { + + function checkboxevent(event) { var index = $(this).attr('index'); events[index].checked = $(this).is(':checked'); - calibrations_drawelements(); + drawelements(); event.preventDefault(); } - function calibrations_drawelements() { - calibrations_drawChart(); + function drawelements() { + drawChart(); for (var i=0; i5*60*1000) { @@ -254,7 +253,7 @@ calibrations.report = function report_calibrations(datastorage,daystoshow) { } } - function calibrations_drawmbg(mbg) { + function drawmbg(mbg) { var color = mbg.bgcolor; if (mbg.raw) { calibration_context.append('circle') @@ -268,7 +267,7 @@ calibrations.report = function report_calibrations(datastorage,daystoshow) { } } - function calibrations_findlatest(date,storage) { + function findlatest(date,storage) { var last = null; var time = date.getTime(); for (var i=0; i Date: Fri, 4 Sep 2015 11:10:59 +0200 Subject: [PATCH 045/176] more treatments.js refactoring --- lib/report_plugins/treatments.js | 67 +++++++++++++++++++------------- static/report/js/report.js | 20 +++++----- 2 files changed, 49 insertions(+), 38 deletions(-) diff --git a/lib/report_plugins/treatments.js b/lib/report_plugins/treatments.js index 586ef4bbb7b..9eb50a1864f 100644 --- a/lib/report_plugins/treatments.js +++ b/lib/report_plugins/treatments.js @@ -1,5 +1,4 @@ 'use strict'; -var translate = require('../language')().translate; var treatments = { name: 'treatments' @@ -70,6 +69,31 @@ treatments.report = function report_treatments(datastorage, daystoshow, options) var translate = client.translate; var report_plugins = Nightscout.report_plugins; + function buildConfirmText(data) { + var text = [ + translate('Delete this treatment?')+'\n' + , '\n'+translate('Event Type')+': ' + translate(resolveEventName(data.eventType)) + ]; + + function pushIf (check, valueText) { + if (check) { + text.push(valueText); + } + } + + pushIf(data.glucose, translate('Blood Glucose') + ': ' + data.glucose); + pushIf(data.glucoseType, translate('Measurement Method') + ': ' + translate(data.glucoseType)); + + pushIf(data.carbs, translate('Carbs Given') + ': ' + data.carbs); + pushIf(data.insulin, translate('Insulin Given') + ': ' + data.insulin); + pushIf(data.preBolus, translate('Carb Time') + ': ' + data.preBolus + ' ' + translate('mins')); + pushIf(data.notes, translate('Notes') + ': ' + data.notes); + pushIf(data.enteredBy, translate('Entered By') + ': ' + data.enteredBy); + + text.push(translate('Event Time') + ': ' + (data.eventTime ? data.eventTime.toLocaleString() : new Date().toLocaleString())); + return text.join('\n'); + } + function deleteTreatment(event) { if (!client.hashauth.isAuthenticated()) { alert(translate('Your device is not authenticated yet')); @@ -79,34 +103,10 @@ treatments.report = function report_treatments(datastorage, daystoshow, options) var data = JSON.parse($(this).attr('data')); var day = $(this).attr('day'); - var ok = window.confirm( - translate('Delete this treatment?')+'\n' + - '\n'+translate('Event Type')+': ' + translate(resolveEventName(data.eventType)) + - (data.glucose ? '\n'+translate('Blood Glucose')+': ' + data.glucose : '')+ - (data.glucoseType ? '\n'+translate('Method')+': ' + data.glucoseType : '')+ - (data.carbs ? '\n'+translate('Carbs Given')+': ' + data.carbs : '' )+ - (data.insulin ? '\n'+translate('Insulin Given')+': ' + data.insulin : '')+ - (data.preBolus ? '\n'+translate('Pre Bolus')+': ' + data.preBolus : '')+ - (data.notes ? '\n'+translate('Notes')+': ' + data.notes : '' )+ - (data.enteredBy ? '\n'+translate('Entered By')+': ' + data.enteredBy : '' )+ - ('\n'+translate('Event Time')+': ' + new Date(data.created_at).toLocaleString()) - ); - - if (ok) { - deleteTreatmentRecord(data._id); - delete datastorage[day]; - report_plugins.show(); - } - if (event) { - event.preventDefault(); - } - return false; - } - - function deleteTreatmentRecord(_id) { + if (window.confirm(buildConfirmText(data))) { $.ajax({ method: 'DELETE' - , url: '/api/v1/treatments/' + _id + , url: '/api/v1/treatments/' + data._id , headers: { 'api-secret': client.hashauth.hash() } @@ -116,7 +116,11 @@ treatments.report = function report_treatments(datastorage, daystoshow, options) console.info('treatment delete failed', response); alert(translate('Deleting record failed') + '. ' + translate('Status') + ': ' + response.status); }); - return true; + delete datastorage[day]; + report_plugins.show(); + } + maybePrevent(event); + return false; } function editTreatment(event) { @@ -215,6 +219,13 @@ treatments.report = function report_treatments(datastorage, daystoshow, options) return value; } + function maybePrevent (event) { + if (event) { + event.preventDefault(); + } + return false; + } + var icon_remove = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACrElEQVQ4T42Ty2sTQRzHv5tmk2yyjRNtpfZhL8V6s2KoUNC2XqwgaCsVQcGiFqpHi0c9iRdR/ANE9KR40FIQX4cueKoPaKFoLdSYNtE0abKT1+5s9iW7aUMiHtzTzO7v85md+c6PA4DrHbsPCKIgOWO1pA7dT6YXnXH949SE/F63pqwZtRrO+SCKgjQ5NUV+azpmHj2krMwaJC4c8Erj+/eRyloMMwWFKgbn1nC3ervlK1evkXBLGBZT8SOewotnTylTNLdgeg/pDgZDC2cPHSR8bB22DVC9hFe0SG/H0xFXcHlykjRHRDBWgJcZSCY38Xx2lhqMnRYE34Px/sN9vlQWeoHBAx2yXsRruVAVuFsIBaSJ8+eJGPaBqQV4NROJjTzez89jLBoFn6FgybQL54wS3uTyVDFQ3cL2IYpBv3RhdJSIIQ80tQyv7gEqJvS8AmUlBs7UXPhtjtZgh3UFNYngk86NHCfNAg9dMwHVBPu+CpsVkTXKeJeVG+AGgTOZ3tt6MSKKjy+NjEBjFrR4ElZmA4pdxstMFsyyJu6tZZ7Ux9vwB6EAL50ZGiRECEPPUOixVTRxHlicgSVWxEdZpuZWfNuS2hk48NjwMIkIYZglBnV5Cbqtws/5IaAJmsfCglrEl2y2QeKmEBJ80tixKmxrFpSVr0gV0viQoxho2YUuPohmeFD22PiklLC4ma5JuBvdrfLJI0dJd0s7bM0ES8aR/BXDXGaTskqlL+D3Lwy0tZEePoAd4EA5YF4tYymdonfjmQh3s6dTPjU4SHYGwjAKecSXFyGlM1TdytntE56T+ts7SC/vhw3gm6njc2Kd3vm5Ub1IwQAvnYhGiZpYw1wiWYPrIw7wnBTt7CLOOwdmut14kQQvqt24tfK/utGR6LaF+iRqMf4N/O/8D28HiiCRYqzAAAAAAElFTkSuQmCC'; var icon_edit = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABEUlEQVQ4jZ3MMUsCYQDG8ee8IySQbNCLyyEKG/RLNAXicqvQcAeNLrcFLlE0+xHuNpt8wy04rrYm8Q4HQRE56BSC3lSqU1BwCoxM39dnffj9BWyxXvVeEzvtctBwHyRebNu2Nk2lzMlrgJB+qBEeTByiKYpihl+fIO8jTI9PDJEVF1+K2iw+M6PhDuyag4NkQi/c3FkCK5Z3ZbM76qLltpCbn+vXxq0FABsDy9hzPdBvqvtXvvXzrw1swmsDLPjfACteGeDBfwK8+FdgGwwAIgC0ncsjxGRSH/eiPBgAJADY2z8sJ4JBfNBsDqlADVYMANIzKalv/bHaefKsTH9iPFb8ISsGAJym0+Qinz3jQktbAHcxvx3559eSAAAAAElFTkSuQmCC'; diff --git a/static/report/js/report.js b/static/report/js/report.js index c8db0cedf94..bcfb0dba14b 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -64,7 +64,7 @@ $('#rp_subcategory').change(doFoodFilter); $('#rp_name').on('input',doFoodFilter); - return maybePreventDefault(event); + return maybePrevent(event); } function fillFoodSubcategories(event) { @@ -77,7 +77,7 @@ } } doFoodFilter(); - return maybePreventDefault(event); + return maybePrevent(event); } function doFoodFilter(event) { @@ -99,7 +99,7 @@ $('#rp_food').append(new Option(o,food_list[i]._id)); } - return maybePreventDefault(event); + return maybePrevent(event); } $('#info').html(''+translate('Loading food database')+' ...'); @@ -128,7 +128,7 @@ $('.rp_foodgui').css('display',''); $('#rp_food').change(function (event) { $('#rp_enablefood').prop('checked',true); - return maybePreventDefault(event); + return maybePrevent(event); }); } @@ -149,11 +149,11 @@ $('#rp_show').click(show); $('#rp_notes').bind('input', function (event) { $('#rp_enablenotes').prop('checked',true); - return maybePreventDefault(event); + return maybePrevent(event); }); $('#rp_eventtype').bind('input', function (event) { $('#rp_enableeventtype').prop('checked',true); - return maybePreventDefault(event); + return maybePrevent(event); }); // fill careportal events @@ -429,7 +429,7 @@ daystoshow = {}; datefilter(); - return maybePreventDefault(event); + return maybePrevent(event); } function showreports(options) { @@ -458,7 +458,7 @@ function setDataRange(event,days) { $('#rp_to').val(moment().format('YYYY-MM-DD')); $('#rp_from').val(moment().add(-days+1, 'days').format('YYYY-MM-DD')); - return maybePreventDefault(event); + return maybePrevent(event); } function switchreport_handler(event) { @@ -469,7 +469,7 @@ $('.tabplaceholder').css('display','none'); $('#'+id+'-placeholder').css('display',''); - return maybePreventDefault(event); + return maybePrevent(event); } function loadData(day, options, callback) { @@ -623,7 +623,7 @@ callback(); } - function maybePreventDefault(event) { + function maybePrevent(event) { if (event) { event.preventDefault(); } From 84259d9746ddb435d3e5292b63cda8883095086e Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 4 Sep 2015 12:08:43 +0200 Subject: [PATCH 046/176] even more treatments.js refactoring --- lib/report_plugins/treatments.js | 48 ++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/lib/report_plugins/treatments.js b/lib/report_plugins/treatments.js index 9eb50a1864f..b07a2eac804 100644 --- a/lib/report_plugins/treatments.js +++ b/lib/report_plugins/treatments.js @@ -229,29 +229,41 @@ treatments.report = function report_treatments(datastorage, daystoshow, options) var icon_remove = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACrElEQVQ4T42Ty2sTQRzHv5tmk2yyjRNtpfZhL8V6s2KoUNC2XqwgaCsVQcGiFqpHi0c9iRdR/ANE9KR40FIQX4cueKoPaKFoLdSYNtE0abKT1+5s9iW7aUMiHtzTzO7v85md+c6PA4DrHbsPCKIgOWO1pA7dT6YXnXH949SE/F63pqwZtRrO+SCKgjQ5NUV+azpmHj2krMwaJC4c8Erj+/eRyloMMwWFKgbn1nC3ervlK1evkXBLGBZT8SOewotnTylTNLdgeg/pDgZDC2cPHSR8bB22DVC9hFe0SG/H0xFXcHlykjRHRDBWgJcZSCY38Xx2lhqMnRYE34Px/sN9vlQWeoHBAx2yXsRruVAVuFsIBaSJ8+eJGPaBqQV4NROJjTzez89jLBoFn6FgybQL54wS3uTyVDFQ3cL2IYpBv3RhdJSIIQ80tQyv7gEqJvS8AmUlBs7UXPhtjtZgh3UFNYngk86NHCfNAg9dMwHVBPu+CpsVkTXKeJeVG+AGgTOZ3tt6MSKKjy+NjEBjFrR4ElZmA4pdxstMFsyyJu6tZZ7Ux9vwB6EAL50ZGiRECEPPUOixVTRxHlicgSVWxEdZpuZWfNuS2hk48NjwMIkIYZglBnV5Cbqtws/5IaAJmsfCglrEl2y2QeKmEBJ80tixKmxrFpSVr0gV0viQoxho2YUuPohmeFD22PiklLC4ma5JuBvdrfLJI0dJd0s7bM0ES8aR/BXDXGaTskqlL+D3Lwy0tZEePoAd4EA5YF4tYymdonfjmQh3s6dTPjU4SHYGwjAKecSXFyGlM1TdytntE56T+ts7SC/vhw3gm6njc2Kd3vm5Ub1IwQAvnYhGiZpYw1wiWYPrIw7wnBTt7CLOOwdmut14kQQvqt24tfK/utGR6LaF+iRqMf4N/O/8D28HiiCRYqzAAAAAAElFTkSuQmCC'; var icon_edit = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABEUlEQVQ4jZ3MMUsCYQDG8ee8IySQbNCLyyEKG/RLNAXicqvQcAeNLrcFLlE0+xHuNpt8wy04rrYm8Q4HQRE56BSC3lSqU1BwCoxM39dnffj9BWyxXvVeEzvtctBwHyRebNu2Nk2lzMlrgJB+qBEeTByiKYpihl+fIO8jTI9PDJEVF1+K2iw+M6PhDuyag4NkQi/c3FkCK5Z3ZbM76qLltpCbn+vXxq0FABsDy9hzPdBvqvtXvvXzrw1swmsDLPjfACteGeDBfwK8+FdgGwwAIgC0ncsjxGRSH/eiPBgAJADY2z8sJ4JBfNBsDqlADVYMANIzKalv/bHaefKsTH9iPFb8ISsGAJym0+Qinz3jQktbAHcxvx3559eSAAAAAElFTkSuQmCC'; - var table = ''; - table += ''; + var table = $('
    '+translate('Time')+''+translate('Event Type')+''+translate('Blood Glucose')+''+translate('Insulin')+''+translate('Carbs')+''+translate('Entered By')+''+translate('Notes')+'
    '); + table.append($('').css('background','gray') + .append($(''; + table.append($('') + .append($(''; - table += ''; - table += ''; - table += ''; - table += ''; - table += ''; - table += ''; - table += ''; - - table += ''; + table.append($('').addClass('border_bottom') + .append($('').should.be.greaterThan(-1); //dailystats result.indexOf('td class="tdborder" style="background-color:#8f8">Normal: ').should.be.greaterThan(-1); // distribution result.indexOf('').should.be.greaterThan(-1); // hourlystats - result.indexOf('
    ').should.be.greaterThan(-1); //success + result.indexOf('
    ').should.be.greaterThan(-1); //success result.indexOf('CAL: Scale: 1.10 Intercept: 31102 Slope: 776.91').should.be.greaterThan(-1); //calibrations result.indexOf('
    ').should.be.greaterThan(-1); //treatments From 8b1b17eba0bfc39ed868e7ad6a61745fe23925be Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Wed, 9 Sep 2015 20:40:54 +0200 Subject: [PATCH 126/176] try more clicking around --- tests/reports.test.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/reports.test.js b/tests/reports.test.js index 2af431fc5b9..234f4a5b3c4 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -26,7 +26,8 @@ var someData = { '/api/v1/treatments.json?find[created_at][$gte]=2015-08-13T00:00:00.000Z&find[created_at][$lt]=2015-08-14T00:00:00.000Z': [{"enteredBy":"Mom ","eventType":"Correction Bolus","glucose":250,"glucoseType":"Sensor","insulin":0.75,"units":"mg/dl","created_at":"2015-08-13T23:45:56.927Z","_id":"55cd2c3497fa97ac5d8bc53b"},{"enteredBy":"Mom ","eventType":"Correction Bolus","glucose":198,"glucoseType":"Sensor","insulin":1.1,"units":"mg/dl","created_at":"2015-08-13T23:11:00.293Z","_id":"55cd240497fa97ac5d8bc535"}], '/api/v1/entries.json?find[date][$gte]=1439510400000&find[date][$lt]=1439596800000&count=10000': [{"_id":"55ce80e338a8d88ad1b49397","unfiltered":179936,"filtered":202080,"direction":"SingleDown","device":"dexcom","rssi":179,"sgv":182,"dateString":"Fri Aug 14 16:58:20 PDT 2015","type":"sgv","date":1439596700000,"noise":1},{"_id":"55ce7fb738a8d88ad1b4938d","unfiltered":192288,"filtered":213792,"direction":"SingleDown","device":"dexcom","rssi":180,"sgv":197,"dateString":"Fri Aug 14 16:53:20 PDT 2015","type":"sgv","date":1439596400000,"noise":1}], '/api/v1/treatments.json?find[created_at][$gte]=2015-08-14T00:00:00.000Z&find[created_at][$lt]=2015-08-15T00:00:00.000Z': [{"enteredBy":"Dad","eventType":"Site Change","glucose":268,"glucoseType":"Finger","insulin":1.75,"units":"mg/dl","created_at":"2015-08-14T23:25:50.718Z","_id":"55ce78fe925aa80e7071e5d6"},{"enteredBy":"Mom ","eventType":"Meal Bolus","glucose":89,"glucoseType":"Finger","carbs":54,"insulin":3.15,"units":"mg/dl","created_at":"2015-08-14T21:00:00.000Z","_id":"55ce59bb925aa80e7071e5ba"}], - '/api/v1/entries.json?find[date][$gte]=1439596800000&find[date][$lt]=1439683200000&count=10000': [{"_id":"55cfd25f38a8d88ad1b49931","unfiltered":283136,"filtered":304768,"direction":"SingleDown","device":"dexcom","rssi":185,"sgv":306,"dateString":"Sat Aug 15 16:58:16 PDT 2015","type":"sgv","date":1439683096000,"noise":1},{"_id":"55cfd13338a8d88ad1b4992e","unfiltered":302528,"filtered":312576,"direction":"FortyFiveDown","device":"dexcom","rssi":179,"sgv":329,"dateString":"Sat Aug 15 16:53:16 PDT 2015","type":"sgv","date":1439682796000,"noise":1}] + '/api/v1/entries.json?find[date][$gte]=1439596800000&find[date][$lt]=1439683200000&count=10000': [{"_id":"55cfd25f38a8d88ad1b49931","unfiltered":283136,"filtered":304768,"direction":"SingleDown","device":"dexcom","rssi":185,"sgv":306,"dateString":"Sat Aug 15 16:58:16 PDT 2015","type":"sgv","date":1439683096000,"noise":1},{"_id":"55cfd13338a8d88ad1b4992e","unfiltered":302528,"filtered":312576,"direction":"FortyFiveDown","device":"dexcom","rssi":179,"sgv":329,"dateString":"Sat Aug 15 16:53:16 PDT 2015","type":"sgv","date":1439682796000,"noise":1}], + '/api/v1/food/regular.json': [{"_id":"552ece84a6947ea011db35bb","type":"food","category":"Zakladni","subcategory":"Sladkosti","name":"Bebe male","portion":18,"carbs":12,"gi":1,"unit":"pcs","created_at":"2015-04-15T20:48:04.966Z"}] }; var exampleProfile = [ @@ -144,6 +145,7 @@ describe('reports', function ( ) { benv.require(__dirname + '/../bundle/bundle.source.js'); benv.require(__dirname + '/../static/report/js/report.js'); benv.require(__dirname + '/../static/report/js/time.js'); + benv.require(__dirname + '/../bower_components/jQuery-Storage-API/jquery.storageapi.min.js'); done(); }); @@ -172,16 +174,23 @@ describe('reports', function ( ) { // Load profile, we need to operate in UTC client.sbx.data.profile.loadData(exampleProfile); + $('a.presetdates :first').click(); + $('#rp_notes').val('something'); + $('#rp_eventtype').val('BG Check'); $('#rp_from').val('2015/08/08'); $('#rp_to').val('2015/09/07'); $('#rp_optionsraw').prop('checked',true); $('#rp_optionsiob').prop('checked',true); $('#rp_optionscob').prop('checked',true); + $('#rp_enableeventtype').click(); + $('#rp_enablenotes').click(); + $('#rp_enablefood').click(); $('#rp_log').prop('checked',true); $('#rp_show').click(); $('#rp_linear').prop('checked',true); $('#rp_show').click(); + $('#dailystats').click(); var result = $('body').html(); //var filesys = require('fs'); From fa01ecb8af192e996466abccf4817ccd3e01bb5c Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Wed, 9 Sep 2015 20:50:38 +0200 Subject: [PATCH 127/176] wrong file to include --- tests/reports.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/reports.test.js b/tests/reports.test.js index 234f4a5b3c4..982cfb553df 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -145,7 +145,7 @@ describe('reports', function ( ) { benv.require(__dirname + '/../bundle/bundle.source.js'); benv.require(__dirname + '/../static/report/js/report.js'); benv.require(__dirname + '/../static/report/js/time.js'); - benv.require(__dirname + '/../bower_components/jQuery-Storage-API/jquery.storageapi.min.js'); + benv.require(__dirname + '/../static/bower_components/jquery-ui/jquery-ui.min.js'); done(); }); From 233a70bf89e69dc207ca7e936293b99927874a0c Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Wed, 9 Sep 2015 21:12:34 +0200 Subject: [PATCH 128/176] just refresh travis --- tests/reports.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/reports.test.js b/tests/reports.test.js index 982cfb553df..729ca006b5f 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -145,7 +145,7 @@ describe('reports', function ( ) { benv.require(__dirname + '/../bundle/bundle.source.js'); benv.require(__dirname + '/../static/report/js/report.js'); benv.require(__dirname + '/../static/report/js/time.js'); - benv.require(__dirname + '/../static/bower_components/jquery-ui/jquery-ui.min.js'); + benv.require(__dirname + '/../static/bower_components/jquery-ui/jquery-ui.min.js'); done(); }); From 853a306dc60f73c3318bfd4e8e6beee72b77ff05 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 11 Sep 2015 08:57:26 +0200 Subject: [PATCH 129/176] more clicking in test --- static/report/js/report.js | 4 +- tests/reports.test.js | 77 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 75 insertions(+), 6 deletions(-) diff --git a/static/report/js/report.js b/static/report/js/report.js index 76a8f026555..4dfdd109e60 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -95,7 +95,7 @@ } $('#rp_food').empty(); for (var i=0; i' + o + ''); } return maybePrevent(event); diff --git a/tests/reports.test.js b/tests/reports.test.js index 729ca006b5f..ac8d5d6b1a1 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -27,7 +27,73 @@ var someData = { '/api/v1/entries.json?find[date][$gte]=1439510400000&find[date][$lt]=1439596800000&count=10000': [{"_id":"55ce80e338a8d88ad1b49397","unfiltered":179936,"filtered":202080,"direction":"SingleDown","device":"dexcom","rssi":179,"sgv":182,"dateString":"Fri Aug 14 16:58:20 PDT 2015","type":"sgv","date":1439596700000,"noise":1},{"_id":"55ce7fb738a8d88ad1b4938d","unfiltered":192288,"filtered":213792,"direction":"SingleDown","device":"dexcom","rssi":180,"sgv":197,"dateString":"Fri Aug 14 16:53:20 PDT 2015","type":"sgv","date":1439596400000,"noise":1}], '/api/v1/treatments.json?find[created_at][$gte]=2015-08-14T00:00:00.000Z&find[created_at][$lt]=2015-08-15T00:00:00.000Z': [{"enteredBy":"Dad","eventType":"Site Change","glucose":268,"glucoseType":"Finger","insulin":1.75,"units":"mg/dl","created_at":"2015-08-14T23:25:50.718Z","_id":"55ce78fe925aa80e7071e5d6"},{"enteredBy":"Mom ","eventType":"Meal Bolus","glucose":89,"glucoseType":"Finger","carbs":54,"insulin":3.15,"units":"mg/dl","created_at":"2015-08-14T21:00:00.000Z","_id":"55ce59bb925aa80e7071e5ba"}], '/api/v1/entries.json?find[date][$gte]=1439596800000&find[date][$lt]=1439683200000&count=10000': [{"_id":"55cfd25f38a8d88ad1b49931","unfiltered":283136,"filtered":304768,"direction":"SingleDown","device":"dexcom","rssi":185,"sgv":306,"dateString":"Sat Aug 15 16:58:16 PDT 2015","type":"sgv","date":1439683096000,"noise":1},{"_id":"55cfd13338a8d88ad1b4992e","unfiltered":302528,"filtered":312576,"direction":"FortyFiveDown","device":"dexcom","rssi":179,"sgv":329,"dateString":"Sat Aug 15 16:53:16 PDT 2015","type":"sgv","date":1439682796000,"noise":1}], - '/api/v1/food/regular.json': [{"_id":"552ece84a6947ea011db35bb","type":"food","category":"Zakladni","subcategory":"Sladkosti","name":"Bebe male","portion":18,"carbs":12,"gi":1,"unit":"pcs","created_at":"2015-04-15T20:48:04.966Z"}] + '/api/v1/food/regular.json': [{"_id":"552ece84a6947ea011db35bb","type":"food","category":"Zakladni","subcategory":"Sladkosti","name":"Bebe male","portion":18,"carbs":12,"gi":1,"unit":"pcs","created_at":"2015-04-15T20:48:04.966Z"}], + '/api/v1/treatments.json?find[eventType]=/BG Check/i&find[created_at][$gte]=2015-08-07T22:00:00.000Z&find[created_at][$lt]=2015-09-06T22:00:00.000Z': [ + {"created_at":"2015-08-07T23:25:50.718Z"}, + {"created_at":"2015-08-08T23:25:50.718Z"}, + {"created_at":"2015-08-09T23:25:50.718Z"}, + {"created_at":"2015-08-10T23:25:50.718Z"}, + {"created_at":"2015-08-11T23:25:50.718Z"}, + {"created_at":"2015-08-12T23:25:50.718Z"}, + {"created_at":"2015-08-13T23:25:50.718Z"}, + {"created_at":"2015-08-14T23:25:50.718Z"}, + {"created_at":"2015-08-15T23:25:50.718Z"}, + {"created_at":"2015-08-16T23:25:50.718Z"}, + {"created_at":"2015-08-17T23:25:50.718Z"}, + {"created_at":"2015-08-18T23:25:50.718Z"}, + {"created_at":"2015-08-19T23:25:50.718Z"}, + {"created_at":"2015-08-20T23:25:50.718Z"}, + {"created_at":"2015-08-21T23:25:50.718Z"}, + {"created_at":"2015-08-22T23:25:50.718Z"}, + {"created_at":"2015-08-23T23:25:50.718Z"}, + {"created_at":"2015-08-24T23:25:50.718Z"}, + {"created_at":"2015-08-25T23:25:50.718Z"}, + {"created_at":"2015-08-26T23:25:50.718Z"}, + {"created_at":"2015-08-27T23:25:50.718Z"}, + {"created_at":"2015-08-28T23:25:50.718Z"}, + {"created_at":"2015-08-29T23:25:50.718Z"}, + {"created_at":"2015-08-30T23:25:50.718Z"}, + {"created_at":"2015-08-31T23:25:50.718Z"}, + {"created_at":"2015-09-01T23:25:50.718Z"}, + {"created_at":"2015-09-02T23:25:50.718Z"}, + {"created_at":"2015-09-03T23:25:50.718Z"}, + {"created_at":"2015-09-04T23:25:50.718Z"}, + {"created_at":"2015-09-05T23:25:50.718Z"}, + {"created_at":"2015-09-06T23:25:50.718Z"} + ], + '/api/v1/treatments.json?find[notes]=/something/i&find[created_at][$gte]=2015-08-07T22:00:00.000Z&find[created_at][$lt]=2015-09-06T22:00:00.000Z': [ + {"created_at":"2015-08-07T23:25:50.718Z"}, + {"created_at":"2015-08-08T23:25:50.718Z"}, + {"created_at":"2015-08-09T23:25:50.718Z"}, + {"created_at":"2015-08-10T23:25:50.718Z"}, + {"created_at":"2015-08-11T23:25:50.718Z"}, + {"created_at":"2015-08-12T23:25:50.718Z"}, + {"created_at":"2015-08-13T23:25:50.718Z"}, + {"created_at":"2015-08-14T23:25:50.718Z"}, + {"created_at":"2015-08-15T23:25:50.718Z"}, + {"created_at":"2015-08-16T23:25:50.718Z"}, + {"created_at":"2015-08-17T23:25:50.718Z"}, + {"created_at":"2015-08-18T23:25:50.718Z"}, + {"created_at":"2015-08-19T23:25:50.718Z"}, + {"created_at":"2015-08-20T23:25:50.718Z"}, + {"created_at":"2015-08-21T23:25:50.718Z"}, + {"created_at":"2015-08-22T23:25:50.718Z"}, + {"created_at":"2015-08-23T23:25:50.718Z"}, + {"created_at":"2015-08-24T23:25:50.718Z"}, + {"created_at":"2015-08-25T23:25:50.718Z"}, + {"created_at":"2015-08-26T23:25:50.718Z"}, + {"created_at":"2015-08-27T23:25:50.718Z"}, + {"created_at":"2015-08-28T23:25:50.718Z"}, + {"created_at":"2015-08-29T23:25:50.718Z"}, + {"created_at":"2015-08-30T23:25:50.718Z"}, + {"created_at":"2015-08-31T23:25:50.718Z"}, + {"created_at":"2015-09-01T23:25:50.718Z"}, + {"created_at":"2015-09-02T23:25:50.718Z"}, + {"created_at":"2015-09-03T23:25:50.718Z"}, + {"created_at":"2015-09-04T23:25:50.718Z"}, + {"created_at":"2015-09-05T23:25:50.718Z"}, + {"created_at":"2015-09-06T23:25:50.718Z"} + ] }; var exampleProfile = [ @@ -114,9 +180,11 @@ describe('reports', function ( ) { opts.success([]); } fn(); - return { - fail: function () {} - }; + return self.$.ajax(); + }, + fail: function mockFail (fn) { + fn(); + return self.$.ajax(); } }; }; @@ -185,6 +253,7 @@ describe('reports', function ( ) { $('#rp_enableeventtype').click(); $('#rp_enablenotes').click(); $('#rp_enablefood').click(); + $('#rp_enablefood').click(); $('#rp_log').prop('checked',true); $('#rp_show').click(); From 536ab649cc25754fce7fa40efd5ebb7585f9d1ce Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 11 Sep 2015 09:04:20 +0200 Subject: [PATCH 130/176] doublequotes --- tests/reports.test.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/reports.test.js b/tests/reports.test.js index ac8d5d6b1a1..35d08f8df20 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -12,22 +12,22 @@ var nowData = { }; var someData = { - '/api/v1/entries.json?find[date][$gte]=1438992000000&find[date][$lt]=1439078400000&count=10000': [{"_id":"55c697f9459cf1fa5ed71cd8","unfiltered":213888,"filtered":218560,"direction":"Flat","device":"dexcom","rssi":172,"sgv":208,"dateString":"Sat Aug 08 16:58:44 PDT 2015","type":"sgv","date":1439078324000,"noise":1},{"_id":"55c696cc459cf1fa5ed71cd7","unfiltered":217952,"filtered":220864,"direction":"Flat","device":"dexcom","rssi":430,"sgv":212,"dateString":"Sat Aug 08 16:53:45 PDT 2015","type":"sgv","date":1439078025000,"noise":1},{"_id":"55c5d0c6459cf1fa5ed71a04","device":"dexcom","scale":1.1,"dateString":"Sat Aug 08 02:48:05 PDT 2015","date":1439027285000,"type":"cal","intercept":31102.323470336833,"slope":776.9097574914869},{"_id":"55c5d0c5459cf1fa5ed71a03","device":"dexcom","dateString":"Sat Aug 08 02:48:03 PDT 2015","mbg":120,"date":1439027283000,"type":"mbg"}], - '/api/v1/treatments.json?find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-08-09T00:00:00.000Z': [{"enteredBy":"Dad","eventType":"Correction Bolus","glucose":201,"glucoseType":"Finger","insulin":0.65,"units":"mg/dl","created_at":"2015-08-08T23:22:00.000Z","_id":"55c695628a00a3c97a6611ed"},{"enteredBy":"Mom ","eventType":"Correction Bolus","glucose":163,"glucoseType":"Sensor","insulin":0.7,"units":"mg/dl","created_at":"2015-08-08T22:53:11.021Z","_id":"55c68857cd6dd2036036705f"}], - '/api/v1/entries.json?find[date][$gte]=1439078400000&find[date][$lt]=1439164800000&count=10000': [{"_id":"55c7e85f459cf1fa5ed71dc8","unfiltered":183520,"filtered":193120,"direction":"NOT COMPUTABLE","device":"dexcom","rssi":161,"sgv":149,"dateString":"Sun Aug 09 16:53:40 PDT 2015","type":"sgv","date":1439164420000,"noise":1},{"_id":"55c7e270459cf1fa5ed71dc7","unfiltered":199328,"filtered":192608,"direction":"Flat","device":"dexcom","rssi":161,"sgv":166,"dateString":"Sun Aug 09 16:28:40 PDT 2015","type":"sgv","date":1439162920000,"noise":1}], - '/api/v1/treatments.json?find[created_at][$gte]=2015-08-09T00:00:00.000Z&find[created_at][$lt]=2015-08-10T00:00:00.000Z': [{"enteredBy":"Dad","eventType":"Snack Bolus","carbs":18,"insulin":1.1,"created_at":"2015-08-09T22:41:56.253Z","_id":"55c7d734270fbd97191013c2"},{"enteredBy":"Dad","eventType":"Carb Correction","carbs":5,"created_at":"2015-08-09T21:39:13.995Z","_id":"55c7c881270fbd97191013b4"}], - '/api/v1/entries.json?find[date][$gte]=1439164800000&find[date][$lt]=1439251200000&count=10000': [{"_id":"55c93af4459cf1fa5ed71ecc","unfiltered":193248,"filtered":188384,"direction":"NOT COMPUTABLE","device":"dexcom","rssi":194,"sgv":193,"dateString":"Mon Aug 10 16:58:36 PDT 2015","type":"sgv","date":1439251116000,"noise":1},{"_id":"55c939d8459cf1fa5ed71ecb","unfiltered":189888,"filtered":184960,"direction":"NOT COMPUTABLE","device":"dexcom","rssi":931,"sgv":188,"dateString":"Mon Aug 10 16:53:38 PDT 2015","type":"sgv","date":1439250818000,"noise":1}], - '/api/v1/treatments.json?find[created_at][$gte]=2015-08-10T00:00:00.000Z&find[created_at][$lt]=2015-08-11T00:00:00.000Z': [{"enteredBy":"Mom ","eventType":"Snack Bolus","glucose":180,"glucoseType":"Sensor","carbs":18,"insulin":1.9,"units":"mg/dl","created_at":"2015-08-10T23:53:31.970Z","_id":"55c9397b865550df020e3560"},{"enteredBy":"Mom ","eventType":"Meal Bolus","glucose":140,"glucoseType":"Finger","carbs":50,"insulin":3.4,"units":"mg/dl","created_at":"2015-08-10T20:41:23.516Z","_id":"55c90c73865550df020e3539"}], - '/api/v1/entries.json?find[date][$gte]=1439251200000&find[date][$lt]=1439337600000&count=10000': [{"_id":"55ca8c6e459cf1fa5ed71fe2","unfiltered":174080,"filtered":184576,"direction":"FortyFiveDown","device":"dexcom","rssi":169,"sgv":156,"dateString":"Tue Aug 11 16:58:32 PDT 2015","type":"sgv","date":1439337512000,"noise":1},{"_id":"55ca8b42459cf1fa5ed71fe1","unfiltered":180192,"filtered":192768,"direction":"FortyFiveDown","device":"dexcom","rssi":182,"sgv":163,"dateString":"Tue Aug 11 16:53:32 PDT 2015","type":"sgv","date":1439337212000,"noise":1}], - '/api/v1/treatments.json?find[created_at][$gte]=2015-08-11T00:00:00.000Z&find[created_at][$lt]=2015-08-12T00:00:00.000Z': [{"created_at":"2015-08-11T23:37:00.000Z","eventType":"Snack Bolus","carbs":18,"_id":"55ca8644ca3c57683d19c211"},{"enteredBy":"Mom ","eventType":"Snack Bolus","glucose":203,"glucoseType":"Sensor","insulin":1,"preBolus":15,"units":"mg/dl","created_at":"2015-08-11T23:22:00.000Z","_id":"55ca8644ca3c57683d19c210"}], - '/api/v1/entries.json?find[date][$gte]=1439337600000&find[date][$lt]=1439424000000&count=10000': [{"_id":"55cbddee38a8d88ad1b48647","unfiltered":165760,"filtered":167488,"direction":"Flat","device":"dexcom","rssi":165,"sgv":157,"dateString":"Wed Aug 12 16:58:28 PDT 2015","type":"sgv","date":1439423908000,"noise":1},{"_id":"55cbdccc38a8d88ad1b48644","unfiltered":167456,"filtered":169312,"direction":"Flat","device":"dexcom","rssi":168,"sgv":159,"dateString":"Wed Aug 12 16:53:28 PDT 2015","type":"sgv","date":1439423608000,"noise":1}], - '/api/v1/treatments.json?find[created_at][$gte]=2015-08-12T00:00:00.000Z&find[created_at][$lt]=2015-08-13T00:00:00.000Z': [{"enteredBy":"Dad","eventType":"Correction Bolus","insulin":0.8,"created_at":"2015-08-12T23:21:08.907Z","_id":"55cbd4e47e726599048a3f91"},{"enteredBy":"Dad","eventType":"Note","notes":"Milk now","created_at":"2015-08-12T21:23:00.000Z","_id":"55cbba4e7e726599048a3f79"}], - '/api/v1/entries.json?find[date][$gte]=1439424000000&find[date][$lt]=1439510400000&count=10000': [{"_id":"55cd2f6738a8d88ad1b48ca1","unfiltered":209792,"filtered":229344,"direction":"SingleDown","device":"dexcom","rssi":436,"sgv":205,"dateString":"Thu Aug 13 16:58:24 PDT 2015","type":"sgv","date":1439510304000,"noise":1},{"_id":"55cd2e3b38a8d88ad1b48c95","unfiltered":220928,"filtered":237472,"direction":"FortyFiveDown","device":"dexcom","rssi":418,"sgv":219,"dateString":"Thu Aug 13 16:53:24 PDT 2015","type":"sgv","date":1439510004000,"noise":1}], - '/api/v1/treatments.json?find[created_at][$gte]=2015-08-13T00:00:00.000Z&find[created_at][$lt]=2015-08-14T00:00:00.000Z': [{"enteredBy":"Mom ","eventType":"Correction Bolus","glucose":250,"glucoseType":"Sensor","insulin":0.75,"units":"mg/dl","created_at":"2015-08-13T23:45:56.927Z","_id":"55cd2c3497fa97ac5d8bc53b"},{"enteredBy":"Mom ","eventType":"Correction Bolus","glucose":198,"glucoseType":"Sensor","insulin":1.1,"units":"mg/dl","created_at":"2015-08-13T23:11:00.293Z","_id":"55cd240497fa97ac5d8bc535"}], - '/api/v1/entries.json?find[date][$gte]=1439510400000&find[date][$lt]=1439596800000&count=10000': [{"_id":"55ce80e338a8d88ad1b49397","unfiltered":179936,"filtered":202080,"direction":"SingleDown","device":"dexcom","rssi":179,"sgv":182,"dateString":"Fri Aug 14 16:58:20 PDT 2015","type":"sgv","date":1439596700000,"noise":1},{"_id":"55ce7fb738a8d88ad1b4938d","unfiltered":192288,"filtered":213792,"direction":"SingleDown","device":"dexcom","rssi":180,"sgv":197,"dateString":"Fri Aug 14 16:53:20 PDT 2015","type":"sgv","date":1439596400000,"noise":1}], - '/api/v1/treatments.json?find[created_at][$gte]=2015-08-14T00:00:00.000Z&find[created_at][$lt]=2015-08-15T00:00:00.000Z': [{"enteredBy":"Dad","eventType":"Site Change","glucose":268,"glucoseType":"Finger","insulin":1.75,"units":"mg/dl","created_at":"2015-08-14T23:25:50.718Z","_id":"55ce78fe925aa80e7071e5d6"},{"enteredBy":"Mom ","eventType":"Meal Bolus","glucose":89,"glucoseType":"Finger","carbs":54,"insulin":3.15,"units":"mg/dl","created_at":"2015-08-14T21:00:00.000Z","_id":"55ce59bb925aa80e7071e5ba"}], - '/api/v1/entries.json?find[date][$gte]=1439596800000&find[date][$lt]=1439683200000&count=10000': [{"_id":"55cfd25f38a8d88ad1b49931","unfiltered":283136,"filtered":304768,"direction":"SingleDown","device":"dexcom","rssi":185,"sgv":306,"dateString":"Sat Aug 15 16:58:16 PDT 2015","type":"sgv","date":1439683096000,"noise":1},{"_id":"55cfd13338a8d88ad1b4992e","unfiltered":302528,"filtered":312576,"direction":"FortyFiveDown","device":"dexcom","rssi":179,"sgv":329,"dateString":"Sat Aug 15 16:53:16 PDT 2015","type":"sgv","date":1439682796000,"noise":1}], - '/api/v1/food/regular.json': [{"_id":"552ece84a6947ea011db35bb","type":"food","category":"Zakladni","subcategory":"Sladkosti","name":"Bebe male","portion":18,"carbs":12,"gi":1,"unit":"pcs","created_at":"2015-04-15T20:48:04.966Z"}], + '/api/v1/entries.json?find[date][$gte]=1438992000000&find[date][$lt]=1439078400000&count=10000': [{'_id':'55c697f9459cf1fa5ed71cd8','unfiltered':213888,'filtered':218560,'direction':'Flat','device':'dexcom','rssi':172,'sgv':208,'dateString':'Sat Aug 08 16:58:44 PDT 2015','type':'sgv','date':1439078324000,'noise':1},{'_id':'55c696cc459cf1fa5ed71cd7','unfiltered':217952,'filtered':220864,'direction':'Flat','device':'dexcom','rssi':430,'sgv':212,'dateString':'Sat Aug 08 16:53:45 PDT 2015','type':'sgv','date':1439078025000,'noise':1},{'_id':'55c5d0c6459cf1fa5ed71a04','device':'dexcom','scale':1.1,'dateString':'Sat Aug 08 02:48:05 PDT 2015','date':1439027285000,'type':'cal','intercept':31102.323470336833,'slope':776.9097574914869},{'_id':'55c5d0c5459cf1fa5ed71a03','device':'dexcom','dateString':'Sat Aug 08 02:48:03 PDT 2015','mbg':120,'date':1439027283000,'type':'mbg'}], + '/api/v1/treatments.json?find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-08-09T00:00:00.000Z': [{'enteredBy':'Dad','eventType':'Correction Bolus','glucose':201,'glucoseType':'Finger','insulin':0.65,'units':'mg/dl','created_at':'2015-08-08T23:22:00.000Z','_id':'55c695628a00a3c97a6611ed'},{'enteredBy':'Mom ','eventType':'Correction Bolus','glucose':163,'glucoseType':'Sensor','insulin':0.7,'units':'mg/dl','created_at':'2015-08-08T22:53:11.021Z','_id':'55c68857cd6dd2036036705f'}], + '/api/v1/entries.json?find[date][$gte]=1439078400000&find[date][$lt]=1439164800000&count=10000': [{'_id':'55c7e85f459cf1fa5ed71dc8','unfiltered':183520,'filtered':193120,'direction':'NOT COMPUTABLE','device':'dexcom','rssi':161,'sgv':149,'dateString':'Sun Aug 09 16:53:40 PDT 2015','type':'sgv','date':1439164420000,'noise':1},{'_id':'55c7e270459cf1fa5ed71dc7','unfiltered':199328,'filtered':192608,'direction':'Flat','device':'dexcom','rssi':161,'sgv':166,'dateString':'Sun Aug 09 16:28:40 PDT 2015','type':'sgv','date':1439162920000,'noise':1}], + '/api/v1/treatments.json?find[created_at][$gte]=2015-08-09T00:00:00.000Z&find[created_at][$lt]=2015-08-10T00:00:00.000Z': [{'enteredBy':'Dad','eventType':'Snack Bolus','carbs':18,'insulin':1.1,'created_at':'2015-08-09T22:41:56.253Z','_id':'55c7d734270fbd97191013c2'},{'enteredBy':'Dad','eventType':'Carb Correction','carbs':5,'created_at':'2015-08-09T21:39:13.995Z','_id':'55c7c881270fbd97191013b4'}], + '/api/v1/entries.json?find[date][$gte]=1439164800000&find[date][$lt]=1439251200000&count=10000': [{'_id':'55c93af4459cf1fa5ed71ecc','unfiltered':193248,'filtered':188384,'direction':'NOT COMPUTABLE','device':'dexcom','rssi':194,'sgv':193,'dateString':'Mon Aug 10 16:58:36 PDT 2015','type':'sgv','date':1439251116000,'noise':1},{'_id':'55c939d8459cf1fa5ed71ecb','unfiltered':189888,'filtered':184960,'direction':'NOT COMPUTABLE','device':'dexcom','rssi':931,'sgv':188,'dateString':'Mon Aug 10 16:53:38 PDT 2015','type':'sgv','date':1439250818000,'noise':1}], + '/api/v1/treatments.json?find[created_at][$gte]=2015-08-10T00:00:00.000Z&find[created_at][$lt]=2015-08-11T00:00:00.000Z': [{'enteredBy':'Mom ','eventType':'Snack Bolus','glucose':180,'glucoseType':'Sensor','carbs':18,'insulin':1.9,'units':'mg/dl','created_at':'2015-08-10T23:53:31.970Z','_id':'55c9397b865550df020e3560'},{'enteredBy':'Mom ','eventType':'Meal Bolus','glucose':140,'glucoseType':'Finger','carbs':50,'insulin':3.4,'units':'mg/dl','created_at':'2015-08-10T20:41:23.516Z','_id':'55c90c73865550df020e3539'}], + '/api/v1/entries.json?find[date][$gte]=1439251200000&find[date][$lt]=1439337600000&count=10000': [{'_id':'55ca8c6e459cf1fa5ed71fe2','unfiltered':174080,'filtered':184576,'direction':'FortyFiveDown','device':'dexcom','rssi':169,'sgv':156,'dateString':'Tue Aug 11 16:58:32 PDT 2015','type':'sgv','date':1439337512000,'noise':1},{'_id':'55ca8b42459cf1fa5ed71fe1','unfiltered':180192,'filtered':192768,'direction':'FortyFiveDown','device':'dexcom','rssi':182,'sgv':163,'dateString':'Tue Aug 11 16:53:32 PDT 2015','type':'sgv','date':1439337212000,'noise':1}], + '/api/v1/treatments.json?find[created_at][$gte]=2015-08-11T00:00:00.000Z&find[created_at][$lt]=2015-08-12T00:00:00.000Z': [{'created_at':'2015-08-11T23:37:00.000Z','eventType':'Snack Bolus','carbs':18,'_id':'55ca8644ca3c57683d19c211'},{'enteredBy':'Mom ','eventType':'Snack Bolus','glucose':203,'glucoseType':'Sensor','insulin':1,'preBolus':15,'units':'mg/dl','created_at':'2015-08-11T23:22:00.000Z','_id':'55ca8644ca3c57683d19c210'}], + '/api/v1/entries.json?find[date][$gte]=1439337600000&find[date][$lt]=1439424000000&count=10000': [{'_id':'55cbddee38a8d88ad1b48647','unfiltered':165760,'filtered':167488,'direction':'Flat','device':'dexcom','rssi':165,'sgv':157,'dateString':'Wed Aug 12 16:58:28 PDT 2015','type':'sgv','date':1439423908000,'noise':1},{'_id':'55cbdccc38a8d88ad1b48644','unfiltered':167456,'filtered':169312,'direction':'Flat','device':'dexcom','rssi':168,'sgv':159,'dateString':'Wed Aug 12 16:53:28 PDT 2015','type':'sgv','date':1439423608000,'noise':1}], + '/api/v1/treatments.json?find[created_at][$gte]=2015-08-12T00:00:00.000Z&find[created_at][$lt]=2015-08-13T00:00:00.000Z': [{'enteredBy':'Dad','eventType':'Correction Bolus','insulin':0.8,'created_at':'2015-08-12T23:21:08.907Z','_id':'55cbd4e47e726599048a3f91'},{'enteredBy':'Dad','eventType':'Note','notes':'Milk now','created_at':'2015-08-12T21:23:00.000Z','_id':'55cbba4e7e726599048a3f79'}], + '/api/v1/entries.json?find[date][$gte]=1439424000000&find[date][$lt]=1439510400000&count=10000': [{'_id':'55cd2f6738a8d88ad1b48ca1','unfiltered':209792,'filtered':229344,'direction':'SingleDown','device':'dexcom','rssi':436,'sgv':205,'dateString':'Thu Aug 13 16:58:24 PDT 2015','type':'sgv','date':1439510304000,'noise':1},{'_id':'55cd2e3b38a8d88ad1b48c95','unfiltered':220928,'filtered':237472,'direction':'FortyFiveDown','device':'dexcom','rssi':418,'sgv':219,'dateString':'Thu Aug 13 16:53:24 PDT 2015','type':'sgv','date':1439510004000,'noise':1}], + '/api/v1/treatments.json?find[created_at][$gte]=2015-08-13T00:00:00.000Z&find[created_at][$lt]=2015-08-14T00:00:00.000Z': [{'enteredBy':'Mom ','eventType':'Correction Bolus','glucose':250,'glucoseType':'Sensor','insulin':0.75,'units':'mg/dl','created_at':'2015-08-13T23:45:56.927Z','_id':'55cd2c3497fa97ac5d8bc53b'},{'enteredBy':'Mom ','eventType':'Correction Bolus','glucose':198,'glucoseType':'Sensor','insulin':1.1,'units':'mg/dl','created_at':'2015-08-13T23:11:00.293Z','_id':'55cd240497fa97ac5d8bc535'}], + '/api/v1/entries.json?find[date][$gte]=1439510400000&find[date][$lt]=1439596800000&count=10000': [{'_id':'55ce80e338a8d88ad1b49397','unfiltered':179936,'filtered':202080,'direction':'SingleDown','device':'dexcom','rssi':179,'sgv':182,'dateString':'Fri Aug 14 16:58:20 PDT 2015','type':'sgv','date':1439596700000,'noise':1},{'_id':'55ce7fb738a8d88ad1b4938d','unfiltered':192288,'filtered':213792,'direction':'SingleDown','device':'dexcom','rssi':180,'sgv':197,'dateString':'Fri Aug 14 16:53:20 PDT 2015','type':'sgv','date':1439596400000,'noise':1}], + '/api/v1/treatments.json?find[created_at][$gte]=2015-08-14T00:00:00.000Z&find[created_at][$lt]=2015-08-15T00:00:00.000Z': [{'enteredBy':'Dad','eventType':'Site Change','glucose':268,'glucoseType':'Finger','insulin':1.75,'units':'mg/dl','created_at':'2015-08-14T23:25:50.718Z','_id':'55ce78fe925aa80e7071e5d6'},{'enteredBy':'Mom ','eventType':'Meal Bolus','glucose':89,'glucoseType':'Finger','carbs':54,'insulin':3.15,'units':'mg/dl','created_at':'2015-08-14T21:00:00.000Z','_id':'55ce59bb925aa80e7071e5ba'}], + '/api/v1/entries.json?find[date][$gte]=1439596800000&find[date][$lt]=1439683200000&count=10000': [{'_id':'55cfd25f38a8d88ad1b49931','unfiltered':283136,'filtered':304768,'direction':'SingleDown','device':'dexcom','rssi':185,'sgv':306,'dateString':'Sat Aug 15 16:58:16 PDT 2015','type':'sgv','date':1439683096000,'noise':1},{'_id':'55cfd13338a8d88ad1b4992e','unfiltered':302528,'filtered':312576,'direction':'FortyFiveDown','device':'dexcom','rssi':179,'sgv':329,'dateString':'Sat Aug 15 16:53:16 PDT 2015','type':'sgv','date':1439682796000,'noise':1}], + '/api/v1/food/regular.json': [{'_id':'552ece84a6947ea011db35bb','type':'food','category':'Zakladni','subcategory':'Sladkosti','name':'Bebe male','portion':18,'carbs':12,'gi':1,'unit':'pcs','created_at':'2015-04-15T20:48:04.966Z'}], '/api/v1/treatments.json?find[eventType]=/BG Check/i&find[created_at][$gte]=2015-08-07T22:00:00.000Z&find[created_at][$lt]=2015-09-06T22:00:00.000Z': [ {"created_at":"2015-08-07T23:25:50.718Z"}, {"created_at":"2015-08-08T23:25:50.718Z"}, From a1ea94afa08653a4425f0cc2215d9330d48e8a25 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 11 Sep 2015 09:18:40 +0200 Subject: [PATCH 131/176] display html in travis --- tests/reports.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/reports.test.js b/tests/reports.test.js index 35d08f8df20..397116b1730 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -265,6 +265,8 @@ describe('reports', function ( ) { //var filesys = require('fs'); //var logfile = filesys.createWriteStream('out.txt', { flags: 'a'} ) //logfile.write($('body').html()); + + console.log(result); result.indexOf('Milk now').should.be.greaterThan(-1); // daytoday result.indexOf('50 g (1.67U)').should.be.greaterThan(-1); // daytoday From 69e318ab57deb2771bf2b7123bdf416e1c0359da Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 11 Sep 2015 09:31:25 +0200 Subject: [PATCH 132/176] add more log again --- static/report/js/report.js | 2 +- tests/reports.test.js | 126 ++++++++++++++++++------------------- 2 files changed, 64 insertions(+), 64 deletions(-) diff --git a/static/report/js/report.js b/static/report/js/report.js index 4dfdd109e60..d76292bb24b 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -238,7 +238,7 @@ }; // default time range if no time range specified in GUI - var timerange = '&find[created_at][$gte]='+new Date('1970-01-01').toISOString(); + var timerange = '&find[created_at][$gte]='+moment('1970-01-01').toDate().toISOString(); options.targetLow = parseFloat($('#rp_targetlow').val().replace(',','.')); options.targetHigh = parseFloat($('#rp_targethigh').val().replace(',','.')); diff --git a/tests/reports.test.js b/tests/reports.test.js index 397116b1730..899c675094e 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -30,69 +30,69 @@ var someData = { '/api/v1/food/regular.json': [{'_id':'552ece84a6947ea011db35bb','type':'food','category':'Zakladni','subcategory':'Sladkosti','name':'Bebe male','portion':18,'carbs':12,'gi':1,'unit':'pcs','created_at':'2015-04-15T20:48:04.966Z'}], '/api/v1/treatments.json?find[eventType]=/BG Check/i&find[created_at][$gte]=2015-08-07T22:00:00.000Z&find[created_at][$lt]=2015-09-06T22:00:00.000Z': [ {"created_at":"2015-08-07T23:25:50.718Z"}, - {"created_at":"2015-08-08T23:25:50.718Z"}, - {"created_at":"2015-08-09T23:25:50.718Z"}, - {"created_at":"2015-08-10T23:25:50.718Z"}, - {"created_at":"2015-08-11T23:25:50.718Z"}, - {"created_at":"2015-08-12T23:25:50.718Z"}, - {"created_at":"2015-08-13T23:25:50.718Z"}, - {"created_at":"2015-08-14T23:25:50.718Z"}, - {"created_at":"2015-08-15T23:25:50.718Z"}, - {"created_at":"2015-08-16T23:25:50.718Z"}, - {"created_at":"2015-08-17T23:25:50.718Z"}, - {"created_at":"2015-08-18T23:25:50.718Z"}, - {"created_at":"2015-08-19T23:25:50.718Z"}, - {"created_at":"2015-08-20T23:25:50.718Z"}, - {"created_at":"2015-08-21T23:25:50.718Z"}, - {"created_at":"2015-08-22T23:25:50.718Z"}, - {"created_at":"2015-08-23T23:25:50.718Z"}, - {"created_at":"2015-08-24T23:25:50.718Z"}, - {"created_at":"2015-08-25T23:25:50.718Z"}, - {"created_at":"2015-08-26T23:25:50.718Z"}, - {"created_at":"2015-08-27T23:25:50.718Z"}, - {"created_at":"2015-08-28T23:25:50.718Z"}, - {"created_at":"2015-08-29T23:25:50.718Z"}, - {"created_at":"2015-08-30T23:25:50.718Z"}, - {"created_at":"2015-08-31T23:25:50.718Z"}, - {"created_at":"2015-09-01T23:25:50.718Z"}, - {"created_at":"2015-09-02T23:25:50.718Z"}, - {"created_at":"2015-09-03T23:25:50.718Z"}, - {"created_at":"2015-09-04T23:25:50.718Z"}, - {"created_at":"2015-09-05T23:25:50.718Z"}, - {"created_at":"2015-09-06T23:25:50.718Z"} + {'created_at':'2015-08-08T23:25:50.718Z'}, + {'created_at':'2015-08-09T23:25:50.718Z'}, + {'created_at':'2015-08-10T23:25:50.718Z'}, + {'created_at':'2015-08-11T23:25:50.718Z'}, + {'created_at':'2015-08-12T23:25:50.718Z'}, + {'created_at':'2015-08-13T23:25:50.718Z'}, + {'created_at':'2015-08-14T23:25:50.718Z'}, + {'created_at':'2015-08-15T23:25:50.718Z'}, + {'created_at':'2015-08-16T23:25:50.718Z'}, + {'created_at':'2015-08-17T23:25:50.718Z'}, + {'created_at':'2015-08-18T23:25:50.718Z'}, + {'created_at':'2015-08-19T23:25:50.718Z'}, + {'created_at':'2015-08-20T23:25:50.718Z'}, + {'created_at':'2015-08-21T23:25:50.718Z'}, + {'created_at':'2015-08-22T23:25:50.718Z'}, + {'created_at':'2015-08-23T23:25:50.718Z'}, + {'created_at':'2015-08-24T23:25:50.718Z'}, + {'created_at':'2015-08-25T23:25:50.718Z'}, + {'created_at':'2015-08-26T23:25:50.718Z'}, + {'created_at':'2015-08-27T23:25:50.718Z'}, + {'created_at':'2015-08-28T23:25:50.718Z'}, + {'created_at':'2015-08-29T23:25:50.718Z'}, + {'created_at':'2015-08-30T23:25:50.718Z'}, + {'created_at':'2015-08-31T23:25:50.718Z'}, + {'created_at':'2015-09-01T23:25:50.718Z'}, + {'created_at':'2015-09-02T23:25:50.718Z'}, + {'created_at':'2015-09-03T23:25:50.718Z'}, + {'created_at':'2015-09-04T23:25:50.718Z'}, + {'created_at':'2015-09-05T23:25:50.718Z'}, + {'created_at':'2015-09-06T23:25:50.718Z'} ], '/api/v1/treatments.json?find[notes]=/something/i&find[created_at][$gte]=2015-08-07T22:00:00.000Z&find[created_at][$lt]=2015-09-06T22:00:00.000Z': [ - {"created_at":"2015-08-07T23:25:50.718Z"}, - {"created_at":"2015-08-08T23:25:50.718Z"}, - {"created_at":"2015-08-09T23:25:50.718Z"}, - {"created_at":"2015-08-10T23:25:50.718Z"}, - {"created_at":"2015-08-11T23:25:50.718Z"}, - {"created_at":"2015-08-12T23:25:50.718Z"}, - {"created_at":"2015-08-13T23:25:50.718Z"}, - {"created_at":"2015-08-14T23:25:50.718Z"}, - {"created_at":"2015-08-15T23:25:50.718Z"}, - {"created_at":"2015-08-16T23:25:50.718Z"}, - {"created_at":"2015-08-17T23:25:50.718Z"}, - {"created_at":"2015-08-18T23:25:50.718Z"}, - {"created_at":"2015-08-19T23:25:50.718Z"}, - {"created_at":"2015-08-20T23:25:50.718Z"}, - {"created_at":"2015-08-21T23:25:50.718Z"}, - {"created_at":"2015-08-22T23:25:50.718Z"}, - {"created_at":"2015-08-23T23:25:50.718Z"}, - {"created_at":"2015-08-24T23:25:50.718Z"}, - {"created_at":"2015-08-25T23:25:50.718Z"}, - {"created_at":"2015-08-26T23:25:50.718Z"}, - {"created_at":"2015-08-27T23:25:50.718Z"}, - {"created_at":"2015-08-28T23:25:50.718Z"}, - {"created_at":"2015-08-29T23:25:50.718Z"}, - {"created_at":"2015-08-30T23:25:50.718Z"}, - {"created_at":"2015-08-31T23:25:50.718Z"}, - {"created_at":"2015-09-01T23:25:50.718Z"}, - {"created_at":"2015-09-02T23:25:50.718Z"}, - {"created_at":"2015-09-03T23:25:50.718Z"}, - {"created_at":"2015-09-04T23:25:50.718Z"}, - {"created_at":"2015-09-05T23:25:50.718Z"}, - {"created_at":"2015-09-06T23:25:50.718Z"} + {'created_at':'2015-08-07T23:25:50.718Z'}, + {'created_at':'2015-08-08T23:25:50.718Z'}, + {'created_at':'2015-08-09T23:25:50.718Z'}, + {'created_at':'2015-08-10T23:25:50.718Z'}, + {'created_at':'2015-08-11T23:25:50.718Z'}, + {'created_at':'2015-08-12T23:25:50.718Z'}, + {'created_at':'2015-08-13T23:25:50.718Z'}, + {'created_at':'2015-08-14T23:25:50.718Z'}, + {'created_at':'2015-08-15T23:25:50.718Z'}, + {'created_at':'2015-08-16T23:25:50.718Z'}, + {'created_at':'2015-08-17T23:25:50.718Z'}, + {'created_at':'2015-08-18T23:25:50.718Z'}, + {'created_at':'2015-08-19T23:25:50.718Z'}, + {'created_at':'2015-08-20T23:25:50.718Z'}, + {'created_at':'2015-08-21T23:25:50.718Z'}, + {'created_at':'2015-08-22T23:25:50.718Z'}, + {'created_at':'2015-08-23T23:25:50.718Z'}, + {'created_at':'2015-08-24T23:25:50.718Z'}, + {'created_at':'2015-08-25T23:25:50.718Z'}, + {'created_at':'2015-08-26T23:25:50.718Z'}, + {'created_at':'2015-08-27T23:25:50.718Z'}, + {'created_at':'2015-08-28T23:25:50.718Z'}, + {'created_at':'2015-08-29T23:25:50.718Z'}, + {'created_at':'2015-08-30T23:25:50.718Z'}, + {'created_at':'2015-08-31T23:25:50.718Z'}, + {'created_at':'2015-09-01T23:25:50.718Z'}, + {'created_at':'2015-09-02T23:25:50.718Z'}, + {'created_at':'2015-09-03T23:25:50.718Z'}, + {'created_at':'2015-09-04T23:25:50.718Z'}, + {'created_at':'2015-09-05T23:25:50.718Z'}, + {'created_at':'2015-09-06T23:25:50.718Z'} ] }; @@ -173,10 +173,10 @@ describe('reports', function ( ) { return { done: function mockDone (fn) { if (opts && opts.success && opts.success.call && someData[url]) { - //console.log('+++++Data for ' + url + ' sent'); + console.log('+++++Data for ' + url + ' sent'); opts.success(someData[url]); } else { - //console.log('-----Data for ' + url + ' missing'); + console.log('-----Data for ' + url + ' missing'); opts.success([]); } fn(); From 28d5e31bb1ee2400963b73b9ec92a83c83f40053 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 11 Sep 2015 09:53:09 +0200 Subject: [PATCH 133/176] add timezone to query filter --- static/report/js/report.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/static/report/js/report.js b/static/report/js/report.js index d76292bb24b..ec5df1353d6 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -238,7 +238,9 @@ }; // default time range if no time range specified in GUI - var timerange = '&find[created_at][$gte]='+moment('1970-01-01').toDate().toISOString(); + var zone = client.sbx.data.profile.getTimezone(); + var timerange = '&find[created_at][$gte]='+moment.tz('1970-01-01',zone).toDate().toISOString(); +console.log(timerange,zone); options.targetLow = parseFloat($('#rp_targetlow').val().replace(',','.')); options.targetHigh = parseFloat($('#rp_targethigh').val().replace(',','.')); @@ -261,7 +263,8 @@ matchesneeded++; var from = moment($('#rp_from').val()); var to = moment($('#rp_to').val()); - timerange = '&find[created_at][$gte]='+new Date(from).toISOString()+'&find[created_at][$lt]='+new Date(to).toISOString(); + timerange = '&find[created_at][$gte]='+moment.tz(from,zone).toDate().toISOString()+'&find[created_at][$lt]='+moment.tz(to,zone).toDate().toISOString(); +console.log(timerange,zone); while (from <= to) { if (daystoshow[from.format('YYYY-MM-DD')]) { daystoshow[from.format('YYYY-MM-DD')]++; From 7c0e6e7dd8b81d39aacfe22794d4dcad12b7a52f Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 11 Sep 2015 09:59:15 +0200 Subject: [PATCH 134/176] modify mock urls --- static/report/js/report.js | 2 -- tests/reports.test.js | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/static/report/js/report.js b/static/report/js/report.js index ec5df1353d6..7fc1fcfb554 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -240,7 +240,6 @@ // default time range if no time range specified in GUI var zone = client.sbx.data.profile.getTimezone(); var timerange = '&find[created_at][$gte]='+moment.tz('1970-01-01',zone).toDate().toISOString(); -console.log(timerange,zone); options.targetLow = parseFloat($('#rp_targetlow').val().replace(',','.')); options.targetHigh = parseFloat($('#rp_targethigh').val().replace(',','.')); @@ -264,7 +263,6 @@ console.log(timerange,zone); var from = moment($('#rp_from').val()); var to = moment($('#rp_to').val()); timerange = '&find[created_at][$gte]='+moment.tz(from,zone).toDate().toISOString()+'&find[created_at][$lt]='+moment.tz(to,zone).toDate().toISOString(); -console.log(timerange,zone); while (from <= to) { if (daystoshow[from.format('YYYY-MM-DD')]) { daystoshow[from.format('YYYY-MM-DD')]++; diff --git a/tests/reports.test.js b/tests/reports.test.js index 899c675094e..8cf201df6fe 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -28,7 +28,7 @@ var someData = { '/api/v1/treatments.json?find[created_at][$gte]=2015-08-14T00:00:00.000Z&find[created_at][$lt]=2015-08-15T00:00:00.000Z': [{'enteredBy':'Dad','eventType':'Site Change','glucose':268,'glucoseType':'Finger','insulin':1.75,'units':'mg/dl','created_at':'2015-08-14T23:25:50.718Z','_id':'55ce78fe925aa80e7071e5d6'},{'enteredBy':'Mom ','eventType':'Meal Bolus','glucose':89,'glucoseType':'Finger','carbs':54,'insulin':3.15,'units':'mg/dl','created_at':'2015-08-14T21:00:00.000Z','_id':'55ce59bb925aa80e7071e5ba'}], '/api/v1/entries.json?find[date][$gte]=1439596800000&find[date][$lt]=1439683200000&count=10000': [{'_id':'55cfd25f38a8d88ad1b49931','unfiltered':283136,'filtered':304768,'direction':'SingleDown','device':'dexcom','rssi':185,'sgv':306,'dateString':'Sat Aug 15 16:58:16 PDT 2015','type':'sgv','date':1439683096000,'noise':1},{'_id':'55cfd13338a8d88ad1b4992e','unfiltered':302528,'filtered':312576,'direction':'FortyFiveDown','device':'dexcom','rssi':179,'sgv':329,'dateString':'Sat Aug 15 16:53:16 PDT 2015','type':'sgv','date':1439682796000,'noise':1}], '/api/v1/food/regular.json': [{'_id':'552ece84a6947ea011db35bb','type':'food','category':'Zakladni','subcategory':'Sladkosti','name':'Bebe male','portion':18,'carbs':12,'gi':1,'unit':'pcs','created_at':'2015-04-15T20:48:04.966Z'}], - '/api/v1/treatments.json?find[eventType]=/BG Check/i&find[created_at][$gte]=2015-08-07T22:00:00.000Z&find[created_at][$lt]=2015-09-06T22:00:00.000Z': [ + '/api/v1/treatments.json?find[eventType]=/BG Check/i&find[created_at][$gte]=2015-08-07T00:00:00.000Z&find[created_at][$lt]=2015-09-06T00:00:00.000Z': [ {"created_at":"2015-08-07T23:25:50.718Z"}, {'created_at':'2015-08-08T23:25:50.718Z'}, {'created_at':'2015-08-09T23:25:50.718Z'}, @@ -61,7 +61,7 @@ var someData = { {'created_at':'2015-09-05T23:25:50.718Z'}, {'created_at':'2015-09-06T23:25:50.718Z'} ], - '/api/v1/treatments.json?find[notes]=/something/i&find[created_at][$gte]=2015-08-07T22:00:00.000Z&find[created_at][$lt]=2015-09-06T22:00:00.000Z': [ + '/api/v1/treatments.json?find[notes]=/something/i&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-07T00:00:00.000Z': [ {'created_at':'2015-08-07T23:25:50.718Z'}, {'created_at':'2015-08-08T23:25:50.718Z'}, {'created_at':'2015-08-09T23:25:50.718Z'}, From afbbcc4a4d6ac4fee9da71ae8a6078c778eea77e Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 11 Sep 2015 10:03:09 +0200 Subject: [PATCH 135/176] add timezone to query filter 2nd --- tests/reports.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/reports.test.js b/tests/reports.test.js index 8cf201df6fe..ddb7626a19d 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -28,7 +28,7 @@ var someData = { '/api/v1/treatments.json?find[created_at][$gte]=2015-08-14T00:00:00.000Z&find[created_at][$lt]=2015-08-15T00:00:00.000Z': [{'enteredBy':'Dad','eventType':'Site Change','glucose':268,'glucoseType':'Finger','insulin':1.75,'units':'mg/dl','created_at':'2015-08-14T23:25:50.718Z','_id':'55ce78fe925aa80e7071e5d6'},{'enteredBy':'Mom ','eventType':'Meal Bolus','glucose':89,'glucoseType':'Finger','carbs':54,'insulin':3.15,'units':'mg/dl','created_at':'2015-08-14T21:00:00.000Z','_id':'55ce59bb925aa80e7071e5ba'}], '/api/v1/entries.json?find[date][$gte]=1439596800000&find[date][$lt]=1439683200000&count=10000': [{'_id':'55cfd25f38a8d88ad1b49931','unfiltered':283136,'filtered':304768,'direction':'SingleDown','device':'dexcom','rssi':185,'sgv':306,'dateString':'Sat Aug 15 16:58:16 PDT 2015','type':'sgv','date':1439683096000,'noise':1},{'_id':'55cfd13338a8d88ad1b4992e','unfiltered':302528,'filtered':312576,'direction':'FortyFiveDown','device':'dexcom','rssi':179,'sgv':329,'dateString':'Sat Aug 15 16:53:16 PDT 2015','type':'sgv','date':1439682796000,'noise':1}], '/api/v1/food/regular.json': [{'_id':'552ece84a6947ea011db35bb','type':'food','category':'Zakladni','subcategory':'Sladkosti','name':'Bebe male','portion':18,'carbs':12,'gi':1,'unit':'pcs','created_at':'2015-04-15T20:48:04.966Z'}], - '/api/v1/treatments.json?find[eventType]=/BG Check/i&find[created_at][$gte]=2015-08-07T00:00:00.000Z&find[created_at][$lt]=2015-09-06T00:00:00.000Z': [ + '/api/v1/treatments.json?find[eventType]=/BG Check/i&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-07T00:00:00.000Z': [ {"created_at":"2015-08-07T23:25:50.718Z"}, {'created_at':'2015-08-08T23:25:50.718Z'}, {'created_at':'2015-08-09T23:25:50.718Z'}, From 04180c0d1f4b8c214803de1cbb566113f3565aed Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 11 Sep 2015 10:09:55 +0200 Subject: [PATCH 136/176] wrong change --- static/report/js/report.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/report/js/report.js b/static/report/js/report.js index 7fc1fcfb554..50bafe77d18 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -95,7 +95,7 @@ } $('#rp_food').empty(); for (var i=0; i Date: Fri, 11 Sep 2015 10:14:43 +0200 Subject: [PATCH 137/176] one more day needed in utc --- tests/reports.test.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/reports.test.js b/tests/reports.test.js index ddb7626a19d..fc87a4b1fbd 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -59,7 +59,8 @@ var someData = { {'created_at':'2015-09-03T23:25:50.718Z'}, {'created_at':'2015-09-04T23:25:50.718Z'}, {'created_at':'2015-09-05T23:25:50.718Z'}, - {'created_at':'2015-09-06T23:25:50.718Z'} + {'created_at':'2015-09-06T23:25:50.718Z'}, + {'created_at':'2015-09-07T23:25:50.718Z'} ], '/api/v1/treatments.json?find[notes]=/something/i&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-07T00:00:00.000Z': [ {'created_at':'2015-08-07T23:25:50.718Z'}, @@ -92,7 +93,8 @@ var someData = { {'created_at':'2015-09-03T23:25:50.718Z'}, {'created_at':'2015-09-04T23:25:50.718Z'}, {'created_at':'2015-09-05T23:25:50.718Z'}, - {'created_at':'2015-09-06T23:25:50.718Z'} + {'created_at':'2015-09-06T23:25:50.718Z'}, + {'created_at':'2015-09-07T23:25:50.718Z'} ] }; From 14cfe3d3faf48e3749ea1c0df316c19c02aa889f Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 11 Sep 2015 10:19:37 +0200 Subject: [PATCH 138/176] add log --- static/report/js/report.js | 1 + tests/reports.test.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/static/report/js/report.js b/static/report/js/report.js index 50bafe77d18..360592dbfb1 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -455,6 +455,7 @@ datastorage.allstatsrecords = []; datastorage.alldays = 0; Object.keys(daystoshow).forEach(function (day) { +console.log(day); datastorage.allstatsrecords = datastorage.allstatsrecords.concat(datastorage[day].statsrecords); datastorage.alldays++; }); diff --git a/tests/reports.test.js b/tests/reports.test.js index fc87a4b1fbd..4a2dc3cdd9e 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -29,7 +29,7 @@ var someData = { '/api/v1/entries.json?find[date][$gte]=1439596800000&find[date][$lt]=1439683200000&count=10000': [{'_id':'55cfd25f38a8d88ad1b49931','unfiltered':283136,'filtered':304768,'direction':'SingleDown','device':'dexcom','rssi':185,'sgv':306,'dateString':'Sat Aug 15 16:58:16 PDT 2015','type':'sgv','date':1439683096000,'noise':1},{'_id':'55cfd13338a8d88ad1b4992e','unfiltered':302528,'filtered':312576,'direction':'FortyFiveDown','device':'dexcom','rssi':179,'sgv':329,'dateString':'Sat Aug 15 16:53:16 PDT 2015','type':'sgv','date':1439682796000,'noise':1}], '/api/v1/food/regular.json': [{'_id':'552ece84a6947ea011db35bb','type':'food','category':'Zakladni','subcategory':'Sladkosti','name':'Bebe male','portion':18,'carbs':12,'gi':1,'unit':'pcs','created_at':'2015-04-15T20:48:04.966Z'}], '/api/v1/treatments.json?find[eventType]=/BG Check/i&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-07T00:00:00.000Z': [ - {"created_at":"2015-08-07T23:25:50.718Z"}, + {'created_at":"2015-08-07T23:25:50.718Z'}, {'created_at':'2015-08-08T23:25:50.718Z'}, {'created_at':'2015-08-09T23:25:50.718Z'}, {'created_at':'2015-08-10T23:25:50.718Z'}, From d77a240e90f38e46b7c760e7d8be03b557473a1b Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 11 Sep 2015 10:22:33 +0200 Subject: [PATCH 139/176] double quotes --- tests/reports.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/reports.test.js b/tests/reports.test.js index 4a2dc3cdd9e..605815c9e22 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -29,7 +29,7 @@ var someData = { '/api/v1/entries.json?find[date][$gte]=1439596800000&find[date][$lt]=1439683200000&count=10000': [{'_id':'55cfd25f38a8d88ad1b49931','unfiltered':283136,'filtered':304768,'direction':'SingleDown','device':'dexcom','rssi':185,'sgv':306,'dateString':'Sat Aug 15 16:58:16 PDT 2015','type':'sgv','date':1439683096000,'noise':1},{'_id':'55cfd13338a8d88ad1b4992e','unfiltered':302528,'filtered':312576,'direction':'FortyFiveDown','device':'dexcom','rssi':179,'sgv':329,'dateString':'Sat Aug 15 16:53:16 PDT 2015','type':'sgv','date':1439682796000,'noise':1}], '/api/v1/food/regular.json': [{'_id':'552ece84a6947ea011db35bb','type':'food','category':'Zakladni','subcategory':'Sladkosti','name':'Bebe male','portion':18,'carbs':12,'gi':1,'unit':'pcs','created_at':'2015-04-15T20:48:04.966Z'}], '/api/v1/treatments.json?find[eventType]=/BG Check/i&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-07T00:00:00.000Z': [ - {'created_at":"2015-08-07T23:25:50.718Z'}, + {'created_at':'2015-08-07T23:25:50.718Z'}, {'created_at':'2015-08-08T23:25:50.718Z'}, {'created_at':'2015-08-09T23:25:50.718Z'}, {'created_at':'2015-08-10T23:25:50.718Z'}, From 950117cfe8e5cd859dcb265196c78b2e1dd37b83 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 11 Sep 2015 10:28:30 +0200 Subject: [PATCH 140/176] try to remove failing data --- tests/reports.test.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/reports.test.js b/tests/reports.test.js index 605815c9e22..93ed09dfad0 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -29,7 +29,6 @@ var someData = { '/api/v1/entries.json?find[date][$gte]=1439596800000&find[date][$lt]=1439683200000&count=10000': [{'_id':'55cfd25f38a8d88ad1b49931','unfiltered':283136,'filtered':304768,'direction':'SingleDown','device':'dexcom','rssi':185,'sgv':306,'dateString':'Sat Aug 15 16:58:16 PDT 2015','type':'sgv','date':1439683096000,'noise':1},{'_id':'55cfd13338a8d88ad1b4992e','unfiltered':302528,'filtered':312576,'direction':'FortyFiveDown','device':'dexcom','rssi':179,'sgv':329,'dateString':'Sat Aug 15 16:53:16 PDT 2015','type':'sgv','date':1439682796000,'noise':1}], '/api/v1/food/regular.json': [{'_id':'552ece84a6947ea011db35bb','type':'food','category':'Zakladni','subcategory':'Sladkosti','name':'Bebe male','portion':18,'carbs':12,'gi':1,'unit':'pcs','created_at':'2015-04-15T20:48:04.966Z'}], '/api/v1/treatments.json?find[eventType]=/BG Check/i&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-07T00:00:00.000Z': [ - {'created_at':'2015-08-07T23:25:50.718Z'}, {'created_at':'2015-08-08T23:25:50.718Z'}, {'created_at':'2015-08-09T23:25:50.718Z'}, {'created_at':'2015-08-10T23:25:50.718Z'}, @@ -63,7 +62,6 @@ var someData = { {'created_at':'2015-09-07T23:25:50.718Z'} ], '/api/v1/treatments.json?find[notes]=/something/i&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-07T00:00:00.000Z': [ - {'created_at':'2015-08-07T23:25:50.718Z'}, {'created_at':'2015-08-08T23:25:50.718Z'}, {'created_at':'2015-08-09T23:25:50.718Z'}, {'created_at':'2015-08-10T23:25:50.718Z'}, From d530af7ec7666afff36508163ed238a245fc1aa1 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 11 Sep 2015 10:40:56 +0200 Subject: [PATCH 141/176] fix daystoshow --- static/report/js/report.js | 1 + 1 file changed, 1 insertion(+) diff --git a/static/report/js/report.js b/static/report/js/report.js index 360592dbfb1..fc4cb77a863 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -411,6 +411,7 @@ loadData(d, options, dataLoadedCallback); } else { $('#info').append($('
    '+d+' '+translate('not displayed')+'.
    ')); + delete daystoshow[d]; } } else { delete daystoshow[d]; From b8d9e3278aeeaad8734194bc4128cf08e57a1bc0 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 11 Sep 2015 11:00:19 +0200 Subject: [PATCH 142/176] remove log & fix some codacy --- static/report/js/report.js | 27 +++++++++++++++------------ tests/reports.test.js | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/static/report/js/report.js b/static/report/js/report.js index fc4cb77a863..0e8fc8aae27 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -387,14 +387,16 @@ function daysfilter() { matchesneeded++; for (var d in daystoshow) { - var day = new Date(d).getDay(); - if (day===0 && $('#rp_su').is(':checked')) { daystoshow[d]++; } - if (day===1 && $('#rp_mo').is(':checked')) { daystoshow[d]++; } - if (day===2 && $('#rp_tu').is(':checked')) { daystoshow[d]++; } - if (day===3 && $('#rp_we').is(':checked')) { daystoshow[d]++; } - if (day===4 && $('#rp_th').is(':checked')) { daystoshow[d]++; } - if (day===5 && $('#rp_fr').is(':checked')) { daystoshow[d]++; } - if (day===6 && $('#rp_sa').is(':checked')) { daystoshow[d]++; } + if (daystoshow.hasOwnProperty(d)) { + var day = new Date(d).getDay(); + if (day===0 && $('#rp_su').is(':checked')) { daystoshow[d]++; } + if (day===1 && $('#rp_mo').is(':checked')) { daystoshow[d]++; } + if (day===2 && $('#rp_tu').is(':checked')) { daystoshow[d]++; } + if (day===3 && $('#rp_we').is(':checked')) { daystoshow[d]++; } + if (day===4 && $('#rp_th').is(':checked')) { daystoshow[d]++; } + if (day===5 && $('#rp_fr').is(':checked')) { daystoshow[d]++; } + if (day===6 && $('#rp_sa').is(':checked')) { daystoshow[d]++; } + } } countDays(); display(); @@ -428,9 +430,11 @@ function countDays() { for (var d in daystoshow) { - if (daystoshow[d]===matchesneeded) { - if (dayscount < maxdays) { - dayscount++; + if (daystoshow.hasOwnProperty(d)) { + if (daystoshow[d]===matchesneeded) { + if (dayscount < maxdays) { + dayscount++; + } } } } @@ -456,7 +460,6 @@ datastorage.allstatsrecords = []; datastorage.alldays = 0; Object.keys(daystoshow).forEach(function (day) { -console.log(day); datastorage.allstatsrecords = datastorage.allstatsrecords.concat(datastorage[day].statsrecords); datastorage.alldays++; }); diff --git a/tests/reports.test.js b/tests/reports.test.js index 93ed09dfad0..c5a20f0b315 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -266,7 +266,7 @@ describe('reports', function ( ) { //var logfile = filesys.createWriteStream('out.txt', { flags: 'a'} ) //logfile.write($('body').html()); - console.log(result); + //console.log(result); result.indexOf('Milk now').should.be.greaterThan(-1); // daytoday result.indexOf('50 g (1.67U)').should.be.greaterThan(-1); // daytoday From 9fd1d0b9b5a1feda8bd362d0a773a2551e518e4b Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 11 Sep 2015 11:05:02 +0200 Subject: [PATCH 143/176] try to click delete record --- tests/reports.test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/reports.test.js b/tests/reports.test.js index c5a20f0b315..df6c4105416 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -235,6 +235,9 @@ describe('reports', function ( ) { next(true); }; + window.confirm = function mockConfirm () { + return true; + } client.init(serverSettings, plugins); client.dataUpdate(nowData); @@ -260,6 +263,8 @@ describe('reports', function ( ) { $('#rp_linear').prop('checked',true); $('#rp_show').click(); $('#dailystats').click(); + + $('img.deleteTreatment :first').click(); var result = $('body').html(); //var filesys = require('fs'); From 7b25a9dcdb70968bd32e92d0e41d4ae9a0d2d48b Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 11 Sep 2015 11:27:27 +0200 Subject: [PATCH 144/176] .. and click save --- tests/reports.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/reports.test.js b/tests/reports.test.js index df6c4105416..69f8942103e 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -265,6 +265,8 @@ describe('reports', function ( ) { $('#dailystats').click(); $('img.deleteTreatment :first').click(); + $('img.editTreatment :first').click(); + $('.ui-button:contains("Save")').click() var result = $('body').html(); //var filesys = require('fs'); From 8b7405265d204fd2c313bc4109f1a1de5fea6c54 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 11 Sep 2015 11:41:47 +0200 Subject: [PATCH 145/176] unwanted space --- tests/reports.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/reports.test.js b/tests/reports.test.js index 69f8942103e..63caf26d2c7 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -264,8 +264,8 @@ describe('reports', function ( ) { $('#rp_show').click(); $('#dailystats').click(); - $('img.deleteTreatment :first').click(); - $('img.editTreatment :first').click(); + $('img.deleteTreatment:first').click(); + $('img.editTreatment:first').click(); $('.ui-button:contains("Save")').click() var result = $('body').html(); From 3fab1a55bb19e77425a3b02f1fe74b37ea11f545 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 11 Sep 2015 11:51:40 +0200 Subject: [PATCH 146/176] modify mock func --- tests/reports.test.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/reports.test.js b/tests/reports.test.js index 63caf26d2c7..190b82591f8 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -172,12 +172,14 @@ describe('reports', function ( ) { //logfile.write(url+'\n'); return { done: function mockDone (fn) { - if (opts && opts.success && opts.success.call && someData[url]) { - console.log('+++++Data for ' + url + ' sent'); - opts.success(someData[url]); - } else { - console.log('-----Data for ' + url + ' missing'); - opts.success([]); + if (opts && opts.success && opts.success.call) { + if (someData[url]) { + console.log('+++++Data for ' + url + ' sent'); + opts.success(someData[url]); + } else { + console.log('-----Data for ' + url + ' missing'); + opts.success([]); + } } fn(); return self.$.ajax(); @@ -266,7 +268,7 @@ describe('reports', function ( ) { $('img.deleteTreatment:first').click(); $('img.editTreatment:first').click(); - $('.ui-button:contains("Save")').click() + $('.ui-button:contains("Save")').click(); var result = $('body').html(); //var filesys = require('fs'); From 8662568641563d3e1ac9d645fcd302a1d1520968 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 11 Sep 2015 11:57:51 +0200 Subject: [PATCH 147/176] add mock window.alert --- lib/report_plugins/treatments.js | 8 ++++---- tests/reports.test.js | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/report_plugins/treatments.js b/lib/report_plugins/treatments.js index 9a4220432c2..be887ac9a84 100644 --- a/lib/report_plugins/treatments.js +++ b/lib/report_plugins/treatments.js @@ -98,7 +98,7 @@ treatments.report = function report_treatments(datastorage, daystoshow, options) function deleteTreatment(event) { if (!client.hashauth.isAuthenticated()) { - alert(translate('Your device is not authenticated yet')); + window.alert(translate('Your device is not authenticated yet')); return false; } @@ -116,7 +116,7 @@ treatments.report = function report_treatments(datastorage, daystoshow, options) console.info('treatment deleted', response); }).fail(function treatmentDeleteFail (response) { console.info('treatment delete failed', response); - alert(translate('Deleting record failed') + '. ' + translate('Status') + ': ' + response.status); + window.alert(translate('Deleting record failed') + '. ' + translate('Status') + ': ' + response.status); }); delete datastorage[day]; report_plugins.show(); @@ -191,7 +191,7 @@ treatments.report = function report_treatments(datastorage, daystoshow, options) function saveTreatmentRecord(data) { if (!client.hashauth.isAuthenticated()) { - alert(translate('Your device is not authenticated yet')); + window.alert(translate('Your device is not authenticated yet')); return false; } @@ -206,7 +206,7 @@ treatments.report = function report_treatments(datastorage, daystoshow, options) console.info('treatment saved', response); }).fail(function treatmentSaveFail (response) { console.info('treatment save failed', response); - alert(translate('Saving record failed') + '. ' + translate('Status') + ': ' + response.status); + window.alert(translate('Saving record failed') + '. ' + translate('Status') + ': ' + response.status); }); return true; diff --git a/tests/reports.test.js b/tests/reports.test.js index 190b82591f8..b2bc5e8a9f1 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -239,7 +239,11 @@ describe('reports', function ( ) { window.confirm = function mockConfirm () { return true; - } + }; + + window.alert = function mockAlert () { + return true; + }; client.init(serverSettings, plugins); client.dataUpdate(nowData); From 04056757b12542e64261b8b30180839486f2d5e6 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 11 Sep 2015 12:06:16 +0200 Subject: [PATCH 148/176] mock fail return status --- tests/reports.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/reports.test.js b/tests/reports.test.js index b2bc5e8a9f1..e001efe6bd7 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -174,10 +174,10 @@ describe('reports', function ( ) { done: function mockDone (fn) { if (opts && opts.success && opts.success.call) { if (someData[url]) { - console.log('+++++Data for ' + url + ' sent'); + //console.log('+++++Data for ' + url + ' sent'); opts.success(someData[url]); } else { - console.log('-----Data for ' + url + ' missing'); + //console.log('-----Data for ' + url + ' missing'); opts.success([]); } } @@ -185,7 +185,7 @@ describe('reports', function ( ) { return self.$.ajax(); }, fail: function mockFail (fn) { - fn(); + fn({status: 400}); return self.$.ajax(); } }; From bd40940a1fe165797511a03ae8bd46059801c1fa Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 11 Sep 2015 12:10:39 +0200 Subject: [PATCH 149/176] add moment --- lib/report_plugins/treatments.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/report_plugins/treatments.js b/lib/report_plugins/treatments.js index be887ac9a84..d95fcf43a67 100644 --- a/lib/report_plugins/treatments.js +++ b/lib/report_plugins/treatments.js @@ -1,6 +1,7 @@ 'use strict'; var _ = window._; +var moment = window.moment; var treatments = { name: 'treatments' From a53c3515deeca24f18627816f4b1c54cfbbdce60 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 11 Sep 2015 18:44:59 +0200 Subject: [PATCH 150/176] local test fix --- static/report/js/report.js | 13 ++-- tests/reports.test.js | 126 ++++++++++++++++++------------------- 2 files changed, 71 insertions(+), 68 deletions(-) diff --git a/static/report/js/report.js b/static/report/js/report.js index 0e8fc8aae27..1f6c78c51cc 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -239,8 +239,8 @@ // default time range if no time range specified in GUI var zone = client.sbx.data.profile.getTimezone(); - var timerange = '&find[created_at][$gte]='+moment.tz('1970-01-01',zone).toDate().toISOString(); - + var timerange = '&find[created_at][$gte]='+moment.tz('2000-01-01',zone).toISOString(); + //console.log(timerange,zone); options.targetLow = parseFloat($('#rp_targetlow').val().replace(',','.')); options.targetHigh = parseFloat($('#rp_targethigh').val().replace(',','.')); options.raw = $('#rp_optionsraw').is(':checked'); @@ -260,9 +260,12 @@ function datefilter() { if ($('#rp_enabledate').is(':checked')) { matchesneeded++; - var from = moment($('#rp_from').val()); - var to = moment($('#rp_to').val()); - timerange = '&find[created_at][$gte]='+moment.tz(from,zone).toDate().toISOString()+'&find[created_at][$lt]='+moment.tz(to,zone).toDate().toISOString(); + var fromdate = new Date($('#rp_from').val()); + var todate = new Date($('#rp_to').val()); + var from = moment.tz([fromdate.getFullYear(), fromdate.getMonth(), fromdate.getDate()],zone); + var to = moment.tz([todate.getFullYear(), todate.getMonth(), todate.getDate()],zone); + timerange = '&find[created_at][$gte]='+from.toISOString()+'&find[created_at][$lt]='+to.toISOString(); + //console.log($('#rp_from').val(),$('#rp_to').val(),zone,timerange); while (from <= to) { if (daystoshow[from.format('YYYY-MM-DD')]) { daystoshow[from.format('YYYY-MM-DD')]++; diff --git a/tests/reports.test.js b/tests/reports.test.js index e001efe6bd7..41ef419c47e 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -25,74 +25,74 @@ var someData = { '/api/v1/entries.json?find[date][$gte]=1439424000000&find[date][$lt]=1439510400000&count=10000': [{'_id':'55cd2f6738a8d88ad1b48ca1','unfiltered':209792,'filtered':229344,'direction':'SingleDown','device':'dexcom','rssi':436,'sgv':205,'dateString':'Thu Aug 13 16:58:24 PDT 2015','type':'sgv','date':1439510304000,'noise':1},{'_id':'55cd2e3b38a8d88ad1b48c95','unfiltered':220928,'filtered':237472,'direction':'FortyFiveDown','device':'dexcom','rssi':418,'sgv':219,'dateString':'Thu Aug 13 16:53:24 PDT 2015','type':'sgv','date':1439510004000,'noise':1}], '/api/v1/treatments.json?find[created_at][$gte]=2015-08-13T00:00:00.000Z&find[created_at][$lt]=2015-08-14T00:00:00.000Z': [{'enteredBy':'Mom ','eventType':'Correction Bolus','glucose':250,'glucoseType':'Sensor','insulin':0.75,'units':'mg/dl','created_at':'2015-08-13T23:45:56.927Z','_id':'55cd2c3497fa97ac5d8bc53b'},{'enteredBy':'Mom ','eventType':'Correction Bolus','glucose':198,'glucoseType':'Sensor','insulin':1.1,'units':'mg/dl','created_at':'2015-08-13T23:11:00.293Z','_id':'55cd240497fa97ac5d8bc535'}], '/api/v1/entries.json?find[date][$gte]=1439510400000&find[date][$lt]=1439596800000&count=10000': [{'_id':'55ce80e338a8d88ad1b49397','unfiltered':179936,'filtered':202080,'direction':'SingleDown','device':'dexcom','rssi':179,'sgv':182,'dateString':'Fri Aug 14 16:58:20 PDT 2015','type':'sgv','date':1439596700000,'noise':1},{'_id':'55ce7fb738a8d88ad1b4938d','unfiltered':192288,'filtered':213792,'direction':'SingleDown','device':'dexcom','rssi':180,'sgv':197,'dateString':'Fri Aug 14 16:53:20 PDT 2015','type':'sgv','date':1439596400000,'noise':1}], - '/api/v1/treatments.json?find[created_at][$gte]=2015-08-14T00:00:00.000Z&find[created_at][$lt]=2015-08-15T00:00:00.000Z': [{'enteredBy':'Dad','eventType':'Site Change','glucose':268,'glucoseType':'Finger','insulin':1.75,'units':'mg/dl','created_at':'2015-08-14T23:25:50.718Z','_id':'55ce78fe925aa80e7071e5d6'},{'enteredBy':'Mom ','eventType':'Meal Bolus','glucose':89,'glucoseType':'Finger','carbs':54,'insulin':3.15,'units':'mg/dl','created_at':'2015-08-14T21:00:00.000Z','_id':'55ce59bb925aa80e7071e5ba'}], + '/api/v1/treatments.json?find[created_at][$gte]=2015-08-14T00:00:00.000Z&find[created_at][$lt]=2015-08-15T00:00:00.000Z': [{'enteredBy':'Dad','eventType':'Site Change','glucose':268,'glucoseType':'Finger','insulin':1.75,'units':'mg/dl','created_at':'2015-08-14T00:00:00.000Z','_id':'55ce78fe925aa80e7071e5d6'},{'enteredBy':'Mom ','eventType':'Meal Bolus','glucose':89,'glucoseType':'Finger','carbs':54,'insulin':3.15,'units':'mg/dl','created_at':'2015-08-14T21:00:00.000Z','_id':'55ce59bb925aa80e7071e5ba'}], '/api/v1/entries.json?find[date][$gte]=1439596800000&find[date][$lt]=1439683200000&count=10000': [{'_id':'55cfd25f38a8d88ad1b49931','unfiltered':283136,'filtered':304768,'direction':'SingleDown','device':'dexcom','rssi':185,'sgv':306,'dateString':'Sat Aug 15 16:58:16 PDT 2015','type':'sgv','date':1439683096000,'noise':1},{'_id':'55cfd13338a8d88ad1b4992e','unfiltered':302528,'filtered':312576,'direction':'FortyFiveDown','device':'dexcom','rssi':179,'sgv':329,'dateString':'Sat Aug 15 16:53:16 PDT 2015','type':'sgv','date':1439682796000,'noise':1}], '/api/v1/food/regular.json': [{'_id':'552ece84a6947ea011db35bb','type':'food','category':'Zakladni','subcategory':'Sladkosti','name':'Bebe male','portion':18,'carbs':12,'gi':1,'unit':'pcs','created_at':'2015-04-15T20:48:04.966Z'}], '/api/v1/treatments.json?find[eventType]=/BG Check/i&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-07T00:00:00.000Z': [ - {'created_at':'2015-08-08T23:25:50.718Z'}, - {'created_at':'2015-08-09T23:25:50.718Z'}, - {'created_at':'2015-08-10T23:25:50.718Z'}, - {'created_at':'2015-08-11T23:25:50.718Z'}, - {'created_at':'2015-08-12T23:25:50.718Z'}, - {'created_at':'2015-08-13T23:25:50.718Z'}, - {'created_at':'2015-08-14T23:25:50.718Z'}, - {'created_at':'2015-08-15T23:25:50.718Z'}, - {'created_at':'2015-08-16T23:25:50.718Z'}, - {'created_at':'2015-08-17T23:25:50.718Z'}, - {'created_at':'2015-08-18T23:25:50.718Z'}, - {'created_at':'2015-08-19T23:25:50.718Z'}, - {'created_at':'2015-08-20T23:25:50.718Z'}, - {'created_at':'2015-08-21T23:25:50.718Z'}, - {'created_at':'2015-08-22T23:25:50.718Z'}, - {'created_at':'2015-08-23T23:25:50.718Z'}, - {'created_at':'2015-08-24T23:25:50.718Z'}, - {'created_at':'2015-08-25T23:25:50.718Z'}, - {'created_at':'2015-08-26T23:25:50.718Z'}, - {'created_at':'2015-08-27T23:25:50.718Z'}, - {'created_at':'2015-08-28T23:25:50.718Z'}, - {'created_at':'2015-08-29T23:25:50.718Z'}, - {'created_at':'2015-08-30T23:25:50.718Z'}, - {'created_at':'2015-08-31T23:25:50.718Z'}, - {'created_at':'2015-09-01T23:25:50.718Z'}, - {'created_at':'2015-09-02T23:25:50.718Z'}, - {'created_at':'2015-09-03T23:25:50.718Z'}, - {'created_at':'2015-09-04T23:25:50.718Z'}, - {'created_at':'2015-09-05T23:25:50.718Z'}, - {'created_at':'2015-09-06T23:25:50.718Z'}, - {'created_at':'2015-09-07T23:25:50.718Z'} + {'created_at':'2015-08-08T00:00:00.000Z'}, + {'created_at':'2015-08-09T00:00:00.000Z'}, + {'created_at':'2015-08-10T00:00:00.000Z'}, + {'created_at':'2015-08-11T00:00:00.000Z'}, + {'created_at':'2015-08-12T00:00:00.000Z'}, + {'created_at':'2015-08-13T00:00:00.000Z'}, + {'created_at':'2015-08-14T00:00:00.000Z'}, + {'created_at':'2015-08-15T00:00:00.000Z'}, + {'created_at':'2015-08-16T00:00:00.000Z'}, + {'created_at':'2015-08-17T00:00:00.000Z'}, + {'created_at':'2015-08-18T00:00:00.000Z'}, + {'created_at':'2015-08-19T00:00:00.000Z'}, + {'created_at':'2015-08-20T00:00:00.000Z'}, + {'created_at':'2015-08-21T00:00:00.000Z'}, + {'created_at':'2015-08-22T00:00:00.000Z'}, + {'created_at':'2015-08-23T00:00:00.000Z'}, + {'created_at':'2015-08-24T00:00:00.000Z'}, + {'created_at':'2015-08-25T00:00:00.000Z'}, + {'created_at':'2015-08-26T00:00:00.000Z'}, + {'created_at':'2015-08-27T00:00:00.000Z'}, + {'created_at':'2015-08-28T00:00:00.000Z'}, + {'created_at':'2015-08-29T00:00:00.000Z'}, + {'created_at':'2015-08-30T00:00:00.000Z'}, + {'created_at':'2015-08-31T00:00:00.000Z'}, + {'created_at':'2015-09-01T00:00:00.000Z'}, + {'created_at':'2015-09-02T00:00:00.000Z'}, + {'created_at':'2015-09-03T00:00:00.000Z'}, + {'created_at':'2015-09-04T00:00:00.000Z'}, + {'created_at':'2015-09-05T00:00:00.000Z'}, + {'created_at':'2015-09-06T00:00:00.000Z'}, + {'created_at':'2015-09-07T00:00:00.000Z'} ], '/api/v1/treatments.json?find[notes]=/something/i&find[created_at][$gte]=2015-08-08T00:00:00.000Z&find[created_at][$lt]=2015-09-07T00:00:00.000Z': [ - {'created_at':'2015-08-08T23:25:50.718Z'}, - {'created_at':'2015-08-09T23:25:50.718Z'}, - {'created_at':'2015-08-10T23:25:50.718Z'}, - {'created_at':'2015-08-11T23:25:50.718Z'}, - {'created_at':'2015-08-12T23:25:50.718Z'}, - {'created_at':'2015-08-13T23:25:50.718Z'}, - {'created_at':'2015-08-14T23:25:50.718Z'}, - {'created_at':'2015-08-15T23:25:50.718Z'}, - {'created_at':'2015-08-16T23:25:50.718Z'}, - {'created_at':'2015-08-17T23:25:50.718Z'}, - {'created_at':'2015-08-18T23:25:50.718Z'}, - {'created_at':'2015-08-19T23:25:50.718Z'}, - {'created_at':'2015-08-20T23:25:50.718Z'}, - {'created_at':'2015-08-21T23:25:50.718Z'}, - {'created_at':'2015-08-22T23:25:50.718Z'}, - {'created_at':'2015-08-23T23:25:50.718Z'}, - {'created_at':'2015-08-24T23:25:50.718Z'}, - {'created_at':'2015-08-25T23:25:50.718Z'}, - {'created_at':'2015-08-26T23:25:50.718Z'}, - {'created_at':'2015-08-27T23:25:50.718Z'}, - {'created_at':'2015-08-28T23:25:50.718Z'}, - {'created_at':'2015-08-29T23:25:50.718Z'}, - {'created_at':'2015-08-30T23:25:50.718Z'}, - {'created_at':'2015-08-31T23:25:50.718Z'}, - {'created_at':'2015-09-01T23:25:50.718Z'}, - {'created_at':'2015-09-02T23:25:50.718Z'}, - {'created_at':'2015-09-03T23:25:50.718Z'}, - {'created_at':'2015-09-04T23:25:50.718Z'}, - {'created_at':'2015-09-05T23:25:50.718Z'}, - {'created_at':'2015-09-06T23:25:50.718Z'}, - {'created_at':'2015-09-07T23:25:50.718Z'} + {'created_at':'2015-08-08T00:00:00.000Z'}, + {'created_at':'2015-08-09T00:00:00.000Z'}, + {'created_at':'2015-08-10T00:00:00.000Z'}, + {'created_at':'2015-08-11T00:00:00.000Z'}, + {'created_at':'2015-08-12T00:00:00.000Z'}, + {'created_at':'2015-08-13T00:00:00.000Z'}, + {'created_at':'2015-08-14T00:00:00.000Z'}, + {'created_at':'2015-08-15T00:00:00.000Z'}, + {'created_at':'2015-08-16T00:00:00.000Z'}, + {'created_at':'2015-08-17T00:00:00.000Z'}, + {'created_at':'2015-08-18T00:00:00.000Z'}, + {'created_at':'2015-08-19T00:00:00.000Z'}, + {'created_at':'2015-08-20T00:00:00.000Z'}, + {'created_at':'2015-08-21T00:00:00.000Z'}, + {'created_at':'2015-08-22T00:00:00.000Z'}, + {'created_at':'2015-08-23T00:00:00.000Z'}, + {'created_at':'2015-08-24T00:00:00.000Z'}, + {'created_at':'2015-08-25T00:00:00.000Z'}, + {'created_at':'2015-08-26T00:00:00.000Z'}, + {'created_at':'2015-08-27T00:00:00.000Z'}, + {'created_at':'2015-08-28T00:00:00.000Z'}, + {'created_at':'2015-08-29T00:00:00.000Z'}, + {'created_at':'2015-08-30T00:00:00.000Z'}, + {'created_at':'2015-08-31T00:00:00.000Z'}, + {'created_at':'2015-09-01T00:00:00.000Z'}, + {'created_at':'2015-09-02T00:00:00.000Z'}, + {'created_at':'2015-09-03T00:00:00.000Z'}, + {'created_at':'2015-09-04T00:00:00.000Z'}, + {'created_at':'2015-09-05T00:00:00.000Z'}, + {'created_at':'2015-09-06T00:00:00.000Z'}, + {'created_at':'2015-09-07T00:00:00.000Z'} ] }; From 1a0e9c3330f022d6b8d1fea1509dcea30da12868 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Tue, 15 Sep 2015 19:44:38 +0200 Subject: [PATCH 151/176] timezones to records in filters --- static/report/js/report.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/static/report/js/report.js b/static/report/js/report.js index 1f6c78c51cc..eac70b7524e 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -290,7 +290,7 @@ $.ajax('/api/v1/treatments.json'+tquery, { success: function (xhr) { treatmentData = xhr.map(function (treatment) { - return moment(treatment.created_at).format('YYYY-MM-DD'); + return moment.tz(treatment.created_at,zone).format('YYYY-MM-DD'); }); // unique it treatmentData = $.grep(treatmentData, function(v, k){ @@ -326,7 +326,7 @@ $.ajax('/api/v1/treatments.json' + tquery + timerange, { success: function (xhr) { treatmentData = xhr.map(function (treatment) { - return moment(treatment.created_at).format('YYYY-MM-DD'); + return moment.tz(treatment.created_at,zone).format('YYYY-MM-DD'); }); // unique it treatmentData = $.grep(treatmentData, function(v, k){ @@ -362,7 +362,7 @@ $.ajax('/api/v1/treatments.json' + tquery + timerange, { success: function (xhr) { treatmentData = xhr.map(function (treatment) { - return moment(treatment.created_at).format('YYYY-MM-DD'); + return moment.tz(treatment.created_at,zone).format('YYYY-MM-DD'); }); // unique it treatmentData = $.grep(treatmentData, function(v, k){ From 13aafe280522376877f3618548f848fe1223d68e Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Tue, 15 Sep 2015 21:46:58 +0200 Subject: [PATCH 152/176] ordering in reports, tranlation fixes --- lib/language.js | 11 ++++++++++- lib/report_plugins/calibrations.js | 10 +++++----- lib/report_plugins/dailystats.js | 4 ++-- lib/report_plugins/daytoday.js | 15 ++++++++------- lib/report_plugins/glucosedistribution.js | 2 +- lib/report_plugins/hourlystats.js | 13 ++----------- lib/report_plugins/index.js | 2 ++ lib/report_plugins/percentile.js | 2 +- lib/report_plugins/success.js | 2 +- lib/report_plugins/treatments.js | 9 ++++++--- static/report/index.html | 11 +++++++++++ static/report/js/report.js | 13 ++++++++++++- 12 files changed, 61 insertions(+), 33 deletions(-) diff --git a/lib/language.js b/lib/language.js index 6f94313f2ee..92e89be3ad8 100644 --- a/lib/language.js +++ b/lib/language.js @@ -2989,7 +2989,7 @@ function init() { ,nb: 'Trening' } ,'Pump Site Change' : { - cs: 'Přepíchnutí kanyly' + cs: 'Výměna setu' ,de: 'Pumpen-Katheter Wechsel' ,es: 'Cambio de catéter' ,fr: 'Changement de site pompe' @@ -3911,6 +3911,15 @@ function init() { cs: 'Aktualizovat' ,pt: 'Atualizar' } + ,'Order' : { + cs: 'Pořadí' + } + ,'oldest on top' : { + cs: 'nejstarší nahoře' + } + ,'newest on top' : { + cs: 'nejnovější nahoře' + } }; diff --git a/lib/report_plugins/calibrations.js b/lib/report_plugins/calibrations.js index c771a6452f1..72d6f5e3239 100644 --- a/lib/report_plugins/calibrations.js +++ b/lib/report_plugins/calibrations.js @@ -23,13 +23,13 @@ calibrations.html = function html(client) { return ret; }; -calibrations.report = function report_calibrations(datastorage,daystoshow) { +calibrations.report = function report_calibrations(datastorage,sorteddaystoshow) { var Nightscout = window.Nightscout; var report_plugins = Nightscout.report_plugins; var padding = { top: 15, right: 15, bottom: 30, left: 70 }; var treatments = []; - Object.keys(daystoshow).forEach(function (day) { + sorteddaystoshow.forEach(function (day) { treatments = treatments.concat(datastorage[day].treatments.filter(function (t) { if (t.eventType === 'Sensor Start') { return true; @@ -42,17 +42,17 @@ calibrations.report = function report_calibrations(datastorage,daystoshow) { }); var cals = []; - Object.keys(daystoshow).forEach(function (day) { + sorteddaystoshow.forEach(function (day) { cals = cals.concat(datastorage[day].cal); }); var sgvs = []; - Object.keys(daystoshow).forEach(function (day) { + sorteddaystoshow.forEach(function (day) { sgvs = sgvs.concat(datastorage[day].sgv); }); var mbgs = []; - Object.keys(daystoshow).forEach(function (day) { + sorteddaystoshow.forEach(function (day) { mbgs = mbgs.concat(datastorage[day].mbg); }); mbgs.forEach(function (mbg) { calcmbg(mbg); }); diff --git a/lib/report_plugins/dailystats.js b/lib/report_plugins/dailystats.js index f1d81e0979a..59438c9083f 100644 --- a/lib/report_plugins/dailystats.js +++ b/lib/report_plugins/dailystats.js @@ -21,7 +21,7 @@ dailystats.html = function html(client) { return ret; }; -dailystats.report = function report_dailystats(datastorage,daystoshow,options) { +dailystats.report = function report_dailystats(datastorage,sorteddaystoshow,options) { var Nightscout = window.Nightscout; var client = Nightscout.client; var translate = client.translate; @@ -51,7 +51,7 @@ dailystats.report = function report_dailystats(datastorage,daystoshow,options) { $('
    ').appendTo(thead); thead.appendTo(table); - Object.keys(daystoshow).forEach(function (day) { + sorteddaystoshow.forEach(function (day) { var tr = $(''); var daysRecords = datastorage[day].statsrecords; diff --git a/lib/report_plugins/daytoday.js b/lib/report_plugins/daytoday.js index cd9d32c1c5f..18ba0f23531 100644 --- a/lib/report_plugins/daytoday.js +++ b/lib/report_plugins/daytoday.js @@ -46,24 +46,25 @@ daytoday.html = function html(client) { return ret; }; -daytoday.prepareHtml = function daytodayPrepareHtml(daystoshow) { +daytoday.prepareHtml = function daytodayPrepareHtml(sorteddaystoshow) { $('#daytodaycharts').html(''); - for (var d in daystoshow) { + sorteddaystoshow.forEach(function eachDay(d) { $('#daytodaycharts').append($('
    ')); - } + }); }; -daytoday.report = function report_daytoday(datastorage,daystoshow,options) { +daytoday.report = function report_daytoday(datastorage,sorteddaystoshow,options) { var Nightscout = window.Nightscout; var client = Nightscout.client; + var translate = client.translate; var profile = client.sbx.data.profile; var report_plugins = Nightscout.report_plugins; var scaledTreatmentBG = report_plugins.utils.scaledTreatmentBG; var padding = { top: 15, right: 22, bottom: 30, left: 35 }; - daytoday.prepareHtml(daystoshow) ; - _.each(daystoshow, function (n, day) { + daytoday.prepareHtml(sorteddaystoshow) ; + sorteddaystoshow.forEach( function eachDay(day) { drawChart(day,datastorage[day],options); }); @@ -419,7 +420,7 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { .attr('fill', 'purple') .attr('y', yScale2(scaledTreatmentBG(treatment,data.sgv)) + padding.top -10) .attr('x', xScale2(treatment.mills) + padding.left + 10) - .text(treatment.eventType); + .text(translate(client.careportal.resolveEventName(treatment.eventType))); } }); } diff --git a/lib/report_plugins/glucosedistribution.js b/lib/report_plugins/glucosedistribution.js index 5f5fef990a4..a606d3d91bc 100644 --- a/lib/report_plugins/glucosedistribution.js +++ b/lib/report_plugins/glucosedistribution.js @@ -46,7 +46,7 @@ glucosedistribution.css = -glucosedistribution.report = function report_glucosedistribution(datastorage,daystoshow,options) { +glucosedistribution.report = function report_glucosedistribution(datastorage,sorteddaystoshow,options) { var Nightscout = window.Nightscout; var client = Nightscout.client; var translate = client.translate; diff --git a/lib/report_plugins/hourlystats.js b/lib/report_plugins/hourlystats.js index 4ba0bd6f1da..552f5a460e2 100644 --- a/lib/report_plugins/hourlystats.js +++ b/lib/report_plugins/hourlystats.js @@ -22,7 +22,7 @@ hourlystats.html = function html(client) { return ret; }; -hourlystats.report = function report_hourlystats(datastorage, daystoshow, options) { +hourlystats.report = function report_hourlystats(datastorage, sorteddaystoshow, options) { //console.log(window); var ss = require('simple-statistics'); var Nightscout = window.Nightscout; @@ -57,16 +57,7 @@ hourlystats.report = function report_hourlystats(datastorage, daystoshow, option [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23].forEach(function(hour) { var tr = $(''); - var display = hour % 12; - if (hour === 0) { - display = '12'; - } - display += ':00 '; - if (hour >= 12) { - display += 'PM'; - } else { - display += 'AM'; - } + var display = new Date(0, 0 , 1, hour, 0, 0, 0).toLocaleTimeString().replace(/([\d]+:[\d]{2})(:[\d]{2})(.*)/, '$1$3'); var avg = Math.floor(pivotedByHour[hour].map(function(r) { return r.sgv; }).reduce(function(o,v){ return o+v; }, 0) / pivotedByHour[hour].length); var d = new Date(hour.hours()); diff --git a/lib/report_plugins/index.js b/lib/report_plugins/index.js index b2c929ec778..91c8ea4a66c 100644 --- a/lib/report_plugins/index.js +++ b/lib/report_plugins/index.js @@ -6,6 +6,8 @@ function init() { var consts = { SCALE_LINEAR: 0 , SCALE_LOG: 1 + , ORDER_OLDESTONTOP: 0 + , ORDER_NEWESTONTOP: 1 } , allPlugins = [ require('./daytoday')() diff --git a/lib/report_plugins/percentile.js b/lib/report_plugins/percentile.js index 43ab7123719..9da62a906ad 100644 --- a/lib/report_plugins/percentile.js +++ b/lib/report_plugins/percentile.js @@ -23,7 +23,7 @@ percentile.html = function html(client) { return ret; }; -percentile.report = function report_percentile(datastorage,daystoshow,options) { +percentile.report = function report_percentile(datastorage, sorteddaystoshow, options) { var Nightscout = window.Nightscout; var client = Nightscout.client; var translate = client.translate; diff --git a/lib/report_plugins/success.js b/lib/report_plugins/success.js index f0f9929004d..8ecc924b5df 100644 --- a/lib/report_plugins/success.js +++ b/lib/report_plugins/success.js @@ -21,7 +21,7 @@ success.html = function html(client) { return ret; }; -success.report = function report_success(datastorage,daystoshow,options) { +success.report = function report_success(datastorage, sorteddaystoshow, options) { var Nightscout = window.Nightscout; var client = Nightscout.client; var translate = client.translate; diff --git a/lib/report_plugins/treatments.js b/lib/report_plugins/treatments.js index d95fcf43a67..443ef6eadb6 100644 --- a/lib/report_plugins/treatments.js +++ b/lib/report_plugins/treatments.js @@ -66,7 +66,7 @@ treatments.html = function html(client) { return ret; }; -treatments.report = function report_treatments(datastorage, daystoshow, options) { +treatments.report = function report_treatments(datastorage, sorteddaystoshow, options) { var Nightscout = window.Nightscout; var client = Nightscout.client; var translate = client.translate; @@ -235,13 +235,16 @@ treatments.report = function report_treatments(datastorage, daystoshow, options) .append($('') .append($(' + + + +
    ')) + .append($('').css('width','80px').attr('align','left').append(translate('Time'))) + .append($('').css('width','150px').attr('align','left').append(translate('Event Type'))) + .append($('').css('width','150px').attr('align','left').append(translate('Blood Glucose'))) + .append($('').css('width','50px').attr('align','left').append(translate('Insulin'))) + .append($('').css('width','50px').attr('align','left').append(translate('Carbs'))) + .append($('').css('width','150px').attr('align','left').append(translate('Entered By'))) + .append($('').css('width','300px').attr('align','left').append(translate('Notes'))) + ); Object.keys(daystoshow).forEach(function (day) { - table += '
    '+report_plugins.utils.localeDate(day)+'
    ').attr('colspan','8').css('background','lightgray') + .append($('').append(report_plugins.utils.localeDate(day))) + ) + ); var treatments = datastorage[day].treatments; for (var t=0; t'; - table += ' '; - table += ''; - table += ''+(new Date(tr.created_at).toLocaleTimeString().replace(/([\d]+:[\d]{2})(:[\d]{2})(.*)/, '$1$3'))+''+(tr.eventType ? translate(resolveEventName(tr.eventType)) : '')+''+(tr.glucose ? tr.glucose + ' ('+translate(tr.glucoseType)+')' : '')+''+(tr.insulin ? tr.insulin : '')+''+(tr.carbs ? tr.carbs : '')+''+(tr.enteredBy ? tr.enteredBy : '')+''+(tr.notes ? tr.notes : '')+'
    ') + .append($('').addClass('deleteTreatment').css('cursor','pointer').attr('title',translate('Delete record')).attr('src',icon_remove).attr('data',JSON.stringify(tr)).attr('day',day)) + .append(' ') + .append($('').addClass('editTreatment').css('cursor','pointer').attr('title',translate('Edit record')).attr('src',icon_edit).attr('data',JSON.stringify(tr)).attr('day',day)) + ) + .append($('').append(new Date(tr.created_at).toLocaleTimeString().replace(/([\d]+:[\d]{2})(:[\d]{2})(.*)/, '$1$3'))) + .append($('').append(tr.eventType ? translate(resolveEventName(tr.eventType)) : '')) + .append($('').attr('align','center').append(tr.glucose ? tr.glucose + ' ('+translate(tr.glucoseType)+')' : '')) + .append($('').attr('align','center').append(tr.insulin ? tr.insulin : '')) + .append($('').attr('align','center').append(tr.carbs ? tr.carbs : '')) + .append($('').append(tr.enteredBy ? tr.enteredBy : '')) + .append($('').append(tr.notes ? tr.notes : '')) + ); } }); $('#treatments-report').html(table); From 816caa296e182e3a58e8417ad00825988565fa8b Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Fri, 4 Sep 2015 23:21:31 +0200 Subject: [PATCH 047/176] fix mg/dl vs mg/dL issue --- static/report/js/report.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/report/js/report.js b/static/report/js/report.js index bcfb0dba14b..6b54a558958 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -163,8 +163,8 @@ }); $('#rp_eventtype').append(''); - $('#rp_targetlow').val(targetBGdefault[client.settings.units].low); - $('#rp_targethigh').val(targetBGdefault[client.settings.units].high); + $('#rp_targetlow').val(targetBGdefault[client.settings.units.toLowerCase()].low); + $('#rp_targethigh').val(targetBGdefault[client.settings.units.toLowerCase()].high); $('.menutab').click(switchreport_handler); From 33f4555a792b225a7dbc100e9b1f23165b313b7b Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 4 Sep 2015 23:47:07 +0200 Subject: [PATCH 048/176] check basal object in profileeditor too --- static/profile/js/profileeditor.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/static/profile/js/profileeditor.js b/static/profile/js/profileeditor.js index 7f8c3e39f24..92309e89523 100644 --- a/static/profile/js/profileeditor.js +++ b/static/profile/js/profileeditor.js @@ -122,6 +122,7 @@ if (typeof profile.sens !== 'object') { profile.sens = [{ 'time': '00:00', 'value': profile.sens }]; } if (typeof profile.target_low !== 'object') { profile.target_low = [{ 'time': '00:00', 'value': profile.target_low }]; } if (typeof profile.target_high !== 'object') { profile.target_high = [{ 'time': '00:00', 'value': profile.target_high }]; } + if (typeof profile.basal !== 'object') { profile.basal = [{ 'time': '00:00', 'value': profile.basal }]; } if (profile.target_high.length !== profile.target_low.length) { alert('Time ranges of target_low and target_high don\'t match. Values are restored to defaults.'); profile.target_low = _.cloneDeep(defaultprofile.target_low); @@ -513,4 +514,4 @@ return false; } -})(); \ No newline at end of file +})(); From 68cf970aa1b7f50c352265716649c030073e568a Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sat, 5 Sep 2015 00:13:00 +0200 Subject: [PATCH 049/176] use profile timezone --- static/report/js/report.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/static/report/js/report.js b/static/report/js/report.js index 6b54a558958..64a24fa12c4 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -140,6 +140,16 @@ // ****** FOOD CODE END ****** + function getTimeZoneOffset () { + var offset; + if (client.sbx.data.profile.getTimezone()) { + offset = moment().tz(client.sbx.data.profile.getTimezone())._offset; + } else { + offset = new Date().getTimezoneOffset(); + } + return offset; + } + function prepareGUI() { $('.presetdates').click(function(event) { var days = $(this).attr('days'); @@ -486,7 +496,7 @@ , calData = [] ; var dt = new Date(day); - var from = dt.getTime() + dt.getTimezoneOffset() * 60 * 1000; + var from = dt.getTime() + getTimeZoneOffset() * 60 * 1000; var to = from + 1000 * 60 * 60 * 24; var query = '?find[date][$gte]='+from+'&find[date][$lt]='+to+'&count=10000'; @@ -588,7 +598,7 @@ data.sgv = data.sgv.concat(data.mbg.map(function (obj) { return { date: new Date(obj.mills), y: obj.y, sgv: client.utils.scaleMgdl(obj.y), color: 'red', type: 'mbg', device: obj.device } })); // make sure data range will be exactly 24h - var from = new Date(new Date(day).getTime() + (new Date().getTimezoneOffset()*60*1000)); + var from = new Date(new Date(day).getTime() + (getTimeZoneOffset() * 60 * 1000)); var to = new Date(from.getTime() + 1000 * 60 * 60 * 24); data.sgv.push({ date: from, y: 40, sgv: 40, color: 'transparent', type: 'rawbg'}); data.sgv.push({ date: to, y: 40, sgv: 40, color: 'transparent', type: 'rawbg'}); From bbe760abc2ef0d067c31f7ddb46b132dbe7f317c Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sat, 5 Sep 2015 00:49:46 +0200 Subject: [PATCH 050/176] 1 day shift fix --- lib/report_plugins/utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/report_plugins/utils.js b/lib/report_plugins/utils.js index d5e00cc3f1d..fb3d1e190b5 100644 --- a/lib/report_plugins/utils.js +++ b/lib/report_plugins/utils.js @@ -13,12 +13,12 @@ utils.localeDate = function localeDate(day) { var ret = [translate('Sunday'),translate('Monday'),translate('Tuesday'),translate('Wednesday'),translate('Thursday'),translate('Friday'),translate('Saturday')][new Date(day).getDay()]; ret += ' '; - ret += new Date(day).toLocaleDateString(); + ret += new Date(day + ' 00:00:00').toLocaleDateString(); return ret; }; utils.localeDateTime = function localeDateTime(day) { - var ret = new Date(day).toLocaleDateString() + ' ' + new Date(day).toLocaleTimeString(); + var ret = new Date(day + ' 00:00:00').toLocaleDateString() + ' ' + new Date(day).toLocaleTimeString(); return ret; }; From 2164ea2ace0e2138e65b7fd7fc1a43ae6f77c1a1 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sat, 5 Sep 2015 08:59:42 +0200 Subject: [PATCH 051/176] fixed day name too --- lib/report_plugins/utils.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/report_plugins/utils.js b/lib/report_plugins/utils.js index fb3d1e190b5..e8cf86158f6 100644 --- a/lib/report_plugins/utils.js +++ b/lib/report_plugins/utils.js @@ -10,15 +10,17 @@ module.exports = init; utils.localeDate = function localeDate(day) { var translate = Nightscout.client.translate; + var date = new Date(day + ' 00:00:00'); var ret = - [translate('Sunday'),translate('Monday'),translate('Tuesday'),translate('Wednesday'),translate('Thursday'),translate('Friday'),translate('Saturday')][new Date(day).getDay()]; + [translate('Sunday'),translate('Monday'),translate('Tuesday'),translate('Wednesday'),translate('Thursday'),translate('Friday'),translate('Saturday')][date.getDay()]; ret += ' '; - ret += new Date(day + ' 00:00:00').toLocaleDateString(); + ret += date.toLocaleDateString(); return ret; }; utils.localeDateTime = function localeDateTime(day) { - var ret = new Date(day + ' 00:00:00').toLocaleDateString() + ' ' + new Date(day).toLocaleTimeString(); + var date = new Date(day + ' 00:00:00'); + var ret = date.toLocaleDateString() + ' ' + date.toLocaleTimeString(); return ret; }; From dd015ba1020769c3cf16a78f8ad24531992b3def Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sat, 5 Sep 2015 00:20:04 -0700 Subject: [PATCH 052/176] support for per event alarm settings, use same setting for browser and pushover --- README.md | 24 +++++++++---- lib/client/index.js | 7 ++++ lib/pushnotify.js | 7 ++-- lib/settings.js | 77 ++++++++++++++++++++++++++++++++++++++++-- static/index.html | 7 +--- tests/settings.test.js | 23 +++++++++++++ 6 files changed, 129 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index fe85ee1a0b5..84a9b73143e 100644 --- a/README.md +++ b/README.md @@ -142,18 +142,34 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm * `MONGO_CONNECTION` - Your mongo uri, for example: `mongodb://sally:sallypass@ds099999.mongolab.com:99999/nightscout` * `DISPLAY_UNITS` (`mg/dl`) - Choices: `mg/dl` and `mmol`. Setting to `mmol` puts the entire server into `mmol` mode by default, no further settings needed. + * `BASE_URL` - Used for building links to your sites api, ie pushover callbacks, usually the URL of your Nightscout site you may want https instead of http ### Features/Labs * `ENABLE` - Used to enable optional features, expects a space delimited list, such as: `careportal rawbg iob`, see [plugins](#plugins) below * `DISABLE` - Used to disable default features, expects a space delimited list, such as: `direction upbat`, see [plugins](#plugins) below * `API_SECRET` - A secret passphrase that must be at least 12 characters long, required to enable `POST` and `PUT`; also required for the Care Portal + + +### Alarms + + These alarm setting effect all delivery methods (browser, pushover, maker, etc), some settings can be overridden per client (web browser) + + * `ALARM_TYPES` (`simple` if any `BG_`* ENV's are set, otherwise `predict`) - currently 2 alarm types are supported, and can be used independently or combined. The `simple` alarm type only compares the current BG to `BG_` thresholds above, the `predict` alarm type uses highly tuned formula that forecasts where the BG is going based on it's trend. `predict` **DOES NOT** currently use any of the `BG_`* ENV's * `BG_HIGH` (`260`) - must be set using mg/dl units; the high BG outside the target range that is considered urgent * `BG_TARGET_TOP` (`180`) - must be set using mg/dl units; the top of the target range, also used to draw the line on the chart * `BG_TARGET_BOTTOM` (`80`) - must be set using mg/dl units; the bottom of the target range, also used to draw the line on the chart * `BG_LOW` (`55`) - must be set using mg/dl units; the low BG outside the target range that is considered urgent - * `ALARM_TYPES` (`simple` if any `BG_`* ENV's are set, otherwise `predict`) - currently 2 alarm types are supported, and can be used independently or combined. The `simple` alarm type only compares the current BG to `BG_` thresholds above, the `predict` alarm type uses highly tuned formula that forecasts where the BG is going based on it's trend. `predict` **DOES NOT** currently use any of the `BG_`* ENV's - * `BASE_URL` - Used for building links to your sites api, ie pushover callbacks, usually the URL of your Nightscout site you may want https instead of http + * `ALARM_URGENT_HIGH` (`on`) - possible values `on` or `off` + * `ALARM_URGENT_HIGH_MINS` (`30 60 90 120`) - Number of minutes to snooze urgent high alarms, space separated for options in browser, first used for pushover + * `ALARM_HIGH` (`on`) - possible values `on` or `off` + * `ALARM_HIGH_MINS` (`30 60 90 120`) - Number of minutes to snooze high alarms, space separated for options in browser, first used for pushover + * `ALARM_LOW` (`on`) - possible values `on` or `off` + * `ALARM_LOW_MINS` (`30 60 90 120`) - Number of minutes to snooze low alarms, space separated for options in browser, first used for pushover + * `ALARM_URGENT_LOW` (`on`) - possible values `on` or `off` + * `ALARM_URGENT_LOW_MINS` (`30 60 90 120`) - Number of minutes to snooze urgent low alarms, space separated for options in browser, first used for pushover + * `ALARM_URGENT_MINS` (`30 60 90 120`) - Number of minutes to snooze urgent alarms (that aren't tagged as high or low), space separated for options in browser, first used for pushover + * `ALARM_WARN_MINS` (`30 60 90 120`) - Number of minutes to snooze warning alarms (that aren't tagged as high or low), space separated for options in browser, first used for pushover ### Core @@ -173,10 +189,6 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm * `SHOW_RAWBG` (`never`) - possible values `always`, `never` or `noise` * `CUSTOM_TITLE` (`Nightscout`) - Usually name of T1 * `THEME` (`default`) - possible values `default` or `colors` - * `ALARM_URGENT_HIGH` (`on`) - possible values `on` or `off` - * `ALARM_HIGH` (`on`) - possible values `on` or `off` - * `ALARM_LOW` (`on`) - possible values `on` or `off` - * `ALARM_URGENT_LOW` (`on`) - possible values `on` or `off` * `ALARM_TIMEAGO_WARN` (`on`) - possible values `on` or `off` * `ALARM_TIMEAGO_WARN_MINS` (`15`) - minutes since the last reading to trigger a warning * `ALARM_TIMEAGO_URGENT` (`on`) - possible values `on` or `off` diff --git a/lib/client/index.js b/lib/client/index.js index f2dba0e9a2e..c78afe64dc4 100644 --- a/lib/client/index.js +++ b/lib/client/index.js @@ -405,6 +405,13 @@ client.init = function init(serverSettings, plugins) { container.addClass('alarming').addClass(file === urgentAlarmSound ? 'urgent' : 'warning'); + var silenceBtn = $('#silenceBtn'); + silenceBtn.empty(); + + _.each(client.settings.snoozeMinsForAlarmEvent(notify), function eachOption (mins) { + silenceBtn.append('
  • Silence for ' + mins + ' minutes
  • '); + }); + updateTitle(); } diff --git a/lib/pushnotify.js b/lib/pushnotify.js index e6cd18d5c25..8ceaa71dcf3 100644 --- a/lib/pushnotify.js +++ b/lib/pushnotify.js @@ -40,7 +40,9 @@ function init(env, ctx) { if (recentlySent.get(key)) { console.info('notify: ' + key + ' has ALREADY been sent'); - + return; + } else if (!env.settings.isAlarmEventEnabled(notify)) { + console.info('notify: ' + key + ' will NOT be sent, it\'s been disabled'); return; } @@ -57,7 +59,8 @@ function init(env, ctx) { var notify = receipts.get(response.receipt); console.info('push ack, response: ', response, ', notify: ', notify); if (notify) { - ctx.notifications.ack(notify.level, times.mins(30).msecs, true); + var snoozeMins = env.settings.snoozeFirstMinsForAlarmEvent(notify); + ctx.notifications.ack(notify.level, times.mins(snoozeMins).msecs, true); receipts.del(response.receipt); } return !!notify; diff --git a/lib/settings.js b/lib/settings.js index c2f2c7d3669..52fa6086117 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -1,6 +1,7 @@ 'use strict'; var _ = require('lodash'); +var levels = require('./levels'); function init ( ) { @@ -12,9 +13,15 @@ function init ( ) { , customTitle: 'Nightscout' , theme: 'default' , alarmUrgentHigh: true + , alarmUrgentHighMins: [30, 60, 90, 120] , alarmHigh: true + , alarmHighMins: [30, 60, 90, 120] , alarmLow: true + , alarmLowMins: [15, 30, 45, 60] , alarmUrgentLow: true + , alarmUrgentLowMins: [15, 30, 45] + , alarmUrgentMins: [30, 60, 90, 120] + , alarmWarnMins: [30, 60, 90, 120] , alarmTimeagoWarn: true , alarmTimeagoWarnMins: 15 , alarmTimeagoUrgent: true @@ -29,13 +36,37 @@ function init ( ) { } }; + var valueMappers = { + alarmUrgentHighMins: mapNumberArray + , alarmHighMins: mapNumberArray + , alarmLowMins: mapNumberArray + , alarmUrgentLowMins: mapNumberArray + , alarmUrgentMins: mapNumberArray + , alarmWarnMins: mapNumberArray + }; + + function mapNumberArray (value) { + if (!value || _.isArray(value)) { + return value; + } + + if (isNaN(value)) { + var rawValues = value && value.split(' ') || []; + return _.map(rawValues, function (num) { + return isNaN(num) ? null : Number(num) + }); + } else { + return value; + } + } + //TODO: getting sent in status.json, shouldn't be settings.DEFAULT_FEATURES = ['delta', 'direction', 'upbat', 'errorcodes']; var wasSet = []; function isSimple (value) { - return typeof value !== 'function' && typeof value !== 'object'; + return _.isArray(value) || (typeof value !== 'function' && typeof value !== 'object'); } function nameFromKey (key, nameType) { @@ -49,8 +80,9 @@ function init ( ) { if (isSimple(value)) { var newValue = accessor(nameFromKey(key, nameType)); if (newValue !== undefined) { + var mapper = valueMappers[key]; wasSet.push(key); - keys[key] = newValue; + keys[key] = mapper ? mapper(newValue) : newValue; } } }); @@ -183,9 +215,50 @@ function init ( ) { return enabled; } + function isAlarmEventEnabled (notify) { + var enabled = false; + + if (!notify.eventName) { + enabled = true; + } else if (notify.eventName === 'high' && notify.level === levels.URGENT && settings.alarmUrgentHigh) { + enabled = true; + } else if (notify.eventName === 'high' && settings.alarmHigh) { + enabled = true; + } else if (notify.eventName === 'low' && notify.level === levels.URGENT && settings.alarmUrgentLow) { + enabled = true; + } else if (notify.eventName === 'low' && settings.alarmLow) { + enabled = true; + } + + return enabled; + } + + function snoozeMinsForAlarmEvent (notify) { + var snoozeTime = [30]; + + if (notify.eventName === 'high' && notify.level === levels.URGENT && settings.alarmUrgentHigh) { + snoozeTime = settings.alarmUrgentHighMins || snoozeTime; + } else if (notify.eventName === 'high' && settings.alarmHigh) { + snoozeTime = settings.alarmHighMins || snoozeTime; + } else if (notify.eventName === 'low' && notify.level === levels.URGENT && settings.alarmUrgentLow) { + snoozeTime = settings.alarmUrgentLowMins || snoozeTime; + } else if (notify.eventName === 'low' && settings.alarmLow) { + snoozeTime = settings.alarmLowMins || snoozeTime; + } + + return snoozeTime; + } + + function snoozeFirstMinsForAlarmEvent (notify) { + return _.first(snoozeMinsForAlarmEvent(notify)); + } + settings.eachSetting = eachSettingAs(); settings.eachSettingAsEnv = eachSettingAs('env'); settings.isEnabled = isEnabled; + settings.isAlarmEventEnabled = isAlarmEventEnabled; + settings.snoozeMinsForAlarmEvent = snoozeMinsForAlarmEvent; + settings.snoozeFirstMinsForAlarmEvent = snoozeFirstMinsForAlarmEvent; return settings; diff --git a/static/index.html b/static/index.html index 49b39e28ece..6025134e61e 100644 --- a/static/index.html +++ b/static/index.html @@ -52,12 +52,7 @@ --- - +
    diff --git a/tests/settings.test.js b/tests/settings.test.js index 9baaffaff35..712928a2a29 100644 --- a/tests/settings.test.js +++ b/tests/settings.test.js @@ -2,6 +2,7 @@ var _ = require('lodash'); var should = require('should'); +var levels = require('../lib/levels'); describe('settings', function ( ) { var settings = require('../lib/settings')(); @@ -13,9 +14,15 @@ describe('settings', function ( ) { settings.customTitle.should.equal('Nightscout'); settings.theme.should.equal('default'); settings.alarmUrgentHigh.should.equal(true); + settings.alarmUrgentHighMins.should.eql([30, 60, 90, 120]); settings.alarmHigh.should.equal(true); + settings.alarmHighMins.should.eql([30, 60, 90, 120]); settings.alarmLow.should.equal(true); + settings.alarmLowMins.should.eql([15, 30, 45, 60]); settings.alarmUrgentLow.should.equal(true); + settings.alarmUrgentLowMins.should.eql([15, 30, 45]); + settings.alarmUrgentMins.should.eql([30, 60, 90, 120]); + settings.alarmWarnMins.should.eql([30, 60, 90, 120]); settings.alarmTimeagoWarn.should.equal(true); settings.alarmTimeagoWarnMins.should.equal(15); settings.alarmTimeagoUrgent.should.equal(true); @@ -128,6 +135,22 @@ describe('settings', function ( ) { fresh.enable.length.should.equal(0); }); + it('parse custom snooze mins', function () { + var userSetting = { + ALARM_URGENT_LOW_MINS: '5 10 15' + }; + + var fresh = require('../lib/settings')(); + fresh.eachSettingAsEnv(function (name) { + return userSetting[name]; + }); + + fresh.alarmUrgentLowMins.should.eql([5, 10, 15]); + + fresh.snoozeMinsForAlarmEvent({eventName: 'low', level: levels.URGENT}).should.eql([5, 10, 15]); + fresh.snoozeFirstMinsForAlarmEvent({eventName: 'low', level: levels.URGENT}).should.equal(5); + }); + it('set thresholds', function () { var userThresholds = { BG_HIGH: '200' From 09a8f62444166f42a41328e55b2bd17f73939074 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sat, 5 Sep 2015 00:26:57 -0700 Subject: [PATCH 053/176] fix license should be a valid SPDX license expression warning --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a73740cbe41..cee77d81bd5 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "Nightscout", "version": "0.8.0", "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": "AGPL3", + "license": "AGPL-3.0", "author": "Nightscout Team", "homepage": "http://nightscout.github.io/", "keywords": [ From abca6a097ca3db54f48a22a7c6d7b9daf51b9d28 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sat, 5 Sep 2015 00:30:34 -0700 Subject: [PATCH 054/176] update readme toc --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 84a9b73143e..bb25961fb4b 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ Community maintained fork of the - [Environment](#environment) - [Required](#required) - [Features/Labs](#featureslabs) + - [Alarms](#alarms) - [Core](#core) - [Predefined values for your browser settings (optional)](#predefined-values-for-your-browser-settings-optional) - [Plugins](#plugins) From 4b4633ccc35f681217c9a46c9314152144700b16 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sat, 5 Sep 2015 01:47:59 -0700 Subject: [PATCH 055/176] include serverTime in status --- lib/api/status.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/api/status.js b/lib/api/status.js index 26bbe9d133e..2e3eeefb8a2 100644 --- a/lib/api/status.js +++ b/lib/api/status.js @@ -13,6 +13,7 @@ function configure (app, wares, env) { var info = { status: 'ok' , name: app.get('name') , version: app.get('version') + , serverTime: new Date().toISOString() , apiEnabled: app.enabled('api') , careportalEnabled: app.enabled('api') && env.settings.enable.indexOf('careportal') > -1 , head: wares.get_head( ) From 0123da3cdaaf9e56bf0d07bf5976b8ff9c35dbe2 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sat, 5 Sep 2015 01:48:45 -0700 Subject: [PATCH 056/176] move baseUrl to settings and add heartbeat to env and readme --- README.md | 1 + env.js | 1 - lib/bus.js | 4 +++- lib/plugins/pushover.js | 4 ++-- lib/settings.js | 2 ++ tests/pushover.test.js | 4 +++- 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fe85ee1a0b5..ac94951a9de 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,7 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm * `SSL_KEY` - Path to your ssl key file, so that ssl(https) can be enabled directly in node.js * `SSL_CERT` - Path to your ssl cert file, so that ssl(https) can be enabled directly in node.js * `SSL_CA` - Path to your ssl ca file, so that ssl(https) can be enabled directly in node.js + * `HEARTBEAT` (`60`) - Number of seconds to wait in between database checks ### Predefined values for your browser settings (optional) diff --git a/env.js b/env.js index c12c4c32a4a..ec44b0a5616 100644 --- a/env.js +++ b/env.js @@ -17,7 +17,6 @@ function config ( ) { */ env.DISPLAY_UNITS = readENV('DISPLAY_UNITS', 'mg/dl'); env.PORT = readENV('PORT', 1337); - env.baseUrl = readENV('BASE_URL'); env.static_files = readENV('NIGHTSCOUT_STATIC_FILES', __dirname + '/static/'); setSSL(); diff --git a/lib/bus.js b/lib/bus.js index 10dbad2e3d1..11dd7337939 100644 --- a/lib/bus.js +++ b/lib/bus.js @@ -1,9 +1,11 @@ +'use strict'; + var Stream = require('stream'); function init (env) { var beats = 0; var started = new Date( ); - var interval = env.HEARTBEAT || 60000; + var interval = env.settings.heartbeat * 1000; var stream = new Stream; diff --git a/lib/plugins/pushover.js b/lib/plugins/pushover.js index 23d615fc84c..f05892006b3 100644 --- a/lib/plugins/pushover.js +++ b/lib/plugins/pushover.js @@ -30,8 +30,8 @@ function init (env) { if (levels.isAlarm(notify.level)) { //ADJUST RETRY TIME based on WARN or URGENT msg.retry = notify.level === levels.URGENT ? times.mins(2).secs : times.mins(15).secs; - if (env.baseUrl) { - msg.callback = env.baseUrl + '/api/v1/notifications/pushovercallback'; + if (env.settings && env.settings.baseUrl) { + msg.callback = env.settings.baseUrl + '/api/v1/notifications/pushovercallback'; } } diff --git a/lib/settings.js b/lib/settings.js index c2f2c7d3669..5e3394ec170 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -21,6 +21,8 @@ function init ( ) { , alarmTimeagoUrgentMins: 30 , language: 'en' , showPlugins: '' + , heartbeat: 60 + , baseURL: '' , thresholds: { bgHigh: 260 , bgTargetTop: 180 diff --git a/tests/pushover.test.js b/tests/pushover.test.js index 609ebf63f11..88d9b7dec86 100644 --- a/tests/pushover.test.js +++ b/tests/pushover.test.js @@ -8,7 +8,9 @@ describe('pushover', function ( ) { var baseurl = 'https://nightscout.test'; var env = { - baseUrl: baseurl + settings: { + baseUrl: baseurl + } , extendedSettings: { pushover: { userKey: '12345' From 34297807b9d3d38958dfeaacf04dbcd2516e92a2 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sat, 5 Sep 2015 02:33:34 -0700 Subject: [PATCH 057/176] added new PUSHOVER_ALARM_KEY with this pushover alarms can be disabled also info level pushes (treatments) can be disabled --- README.md | 5 ++-- lib/plugins/pushover.js | 53 ++++++++++++++++++++++++++++++++++------- 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index bb25961fb4b..bd561017977 100644 --- a/README.md +++ b/README.md @@ -266,8 +266,9 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm * `ENABLE` - `pushover` should be added to the list of plugin, for example: `ENABLE="pushover"`. * `PUSHOVER_API_TOKEN` - Used to enable pushover notifications, this token is specific to the application you create from in [Pushover](https://pushover.net/), ***[additional pushover information](#pushover)*** below. - * `PUSHOVER_USER_KEY` - Your Pushover user key, can be found in the top left of the [Pushover](https://pushover.net/) site, this can also be a pushover delivery group key to send to a group rather than just a single user. This also support a space delimited list of keys. - * `PUSHOVER_ANNOUNCEMENT_KEY` - An optional Pushover user/group key, will be used for system wide user generated announcements. If not defined this will fallback to `PUSHOVER_USER_KEY`. A possible use for this is sending important messages and alarms to a CWD that you don't want to send all notification too. This also support a space delimited list of keys. + * `PUSHOVER_USER_KEY` - Your Pushover user key, can be found in the top left of the [Pushover](https://pushover.net/) site, this can also be a pushover delivery group key to send to a group rather than just a single user. This also supports a space delimited list of keys. To disable `INFO` level pushes set this to `off`. + * `PUSHOVER_ALARMS_KEY` - An optional Pushover user/group key, will be used for system wide alarms (level > `WARN`). If not defined this will fallback to `PUSHOVER_USER_KEY`. A possible use for this is sending important messages and alarms to a CWD that you don't want to send all notification too. This also support a space delimited list of keys. To disable Alarm pushes set this to `off`. + * `PUSHOVER_ANNOUNCEMENT_KEY` - An optional Pushover user/group key, will be used for system wide user generated announcements. If not defined this will fallback to `PUSHOVER_USER_KEY` or `PUSHOVER_ANNOUNCEMENT_KEY`. A possible use for this is sending important messages and alarms to a CWD that you don't want to send all notification too. This also support a space delimited list of keys. To disable Announcement pushes set this to `off`. * `BASE_URL` - Used for pushover callbacks, usually the URL of your Nightscout site, use https when possible. * `API_SECRET` - Used for signing the pushover callback request for acknowledgments. diff --git a/lib/plugins/pushover.js b/lib/plugins/pushover.js index 23d615fc84c..d88786d4b2b 100644 --- a/lib/plugins/pushover.js +++ b/lib/plugins/pushover.js @@ -14,8 +14,29 @@ function init (env) { var pushoverAPI = setupPushover(env); - pushover.send = function wrapSend(notify, callback) { - var selectedKeys = notify.isAnnouncement ? pushoverAPI.announcementKeys : pushoverAPI.userKeys; + function selectKeys (notify) { + var keys = null; + + if (notify.isAnnouncement) { + keys = pushoverAPI.announcementKeys; + } else if (levels.isAlarm(notify.level)) { + keys = pushoverAPI.alarmKeys; + } else { + keys = pushoverAPI.userKeys; + } + + return keys; + } + + pushover.send = function wrapSend (notify, callback) { + var selectedKeys = selectKeys(notify); + + if (selectedKeys.length == 0) { + console.info('No Pushover Keys defined for', notify); + if (callback) { + return callback(); + } + } var msg = { expire: times.mins(15).secs @@ -76,24 +97,38 @@ function init (env) { function setupPushover (env) { var apiToken = env.extendedSettings && env.extendedSettings.pushover && env.extendedSettings.pushover.apiToken; - var userKeys = (env.extendedSettings && env.extendedSettings.pushover && - env.extendedSettings.pushover.userKey && env.extendedSettings.pushover.userKey.split(' ')) || []; + function keysByType (type, fallback) { + fallback = fallback || []; + + var key = env.extendedSettings && env.extendedSettings.pushover && env.extendedSettings.pushover[type]; + + if (key === 'off') { + return []; //don't consider fallback, this type has been disabled + } else if (key && key.split) { + return key.split(' ') || fallback; + } else { + return fallback; + } + } + + var userKeys = keysByType('userKey', []); if (userKeys.length === 0) { - userKeys = (env.extendedSettings && env.extendedSettings.pushover && - env.extendedSettings.pushover.groupKey && env.extendedSettings.pushover.groupKey.split(' ')) || []; + userKeys = keysByType('groupKey') || []; } - var announcementKeys = (env.extendedSettings && env.extendedSettings.pushover && - env.extendedSettings.pushover.announcementKey && env.extendedSettings.pushover.announcementKey.split(' ')) || userKeys; + var alarmKeys = keysByType('alarmKey', userKeys); + + var announcementKeys = keysByType('announcementKey', userKeys || alarmKeys); - if (apiToken && (userKeys.length > 0 || announcementKeys.length > 0)) { + if (apiToken && (userKeys.length > 0 || alarmKeys.length > 0 || announcementKeys.length > 0)) { var pushoverAPI = new Pushover({ token: apiToken }); pushoverAPI.apiToken = apiToken; pushoverAPI.userKeys = userKeys; + pushoverAPI.alarmKeys = alarmKeys; pushoverAPI.announcementKeys = announcementKeys; return pushoverAPI; From addf8e6454cd5f78f3653eb769f2d5dddf20f1e7 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sat, 5 Sep 2015 02:38:46 -0700 Subject: [PATCH 058/176] fix typos --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bd561017977..7710f40c45d 100644 --- a/README.md +++ b/README.md @@ -267,8 +267,8 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm * `ENABLE` - `pushover` should be added to the list of plugin, for example: `ENABLE="pushover"`. * `PUSHOVER_API_TOKEN` - Used to enable pushover notifications, this token is specific to the application you create from in [Pushover](https://pushover.net/), ***[additional pushover information](#pushover)*** below. * `PUSHOVER_USER_KEY` - Your Pushover user key, can be found in the top left of the [Pushover](https://pushover.net/) site, this can also be a pushover delivery group key to send to a group rather than just a single user. This also supports a space delimited list of keys. To disable `INFO` level pushes set this to `off`. - * `PUSHOVER_ALARMS_KEY` - An optional Pushover user/group key, will be used for system wide alarms (level > `WARN`). If not defined this will fallback to `PUSHOVER_USER_KEY`. A possible use for this is sending important messages and alarms to a CWD that you don't want to send all notification too. This also support a space delimited list of keys. To disable Alarm pushes set this to `off`. - * `PUSHOVER_ANNOUNCEMENT_KEY` - An optional Pushover user/group key, will be used for system wide user generated announcements. If not defined this will fallback to `PUSHOVER_USER_KEY` or `PUSHOVER_ANNOUNCEMENT_KEY`. A possible use for this is sending important messages and alarms to a CWD that you don't want to send all notification too. This also support a space delimited list of keys. To disable Announcement pushes set this to `off`. + * `PUSHOVER_ALARM_KEY` - An optional Pushover user/group key, will be used for system wide alarms (level > `WARN`). If not defined this will fallback to `PUSHOVER_USER_KEY`. A possible use for this is sending important messages and alarms to a CWD that you don't want to send all notification too. This also support a space delimited list of keys. To disable Alarm pushes set this to `off`. + * `PUSHOVER_ANNOUNCEMENT_KEY` - An optional Pushover user/group key, will be used for system wide user generated announcements. If not defined this will fallback to `PUSHOVER_USER_KEY` or `PUSHOVER_ALARM_KEY`. A possible use for this is sending important messages and alarms to a CWD that you don't want to send all notification too. This also support a space delimited list of keys. To disable Announcement pushes set this to `off`. * `BASE_URL` - Used for pushover callbacks, usually the URL of your Nightscout site, use https when possible. * `API_SECRET` - Used for signing the pushover callback request for acknowledgments. From c71b43edd53e2cf63eecd5a0f8ba7c0c9bdc42ef Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sat, 5 Sep 2015 02:53:43 -0700 Subject: [PATCH 059/176] clean for codacy issues --- lib/plugins/pushover.js | 41 +++++++++++++++++++++++------------------ lib/settings.js | 2 +- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/lib/plugins/pushover.js b/lib/plugins/pushover.js index d88786d4b2b..b4a8666749a 100644 --- a/lib/plugins/pushover.js +++ b/lib/plugins/pushover.js @@ -31,30 +31,35 @@ function init (env) { pushover.send = function wrapSend (notify, callback) { var selectedKeys = selectKeys(notify); - if (selectedKeys.length == 0) { + function prepareMessage() { + var msg = { + expire: times.mins(15).secs + , title: notify.title + , message: notify.message + , sound: notify.pushoverSound || 'gamelan' + , timestamp: new Date() + //USE PUSHOVER_EMERGENCY for WARN and URGENT so we get the acks + , priority: notify.level >= levels.WARN ? pushover.PRIORITY_EMERGENCY : pushover.PRIORITY_NORMAL + }; + + if (levels.isAlarm(notify.level)) { + //ADJUST RETRY TIME based on WARN or URGENT + msg.retry = notify.level === levels.URGENT ? times.mins(2).secs : times.mins(15).secs; + if (env.baseUrl) { + msg.callback = env.baseUrl + '/api/v1/notifications/pushovercallback'; + } + } + return msg; + } + + if (selectedKeys.length === 0) { console.info('No Pushover Keys defined for', notify); if (callback) { return callback(); } } - var msg = { - expire: times.mins(15).secs - , title: notify.title - , message: notify.message - , sound: notify.pushoverSound || 'gamelan' - , timestamp: new Date() - //USE PUSHOVER_EMERGENCY for WARN and URGENT so we get the acks - , priority: notify.level >= levels.WARN ? pushover.PRIORITY_EMERGENCY : pushover.PRIORITY_NORMAL - }; - - if (levels.isAlarm(notify.level)) { - //ADJUST RETRY TIME based on WARN or URGENT - msg.retry = notify.level === levels.URGENT ? times.mins(2).secs : times.mins(15).secs; - if (env.baseUrl) { - msg.callback = env.baseUrl + '/api/v1/notifications/pushovercallback'; - } - } + var msg = prepareMessage(); _.each(selectedKeys, function eachKey(key) { msg.user = key; diff --git a/lib/settings.js b/lib/settings.js index 52fa6086117..5be924eeceb 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -53,7 +53,7 @@ function init ( ) { if (isNaN(value)) { var rawValues = value && value.split(' ') || []; return _.map(rawValues, function (num) { - return isNaN(num) ? null : Number(num) + return isNaN(num) ? null : Number(num); }); } else { return value; From 1ab11de9727179d23f6f4d5113b7f679b65d63d9 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sat, 5 Sep 2015 17:30:42 +0200 Subject: [PATCH 060/176] another date issue --- lib/report_plugins/utils.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/report_plugins/utils.js b/lib/report_plugins/utils.js index e8cf86158f6..ae33759fb05 100644 --- a/lib/report_plugins/utils.js +++ b/lib/report_plugins/utils.js @@ -10,7 +10,12 @@ module.exports = init; utils.localeDate = function localeDate(day) { var translate = Nightscout.client.translate; - var date = new Date(day + ' 00:00:00'); + var date; + if (typeof day === 'string') { + date = new Date(day + ' 00:00:00'); + } else { + date = day; + } var ret = [translate('Sunday'),translate('Monday'),translate('Tuesday'),translate('Wednesday'),translate('Thursday'),translate('Friday'),translate('Saturday')][date.getDay()]; ret += ' '; @@ -19,7 +24,12 @@ utils.localeDate = function localeDate(day) { }; utils.localeDateTime = function localeDateTime(day) { - var date = new Date(day + ' 00:00:00'); + var date; + if (typeof day === 'string') { + date = new Date(day + ' 00:00:00'); + } else { + date = day; + } var ret = date.toLocaleDateString() + ' ' + date.toLocaleTimeString(); return ret; }; From 93e520d39eb4f1e7eea6022de19f05d2f82cffcc Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sat, 5 Sep 2015 09:45:56 -0700 Subject: [PATCH 061/176] fix snooze bug by adding click handler as new snooze options are added --- lib/client/index.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/client/index.js b/lib/client/index.js index c78afe64dc4..2784def8218 100644 --- a/lib/client/index.js +++ b/lib/client/index.js @@ -409,12 +409,19 @@ client.init = function init(serverSettings, plugins) { silenceBtn.empty(); _.each(client.settings.snoozeMinsForAlarmEvent(notify), function eachOption (mins) { - silenceBtn.append('
  • Silence for ' + mins + ' minutes
  • '); + var snoozeOption = $('
  • Silence for ' + mins + ' minutes
  • '); + snoozeOption.click(snoozeAlarm); + silenceBtn.append(snoozeOption); }); updateTitle(); } + function snoozeAlarm (e) { + stopAlarm(true, $(this).data('snooze-time')); + e.preventDefault(); + } + function playAlarm(audio) { // ?mute=true disables alarms to testers. if (client.browserUtils.queryParms().mute !== 'true') { @@ -625,11 +632,6 @@ client.init = function init(serverSettings, plugins) { } }); - $('#silenceBtn').find('a').click(function (e) { - stopAlarm(true, $(this).data('snooze-time')); - e.preventDefault(); - }); - $('.focus-range li').click(function(e) { var li = $(e.target); $('.focus-range li').removeClass('selected'); From bbb8b0512c34ff64c9d49a2c55565fc5e4f32cf4 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sat, 5 Sep 2015 10:00:52 -0700 Subject: [PATCH 062/176] fixed a regresion bug with mmol in the clock mode --- bundle/bundle.source.js | 1 + static/clock.html | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bundle/bundle.source.js b/bundle/bundle.source.js index f9c9e195411..5548de99df5 100644 --- a/bundle/bundle.source.js +++ b/bundle/bundle.source.js @@ -7,6 +7,7 @@ window.Nightscout = { client: require('../lib/client') + , units: require('../lib/units')() , plugins: require('../lib/plugins/')().registerClientDefaults() }; diff --git a/static/clock.html b/static/clock.html index f633e177ec1..149265cfb13 100644 --- a/static/clock.html +++ b/static/clock.html @@ -53,7 +53,7 @@

    var rec = xhr[0]; var last = new Date(rec.date); var now = new Date( ); - if (window.serverSettings.units == 'mmol') { + if (window.serverSettings.settings.units == 'mmol') { rec.sgv = Nightscout.units.mgdlToMMOL(rec.sgv); } $('.bgnow').text(rec.sgv); From 01464c80699f54446eef6337d42be72d58f8429e Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sat, 5 Sep 2015 10:34:32 -0700 Subject: [PATCH 063/176] also look for alarmUrgentMins and alarmWarnMins if not high/low --- lib/settings.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/settings.js b/lib/settings.js index 5be924eeceb..aae7ab67e10 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -244,6 +244,10 @@ function init ( ) { snoozeTime = settings.alarmUrgentLowMins || snoozeTime; } else if (notify.eventName === 'low' && settings.alarmLow) { snoozeTime = settings.alarmLowMins || snoozeTime; + } else if (notify.level === levels.URGENT) { + snoozeTime = settings.alarmUrgentMins || snoozeTime; + } else if (notify.level === levels.WARN) { + snoozeTime = settings.alarmWarnMins || snoozeTime; } return snoozeTime; From ea7907c52a171d063903b26b9519453c10cef17b Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sat, 5 Sep 2015 11:46:33 -0700 Subject: [PATCH 064/176] fix bug that made announcement alarms impossible to ack added TODO to clean up later when there's more time to test a bigger/better fix --- lib/client/index.js | 6 ++++-- lib/notifications.js | 10 +++++++--- lib/websocket.js | 8 +++++++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/client/index.js b/lib/client/index.js index f2dba0e9a2e..9ef1c64917c 100644 --- a/lib/client/index.js +++ b/lib/client/index.js @@ -702,7 +702,8 @@ client.init = function init(serverSettings, plugins) { var enabled = (isAlarmForHigh() && client.settings.alarmHigh) || (isAlarmForLow() && client.settings.alarmLow); if (enabled) { console.log('Alarm raised!'); - currentAlarmType = 'alarm'; + //TODO: Announcement hack a1/a2 + currentAlarmType = notify.isAnnouncement ? 'a' + notify.level : 'alarm'; generateAlarm(alarmSound,notify); } else { console.info('alarm was disabled locally', client.latestSGV.mgdl, client.settings); @@ -717,7 +718,8 @@ client.init = function init(serverSettings, plugins) { var enabled = (isAlarmForHigh() && client.settings.alarmUrgentHigh) || (isAlarmForLow() && client.settings.alarmUrgentLow); if (enabled) { console.log('Urgent alarm raised!'); - currentAlarmType = 'urgent_alarm'; + //TODO: Announcement hack a1/a2 + currentAlarmType = notify.isAnnouncement ? 'a' + notify.level : 'urgent_alarm'; generateAlarm(urgentAlarmSound,notify); } else { console.info('urgent alarm was disabled locally', client.latestSGV.mgdl, client.settings); diff --git a/lib/notifications.js b/lib/notifications.js index 1a498a84c5b..236c4848499 100644 --- a/lib/notifications.js +++ b/lib/notifications.js @@ -23,7 +23,9 @@ function init (env, ctx) { function getAlarm (level) { var alarm = alarms[level]; if (!alarm) { - alarm = new Alarm(level, levels.toDisplay(level)); + //TODO: Announcement hack a1/a2 + var display = level.indexOf && level.indexOf('a') === 0 ? 'Announcement:' + level : levels.toDisplay(level); + alarm = new Alarm(level, display); alarms[level] = alarm; } @@ -54,8 +56,10 @@ function init (env, ctx) { } function emitNotification (notify) { - var alarm = getAlarm(notify.level); - if (ctx.data.lastUpdated > alarm.lastAckTime + alarm.silenceTime || notify.isAnnouncement) { + //TODO: Announcement hack a1/a2 + var level = notify.isAnnouncement ? 'a' + notify.level : notify.level; + var alarm = getAlarm(level); + if (ctx.data.lastUpdated > alarm.lastAckTime + alarm.silenceTime) { ctx.bus.emit('notification', notify); alarm.lastEmitTime = ctx.data.lastUpdated; logEmitEvent(notify); diff --git a/lib/websocket.js b/lib/websocket.js index 2d63c141f89..0e3b883cb12 100644 --- a/lib/websocket.js +++ b/lib/websocket.js @@ -12,6 +12,11 @@ function init (env, ctx, server) { var watchers = 0; var lastData = {}; + var alarmType2Level = { + urgent_alarm: levels.URGENT + , alarm: levels.WARN + }; + function start ( ) { io = require('socket.io')({ 'transports': ['xhr-polling'], 'log level': 0 @@ -36,7 +41,8 @@ function init (env, ctx, server) { socket.emit('dataUpdate',lastData); io.emit('clients', ++watchers); socket.on('ack', function(alarmType, silenceTime) { - var level = alarmType === 'urgent_alarm' ? 2 : 1; + //TODO: Announcement hack a1/a2 + var level = alarmType2Level[alarmType] || alarmType; ctx.notifications.ack(level, silenceTime, true); }); socket.on('disconnect', function () { From f27e12ef6efaa3098a2768d9829e31deaa281de9 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sat, 5 Sep 2015 12:00:05 -0700 Subject: [PATCH 065/176] Hide the GI specific value till it's integrated --- static/profile/index.html | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/static/profile/index.html b/static/profile/index.html index 54e51fe2c23..91cac548ba1 100644 --- a/static/profile/index.html +++ b/static/profile/index.html @@ -85,14 +85,16 @@

    Profile editor

    - Carbs - ( - - - use GI specific values - - ) - + Carbs + + + + + + + + +
    Carbs activity / absorption rate: [g/hour]
    From c0ef77c85ca311c9132c2ad0bd74b9151c6b861c Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sat, 5 Sep 2015 12:57:44 -0700 Subject: [PATCH 066/176] fix issue where the right of the tooltip goes off the screen --- lib/plugins/pluginbase.js | 7 ++++++- static/css/main.css | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/plugins/pluginbase.js b/lib/plugins/pluginbase.js index e7943af5ec7..fe00b805082 100644 --- a/lib/plugins/pluginbase.js +++ b/lib/plugins/pluginbase.js @@ -2,6 +2,8 @@ var _ = require('lodash'); +var TOOLTIP_WIDTH = 250; //min-width + padding + function init (majorPills, minorPills, statusPills, bgStatus, tooltip) { var pluginBase = { }; @@ -78,8 +80,11 @@ function init (majorPills, minorPills, statusPills, bgStatus, tooltip) { pill.mouseover(function pillMouseover (event) { tooltip.transition().duration(200).style('opacity', .9); + + var windowWidth = $(tooltip).parent().parent().width(); + var left = event.pageX + TOOLTIP_WIDTH < windowWidth ? event.pageX : windowWidth - TOOLTIP_WIDTH; tooltip.html(html) - .style('left', (event.pageX) + 'px') + .style('left', left + 'px') .style('top', (event.pageY + 15) + 'px'); }); diff --git a/static/css/main.css b/static/css/main.css index ac92ef617c7..7852c2ec954 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -290,6 +290,7 @@ body { border: 0; border-radius: 8px; float: right; + min-width: 150px; } .alarms { From b24cc641c881646a4f98f9863392b3218774ce4e Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sun, 6 Sep 2015 09:26:04 -0700 Subject: [PATCH 067/176] beter logging/handling of case where there isn't a pushover key for a specific notification --- lib/plugins/pushover.js | 3 +-- lib/pushnotify.js | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/plugins/pushover.js b/lib/plugins/pushover.js index 8fd07a627cd..2f6f46dd2e0 100644 --- a/lib/plugins/pushover.js +++ b/lib/plugins/pushover.js @@ -53,9 +53,8 @@ function init (env) { } if (selectedKeys.length === 0) { - console.info('No Pushover Keys defined for', notify); if (callback) { - return callback(); + return callback('no-key-defined'); } } diff --git a/lib/pushnotify.js b/lib/pushnotify.js index 8ceaa71dcf3..3cca136131f 100644 --- a/lib/pushnotify.js +++ b/lib/pushnotify.js @@ -87,7 +87,9 @@ function init(env, ctx) { if (ctx.pushover) { //add the key to the cache before sending, but with a short TTL ctx.pushover.send(notify, function pushoverCallback(err, result) { - if (!err) { + if (err) { + console.warn('Unable to send pushover', err, notify); + } else { //result comes back as a string here, so fix it result = JSON.parse(result); //after successfully sent, increase the TTL From 105fd193924a1851df763afbdb5e8615590b09e0 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sun, 6 Sep 2015 10:00:46 -0700 Subject: [PATCH 068/176] make errorcode to level mappings configurable --- README.md | 4 ++++ lib/plugins/errorcodes.js | 36 +++++++++++++++++++++++++++++------- tests/errorcodes.test.js | 19 +++++++++++++++++++ 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 144bc336f68..3fb0121b7eb 100644 --- a/README.md +++ b/README.md @@ -212,6 +212,10 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm * `direction` (BG Direction) - Displays the trend direction. * `upbat` (Uploader Battery) - Displays the most recent battery status from the uploader phone. * `errorcodes` (CGM Error Codes) - Generates alarms for CGM codes `9` (hourglass) and `10` (???). + * Use [extended settings](#extended-settings) to adjust what errorcodes trigger notifications and alarms: + * `ERRORCODES_INFO` (`5`) - By default the needs calibration (blood drop) generates an info level notification, set to a space separate list of number or `off` to disable + * `ERRORCODES_WARN` (`off`) - By default there are no warning configured, set to a space separate list of numbers or `off` to disable + * `ERRORCODES_URGENT` (`9 10`) - By default the hourglass and ??? generate an urgent alarm, set to a space separate list of numbers or `off` to disable * `ar2` ([Forcasting using AR2 algorithm](https://github.com/nightscout/nightscout.github.io/wiki/Forecasting)) - Generates alarms based on forecasted values. * Enabled by default if no thresholds are set **OR** `ALARM_TYPES` includes `predict`. * Use [extended settings](#extended-settings) to adjust AR2 behavior: diff --git a/lib/plugins/errorcodes.js b/lib/plugins/errorcodes.js index c0cba79899e..65b80911fda 100644 --- a/lib/plugins/errorcodes.js +++ b/lib/plugins/errorcodes.js @@ -1,5 +1,6 @@ 'use strict'; +var _ = require('lodash'); var levels = require('../levels'); var times = require('../times'); @@ -22,13 +23,6 @@ function init() { , 12: '?RF' //BAD_RF }; - //TODO: move notification levels to constants - var code2Level = { - 5: levels.INFO - , 9: levels.URGENT - , 10: levels.URGENT - }; - var code2PushoverSound = { 5: 'intermission' , 9: 'alien' @@ -45,6 +39,8 @@ function init() { var now = Date.now(); var lastSGV = sbx.lastSGVEntry(); + var code2Level = buildMappingFromSettings(sbx.extendedSettings); + if (lastSGV && now - lastSGV.mills < times.mins(10).msecs && lastSGV.mgdl < 39) { var errorDisplay = toDisplay(lastSGV.mgdl); @@ -67,6 +63,32 @@ function init() { } }; + function buildMappingFromSettings (extendedSettings) { + var mapping = {}; + + function addValuesToMapping (value, level) { + if (!value || !value.split) { + return []; + } + + var rawValues = value && value.split(' ') || []; + _.each(rawValues, function (num) { + if (!isNaN(num)) { + mapping[Number(num)] = level + } + }); + } + + addValuesToMapping(extendedSettings.info || '5', levels.INFO); + addValuesToMapping(extendedSettings.warn || 'off', levels.WARN); + addValuesToMapping(extendedSettings.urgent || '9 10', levels.URGENT); + + return mapping; + } + + //for tests + errorcodes.buildMappingFromSettings = buildMappingFromSettings; + return errorcodes; diff --git a/tests/errorcodes.test.js b/tests/errorcodes.test.js index b2b65a96c07..de634040d82 100644 --- a/tests/errorcodes.test.js +++ b/tests/errorcodes.test.js @@ -82,4 +82,23 @@ describe('errorcodes', function ( ) { errorcodes.toDisplay(10).should.equal('???'); }); + it('have default code to level mappings', function () { + var mapping = errorcodes.buildMappingFromSettings({}); + mapping[5].should.equal(levels.INFO); + mapping[9].should.equal(levels.URGENT); + mapping[10].should.equal(levels.URGENT); + _.keys(mapping).length.should.equal(3); + }); + + it('allow config of custom code to level mappings', function () { + var mapping = errorcodes.buildMappingFromSettings({ + info: 'off' + , warn: '9 10' + , urgent: 'off' + }); + mapping[9].should.equal(levels.WARN); + mapping[10].should.equal(levels.WARN); + _.keys(mapping).length.should.equal(2); + }); + }); \ No newline at end of file From 6f10f4d02963805c5fdcc2948625d68b93888674 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sun, 6 Sep 2015 19:07:00 +0200 Subject: [PATCH 069/176] solved axis timezone issues --- lib/report_plugins/daytoday.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/report_plugins/daytoday.js b/lib/report_plugins/daytoday.js index 797e141c7a0..34947fcd743 100644 --- a/lib/report_plugins/daytoday.js +++ b/lib/report_plugins/daytoday.js @@ -75,6 +75,18 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { return timeFormat; } + function timeTicks(n,i) { + var t12 = [ + '12 AM', '01 AM', '02 AM', '03 AM', '04 AM', '05 AM', '06 AM', '07 AM', '08 AM', '09 AM', '10 AM', '11 AM', + '12 PM', '01 PM', '02 PM', '03 PM', '04 PM', '05 PM', '06 PM', '07 PM', '08 PM', '09 PM', '10 PM', '11 PM' + ]; + if (Nightscout.client.settings.timeFormat === '24') { + return ('00' + i).slice(-2); + } else { + return t12[i]; + } + } + function drawChart(day,data,options) { var tickValues , charts @@ -157,7 +169,7 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { // define the parts of the axis that aren't dependent on width or height xScale2 = d3.time.scale() - .domain(d3.extent(data.sgv, function (d) { return d.date; })); + .domain(d3.extent(data.sgv, dateFn)); if (options.scale === report_plugins.consts.SCALE_LOG) { yScale2 = d3.scale.log() @@ -175,7 +187,8 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { xAxis2 = d3.svg.axis() .scale(xScale2) - .tickFormat(d3.time.format(getTimeFormat(true))) + //.tickFormat(d3.time.format(getTimeFormat(true))) + .tickFormat(timeTicks) .ticks(24) .orient('bottom'); From 531820c3a3cc06fddd75ef527c2d8b26ab96dfcd Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sun, 6 Sep 2015 10:10:18 -0700 Subject: [PATCH 070/176] if code isn't mapped it's level NONE, not LOW --- lib/plugins/errorcodes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/plugins/errorcodes.js b/lib/plugins/errorcodes.js index 65b80911fda..e4fb825f7ff 100644 --- a/lib/plugins/errorcodes.js +++ b/lib/plugins/errorcodes.js @@ -45,7 +45,7 @@ function init() { var errorDisplay = toDisplay(lastSGV.mgdl); var pushoverSound = code2PushoverSound[lastSGV.mgdl] || null; - var notifyLevel = code2Level[lastSGV.mgdl] || levels.LOW; + var notifyLevel = code2Level[lastSGV.mgdl] || levels.NONE; if (notifyLevel > levels.NONE) { sbx.notifications.requestNotify({ From 47d3ab55d706c963fa89cecdb0a6d0303a37c72f Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sun, 6 Sep 2015 19:16:08 +0200 Subject: [PATCH 071/176] removed unneeded code --- lib/report_plugins/daytoday.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/lib/report_plugins/daytoday.js b/lib/report_plugins/daytoday.js index 34947fcd743..f950ff2880c 100644 --- a/lib/report_plugins/daytoday.js +++ b/lib/report_plugins/daytoday.js @@ -58,23 +58,12 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { var scaledTreatmentBG = report_plugins.utils.scaledTreatmentBG; var padding = { top: 15, right: 15, bottom: 30, left: 35 }; - var - FORMAT_TIME_12 = '%I' - , FORMAT_TIME_24 = '%H'; daytoday.prepareHtml(daystoshow) ; _.each(daystoshow, function (n, day) { drawChart(day,datastorage[day],options); }); - function getTimeFormat() { - var timeFormat = FORMAT_TIME_12; - if (Nightscout.client.settings.timeFormat === '24') { - timeFormat = FORMAT_TIME_24; - } - return timeFormat; - } - function timeTicks(n,i) { var t12 = [ '12 AM', '01 AM', '02 AM', '03 AM', '04 AM', '05 AM', '06 AM', '07 AM', '08 AM', '09 AM', '10 AM', '11 AM', @@ -187,7 +176,6 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { xAxis2 = d3.svg.axis() .scale(xScale2) - //.tickFormat(d3.time.format(getTimeFormat(true))) .tickFormat(timeTicks) .ticks(24) .orient('bottom'); From ffe88beb09d125d4c65e879b7bd3ae87641ee265 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sun, 6 Sep 2015 10:35:44 -0700 Subject: [PATCH 072/176] fix codacy issue --- tests/storage.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/storage.test.js b/tests/storage.test.js index 641b710d920..de9d265325a 100644 --- a/tests/storage.test.js +++ b/tests/storage.test.js @@ -12,7 +12,7 @@ describe('STORAGE', function () { }); it('The storage class should be OK.', function (done) { - should(require('../lib/storage')).be.ok; + should.exist(require('../lib/storage')); done(); }); From f6878883dce2a14b3f27507dbd6df8c28a40e07b Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sun, 6 Sep 2015 10:36:42 -0700 Subject: [PATCH 073/176] to maintain compatability codes 1-8 should be info level, fix bugs --- README.md | 2 +- lib/plugins/errorcodes.js | 9 ++++----- tests/errorcodes.test.js | 13 ++++++++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3fb0121b7eb..ec180b31452 100644 --- a/README.md +++ b/README.md @@ -213,7 +213,7 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm * `upbat` (Uploader Battery) - Displays the most recent battery status from the uploader phone. * `errorcodes` (CGM Error Codes) - Generates alarms for CGM codes `9` (hourglass) and `10` (???). * Use [extended settings](#extended-settings) to adjust what errorcodes trigger notifications and alarms: - * `ERRORCODES_INFO` (`5`) - By default the needs calibration (blood drop) generates an info level notification, set to a space separate list of number or `off` to disable + * `ERRORCODES_INFO` (`1 2 3 4 5 6 7 8`) - By default the needs calibration (blood drop) and other codes below 9 generate an info level notification, set to a space separate list of number or `off` to disable * `ERRORCODES_WARN` (`off`) - By default there are no warning configured, set to a space separate list of numbers or `off` to disable * `ERRORCODES_URGENT` (`9 10`) - By default the hourglass and ??? generate an urgent alarm, set to a space separate list of numbers or `off` to disable * `ar2` ([Forcasting using AR2 algorithm](https://github.com/nightscout/nightscout.github.io/wiki/Forecasting)) - Generates alarms based on forecasted values. diff --git a/lib/plugins/errorcodes.js b/lib/plugins/errorcodes.js index e4fb825f7ff..1b1504cd754 100644 --- a/lib/plugins/errorcodes.js +++ b/lib/plugins/errorcodes.js @@ -42,12 +42,11 @@ function init() { var code2Level = buildMappingFromSettings(sbx.extendedSettings); if (lastSGV && now - lastSGV.mills < times.mins(10).msecs && lastSGV.mgdl < 39) { - var errorDisplay = toDisplay(lastSGV.mgdl); var pushoverSound = code2PushoverSound[lastSGV.mgdl] || null; - var notifyLevel = code2Level[lastSGV.mgdl] || levels.NONE; + var notifyLevel = code2Level[lastSGV.mgdl]; - if (notifyLevel > levels.NONE) { + if (notifyLevel !== undefined) { sbx.notifications.requestNotify({ level: notifyLevel , title: 'CGM Error Code' @@ -74,12 +73,12 @@ function init() { var rawValues = value && value.split(' ') || []; _.each(rawValues, function (num) { if (!isNaN(num)) { - mapping[Number(num)] = level + mapping[Number(num)] = level; } }); } - addValuesToMapping(extendedSettings.info || '5', levels.INFO); + addValuesToMapping(extendedSettings.info || '1 2 3 4 5 6 7 8', levels.INFO); addValuesToMapping(extendedSettings.warn || 'off', levels.WARN); addValuesToMapping(extendedSettings.urgent || '9 10', levels.URGENT); diff --git a/tests/errorcodes.test.js b/tests/errorcodes.test.js index de634040d82..ed1b158637b 100644 --- a/tests/errorcodes.test.js +++ b/tests/errorcodes.test.js @@ -56,7 +56,7 @@ describe('errorcodes', function ( ) { errorcodes.checkNotifications(sbx); should.not.exist(ctx.notifications.findHighestAlarm()); var info = _.first(ctx.notifications.findUnSnoozeable()); - info.level.should.equal(levels.LOW); + info.level.should.equal(levels.INFO); info.pushoverSound.should.equal('intermission'); done(); @@ -64,7 +64,7 @@ describe('errorcodes', function ( ) { it('should trigger a low notification when code < 9', function (done) { - for (var i = 0; i < 9; i++) { + for (var i = 1; i < 9; i++) { ctx.notifications.initRequests(); ctx.data.sgvs = [{mgdl: i, mills: now}]; @@ -84,10 +84,17 @@ describe('errorcodes', function ( ) { it('have default code to level mappings', function () { var mapping = errorcodes.buildMappingFromSettings({}); + mapping[1].should.equal(levels.INFO); + mapping[2].should.equal(levels.INFO); + mapping[3].should.equal(levels.INFO); + mapping[4].should.equal(levels.INFO); mapping[5].should.equal(levels.INFO); + mapping[6].should.equal(levels.INFO); + mapping[7].should.equal(levels.INFO); + mapping[8].should.equal(levels.INFO); mapping[9].should.equal(levels.URGENT); mapping[10].should.equal(levels.URGENT); - _.keys(mapping).length.should.equal(3); + _.keys(mapping).length.should.equal(10); }); it('allow config of custom code to level mappings', function () { From 8a1fbe98d015623319bc1318c8366679ceb2c4b5 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sun, 6 Sep 2015 19:49:23 +0200 Subject: [PATCH 074/176] improved 12h axis format --- lib/report_plugins/daytoday.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/report_plugins/daytoday.js b/lib/report_plugins/daytoday.js index f950ff2880c..043fa304977 100644 --- a/lib/report_plugins/daytoday.js +++ b/lib/report_plugins/daytoday.js @@ -57,7 +57,7 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { var report_plugins = Nightscout.report_plugins; var scaledTreatmentBG = report_plugins.utils.scaledTreatmentBG; - var padding = { top: 15, right: 15, bottom: 30, left: 35 }; + var padding = { top: 15, right: 22, bottom: 30, left: 35 }; daytoday.prepareHtml(daystoshow) ; _.each(daystoshow, function (n, day) { @@ -66,8 +66,8 @@ daytoday.report = function report_daytoday(datastorage,daystoshow,options) { function timeTicks(n,i) { var t12 = [ - '12 AM', '01 AM', '02 AM', '03 AM', '04 AM', '05 AM', '06 AM', '07 AM', '08 AM', '09 AM', '10 AM', '11 AM', - '12 PM', '01 PM', '02 PM', '03 PM', '04 PM', '05 PM', '06 PM', '07 PM', '08 PM', '09 PM', '10 PM', '11 PM' + '12am', '', '2am', '', '4am', '', '6am', '', '8am', '', '10am', '', + '12pm', '', '2pm', '', '4pm', '', '6pm', '', '8pm', '', '10pm', '', '12am' ]; if (Nightscout.client.settings.timeFormat === '24') { return ('00' + i).slice(-2); From 86881a64b00086b1b66640a53462d724f84cf00e Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sun, 6 Sep 2015 11:34:14 -0700 Subject: [PATCH 075/176] fix readme to match defaults for ALARM_LOW_MINS and ALARM_URGENT_MINS --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ec180b31452..5f21d4f83bb 100644 --- a/README.md +++ b/README.md @@ -166,9 +166,9 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm * `ALARM_HIGH` (`on`) - possible values `on` or `off` * `ALARM_HIGH_MINS` (`30 60 90 120`) - Number of minutes to snooze high alarms, space separated for options in browser, first used for pushover * `ALARM_LOW` (`on`) - possible values `on` or `off` - * `ALARM_LOW_MINS` (`30 60 90 120`) - Number of minutes to snooze low alarms, space separated for options in browser, first used for pushover + * `ALARM_LOW_MINS` (`15 30 45 60`) - Number of minutes to snooze low alarms, space separated for options in browser, first used for pushover * `ALARM_URGENT_LOW` (`on`) - possible values `on` or `off` - * `ALARM_URGENT_LOW_MINS` (`30 60 90 120`) - Number of minutes to snooze urgent low alarms, space separated for options in browser, first used for pushover + * `ALARM_URGENT_LOW_MINS` (`15 30 45`) - Number of minutes to snooze urgent low alarms, space separated for options in browser, first used for pushover * `ALARM_URGENT_MINS` (`30 60 90 120`) - Number of minutes to snooze urgent alarms (that aren't tagged as high or low), space separated for options in browser, first used for pushover * `ALARM_WARN_MINS` (`30 60 90 120`) - Number of minutes to snooze warning alarms (that aren't tagged as high or low), space separated for options in browser, first used for pushover From eb3513cf6a8350864dd9977a935fdf075f19dbca Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sun, 6 Sep 2015 11:42:08 -0700 Subject: [PATCH 076/176] more info on Pushover config options --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5f21d4f83bb..ce46457e802 100644 --- a/README.md +++ b/README.md @@ -276,7 +276,13 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm * `PUSHOVER_ANNOUNCEMENT_KEY` - An optional Pushover user/group key, will be used for system wide user generated announcements. If not defined this will fallback to `PUSHOVER_USER_KEY` or `PUSHOVER_ALARM_KEY`. A possible use for this is sending important messages and alarms to a CWD that you don't want to send all notification too. This also support a space delimited list of keys. To disable Announcement pushes set this to `off`. * `BASE_URL` - Used for pushover callbacks, usually the URL of your Nightscout site, use https when possible. * `API_SECRET` - Used for signing the pushover callback request for acknowledgments. - + + If you never want to get info level notifications (treatments) use `PUSHOVER_USER_KEY="off"` + If you never want to get an alarm via pushover use `PUSHOVER_ALARM_KEY="off"` + If you never want to get an announcement via pushover use `PUSHOVER_ANNOUNCEMENT_KEY="off"` + + If only `PUSHOVER_USER_KEY` is set it will be used for all info notifications, alarms, and announcements + For testing/development try [localtunnel](http://localtunnel.me/). #### IFTTT Maker From a21323145883aaccc163bc8be92ee4feb2b9b812 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sun, 6 Sep 2015 11:44:26 -0700 Subject: [PATCH 077/176] 0.8.1 version bump to prepare for patch release --- bower.json | 2 +- package.json | 2 +- static/index.html | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bower.json b/bower.json index 8931fb1247d..3b37b8ba312 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "nightscout", - "version": "0.8.0", + "version": "0.8.1", "dependencies": { "angularjs": "1.3.0-beta.19", "bootstrap": "~3.2.0", diff --git a/package.json b/package.json index cee77d81bd5..c8f043e202d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Nightscout", - "version": "0.8.0", + "version": "0.8.1", "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", diff --git a/static/index.html b/static/index.html index 6025134e61e..7a144a6355a 100644 --- a/static/index.html +++ b/static/index.html @@ -25,10 +25,10 @@ - - + + - + @@ -261,8 +261,8 @@
    - - + + From ebf57a85848bcecd144ef30b9312ca21e5562003 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 6 Sep 2015 21:14:31 +0200 Subject: [PATCH 078/176] upper case in Entered By --- lib/client/renderer.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/client/renderer.js b/lib/client/renderer.js index bab8b4d420e..c475c0815cd 100644 --- a/lib/client/renderer.js +++ b/lib/client/renderer.js @@ -169,7 +169,7 @@ function init (client, d3) { return ''+translate('Time')+': ' + client.formatTime(new Date(d.mills)) + '
    ' + (d.eventType ? ''+translate('Treatment type')+': ' + d.eventType + '
    ' : '') + (d.glucose ? ''+translate('BG')+': ' + d.glucose + (d.glucoseType ? ' (' + translate(d.glucoseType) + ')': '') + '
    ' : '') + - (d.enteredBy ? ''+translate('Entered by')+': ' + d.enteredBy + '
    ' : '') + + (d.enteredBy ? ''+translate('Entered By')+': ' + d.enteredBy + '
    ' : '') + (d.notes ? ''+translate('Notes')+': ' + d.notes : ''); } @@ -177,7 +177,7 @@ function init (client, d3) { return ''+translate('Time')+': ' + client.formatTime(new Date(d.mills)) + '
    ' + (d.eventType ? ''+translate('Announcement')+'
    ' : '') + (d.notes && d.notes.length > 1 ? ''+translate('Message')+': ' + d.notes + '
    ' : '') + - (d.enteredBy ? ''+translate('Entered by')+': ' + d.enteredBy + '
    ' : ''); + (d.enteredBy ? ''+translate('Entered By')+': ' + d.enteredBy + '
    ' : ''); } //NOTE: treatments with insulin or carbs are drawn by drawTreatment() @@ -341,7 +341,7 @@ function init (client, d3) { (treatment.carbs ? '' + translate('Carbs') + ': ' + treatment.carbs + '
    ' : '') + (treatment.insulin ? '' + translate('Insulin') + ': ' + treatment.insulin + '
    ' : '') + (treatment.glucose ? '' + translate('BG') + ': ' + treatment.glucose + (treatment.glucoseType ? ' (' + translate(treatment.glucoseType) + ')' : '') + '
    ' : '') + - (treatment.enteredBy ? '' + translate('Entered by') + ': ' + treatment.enteredBy + '
    ' : '') + + (treatment.enteredBy ? '' + translate('Entered By') + ': ' + treatment.enteredBy + '
    ' : '') + (treatment.notes ? '' + translate('Notes') + ': ' + treatment.notes : '') ) .style('left', (d3.event.pageX) + 'px') From a5e1b836b0e9792e2c334be40caf28875474fbb7 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sun, 6 Sep 2015 12:59:11 -0700 Subject: [PATCH 079/176] removed copy paste typo form readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ce46457e802..44a952c49aa 100644 --- a/README.md +++ b/README.md @@ -273,7 +273,7 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm * `PUSHOVER_API_TOKEN` - Used to enable pushover notifications, this token is specific to the application you create from in [Pushover](https://pushover.net/), ***[additional pushover information](#pushover)*** below. * `PUSHOVER_USER_KEY` - Your Pushover user key, can be found in the top left of the [Pushover](https://pushover.net/) site, this can also be a pushover delivery group key to send to a group rather than just a single user. This also supports a space delimited list of keys. To disable `INFO` level pushes set this to `off`. * `PUSHOVER_ALARM_KEY` - An optional Pushover user/group key, will be used for system wide alarms (level > `WARN`). If not defined this will fallback to `PUSHOVER_USER_KEY`. A possible use for this is sending important messages and alarms to a CWD that you don't want to send all notification too. This also support a space delimited list of keys. To disable Alarm pushes set this to `off`. - * `PUSHOVER_ANNOUNCEMENT_KEY` - An optional Pushover user/group key, will be used for system wide user generated announcements. If not defined this will fallback to `PUSHOVER_USER_KEY` or `PUSHOVER_ALARM_KEY`. A possible use for this is sending important messages and alarms to a CWD that you don't want to send all notification too. This also support a space delimited list of keys. To disable Announcement pushes set this to `off`. + * `PUSHOVER_ANNOUNCEMENT_KEY` - An optional Pushover user/group key, will be used for system wide user generated announcements. If not defined this will fallback to `PUSHOVER_USER_KEY` or `PUSHOVER_ALARM_KEY`. This also support a space delimited list of keys. To disable Announcement pushes set this to `off`. * `BASE_URL` - Used for pushover callbacks, usually the URL of your Nightscout site, use https when possible. * `API_SECRET` - Used for signing the pushover callback request for acknowledgments. From e4f7d35b976f5449cbf4c6ad723eb2c787019bf3 Mon Sep 17 00:00:00 2001 From: Sulka Haro Date: Mon, 7 Sep 2015 00:09:52 +0300 Subject: [PATCH 080/176] Hopefully clearer BWP messaging to explain the negative BWP --- lib/plugins/boluswizardpreview.js | 35 ++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/lib/plugins/boluswizardpreview.js b/lib/plugins/boluswizardpreview.js index e544c4d8531..5dc331e81ec 100644 --- a/lib/plugins/boluswizardpreview.js +++ b/lib/plugins/boluswizardpreview.js @@ -3,6 +3,7 @@ var _ = require('lodash'); var levels = require('../levels'); var times = require('../times'); +var CONST_60_MINUTES_IN_MS = 3600000; function init() { @@ -124,7 +125,20 @@ function init() { results.effect = iob * profile.getSensitivity(sbx.time); results.outcome = scaled - results.effect; var delta = 0; + + var timeSinceLastMeal = 1000000000; + var now = (new Date).getTime(); + for (var i = 0; i < sbx.data.treatments.length; i++) { + var treatment = sbx.data.treatments[i]; + var delta = now - treatment.mills; + if (delta < timeSinceLastMeal) { timeSinceLastMeal = delta;} + } + + results.timeSinceLastMeal = timeSinceLastMeal; + results.mealEatenRecently = false; + if (timeSinceLastMeal < CONST_60_MINUTES_IN_MS) { results.mealEatenRecently = true; } + var target_high = profile.getHighBGTarget(sbx.time); var sens = profile.getSensitivity(sbx.time); @@ -137,6 +151,11 @@ function init() { var target_low = profile.getLowBGTarget(sbx.time); + results.belowLowTarget = false; + if (scaled < target_low) { + results.belowLowTarget = true; + } + if (results.outcome < target_low) { delta = Math.abs(results.outcome - target_low); results.bolusEstimate = delta / sens * -1; @@ -197,6 +216,7 @@ function pushInfo(prop, info, sbx) { }); } else if (prop) { info.push({label: 'Insulin on Board', value: prop.displayIOB + 'U'}); + info.push({label: 'Current target', value: 'Low: '+sbx.data.profile.getLowBGTarget(sbx.time) + ' High: ' + sbx.data.profile.getHighBGTarget(sbx.time)}); info.push({label: 'Sensitivity', value: '-' + sbx.data.profile.getSensitivity(sbx.time) + ' ' + sbx.settings.units + '/U'}); info.push({label: 'Expected effect', value: prop.displayIOB + ' x -' + sbx.data.profile.getSensitivity(sbx.time) + ' = -' + prop.effectDisplay + ' ' + sbx.settings.units}); info.push({label: 'Expected outcome', value: sbx.lastScaledSGV() + '-' + prop.effectDisplay + ' = ' + prop.outcomeDisplay + ' ' + sbx.settings.units}); @@ -205,7 +225,20 @@ function pushInfo(prop, info, sbx) { var carbEquivalent = Math.ceil(Math.abs(sbx.data.profile.getCarbRatio() * prop.bolusEstimateDisplay)); info.unshift({label: 'Carb Equivalent', value: prop.bolusEstimateDisplay + 'U * ' + sbx.data.profile.getCarbRatio() + ' = ' + carbEquivalent + 'g'}); info.unshift({label: 'Current Carb Ratio', value: '1U / ' + sbx.data.profile.getCarbRatio() + ' g'}); - info.unshift({label: '-BWP', value: prop.bolusEstimateDisplay + 'U, maybe covered by carbs?'}); + + if (prop.mealEatenRecently) info.unshift({label: 'Meal eaten recently', value: 'excess IOB is probably your meal bolus?'}); + + if (!prop.belowLowTarget) { + info.unshift({label: '-BWP', value: 'Excess insulin equivalent ' + prop.bolusEstimateDisplay + 'U more than needed to reach low target, not account for carbs'}); + } + + if (prop.belowLowTarget) { + if (prop.iob > 0) { + info.unshift({label: '-BWP', value: 'Excess insulin equivalent ' + prop.bolusEstimateDisplay + 'U more than needed to reach low target, MAKE SURE IOB IS COVERED BY CARBS'}); + } else { + info.unshift({label: '-BWP', value: prop.bolusEstimateDisplay + 'U reduction needed in active insulin to reach low target, too much basal?'}); + } + } } } else { info.push({label: 'Notice', value: 'required info missing'}); From 2acda1d775ad089e07fe01deeaffb645e0e9c258 Mon Sep 17 00:00:00 2001 From: Sulka Haro Date: Mon, 7 Sep 2015 00:11:18 +0300 Subject: [PATCH 081/176] Remove the 'undefined' message from logging --- lib/websocket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/websocket.js b/lib/websocket.js index 0e3b883cb12..7af5f8e009e 100644 --- a/lib/websocket.js +++ b/lib/websocket.js @@ -30,7 +30,7 @@ function init (env, ctx, server) { function emitData (delta) { if (lastData.cals) { - console.log('running websocket.emitData', ctx.data.lastUpdated, delta.recentsgvs && delta.sgvdataupdate.length); + console.log('running websocket.emitData', ctx.data.lastUpdated); io.emit('dataUpdate', delta); } } From f4b0d496e6a0693584a825551e4bc7f253aba4af Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sun, 6 Sep 2015 15:42:37 -0700 Subject: [PATCH 082/176] use event.target instead of this --- lib/client/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/client/index.js b/lib/client/index.js index 2c6138e6c67..906c8010eb0 100644 --- a/lib/client/index.js +++ b/lib/client/index.js @@ -417,9 +417,9 @@ client.init = function init(serverSettings, plugins) { updateTitle(); } - function snoozeAlarm (e) { - stopAlarm(true, $(this).data('snooze-time')); - e.preventDefault(); + function snoozeAlarm (event) { + stopAlarm(true, $(event.target).data('snooze-time')); + event.preventDefault(); } function playAlarm(audio) { From 383c95cffe5b2ab25fa9ceded002f677bb91615c Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sun, 6 Sep 2015 16:03:57 -0700 Subject: [PATCH 083/176] codacy fixes; use times module instead of another time constant --- lib/plugins/boluswizardpreview.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/plugins/boluswizardpreview.js b/lib/plugins/boluswizardpreview.js index 5dc331e81ec..ee99130be86 100644 --- a/lib/plugins/boluswizardpreview.js +++ b/lib/plugins/boluswizardpreview.js @@ -3,7 +3,6 @@ var _ = require('lodash'); var levels = require('../levels'); var times = require('../times'); -var CONST_60_MINUTES_IN_MS = 3600000; function init() { @@ -133,12 +132,11 @@ function init() { var treatment = sbx.data.treatments[i]; var delta = now - treatment.mills; if (delta < timeSinceLastMeal) { timeSinceLastMeal = delta;} - } - - results.timeSinceLastMeal = timeSinceLastMeal; - results.mealEatenRecently = false; - if (timeSinceLastMeal < CONST_60_MINUTES_IN_MS) { results.mealEatenRecently = true; } - + } + + results.timeSinceLastMeal = timeSinceLastMeal; + results.mealEatenRecently = timeSinceLastMeal < times.mins(60).msecs; + var target_high = profile.getHighBGTarget(sbx.time); var sens = profile.getSensitivity(sbx.time); @@ -226,7 +224,9 @@ function pushInfo(prop, info, sbx) { info.unshift({label: 'Carb Equivalent', value: prop.bolusEstimateDisplay + 'U * ' + sbx.data.profile.getCarbRatio() + ' = ' + carbEquivalent + 'g'}); info.unshift({label: 'Current Carb Ratio', value: '1U / ' + sbx.data.profile.getCarbRatio() + ' g'}); - if (prop.mealEatenRecently) info.unshift({label: 'Meal eaten recently', value: 'excess IOB is probably your meal bolus?'}); + if (prop.mealEatenRecently) { + info.unshift({label: 'Meal eaten recently', value: 'excess IOB is probably your meal bolus?'}); + } if (!prop.belowLowTarget) { info.unshift({label: '-BWP', value: 'Excess insulin equivalent ' + prop.bolusEstimateDisplay + 'U more than needed to reach low target, not account for carbs'}); From e9791e32b39a06d16c666e742cd4d24b94d543fc Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sun, 6 Sep 2015 16:43:09 -0700 Subject: [PATCH 084/176] fixes to use sbx.time so this works in retro mode --- lib/plugins/boluswizardpreview.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/plugins/boluswizardpreview.js b/lib/plugins/boluswizardpreview.js index ee99130be86..c5b0b0a50d9 100644 --- a/lib/plugins/boluswizardpreview.js +++ b/lib/plugins/boluswizardpreview.js @@ -125,17 +125,15 @@ function init() { results.outcome = scaled - results.effect; var delta = 0; - var timeSinceLastMeal = 1000000000; - var now = (new Date).getTime(); - - for (var i = 0; i < sbx.data.treatments.length; i++) { - var treatment = sbx.data.treatments[i]; - var delta = now - treatment.mills; - if (delta < timeSinceLastMeal) { timeSinceLastMeal = delta;} - } + var lastMeal = _.findLast(sbx.data.treatments, function eachTreatment (treatment) { + console.info('>>>findLast', treatment, new Date(sbx.time)); + return treatment.mills <= sbx.time && treatment.carbs > 0; + }); - results.timeSinceLastMeal = timeSinceLastMeal; - results.mealEatenRecently = timeSinceLastMeal < times.mins(60).msecs; + results.timeSinceLastMeal = lastMeal ? sbx.time - lastMeal.mills : 1000000000; + results.mealEatenRecently = results.timeSinceLastMeal < times.mins(60).msecs; + + console.info('>>>>>lastMeal', lastMeal, results); var target_high = profile.getHighBGTarget(sbx.time); var sens = profile.getSensitivity(sbx.time); @@ -149,10 +147,10 @@ function init() { var target_low = profile.getLowBGTarget(sbx.time); - results.belowLowTarget = false; - if (scaled < target_low) { - results.belowLowTarget = true; - } + results.belowLowTarget = false; + if (scaled < target_low) { + results.belowLowTarget = true; + } if (results.outcome < target_low) { delta = Math.abs(results.outcome - target_low); From b7282597433573ce769d3880dc5a5dfee0f70948 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sun, 6 Sep 2015 17:14:22 -0700 Subject: [PATCH 085/176] remove debug --- lib/plugins/boluswizardpreview.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/plugins/boluswizardpreview.js b/lib/plugins/boluswizardpreview.js index c5b0b0a50d9..45eecf72ca5 100644 --- a/lib/plugins/boluswizardpreview.js +++ b/lib/plugins/boluswizardpreview.js @@ -126,15 +126,12 @@ function init() { var delta = 0; var lastMeal = _.findLast(sbx.data.treatments, function eachTreatment (treatment) { - console.info('>>>findLast', treatment, new Date(sbx.time)); return treatment.mills <= sbx.time && treatment.carbs > 0; }); results.timeSinceLastMeal = lastMeal ? sbx.time - lastMeal.mills : 1000000000; results.mealEatenRecently = results.timeSinceLastMeal < times.mins(60).msecs; - console.info('>>>>>lastMeal', lastMeal, results); - var target_high = profile.getHighBGTarget(sbx.time); var sens = profile.getSensitivity(sbx.time); From bb9494cd643ebea0852b90471c2191f8af35bbef Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sun, 6 Sep 2015 17:17:17 -0700 Subject: [PATCH 086/176] include level when creating stale data alarms so we use the correct snooze options --- lib/client/index.js | 7 +++++-- lib/settings.js | 16 ++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/client/index.js b/lib/client/index.js index 906c8010eb0..de0c626c0f2 100644 --- a/lib/client/index.js +++ b/lib/client/index.js @@ -516,9 +516,12 @@ client.init = function init(serverSettings, plugins) { currentAlarmType = alarm.type; console.info('generating timeAgoAlarm', alarm.type); container.addClass('alarming-timeago'); - var message = {'title': 'Last data received ' + [ago.value, ago.label].join(' ')}; + var notify = { + title: 'Last data received ' + [ago.value, ago.label].join(' ') + , level: level === 'urgent' ? 2 : 1 + }; var sound = level === 'warn' ? alarmSound : urgentAlarmSound; - generateAlarm(sound, message); + generateAlarm(sound, notify); } container.toggleClass('alarming-timeago', ago.status !== 'current'); diff --git a/lib/settings.js b/lib/settings.js index 4d8848d87e9..dbb8cb1af68 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -236,20 +236,20 @@ function init ( ) { } function snoozeMinsForAlarmEvent (notify) { - var snoozeTime = [30]; + var snoozeTime; if (notify.eventName === 'high' && notify.level === levels.URGENT && settings.alarmUrgentHigh) { - snoozeTime = settings.alarmUrgentHighMins || snoozeTime; + snoozeTime = settings.alarmUrgentHighMins; } else if (notify.eventName === 'high' && settings.alarmHigh) { - snoozeTime = settings.alarmHighMins || snoozeTime; + snoozeTime = settings.alarmHighMins; } else if (notify.eventName === 'low' && notify.level === levels.URGENT && settings.alarmUrgentLow) { - snoozeTime = settings.alarmUrgentLowMins || snoozeTime; + snoozeTime = settings.alarmUrgentLowMins; } else if (notify.eventName === 'low' && settings.alarmLow) { - snoozeTime = settings.alarmLowMins || snoozeTime; + snoozeTime = settings.alarmLowMins; } else if (notify.level === levels.URGENT) { - snoozeTime = settings.alarmUrgentMins || snoozeTime; - } else if (notify.level === levels.WARN) { - snoozeTime = settings.alarmWarnMins || snoozeTime; + snoozeTime = settings.alarmUrgentMins; + } else { + snoozeTime = settings.alarmWarnMins; } return snoozeTime; From 5f67f1f33f35f881f1d1135c082cd1b9015a3402 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sun, 6 Sep 2015 17:44:20 -0700 Subject: [PATCH 087/176] changing 'meal eaten recently' to 'recent carbs' based on some feedback --- lib/plugins/boluswizardpreview.js | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/lib/plugins/boluswizardpreview.js b/lib/plugins/boluswizardpreview.js index 45eecf72ca5..ad80856fd80 100644 --- a/lib/plugins/boluswizardpreview.js +++ b/lib/plugins/boluswizardpreview.js @@ -125,12 +125,13 @@ function init() { results.outcome = scaled - results.effect; var delta = 0; - var lastMeal = _.findLast(sbx.data.treatments, function eachTreatment (treatment) { - return treatment.mills <= sbx.time && treatment.carbs > 0; + var recentCarbs = _.findLast(sbx.data.treatments, function eachTreatment (treatment) { + return treatment.mills <= sbx.time && + sbx.time - treatment.mills < times.mins(60).msecs && + treatment.carbs > 0; }); - results.timeSinceLastMeal = lastMeal ? sbx.time - lastMeal.mills : 1000000000; - results.mealEatenRecently = results.timeSinceLastMeal < times.mins(60).msecs; + results.recentCarbs = recentCarbs; var target_high = profile.getHighBGTarget(sbx.time); var sens = profile.getSensitivity(sbx.time); @@ -219,19 +220,27 @@ function pushInfo(prop, info, sbx) { info.unshift({label: 'Carb Equivalent', value: prop.bolusEstimateDisplay + 'U * ' + sbx.data.profile.getCarbRatio() + ' = ' + carbEquivalent + 'g'}); info.unshift({label: 'Current Carb Ratio', value: '1U / ' + sbx.data.profile.getCarbRatio() + ' g'}); - if (prop.mealEatenRecently) { - info.unshift({label: 'Meal eaten recently', value: 'excess IOB is probably your meal bolus?'}); + if (prop.recentCarbs) { + info.unshift({ + label: 'Recent carbs' + , value: prop.recentCarbs.carbs + 'g @ ' + moment(prop.recentCarbs.mills).format('LT')}); } if (!prop.belowLowTarget) { - info.unshift({label: '-BWP', value: 'Excess insulin equivalent ' + prop.bolusEstimateDisplay + 'U more than needed to reach low target, not account for carbs'}); + info.unshift({ + label: '-BWP' + , value: 'Excess insulin equivalent ' + prop.bolusEstimateDisplay + 'U more than needed to reach low target, not account for carbs'}); } if (prop.belowLowTarget) { if (prop.iob > 0) { - info.unshift({label: '-BWP', value: 'Excess insulin equivalent ' + prop.bolusEstimateDisplay + 'U more than needed to reach low target, MAKE SURE IOB IS COVERED BY CARBS'}); + info.unshift({ + label: '-BWP' + , value: 'Excess insulin equivalent ' + prop.bolusEstimateDisplay + 'U more than needed to reach low target, MAKE SURE IOB IS COVERED BY CARBS'}); } else { - info.unshift({label: '-BWP', value: prop.bolusEstimateDisplay + 'U reduction needed in active insulin to reach low target, too much basal?'}); + info.unshift({ + label: '-BWP' + , value: prop.bolusEstimateDisplay + 'U reduction needed in active insulin to reach low target, too much basal?'}); } } } From de1f000b92b6c1658b1a74af79f9e90b5b705d8f Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Mon, 7 Sep 2015 01:37:53 -0700 Subject: [PATCH 088/176] get thresholds from settings --- static/report/js/report.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/static/report/js/report.js b/static/report/js/report.js index 64a24fa12c4..8639e0985a8 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -34,8 +34,14 @@ var daystoshow = {}; var targetBGdefault = { - 'mg/dl': { low: 72, high: 180 }, - 'mmol': { low: 4, high: 10 } + 'mg/dl': { + low: client.settings.thresholds.bgTargetBottom + , high: client.settings.thresholds.bgTargetTop + } + , 'mmol': { + low: client.utils.scaleMgdl(client.settings.thresholds.bgTargetBottom) + , high: client.utils.scaleMgdl(client.settings.thresholds.bgTargetTop) + } }; var ONE_MIN_IN_MS = 60000; From fbdec7a3fa9491a5ea4a1c5854c6181758f6e06b Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Mon, 7 Sep 2015 02:26:31 -0700 Subject: [PATCH 089/176] version bump for 0.8.1-beta1 --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index cc508793f99..bc5aefbfcd8 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "nightscout", - "version": "0.8.1", + "version": "0.8.1-beta1", "dependencies": { "angularjs": "1.3.0-beta.19", "bootstrap": "~3.2.0", diff --git a/package.json b/package.json index c8f043e202d..c0fcc280ca3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Nightscout", - "version": "0.8.1", + "version": "0.8.1-beta1", "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", From 313ab47465d75c51548c6726f45f7bcc66205eba Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 7 Sep 2015 15:27:55 +0200 Subject: [PATCH 090/176] jquery-ui missing in index.html --- static/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/static/index.html b/static/index.html index 5c2b9d58b8f..122af64b1e1 100644 --- a/static/index.html +++ b/static/index.html @@ -254,6 +254,7 @@ + From 3f55e5c497cfe3ae5f086fd1b39a8c2fcd883a2d Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 7 Sep 2015 19:32:07 +0200 Subject: [PATCH 091/176] Update index.html --- static/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/static/index.html b/static/index.html index 122af64b1e1..cd9995cbb57 100644 --- a/static/index.html +++ b/static/index.html @@ -30,6 +30,7 @@ +
    From 5a5f1418750353fe1ecccf2dd775eed9e99de7f8 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Mon, 7 Sep 2015 10:51:59 -0700 Subject: [PATCH 092/176] bump to 0.8.1-beta1b --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index bc5aefbfcd8..db6a531d295 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "nightscout", - "version": "0.8.1-beta1", + "version": "0.8.1-beta1b", "dependencies": { "angularjs": "1.3.0-beta.19", "bootstrap": "~3.2.0", diff --git a/package.json b/package.json index c0fcc280ca3..6398d65ecc7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Nightscout", - "version": "0.8.1-beta1", + "version": "0.8.1-beta1b", "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", From c82f8fd9f14c5d9e37a062ae829fca7c622d016b Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Mon, 7 Sep 2015 20:59:20 +0200 Subject: [PATCH 093/176] fixed bug on counting scale when date are already cached --- static/css/report.css | 4 ++-- static/report/js/report.js | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/static/css/report.css b/static/css/report.css index d311c8d4b58..d0aef41c81e 100644 --- a/static/css/report.css +++ b/static/css/report.css @@ -19,8 +19,8 @@ body { } #glucosedistribution-overviewchart { - width: 3.0in; - height: 3in; + width: 2.8in; + height: 2.8in; float:left; } #percentile-chart { diff --git a/static/report/js/report.js b/static/report/js/report.js index 8639e0985a8..40814ab58cc 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -456,6 +456,9 @@ datastorage.allstatsrecords = datastorage.allstatsrecords.concat(datastorage[day].statsrecords); datastorage.alldays++; }); + options.maxInsulinValue = maxInsulinValue; + options.maxCarbsValue = maxCarbsValue; + report_plugins.eachPlugin(function (plugin) { // jquery plot doesn't draw to hidden div @@ -634,8 +637,6 @@ datastorage[day] = data; - options.maxInsulinValue = maxInsulinValue; - options.maxCarbsValue = maxCarbsValue; callback(); } From b27a08e810ef7e5b54ec4cff8dfaf900fb43f7f1 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Mon, 7 Sep 2015 21:21:30 +0200 Subject: [PATCH 094/176] allow css injection from plugin --- lib/report_plugins/glucosedistribution.js | 16 ++++++++++++++++ lib/report_plugins/index.js | 7 +++++++ static/css/report.css | 17 ++--------------- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/lib/report_plugins/glucosedistribution.js b/lib/report_plugins/glucosedistribution.js index ce03b12d791..2158dfdf3fb 100644 --- a/lib/report_plugins/glucosedistribution.js +++ b/lib/report_plugins/glucosedistribution.js @@ -30,6 +30,22 @@ glucosedistribution.html = function html(client) { return ret; }; +glucosedistribution.css = + '#glucosedistribution-overviewchart { \ + width: 2.8in; \ + height: 2.8in; \ + float:left; \ + } \ + #glucosedistribution-placeholder .tdborder { \ + width:80px; \ + border: 1px #ccc solid; \ + margin: 0; \ + padding: 1px; \ + }' + ; + + + glucosedistribution.report = function report_glucosedistribution(datastorage,daystoshow,options) { var Nightscout = window.Nightscout; var client = Nightscout.client; diff --git a/lib/report_plugins/index.js b/lib/report_plugins/index.js index f8470a4b6be..b2c929ec778 100644 --- a/lib/report_plugins/index.js +++ b/lib/report_plugins/index.js @@ -44,6 +44,13 @@ function init() { if (p.html && ! $('#' + p.name).length) { $('#tabnav').append($('
  • ').attr('id',p.name).addClass('menutab').append(client.translate(p.label))); } + // add css + if (p.css) { + $(' - - - - - -
    -

    Nightscout: Treatments

    - - - - - - - - - - - - - - - - - - - - - - - -
    TimeEvent TypeBGInsulinCarbsEntered ByNotes
    {{treatment.created_at | date:'short'}}{{treatment.eventType}}{{glucoseDisplay(treatment)}}{{treatment.insulin | number: 2}}{{treatment.carbs}}{{treatment.enteredBy}}{{treatment.notes}}
    -
    - - - From d38f01298442dcd8d07a2ecfbcef0855e857decf Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sun, 13 Sep 2015 10:26:15 -0700 Subject: [PATCH 113/176] 0.8.1-beta2 bump --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 077f9662606..f2dc60ab9a9 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "nightscout", - "version": "0.8.1-beta1b", + "version": "0.8.1-beta2", "dependencies": { "jquery": "2.1.0", "jQuery-Storage-API": "~1.7.2", diff --git a/package.json b/package.json index 3bced14c946..a6b20979b22 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Nightscout", - "version": "0.8.1-beta1b", + "version": "0.8.1-beta2", "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", From 74f675c25465c6da61f1d17b6332a2b1bb753646 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sun, 13 Sep 2015 21:27:55 +0200 Subject: [PATCH 114/176] fix translation in careportal --- lib/client/careportal.js | 11 ++++++++++- lib/report_plugins/treatments.js | 13 ++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/client/careportal.js b/lib/client/careportal.js index 1346b98c024..68cd30df540 100644 --- a/lib/client/careportal.js +++ b/lib/client/careportal.js @@ -57,6 +57,15 @@ function init (client, $) { }); }; + careportal.resolveEventName = function resolveEventName(value) { + _.each(Nightscout.client.careportal.events, function eachEvent(e) { + if (e.val === value) { + value = e.name; + } + }); + return value; + } + careportal.prepare = function prepare ( ) { careportal.prepareEvents(); $('#eventType').val('BG Check'); @@ -100,7 +109,7 @@ function init (client, $) { function buildConfirmText(data) { var text = [ translate('Please verify that the data entered is correct') + ': ' - , translate('Event Type') + ': ' + translate(data.eventType) + , translate('Event Type') + ': ' + translate(careportal.resolveEventName(data.eventType)) ]; function pushIf (check, valueText) { diff --git a/lib/report_plugins/treatments.js b/lib/report_plugins/treatments.js index 85c2ce8d803..9a4220432c2 100644 --- a/lib/report_plugins/treatments.js +++ b/lib/report_plugins/treatments.js @@ -74,7 +74,7 @@ treatments.report = function report_treatments(datastorage, daystoshow, options) function buildConfirmText(data) { var text = [ translate('Delete this treatment?')+'\n' - , '\n'+translate('Event Type')+': ' + translate(resolveEventName(data.eventType)) + , '\n'+translate('Event Type')+': ' + translate(client.careportal.resolveEventName(data.eventType)) ]; function pushIf (check, valueText) { @@ -212,15 +212,6 @@ treatments.report = function report_treatments(datastorage, daystoshow, options) return true; } - function resolveEventName(value) { - _.each(Nightscout.client.careportal.events, function eachEvent(e) { - if (e.val === value) { - value = e.name; - } - }); - return value; - } - function maybePrevent (event) { if (event) { event.preventDefault(); @@ -259,7 +250,7 @@ treatments.report = function report_treatments(datastorage, daystoshow, options) .append($('').addClass('editTreatment').css('cursor','pointer').attr('title',translate('Edit record')).attr('src',icon_edit).attr('data',JSON.stringify(tr)).attr('day',day)) ) .append($('
  • ').append(new Date(tr.created_at).toLocaleTimeString().replace(/([\d]+:[\d]{2})(:[\d]{2})(.*)/, '$1$3'))) - .append($('').append(tr.eventType ? translate(resolveEventName(tr.eventType)) : '')) + .append($('').append(tr.eventType ? translate(client.careportal.resolveEventName(tr.eventType)) : '')) .append($('').attr('align','center').append(tr.glucose ? tr.glucose + ' ('+translate(tr.glucoseType)+')' : '')) .append($('').attr('align','center').append(tr.insulin ? tr.insulin : '')) .append($('').attr('align','center').append(tr.carbs ? tr.carbs : '')) From 87be449bd98cd94cfd5c96a061668a39d0cda9f6 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sun, 13 Sep 2015 21:31:05 +0200 Subject: [PATCH 115/176] remove unneeded refrence --- lib/client/careportal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/careportal.js b/lib/client/careportal.js index 68cd30df540..0fb58c316d8 100644 --- a/lib/client/careportal.js +++ b/lib/client/careportal.js @@ -58,7 +58,7 @@ function init (client, $) { }; careportal.resolveEventName = function resolveEventName(value) { - _.each(Nightscout.client.careportal.events, function eachEvent(e) { + _.each(careportal.events, function eachEvent(e) { if (e.val === value) { value = e.name; } From d3721fa2da4d904d18315b13dda81d5be1bfad70 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Sun, 13 Sep 2015 21:34:58 +0200 Subject: [PATCH 116/176] show glucoseType in confirm dialog only when glucose entered --- lib/client/careportal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/careportal.js b/lib/client/careportal.js index 0fb58c316d8..9d7a051d969 100644 --- a/lib/client/careportal.js +++ b/lib/client/careportal.js @@ -119,7 +119,7 @@ function init (client, $) { } pushIf(data.glucose, translate('Blood Glucose') + ': ' + data.glucose); - pushIf(data.glucoseType, translate('Measurement Method') + ': ' + translate(data.glucoseType)); + pushIf(data.glucose, translate('Measurement Method') + ': ' + translate(data.glucoseType)); pushIf(data.carbs, translate('Carbs Given') + ': ' + data.carbs); pushIf(data.insulin, translate('Insulin Given') + ': ' + data.insulin); From e86c61f62fb9283e40437dde137123b8e2364fac Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sun, 13 Sep 2015 13:04:09 -0700 Subject: [PATCH 117/176] add gear icon before the Setting legend --- static/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/index.html b/static/index.html index 1e61ffaaeca..3140c402d6e 100644 --- a/static/index.html +++ b/static/index.html @@ -85,7 +85,7 @@
  • Profile Editor
  • - Settings + Settings
    Units
    From 111913d47d15be37cc6ec989fa87f4f579d34f8f Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sun, 13 Sep 2015 13:04:55 -0700 Subject: [PATCH 118/176] close drawer when menu links are clicked and prepare form before opening --- lib/client/browser-utils.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/client/browser-utils.js b/lib/client/browser-utils.js index ba3ca71989a..c6f17735c74 100644 --- a/lib/client/browser-utils.js +++ b/lib/client/browser-utils.js @@ -37,6 +37,10 @@ function init ($) { event.preventDefault(); }); + $('.navigation a').click(function navigationClick ( ) { + closeDrawer('#drawer'); + }); + function reload() { //strip '#' so form submission does not fail var url = window.location.href; @@ -80,9 +84,8 @@ function init ($) { closeOpenDraw(function () { lastOpenedDrawer = id; - $(id).css('display', 'block').animate({right: '0'}, 300, function () { - if (callback) { callback(); } - }); + if (callback) { callback(); } + $(id).css('display', 'block').animate({right: '0'}, 300); }); } From d39293338336c7878c7092977474a3ba72643ea3 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Sun, 13 Sep 2015 13:14:35 -0700 Subject: [PATCH 119/176] rename open callback to prepare since it's called before opening --- lib/client/browser-utils.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/client/browser-utils.js b/lib/client/browser-utils.js index c6f17735c74..fc7baf193a1 100644 --- a/lib/client/browser-utils.js +++ b/lib/client/browser-utils.js @@ -73,7 +73,7 @@ function init ($) { }); } - function openDrawer(id, callback) { + function openDrawer(id, prepare) { function closeOpenDraw(callback) { if (lastOpenedDrawer) { closeDrawer(lastOpenedDrawer, callback); @@ -84,17 +84,17 @@ function init ($) { closeOpenDraw(function () { lastOpenedDrawer = id; - if (callback) { callback(); } + if (prepare) { prepare(); } $(id).css('display', 'block').animate({right: '0'}, 300); }); } - function toggleDrawer(id, openCallback, closeCallback) { + function toggleDrawer(id, openPrepare, closeCallback) { if (lastOpenedDrawer === id) { closeDrawer(id, closeCallback); } else { - openDrawer(id, openCallback); + openDrawer(id, openPrepare); } } From 8c88e4655f8c8d886196a81537ad99ea11cf14e2 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 13 Sep 2015 23:22:06 +0200 Subject: [PATCH 120/176] uppercase in Profile Editor --- lib/language.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/language.js b/lib/language.js index 8a665a8fed8..9ddfefd965b 100644 --- a/lib/language.js +++ b/lib/language.js @@ -2367,7 +2367,7 @@ function init() { ,fi: 'Lähetä tiedot' ,nb: 'Lagre' } - ,'Profile editor' : { + ,'Profile Editor' : { cs: 'Editor profilu' ,de: 'Profil-Einstellungen' ,es: 'Editor de perfil' From 876dc53f3da5eb7caf017ff5eb15824e5813240b Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 13 Sep 2015 23:29:57 +0200 Subject: [PATCH 121/176] Reporting tool -> Reports --- lib/language.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/language.js b/lib/language.js index 9ddfefd965b..ab02767fca3 100644 --- a/lib/language.js +++ b/lib/language.js @@ -2382,7 +2382,7 @@ function init() { ,fi: 'Profiilin muokkaus' ,nb: 'Profileditor' } - ,'Reporting tool' : { + ,'Reports' : { cs: 'Výkazy' ,de: 'Berichte' ,es: 'Herramienta de informes' From b66d60185e12709b1ae1fda5efb06c527af8dca8 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 14 Sep 2015 12:59:20 +0200 Subject: [PATCH 122/176] codacy --- lib/client/careportal.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/careportal.js b/lib/client/careportal.js index 9d7a051d969..3d153e5ee42 100644 --- a/lib/client/careportal.js +++ b/lib/client/careportal.js @@ -64,7 +64,7 @@ function init (client, $) { } }); return value; - } + }; careportal.prepare = function prepare ( ) { careportal.prepareEvents(); From 8c0dac67325fece4eeefa4d813ee16e78d0663a9 Mon Sep 17 00:00:00 2001 From: juliatakeuti Date: Mon, 14 Sep 2015 17:25:39 -0300 Subject: [PATCH 123/176] Brazilian Portuguese update --- lib/language.js | 67 ++++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/lib/language.js b/lib/language.js index ab02767fca3..6f94313f2ee 100644 --- a/lib/language.js +++ b/lib/language.js @@ -121,7 +121,7 @@ function init() { ,de: 'Sa' ,es: 'Sab' ,fr: 'Sa' - ,pt: 'Sa' + ,pt: 'Sab' ,sv: 'Lör' ,ro: 'Sa' ,bg: 'Съб' @@ -421,7 +421,7 @@ function init() { ,de: 'Bis' ,es: 'Hasta' ,fr: 'À' - ,pt: 'Para' + ,pt: 'a' ,ro: 'La' ,bg: 'До' ,hr: 'Do' @@ -556,7 +556,7 @@ function init() { ,de: 'Darstellen' ,es: 'Visualizar' ,fr: 'Afficher' - ,pt: 'Mostrar' + ,pt: 'Visualizar' ,ro: 'Afișează' ,bg: 'Покажи' ,hr: 'Prikaži' @@ -842,7 +842,7 @@ function init() { ,de: 'Keine Daten verfügbar' ,es: 'No hay datos disponibles' ,fr: 'Pas de données disponibles' - ,pt: 'não há dados' + ,pt: 'Não há dados' ,ro: 'Fără date' ,bg: 'Няма данни за показване' ,hr: 'Nema raspoloživih podataka' @@ -1097,7 +1097,7 @@ function init() { ,de: 'Gesamttage' ,es: 'Total de días' ,fr: 'jours totaux' - ,pt: 'dias total' + ,pt: 'dias no total' ,sv: 'antal dagar' ,ro: 'total zile' ,bg: 'общо за деня' @@ -1202,7 +1202,7 @@ function init() { ,de: 'Max' ,es: 'Max' ,fr: 'Max' - ,pt: 'Max' + ,pt: 'Máx' ,sv: 'Max' ,ro: 'Max' ,bg: 'Макс.' @@ -1217,7 +1217,7 @@ function init() { ,de: 'Min' ,es: 'Min' ,fr: 'Min' - ,pt: 'Min' + ,pt: 'Mín' ,sv: 'Min' ,ro: 'Min' ,bg: 'Мин.' @@ -1232,7 +1232,7 @@ function init() { ,de: 'Prognose HbA1c*' ,es: 'Estimación de HbA1c*' ,fr: 'Estimation HbA1c*' - ,pt: 'A1c estimada' + ,pt: 'HbA1c estimada*' ,ro: 'HbA1C estimată' ,bg: 'Очакван HbA1c' ,hr: 'Procjena HbA1c-a' @@ -1293,7 +1293,7 @@ function init() { ,de: 'Keine API-Prüfsumme gespeichert. Bitte API-Prüfsumme eingeben.' ,es: 'No se ha almacenado ningún hash todavía. Debe introducir su secreto API.' ,fr: 'Pas de secret API existant. Vous devez l\'en entrer.' - ,pt: 'Hash de segredo de API inexistente. Entre um segredo de API' + ,pt: 'Hash de segredo de API inexistente. Insira um segredo de API.' ,ro: 'Încă nu există cheie API secretă. Aceasta trebuie introdusă.' ,bg: 'Няма запаметена API парола. Tрябва да въведете API парола' ,hr: 'Nema pohranjenog API tajnog hasha. Unesite tajni API' @@ -1503,7 +1503,7 @@ function init() { ,de: 'Fehlerhafte API-Prüfsumme' ,es: 'Secreto API incorrecto' ,fr: 'Secret API erroné' - ,pt: 'Segredo de API fraco' + ,pt: 'Segredo de API incorreto' ,ro: 'Cheie API greșită' ,bg: 'Некоректна API парола' ,hr: 'Neispravan tajni API' @@ -1713,7 +1713,7 @@ function init() { ,de: 'Bearbeitung' ,es: 'Tratamientos' ,fr: 'Traitements' - ,pt: 'Tratamentos' + ,pt: 'Procedimentos' ,sv: 'Behandling' ,ro: 'Tratamente' ,bg: 'Събития' @@ -1788,7 +1788,7 @@ function init() { ,de: 'Bearbeitung löschen' ,es: '¿Borrar este tratamiento?' ,fr: 'Effacer ce traitement?' - ,pt: 'Apagar este tratamento' + ,pt: 'Apagar este procedimento?' ,ro: 'Șterge acest eveniment?' ,bg: 'Изтрий това събитие' ,hr: 'Izbriši ovaj tretman?' @@ -1998,7 +1998,7 @@ function init() { ,de: 'Verwende verzehrte Kohlenhydrate zur Kalkulation' ,es: 'Usar la corrección de COB en los cálculos' ,fr: 'Utiliser les COB dans les calculs' - ,pt: 'Usar COB no cálculo' + ,pt: 'Usar correção de COB no cálculo' ,ro: 'Folosește COB în calcule' ,bg: 'Включи активните ВХ в изчислението' ,hr: 'Koristi aktivne UH u izračunu' @@ -2223,6 +2223,7 @@ function init() { ,de: '15 Min. später' ,es: '15 min más tarde' ,fr: '15 min après' + ,pt: '15 min depois' ,ro: 'după 15 min' ,bg: 'След 15 минути' ,hr: '15 minuta kasnije' @@ -2357,7 +2358,7 @@ function init() { ,de: 'Eingabe senden' ,es: 'Enviar formulario' ,fr: 'Formulaire de soumission' - ,pt: 'Submeter formulário' + ,pt: 'Enviar formulário' ,sv: 'Överför händelse' ,ro: 'Trimite formularul' ,bg: 'Въвеждане на данните' @@ -2387,7 +2388,7 @@ function init() { ,de: 'Berichte' ,es: 'Herramienta de informes' ,fr: 'Outil de rapport' - ,pt: 'Ferramenta de relatórios' + ,pt: 'Relatórios' ,sv: 'Rapportverktyg' ,ro: 'Instrument de rapoarte' ,bg: 'Статистика' @@ -2582,7 +2583,7 @@ function init() { ,de: 'Finger' ,es: 'Dedo' ,fr: 'Doigt' - ,pt: 'Dedo' + ,pt: 'Ponta de dedo' ,sv: 'Finger' ,ro: 'Deget' ,bg: 'От пръстта' @@ -2777,7 +2778,7 @@ function init() { ,de: 'Einstellungen' ,es: 'Ajustes' ,fr: 'Paramètres' - ,pt: 'Definições' + ,pt: 'Ajustes' ,sv: 'Inställningar' ,ro: 'Setări' ,bg: 'Настройки' @@ -2852,7 +2853,7 @@ function init() { ,de: 'Dateneingabe' ,es: 'Apuntar un tratamiento' ,fr: 'Entrer un traitement' - ,pt: 'Entre um tratamento' + ,pt: 'Entre um procedimento' ,ro: 'Înregistrează un eveniment' ,bg: 'Въвеждане на събитие' ,hr: 'Evidencija tretmana' @@ -2927,7 +2928,7 @@ function init() { ,de: 'Kohlenhydrate Korrektur' ,es: 'Hidratos de carbono de corrección' ,fr: 'Correction glucide' - ,pt: 'Carboidrato de correção' + ,pt: 'Correção com carboidrato' ,ro: 'Corecție de carbohidrați' ,bg: 'Корекция чрез въглехидрати' ,hr: 'Bolus za hranu' @@ -2970,6 +2971,7 @@ function init() { ,'Announcement' : { bg: 'Известяване' , fi: 'Tiedoitus' + ,pt: 'Aviso' } ,'Exercise' : { cs: 'Cvičení' @@ -3036,7 +3038,7 @@ function init() { ,de: 'Dexcom Sensor Start' ,es: 'Inicio de sensor Dexcom' ,fr: 'Démarrage senseur Dexcom' - ,pt: 'Início de sensor Dexcom' + ,pt: 'Início de sensor' ,sv: 'Dexcom sensorstart' ,ro: 'Pornire senzor Dexcom' ,bg: 'Поставяне на Декском сензор' @@ -3051,7 +3053,7 @@ function init() { ,de: 'Dexcom Sensor Wechsel' ,es: 'Cambio de sensor Dexcom' ,fr: 'Changement senseur Dexcom' - ,pt: 'Troca de sensor Dexcom' + ,pt: 'Troca de sensor' ,sv: 'Dexcom sensorbyte' ,ro: 'Schimbare senzor Dexcom' ,bg: 'Смяна на Декском сензор' @@ -3186,7 +3188,7 @@ function init() { ,de: 'Zeige alle Eingaben' ,es: 'Visualizar todos los tratamientos' ,fr: 'Voir tous les traitements' - ,pt: 'Visualizar todos os tratamentos' + ,pt: 'Visualizar todos os procedimentos' ,sv: 'Visa behandlingar' ,ro: 'Vezi toate evenimentele' ,bg: 'Преглед на всички събития' @@ -3231,7 +3233,7 @@ function init() { ,de: 'Achtung Hoch Alarm' ,es: 'Alarma de glucemia alta urgente' ,fr: 'Alarme haute urgente' - ,pt: 'Alarme de alto urgente' + ,pt: 'URGENTE: Alarme de glicemia alta' ,sv: 'Brådskande högt larmvärde' ,ro: 'Alarmă urgentă hiper' ,bg: 'Много висока КЗ' @@ -3246,7 +3248,7 @@ function init() { ,de: 'Hoch Alarm' ,es: 'Alarma de glucemia alta' ,fr: 'Alarme haute' - ,pt: 'Alarme de alto' + ,pt: 'Alarme de glicemia alta' ,sv: 'Högt larmvärde' ,ro: 'Alarmă hiper' ,bg: 'Висока КЗ' @@ -3261,7 +3263,7 @@ function init() { ,de: 'Tief Alarm' ,es: 'Alarma de glucemia baja' ,fr: 'Alarme basse' - ,pt: 'Alarme de baixo' + ,pt: 'Alarme de glicemia baixa' ,sv: 'Lågt larmvärde' ,ro: 'Alarmă hipo' ,bg: 'Ниска КЗ' @@ -3276,7 +3278,7 @@ function init() { ,de: 'Achtung Tief Alarm' ,es: 'Alarma de glucemia baja urgente' ,fr: 'Alarme basse urgente' - ,pt: 'Alarme de baixo urgente' + ,pt: 'URGENTE: Alarme de glicemia baixa' ,sv: 'Brådskande lågt larmvärde' ,ro: 'Alarmă urgentă hipo' ,bg: 'Много ниска КЗ' @@ -3351,7 +3353,7 @@ function init() { ,de: 'Wenn aktiviert wird die Anzeige von 22 Uhr - 6 Uhr gedimmt' ,es: 'Cuando esté activo, el brillo de la página bajará de 10pm a 6am.' ,fr: 'Si activé, la page sera assombire de 22:00 à 6:00' - ,pt: 'Se ativado, a página será escurecida de 22h a 6h' + ,pt: 'Se ativado, a página será escurecida entre 22h e 6h' ,sv: 'När aktiverad dimmas sidan mellan 22:00 - 06:00' ,ro: 'La activare va scădea iluminarea între 22 și 6' ,bg: 'Когато е активирано, страницата ще е затъмнена от 22-06ч' @@ -3441,7 +3443,7 @@ function init() { ,de: 'Bei Aktivierung erscheinen kleine weiße Punkte für Roh-Blutglukose Daten' ,es: 'Cuando esté activo, pequeños puntos blancos mostrarán los datos en crudo' ,fr: 'Si activé, des points blancs représenteront les données brutes' - ,pt: 'Se ativado, pontinhos brancos representarão os dados de glicemia não processados' + ,pt: 'Se ativado, pontos brancos representarão os dados de glicemia não processados' ,sv: 'När aktiverad visar de vita punkterna RAW-blodglukosevärden' ,ro: 'La activare vor apărea puncte albe reprezentând citirea brută a glicemiei' ,bg: 'Когато е активно, малки бели точки ще показват RAW данните' @@ -3501,7 +3503,7 @@ function init() { ,de: 'Farben' ,es: 'Colores' ,fr: 'Couleurs' - ,pt: 'Cores' + ,pt: 'Colorido' ,sv: 'Färg' ,ro: 'Colorată' ,bg: 'Цветна' @@ -3561,7 +3563,7 @@ function init() { ,de: 'Bolus Kalkulator' ,es: 'Bolus Wizard' ,fr: 'Calculateur de bolus' - ,pt: 'Bolus Wizard' + ,pt: 'Calculadora de bolus' ,sv: 'Boluskalkylator' ,ro: 'Calculator sugestie bolus' ,bg: 'Съветник при изчисление на болуса' @@ -3771,7 +3773,7 @@ function init() { ,de: 'Eingabe Typ' ,es: 'Tipo de tratamiento' ,fr: 'Type de traitement' - ,pt: 'Tipo de tratamento' + ,pt: 'Tipo de procedimento' ,sv: 'Behandlingstyp' ,ro: 'Tip tratament' ,bg: 'Вид събитие' @@ -3891,6 +3893,7 @@ function init() { ,de: 'Kohlenhydrate Zeit' ,es: 'Momento de la ingesta' ,fr: 'Moment de Glucide' + ,pt: 'Hora do carboidrato' ,bg: 'Ядене след' ,hr: 'Vrijeme unosa UH' ,sv: 'Kolhydratstid' @@ -3902,9 +3905,11 @@ function init() { ,'Language' : { cs: 'Jazyk' ,fi: 'Kieli' + ,pt: 'Língua' } ,'Update' : { // Update button cs: 'Aktualizovat' + ,pt: 'Atualizar' } }; From cc28d373a7c9e53221dbf98c5657bdef673a8ebb Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Wed, 9 Sep 2015 20:20:56 +0200 Subject: [PATCH 124/176] report.test.js coverage increase --- tests/reports.test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/reports.test.js b/tests/reports.test.js index 9ce93c5bc31..4fc7c4cb9a8 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -174,6 +174,13 @@ describe('reports', function ( ) { $('#rp_from').val('2015/08/08'); $('#rp_to').val('2015/09/07'); + $('#rp_optionsraw').prop('checked',true); + $('#rp_optionsiob').prop('checked',true); + $('#rp_optionscob').prop('checked',true); + $('#rp_log').prop('checked',true); + $('#rp_show').click(); + + $('#rp_linear').prop('checked',true); $('#rp_show').click(); var result = $('body').html(); From feb8ad6a3f832aa490823f7a4ab8f4d936cf5b29 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Wed, 9 Sep 2015 20:26:25 +0200 Subject: [PATCH 125/176] commented out success report --- tests/reports.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/reports.test.js b/tests/reports.test.js index 4fc7c4cb9a8..2af431fc5b9 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -193,7 +193,7 @@ describe('reports', function ( ) { result.indexOf('
    0%100%0%28.338%68.78.80.216 (100%)118.38.910.611.718.32.7Correction Bolus250 (Sensor)0.75Mom '+translate('75%')+'
    ').css('width','300px').attr('align','left').append(translate('Notes'))) ); - Object.keys(daystoshow).forEach(function (day) { + sorteddaystoshow.forEach(function (day) { table.append($('
    ').attr('colspan','8').css('background','lightgray') .append($('').append(report_plugins.utils.localeDate(day))) ) ); - var treatments = datastorage[day].treatments; + var treatments = _.clone(datastorage[day].treatments); + if (options.order === report_plugins.consts.ORDER_NEWESTONTOP) { + treatments.reverse(); + } for (var t=0; t').addClass('border_bottom') diff --git a/static/report/index.html b/static/report/index.html index 7cfa86f787e..300372d157e 100644 --- a/static/report/index.html +++ b/static/report/index.html @@ -96,6 +96,17 @@

    Nightscout reporting

    + Order: + + +   + + +
    diff --git a/static/report/js/report.js b/static/report/js/report.js index eac70b7524e..f497532a260 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -33,6 +33,7 @@ var maxdays = 3 * 31; var datastorage = {}; var daystoshow = {}; + var sorteddaystoshow = []; var targetBGdefault = { 'mg/dl': { @@ -251,6 +252,7 @@ options.insulin = $('#rp_optionsinsulin').is(':checked'); options.carbs = $('#rp_optionscarbs').is(':checked'); options.scale = ( $('#rp_linear').is(':checked') ? report_plugins.consts.SCALE_LINEAR : report_plugins.consts.SCALE_LOG ); + options.order = ( $('#rp_oldestontop').is(':checked') ? report_plugins.consts.ORDER_OLDESTONTOP : report_plugins.consts.ORDER_NEWESTONTOP ); options.width = parseInt($('#rp_size :selected').attr('x')); options.height = parseInt($('#rp_size :selected').attr('y')); @@ -447,6 +449,15 @@ function dataLoadedCallback () { loadeddays++; if (loadeddays === dayscount) { + // sort array + sorteddaystoshow = []; + Object.keys(daystoshow).forEach(function (day) { + sorteddaystoshow.push(day); + }); + sorteddaystoshow.sort(); + if (options.order === report_plugins.consts.ORDER_NEWESTONTOP) { + sorteddaystoshow.reverse(); + } showreports(options); } } @@ -474,7 +485,7 @@ // jquery plot doesn't draw to hidden div $('#'+plugin.name+'-placeholder').css('display',''); //console.log('Drawing ',plugin.name); - plugin.report(datastorage,daystoshow,options); + plugin.report(datastorage,sorteddaystoshow,options); if (!$('#'+plugin.name).hasClass('selected')) { $('#'+plugin.name+'-placeholder').css('display','none'); } From eb96f9acd0c5e1b27ed7b22c4f5766bcf3e2a6e7 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Tue, 15 Sep 2015 23:00:53 +0200 Subject: [PATCH 153/176] codacy flotcandle.js --- static/report/js/flotcandle.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/static/report/js/flotcandle.js b/static/report/js/flotcandle.js index 0a6c23d6c2c..8a965e0f4bf 100644 --- a/static/report/js/flotcandle.js +++ b/static/report/js/flotcandle.js @@ -36,15 +36,15 @@ } function drawCandle(ctx, serie, width, dt, open, low, close, high){ if (open < close){ //Rising - y = offset.top + serie.yaxis.p2c(open) + y = offset.top + serie.yaxis.p2c(open); height = serie.yaxis.p2c(close) - serie.yaxis.p2c(open); - ctx.fillStyle = "#51FF21"; + ctx.fillStyle = '#51FF21'; } else { //Decending - y = offset.top + serie.yaxis.p2c(close) + y = offset.top + serie.yaxis.p2c(close); height = serie.yaxis.p2c(open) - serie.yaxis.p2c(close); - ctx.fillStyle = "#FF0000"; + ctx.fillStyle = '#FF0000'; } - ctx.strokeStyle = "#000000"; + ctx.strokeStyle = '#000000'; ctx.lineWidth = 0; x = offset.left + serie.xaxis.p2c(dt); From c7200f121f6252417fa1460a0b59c5fa681bc333 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Tue, 15 Sep 2015 23:36:01 +0200 Subject: [PATCH 154/176] reports css cleanup --- lib/report_plugins/dailystats.js | 14 +++ lib/report_plugins/glucosedistribution.js | 1 + lib/report_plugins/hourlystats.js | 12 ++- lib/report_plugins/percentile.js | 7 ++ lib/report_plugins/success.js | 28 ++++++ lib/report_plugins/treatments.js | 6 ++ static/css/report.css | 108 ++++++---------------- static/report/js/report.js | 2 - 8 files changed, 97 insertions(+), 81 deletions(-) diff --git a/lib/report_plugins/dailystats.js b/lib/report_plugins/dailystats.js index 59438c9083f..7fcbd3a15f8 100644 --- a/lib/report_plugins/dailystats.js +++ b/lib/report_plugins/dailystats.js @@ -21,6 +21,20 @@ dailystats.html = function html(client) { return ret; }; +dailystats.css = + '#dailystats-placeholder .tdborder {' + + ' width:80px;' + + ' border: 1px #ccc solid;' + + ' margin: 0;' + + ' padding: 1px;' + + ' text-align:center;' + + '}' + + '#dailystats-placeholder .inlinepiechart {' + + ' width: 2.0in;' + + ' height: 0.9in;' + + '}' + ; + dailystats.report = function report_dailystats(datastorage,sorteddaystoshow,options) { var Nightscout = window.Nightscout; var client = Nightscout.client; diff --git a/lib/report_plugins/glucosedistribution.js b/lib/report_plugins/glucosedistribution.js index a606d3d91bc..30f62761b3a 100644 --- a/lib/report_plugins/glucosedistribution.js +++ b/lib/report_plugins/glucosedistribution.js @@ -41,6 +41,7 @@ glucosedistribution.css = + ' border: 1px #ccc solid;' + ' margin: 0;' + ' padding: 1px;' + + ' text-align:center;' + '}' ; diff --git a/lib/report_plugins/hourlystats.js b/lib/report_plugins/hourlystats.js index 552f5a460e2..999b18d513b 100644 --- a/lib/report_plugins/hourlystats.js +++ b/lib/report_plugins/hourlystats.js @@ -22,6 +22,16 @@ hourlystats.html = function html(client) { return ret; }; +hourlystats.css = + '#hourlystats-overviewchart {' + + ' width: 100%;' + + ' min-width: 6.5in;' + + ' height: 5in;' + + '}' + + '#hourlystats-placeholder td {' + + ' text-align:center;' + + '}' ; + hourlystats.report = function report_hourlystats(datastorage, sorteddaystoshow, options) { //console.log(window); var ss = require('simple-statistics'); @@ -42,7 +52,7 @@ hourlystats.report = function report_hourlystats(datastorage, sorteddaystoshow, var d = new Date(record.displayTime); pivotedByHour[d.getHours()].push(record); }); - var table = $(''); + var table = $('
    '); var thead = $(''); $('').appendTo(thead); $('').appendTo(thead); diff --git a/lib/report_plugins/percentile.js b/lib/report_plugins/percentile.js index 9da62a906ad..680e7f66d86 100644 --- a/lib/report_plugins/percentile.js +++ b/lib/report_plugins/percentile.js @@ -23,6 +23,13 @@ percentile.html = function html(client) { return ret; }; +percentile.css = + '#percentile-chart {' + + ' width: 100%;' + + ' height: 100%;' + + '}' + ; + percentile.report = function report_percentile(datastorage, sorteddaystoshow, options) { var Nightscout = window.Nightscout; var client = Nightscout.client; diff --git a/lib/report_plugins/success.js b/lib/report_plugins/success.js index 8ecc924b5df..1ef01f1a16a 100644 --- a/lib/report_plugins/success.js +++ b/lib/report_plugins/success.js @@ -21,6 +21,34 @@ success.html = function html(client) { return ret; }; +success.css = + '#success-placeholder td {'+ + ' border: 1px #ccc solid;'+ + ' margin: 0;'+ + ' padding: 1px;'+ + ' text-align:center;'+ + '}'+ + '#success-placeholder .bad {'+ + ' background-color: #fcc;'+ + '}'+ + + '#success-placeholder .good {'+ + ' background-color: #cfc;'+ + '}'+ + + '#success-placeholder th:first-child {'+ + ' width: 30%;'+ + '}'+ + '#success-placeholder th {'+ + ' width: 10%;'+ + '}'+ + '#success-placeholder table {'+ + ' width: 100%;'+ + '}' + ; + + + success.report = function report_success(datastorage, sorteddaystoshow, options) { var Nightscout = window.Nightscout; var client = Nightscout.client; diff --git a/lib/report_plugins/treatments.js b/lib/report_plugins/treatments.js index 443ef6eadb6..899ae39bcc4 100644 --- a/lib/report_plugins/treatments.js +++ b/lib/report_plugins/treatments.js @@ -65,6 +65,12 @@ treatments.html = function html(client) { return ret; }; + +treatments.css = + '.border_bottom td {' + + ' border-bottom:1pt solid #eee;' + + '}' + ; treatments.report = function report_treatments(datastorage, sorteddaystoshow, options) { var Nightscout = window.Nightscout; diff --git a/static/css/report.css b/static/css/report.css index 030c8535244..991bf73be17 100644 --- a/static/css/report.css +++ b/static/css/report.css @@ -4,96 +4,48 @@ html, body { - height: 100%; - margin: 0; - padding: 0; + height: 100%; + margin: 0; + padding: 0; } body { - font-family: 'Open Sans', Helvetica, Arial, sans-serif; - background: white; - color: black; -} -.inlinepiechart { - width: 2.0in; - height: 0.9in; -} - -#percentile-chart { - width: 100%; - height: 100%; -} -#hourlystats-overviewchart { - width: 100%; - min-width: 6.5in; - height: 5in; -} -#success-placeholder table td { - border: 1px #ccc solid; - margin: 0; - padding: 1px; -} - -#success-placeholder td.bad { - background-color: #fcc; -} - -#success-placeholder td.good { - background-color: #cfc; -} - -#success-placeholder th:first-child { - width: 30%; -} -#success-placeholder th { - width: 10%; -} -#success-placeholder table { - width: 100%; -} - -.centeraligned { - text-align:center; -} - -#dailystats-placeholder td.tdborder { - width:80px; - border: 1px #ccc solid; - margin: 0; - padding: 1px; + font-family: 'Open Sans', Helvetica, Arial, sans-serif; + background: white; + color: black; } -ul#tabnav { /* general settings */ -text-align: left; /* set to left, right or center */ -margin: 1em 0 1em 0; /* set margins as desired */ -font: bold 11px verdana, arial, sans-serif; /* set font as desired */ -border-bottom: 1px solid #6c6; /* set border COLOR as desired */ -list-style-type: none; -padding: 3px 10px 3px 10px; /* THIRD number must change with respect to padding-top (X) below */ +#.centeraligned { + text-align:center; } -ul#tabnav li { /* do not change */ -display: inline; +ul#tabnav { + text-align: left; + margin: 1em 0 1em 0; + font: bold 11px verdana, arial, sans-serif; + border-bottom: 1px solid #6c6; + list-style-type: none; + padding: 3px 10px 3px 10px; } -ul#tabnav li{ /* settings for all tab links */ -padding: 3px 4px; /* set padding (tab size) as desired; FIRST number must change with respect to padding-top (X) above */ -border: 1px solid #6c6; /* set border COLOR as desired; usually matches border color specified in #tabnav */ -background-color: #cfc; /* set unselected tab background color as desired */ -color: #666; /* set unselected tab link color as desired */ -margin-right: 0px; /* set additional spacing between tabs as desired */ -text-decoration: none; -border-bottom: none; +ul#tabnav li { + display: inline; } -ul#tabnav li.selected { /* settings selected tab */ -background: #fff; /* set desired selected color */ +ul#tabnav li{ + padding: 3px 4px; + border: 1px solid #6c6; + background-color: #cfc; + color: #666; + margin-right: 0; + text-decoration: none; + border-bottom: none; } -ul#tabnav li:hover { /* settings for hover effect */ -background: #9f9; /* set desired hover color */ -cursor:pointer; +ul#tabnav li.selected { + background: #fff; } -tr.border_bottom td { - border-bottom:1pt solid #eee; +ul#tabnav li:hover { + background: #9f9; + cursor:pointer; } diff --git a/static/report/js/report.js b/static/report/js/report.js index f497532a260..bcb5154e513 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -1,8 +1,6 @@ // TODO: // - bypass nightmode in reports // - get rid of /static/report/js/time.js -// - load css dynamic + optimize -// - add tests // - on save/delete treatment ctx.bus.emit('data-received'); is not enough. we must add something like 'data-updated' (function () { From e9907c079a0b332476888642445efaaded30baed Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Tue, 15 Sep 2015 23:47:44 +0200 Subject: [PATCH 155/176] more codacy flotcandle.js --- static/report/js/flotcandle.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/static/report/js/flotcandle.js b/static/report/js/flotcandle.js index 8a965e0f4bf..3ac641d1cf5 100644 --- a/static/report/js/flotcandle.js +++ b/static/report/js/flotcandle.js @@ -35,6 +35,7 @@ drawCandle(ctx, serie, width, dt, open, low, close, high); } function drawCandle(ctx, serie, width, dt, open, low, close, high){ + var height; if (open < close){ //Rising y = offset.top + serie.yaxis.p2c(open); height = serie.yaxis.p2c(close) - serie.yaxis.p2c(open); @@ -56,9 +57,10 @@ var lowY = serie.yaxis.p2c(low); //top + var lineX; if (highY < y + height){ ctx.beginPath(); - var lineX = x + (width /2); + lineX = x + (width /2); ctx.moveTo(lineX,y + height); ctx.lineTo(lineX,highY); ctx.closePath(); From 499ed62e0ef4edf7437ec63e8f9ebbb318060c29 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Wed, 16 Sep 2015 00:20:09 +0200 Subject: [PATCH 156/176] get rid of time.js from reports --- lib/report_plugins/hourlystats.js | 6 +- lib/report_plugins/success.js | 6 +- static/report/index.html | 1 - static/report/js/time.js | 318 ------------------------------ 4 files changed, 8 insertions(+), 323 deletions(-) delete mode 100644 static/report/js/time.js diff --git a/lib/report_plugins/hourlystats.js b/lib/report_plugins/hourlystats.js index 999b18d513b..59f86be5209 100644 --- a/lib/report_plugins/hourlystats.js +++ b/lib/report_plugins/hourlystats.js @@ -1,5 +1,7 @@ 'use strict'; +var times = require('../times'); + var hourlystats = { name: 'hourlystats' , label: 'Hourly stats' @@ -70,7 +72,7 @@ hourlystats.report = function report_hourlystats(datastorage, sorteddaystoshow, var display = new Date(0, 0 , 1, hour, 0, 0, 0).toLocaleTimeString().replace(/([\d]+:[\d]{2})(:[\d]{2})(.*)/, '$1$3'); var avg = Math.floor(pivotedByHour[hour].map(function(r) { return r.sgv; }).reduce(function(o,v){ return o+v; }, 0) / pivotedByHour[hour].length); - var d = new Date(hour.hours()); + var d = new Date(times.hours(hour).msecs); var dev = ss.standard_deviation(pivotedByHour[hour].map(function(r) { return r.sgv; })); stats.push([ @@ -111,7 +113,7 @@ hourlystats.report = function report_hourlystats(datastorage, sorteddaystoshow, mode: 'time', timeFormat: '%h:00', min: 0, - max: (24).hours()-(1).seconds() + max: times.hours(24).msecs - times.secs(1).msecs }, yaxis: { min: 0, diff --git a/lib/report_plugins/success.js b/lib/report_plugins/success.js index 1ef01f1a16a..0199c453bf1 100644 --- a/lib/report_plugins/success.js +++ b/lib/report_plugins/success.js @@ -1,5 +1,7 @@ 'use strict'; +var times = require('../times'); + var success = { name: 'success' , label: 'Weekly success' @@ -62,7 +64,7 @@ success.report = function report_success(datastorage, sorteddaystoshow, options) var data = datastorage.allstatsrecords; var now = Date.now(); - var period = (7).days(); + var period = 7 * times.hours(24).msecs; var firstDataPoint = data.reduce(function(min, record) { return Math.min(min, record.displayTime); }, Number.MAX_VALUE); @@ -176,7 +178,7 @@ success.report = function report_success(datastorage, sorteddaystoshow, options) }).map(function(quarter) { var INVERT = true; return '' + [ - quarter.starting.format('M d Y') + ' - ' + quarter.ending.format('M d Y'), + quarter.starting.toLocaleDateString() + ' - ' + quarter.ending.toLocaleDateString(), { klass: lowComparison(quarter, averages, 'percentLow'), text: Math.round(quarter.percentLow) + '%' diff --git a/static/report/index.html b/static/report/index.html index 300372d157e..b3ab5d23305 100644 --- a/static/report/index.html +++ b/static/report/index.html @@ -127,7 +127,6 @@

    Nightscout reporting

    - diff --git a/static/report/js/time.js b/static/report/js/time.js deleted file mode 100644 index 0b34d7d47bf..00000000000 --- a/static/report/js/time.js +++ /dev/null @@ -1,318 +0,0 @@ -if (!("milliseconds" in Number.prototype)) - Number.prototype.milliseconds = function() { return this; }; -if (!("seconds" in Number.prototype)) - Number.prototype.seconds = function() { return this.milliseconds() * 1000; }; -if (!("minutes" in Number.prototype)) - Number.prototype.minutes = function() { return this.seconds() * 60; }; -if (!("hours" in Number.prototype)) - Number.prototype.hours = function() { return this.minutes() * 60; }; -if (!("days" in Number.prototype)) - Number.prototype.days = function() { return this.hours() * 24; }; -if (!("weeks" in Number.prototype)) - Number.prototype.weeks = function() { return this.days() * 7; }; -if (!("months" in Number.prototype)) - Number.prototype.months = function() { return this.days() * 30; }; - -if (!("toDays" in Number.prototype)) - Number.prototype.toDays = function() { return this.toHours() / 24; }; -if (!("toHours" in Number.prototype)) - Number.prototype.toHours = function() { return this.toMinutes() / 60; }; -if (!("toMinutes" in Number.prototype)) - Number.prototype.toMinutes = function() { return this.toSeconds() / 60; }; -if (!("toSeconds" in Number.prototype)) - Number.prototype.toSeconds = function() { return this.toMilliseconds() / 1000; }; -if (!("toMilliseconds" in Number.prototype)) - Number.prototype.toMilliseconds = function() { return this; }; - -Date.prototype.format = function(format) { - // discuss at: http://phpjs.org/functions/date/ - // original by: Carlos R. L. Rodrigues (http://www.jsfromhell.com) - // original by: gettimeofday - // parts by: Peter-Paul Koch (http://www.quirksmode.org/js/beat.html) - // improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) - // improved by: MeEtc (http://yass.meetcweb.com) - // improved by: Brad Touesnard - // improved by: Tim Wiel - // improved by: Bryan Elliott - // improved by: David Randall - // improved by: Theriault - // improved by: Theriault - // improved by: Brett Zamir (http://brett-zamir.me) - // improved by: Theriault - // improved by: Thomas Beaucourt (http://www.webapp.fr) - // improved by: JT - // improved by: Theriault - // improved by: Rafał Kukawski (http://blog.kukawski.pl) - // improved by: Theriault - // input by: Brett Zamir (http://brett-zamir.me) - // input by: majak - // input by: Alex - // input by: Martin - // input by: Alex Wilson - // input by: Haravikk - // bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) - // bugfixed by: majak - // bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) - // bugfixed by: Brett Zamir (http://brett-zamir.me) - // bugfixed by: omid (http://phpjs.org/functions/380:380#comment_137122) - // bugfixed by: Chris (http://www.devotis.nl/) - // note: Uses global: php_js to store the default timezone - // note: Although the function potentially allows timezone info (see notes), it currently does not set - // note: per a timezone specified by date_default_timezone_set(). Implementers might use - // note: this.php_js.currentTimezoneOffset and this.php_js.currentTimezoneDST set by that function - // note: in order to adjust the dates in this function (or our other date functions!) accordingly - // example 1: date('H:m:s \\m \\i\\s \\m\\o\\n\\t\\h', 1062402400); - // returns 1: '09:09:40 m is month' - // example 2: date('F j, Y, g:i a', 1062462400); - // returns 2: 'September 2, 2003, 2:26 am' - // example 3: date('Y W o', 1062462400); - // returns 3: '2003 36 2003' - // example 4: x = date('Y m d', (new Date()).getTime()/1000); - // example 4: (x+'').length == 10 // 2009 01 09 - // returns 4: true - // example 5: date('W', 1104534000); - // returns 5: '53' - // example 6: date('B t', 1104534000); - // returns 6: '999 31' - // example 7: date('W U', 1293750000.82); // 2010-12-31 - // returns 7: '52 1293750000' - // example 8: date('W', 1293836400); // 2011-01-01 - // returns 8: '52' - // example 9: date('W Y-m-d', 1293974054); // 2011-01-02 - // returns 9: '52 2011-01-02' - - var that = this, timestamp = this; - var jsdate, f; - // Keep this here (works, but for code commented-out below for file size reasons) - // var tal= []; - var txt_words = [ - 'Sun', 'Mon', 'Tues', 'Wednes', 'Thurs', 'Fri', 'Satur', - 'January', 'February', 'March', 'April', 'May', 'June', - 'July', 'August', 'September', 'October', 'November', 'December' - ]; - // trailing backslash -> (dropped) - // a backslash followed by any character (including backslash) -> the character - // empty string -> empty string - var formatChr = /\\?(.?)/gi; - var formatChrCb = function(t, s) { - return f[t] ? f[t]() : s; - }; - var _pad = function(n, c) { - n = String(n); - while (n.length < c) { - n = '0' + n; - } - return n; - }; - f = { - // Day - d: function() { // Day of month w/leading 0; 01..31 - return _pad(f.j(), 2); - }, - D: function() { // Shorthand day name; Mon...Sun - return f.l() - .slice(0, 3); - }, - j: function() { // Day of month; 1..31 - return jsdate.getDate(); - }, - l: function() { // Full day name; Monday...Sunday - return txt_words[f.w()] + 'day'; - }, - N: function() { // ISO-8601 day of week; 1[Mon]..7[Sun] - return f.w() || 7; - }, - S: function() { // Ordinal suffix for day of month; st, nd, rd, th - var j = f.j(); - var i = j % 10; - if (i <= 3 && parseInt((j % 100) / 10, 10) == 1) { - i = 0; - } - return ['st', 'nd', 'rd'][i - 1] || 'th'; - }, - w: function() { // Day of week; 0[Sun]..6[Sat] - return jsdate.getDay(); - }, - z: function() { // Day of year; 0..365 - var a = new Date(f.Y(), f.n() - 1, f.j()); - var b = new Date(f.Y(), 0, 1); - return Math.round((a - b) / 864e5); - }, - - // Week - W: function() { // ISO-8601 week number - var a = new Date(f.Y(), f.n() - 1, f.j() - f.N() + 3); - var b = new Date(a.getFullYear(), 0, 4); - return _pad(1 + Math.round((a - b) / 864e5 / 7), 2); - }, - - // Month - F: function() { // Full month name; January...December - return txt_words[6 + f.n()]; - }, - m: function() { // Month w/leading 0; 01...12 - return _pad(f.n(), 2); - }, - M: function() { // Shorthand month name; Jan...Dec - return f.F() - .slice(0, 3); - }, - n: function() { // Month; 1...12 - return jsdate.getMonth() + 1; - }, - t: function() { // Days in month; 28...31 - return (new Date(f.Y(), f.n(), 0)) - .getDate(); - }, - - // Year - L: function() { // Is leap year?; 0 or 1 - var j = f.Y(); - return j % 4 === 0 & j % 100 !== 0 | j % 400 === 0; - }, - o: function() { // ISO-8601 year - var n = f.n(); - var W = f.W(); - var Y = f.Y(); - return Y + (n === 12 && W < 9 ? 1 : n === 1 && W > 9 ? -1 : 0); - }, - Y: function() { // Full year; e.g. 1980...2010 - return jsdate.getFullYear(); - }, - y: function() { // Last two digits of year; 00...99 - return f.Y() - .toString() - .slice(-2); - }, - - // Time - a: function() { // am or pm - return jsdate.getHours() > 11 ? 'pm' : 'am'; - }, - A: function() { // AM or PM - return f.a() - .toUpperCase(); - }, - B: function() { // Swatch Internet time; 000..999 - var H = jsdate.getUTCHours() * 36e2; - // Hours - var i = jsdate.getUTCMinutes() * 60; - // Minutes - var s = jsdate.getUTCSeconds(); // Seconds - return _pad(Math.floor((H + i + s + 36e2) / 86.4) % 1e3, 3); - }, - g: function() { // 12-Hours; 1..12 - return f.G() % 12 || 12; - }, - G: function() { // 24-Hours; 0..23 - return jsdate.getHours(); - }, - h: function() { // 12-Hours w/leading 0; 01..12 - return _pad(f.g(), 2); - }, - H: function() { // 24-Hours w/leading 0; 00..23 - return _pad(f.G(), 2); - }, - i: function() { // Minutes w/leading 0; 00..59 - return _pad(jsdate.getMinutes(), 2); - }, - s: function() { // Seconds w/leading 0; 00..59 - return _pad(jsdate.getSeconds(), 2); - }, - u: function() { // Microseconds; 000000-999000 - return _pad(jsdate.getMilliseconds() * 1000, 6); - }, - - // Timezone - e: function() { // Timezone identifier; e.g. Atlantic/Azores, ... - // The following works, but requires inclusion of the very large - // timezone_abbreviations_list() function. - /* return that.date_default_timezone_get(); - */ - throw 'Not supported (see source code of date() for timezone on how to add support)'; - }, - I: function() { // DST observed?; 0 or 1 - // Compares Jan 1 minus Jan 1 UTC to Jul 1 minus Jul 1 UTC. - // If they are not equal, then DST is observed. - var a = new Date(f.Y(), 0); - // Jan 1 - var c = Date.UTC(f.Y(), 0); - // Jan 1 UTC - var b = new Date(f.Y(), 6); - // Jul 1 - var d = Date.UTC(f.Y(), 6); // Jul 1 UTC - return ((a - c) !== (b - d)) ? 1 : 0; - }, - O: function() { // Difference to GMT in hour format; e.g. +0200 - var tzo = jsdate.getTimezoneOffset(); - var a = Math.abs(tzo); - return (tzo > 0 ? '-' : '+') + _pad(Math.floor(a / 60) * 100 + a % 60, 4); - }, - P: function() { // Difference to GMT w/colon; e.g. +02:00 - var O = f.O(); - return (O.substr(0, 3) + ':' + O.substr(3, 2)); - }, - T: function() { // Timezone abbreviation; e.g. EST, MDT, ... - // The following works, but requires inclusion of the very - // large timezone_abbreviations_list() function. - /* var abbr, i, os, _default; - if (!tal.length) { - tal = that.timezone_abbreviations_list(); - } - if (that.php_js && that.php_js.default_timezone) { - _default = that.php_js.default_timezone; - for (abbr in tal) { - for (i = 0; i < tal[abbr].length; i++) { - if (tal[abbr][i].timezone_id === _default) { - return abbr.toUpperCase(); - } - } - } - } - for (abbr in tal) { - for (i = 0; i < tal[abbr].length; i++) { - os = -jsdate.getTimezoneOffset() * 60; - if (tal[abbr][i].offset === os) { - return abbr.toUpperCase(); - } - } - } - */ - return 'UTC'; - }, - Z: function() { // Timezone offset in seconds (-43200...50400) - return -jsdate.getTimezoneOffset() * 60; - }, - - // Full Date/Time - c: function() { // ISO-8601 date. - return 'Y-m-d\\TH:i:sP'.replace(formatChr, formatChrCb); - }, - r: function() { // RFC 2822 - return 'D, d M Y H:i:s O'.replace(formatChr, formatChrCb); - }, - U: function() { // Seconds since UNIX epoch - return jsdate / 1000 | 0; - } - }; - this.date = function(format, timestamp) { - that = this; - jsdate = (timestamp === undefined ? new Date() : // Not provided - (timestamp instanceof Date) ? new Date(timestamp) : // JS Date() - new Date(timestamp * 1000) // UNIX timestamp (auto-convert to int) - ); - return format.replace(formatChr, formatChrCb); - }; - return this.date(format, timestamp); -} - -// http://stackoverflow.com/questions/11887934/check-if-daylight-saving-time-is-in-effect-and-if-it-is-for-how-many-hours -Date.prototype.stdTimezoneOffset = function() { - var jan = new Date(this.getFullYear(), 0, 1); - var jul = new Date(this.getFullYear(), 6, 1); - return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset()); -}; - -Date.prototype.dst = function() { - return this.getTimezoneOffset() < this.stdTimezoneOffset(); -}; \ No newline at end of file From ac37f5c1d32b8783a2ea6ef3fb19c2d1deef2775 Mon Sep 17 00:00:00 2001 From: MilosKozak Date: Wed, 16 Sep 2015 00:24:49 +0200 Subject: [PATCH 157/176] remove todo, remove include from test --- static/report/js/report.js | 1 - tests/reports.test.js | 1 - 2 files changed, 2 deletions(-) diff --git a/static/report/js/report.js b/static/report/js/report.js index bcb5154e513..83a19c3a10e 100644 --- a/static/report/js/report.js +++ b/static/report/js/report.js @@ -1,6 +1,5 @@ // TODO: // - bypass nightmode in reports -// - get rid of /static/report/js/time.js // - on save/delete treatment ctx.bus.emit('data-received'); is not enough. we must add something like 'data-updated' (function () { diff --git a/tests/reports.test.js b/tests/reports.test.js index 41ef419c47e..751db63f5df 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -214,7 +214,6 @@ describe('reports', function ( ) { benv.require(__dirname + '/../bundle/bundle.source.js'); benv.require(__dirname + '/../static/report/js/report.js'); - benv.require(__dirname + '/../static/report/js/time.js'); benv.require(__dirname + '/../static/bower_components/jquery-ui/jquery-ui.min.js'); done(); From bffd2a7ea9a9744c1d81e610de1b7dab9e34f1f1 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Tue, 15 Sep 2015 15:53:19 -0700 Subject: [PATCH 158/176] only check if low/high events are enabled for now --- lib/settings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/settings.js b/lib/settings.js index dbb8cb1af68..9cc486929cc 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -220,7 +220,7 @@ function init ( ) { function isAlarmEventEnabled (notify) { var enabled = false; - if (!notify.eventName) { + if ('high' !== notify.eventName && 'low' !== notify.eventName) { enabled = true; } else if (notify.eventName === 'high' && notify.level === levels.URGENT && settings.alarmUrgentHigh) { enabled = true; From 6675243df12a24171b16d2340d0033b6267037b7 Mon Sep 17 00:00:00 2001 From: xpucuto Date: Wed, 16 Sep 2015 15:42:37 +0300 Subject: [PATCH 159/176] bulgarian language - 16.Sept.2015 --- lib/language.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/language.js b/lib/language.js index 6f94313f2ee..3f8949287dd 100644 --- a/lib/language.js +++ b/lib/language.js @@ -8,7 +8,7 @@ function init() { } language.languages = [ - { code: 'bg', language: 'Български език' } + { code: 'bg', language: 'Български' } , { code: 'cz', language: 'Čeština' } , { code: 'dk', language: 'Dansk' } , { code: 'de', language: 'Deutsch' } @@ -3906,10 +3906,12 @@ function init() { cs: 'Jazyk' ,fi: 'Kieli' ,pt: 'Língua' + ,bg: 'Език' } ,'Update' : { // Update button cs: 'Aktualizovat' ,pt: 'Atualizar' + ,bg: 'Актуализирай' } }; From 2384f6a4bcc6765e7ec5cea81709bc7a1ee50a03 Mon Sep 17 00:00:00 2001 From: avielf Date: Wed, 16 Sep 2015 17:57:16 +0300 Subject: [PATCH 160/176] Initial Hebrew transltation Translated only days. Need to make sure if should be written backwards because of right-to-left compatibility. --- lib/language.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/language.js b/lib/language.js index 6f94313f2ee..e8cde5e64ad 100644 --- a/lib/language.js +++ b/lib/language.js @@ -22,6 +22,7 @@ function init() { , { code: 'ro', language: 'Română' } , { code: 'sv', language: 'Svenska' } , { code: 'fi', language: 'Suomi' } + , { code: 'he', language: 'עברית' } ]; var translations = { @@ -39,6 +40,7 @@ function init() { ,dk: 'Lytter på port' ,fi: 'Kuuntelen porttia' ,nb: 'Lytter på port' + ,he: 'מקשיב על פתחה' } // Client ,'Mo' : { @@ -55,6 +57,7 @@ function init() { ,dk: 'Man' ,fi: 'Ma' ,nb: 'Man' + ,he: 'ב' } ,'Tu' : { cs: 'Út' @@ -70,6 +73,7 @@ function init() { ,dk: 'Tir' ,fi: 'Ti' ,nb: 'Tir' + ,he: 'ג' }, ',We' : { cs: 'St' @@ -85,6 +89,7 @@ function init() { ,dk: 'Ons' ,fi: 'Ke' ,nb: 'Ons' + ,he: 'ד' } ,'Th' : { cs: 'Čt' @@ -100,6 +105,7 @@ function init() { ,dk: 'Tor' ,fi: 'To' ,no: 'Tor' + ,he: 'ה' } ,'Fr' : { cs: 'Pá' @@ -115,6 +121,7 @@ function init() { ,dk: 'Fre' ,fi: 'Pe' ,nb: 'Fre' + ,he: 'ו' } ,'Sa' : { cs: 'So' @@ -130,6 +137,7 @@ function init() { ,dk: 'Lør' ,fi: 'La' ,nb: 'Lør' + ,he: 'ש' } ,'Su' : { cs: 'Ne' @@ -145,6 +153,7 @@ function init() { ,dk: 'Søn' ,fi: 'Su' ,nb: 'Søn' + ,he: 'א' } ,'Monday' : { cs: 'Pondělí' @@ -160,6 +169,7 @@ function init() { ,dk: 'Mandag' ,fi: 'Maanantai' ,nb: 'Mandag' + ,he: 'שני' } ,'Tuesday' : { cs: 'Úterý' @@ -175,6 +185,7 @@ function init() { ,dk: 'Tirsdag' ,fi: 'Tiistai' ,nb: 'Tirsdag' + ,he: 'שלישי' } ,'Wednesday' : { cs: 'Středa' @@ -190,6 +201,7 @@ function init() { ,dk: 'Onsdag' ,fi: 'Keskiviikko' ,nb: 'Onsdag' + ,he: 'רביעי' } ,'Thursday' : { cs: 'Čtvrtek' @@ -205,6 +217,7 @@ function init() { ,dk: 'Torsdag' ,fi: 'Torstai' ,nb: 'Torsdag' + ,he: 'חמישי' } ,'Friday' : { cs: 'Pátek' @@ -220,6 +233,7 @@ function init() { ,dk: 'Fredag' ,fi: 'Perjantai' ,nb: 'Fredag' + ,he: 'שישי' } ,'Saturday' : { cs: 'Sobota' @@ -235,6 +249,7 @@ function init() { ,dk: 'Lørdag' ,fi: 'Lauantai' ,nb: 'Lørdag' + ,he: 'שבת' } ,'Sunday' : { cs: 'Neděle' @@ -250,6 +265,7 @@ function init() { ,dk: 'Søndag' ,fi: 'Sunnuntai' ,nb: 'Søndag' + ,he: 'ראשון' } ,'Category' : { cs: 'Kategorie' From fe95c718a16e068e6a89e51c1db9fa8085637c33 Mon Sep 17 00:00:00 2001 From: avielf Date: Thu, 17 Sep 2015 09:29:15 +0300 Subject: [PATCH 161/176] More Hebrew added --- lib/language.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/language.js b/lib/language.js index e8cde5e64ad..fdfb7af4bc9 100644 --- a/lib/language.js +++ b/lib/language.js @@ -281,6 +281,7 @@ function init() { ,dk: 'Kategori' ,fi: 'Luokka' ,nb: 'Kategori' + ,he: 'קטגוריה' } ,'Subcategory' : { cs: 'Podkategorie' @@ -296,6 +297,7 @@ function init() { ,dk: 'Underkategori' ,fi: 'Alaluokka' ,nb: 'Underkategori' + ,he: 'תת-קטגוריה' } ,'Name' : { cs: 'Jméno' @@ -311,6 +313,7 @@ function init() { ,dk: 'Navn' ,fi: 'Nimi' ,nb: 'Navn' + ,he: 'שם' } ,'Today' : { cs: 'Dnes' @@ -326,6 +329,7 @@ function init() { ,dk: 'Idag' ,fi: 'Tänään' ,nb: 'Idag' + ,he: 'היום' } ,'Last 2 days' : { cs: 'Poslední 2 dny' @@ -341,6 +345,7 @@ function init() { ,dk: 'Sidste 2 dage' ,fi: 'Edelliset 2 päivää' ,nb: 'Siste 2 dager' + ,he: 'יומיים אחרונים' } ,'Last 3 days' : { cs: 'Poslední 3 dny' @@ -356,6 +361,7 @@ function init() { ,dk: 'Sidste 3 dage' ,fi: 'Edelliset 3 päivää' ,nb: 'Siste 3 dager' + ,he: '3 ימים אחרונים' } ,'Last week' : { cs: 'Poslední týden' @@ -371,6 +377,7 @@ function init() { ,dk: 'Sidste uge' ,fi: 'Viime viikko' ,nb: 'Siste uke' + ,he: 'שבוע אחרון' } ,'Last 2 weeks' : { cs: 'Poslední 2 týdny' @@ -386,6 +393,7 @@ function init() { ,dk: 'Sidste 2 uger' ,fi: 'Viimeiset 2 viikkoa' ,nb: 'Siste 2 uker' + ,he: 'שבועיים אחרונים' } ,'Last month' : { cs: 'Poslední měsíc' @@ -401,6 +409,7 @@ function init() { ,dk: 'Sidste måned' ,fi: 'Viime kuu' ,nb: 'Siste måned' + ,he: 'חודש אחרון' } ,'Last 3 months' : { cs: 'Poslední 3 měsíce' @@ -416,6 +425,7 @@ function init() { ,dk: 'Sidste 3 måneder' ,fi: 'Viimeiset 3 kuukautta' ,nb: 'Siste 3 måneder' + ,he: '3 חודשים אחרונים' } ,'From' : { cs: 'Od' @@ -431,6 +441,7 @@ function init() { ,dk: 'Fra' ,fi: 'Alkaen' ,nb: 'Fra' + ,he: 'מ' } ,'To' : { cs: 'Do' @@ -446,6 +457,7 @@ function init() { ,dk: 'Til' ,fi: 'Asti' ,nb: 'Til' + ,he: 'עד' } ,'Notes' : { cs: 'Poznámky' @@ -461,6 +473,7 @@ function init() { ,dk: 'Noter' ,fi: 'Merkinnät' ,nb: 'Notater' + ,he: 'הערות' } ,'Food' : { cs: 'Jídlo' @@ -476,6 +489,7 @@ function init() { ,dk: 'Mad' ,fi: 'Ruoka' ,nb: 'Mat' + ,he: 'אוכל' } ,'Insulin' : { cs: 'Inzulín' @@ -491,6 +505,7 @@ function init() { ,dk: 'Insulin' ,fi: 'Insuliini' ,nb: 'Insulin' + ,he: 'אינסולין' } ,'Carbs' : { cs: 'Sacharidy' @@ -506,6 +521,7 @@ function init() { ,dk: 'Kulhydrater' ,fi: 'Hiilihydraatit' ,nb: 'Karbohydrater' + ,he: 'פחמימות' } ,'Notes contain' : { cs: 'Poznámky obsahují' @@ -536,6 +552,7 @@ function init() { ,dk: 'Nedre grænse for blodsukkerværdier' ,fi: 'Tavoitealueen alaraja' ,nb: 'Nedre grense for blodsukkerverdier' + ,he: 'טווח מטרה סף תחתון' } ,'top' : { cs: 'horní' @@ -581,6 +598,7 @@ function init() { ,dk: 'Vis' ,fi: 'Näyttö' ,nb: 'Vis' + ,he: 'תצוגה' } ,'Loading' : { cs: 'Nahrávám' @@ -596,6 +614,7 @@ function init() { ,dk: 'Indlæser' ,fi: 'Lataan' ,nb: 'Laster' + ,he: 'טוען' } ,'Loading profile' : { cs: 'Nahrávám profil' @@ -611,6 +630,7 @@ function init() { ,dk: 'Indlæser profil' ,fi: 'Lataan profiilia' ,nb: 'Leser profil' + ,he: 'טוען פרופיל' } ,'Loading status' : { cs: 'Nahrávám status' @@ -626,6 +646,7 @@ function init() { ,dk: 'Indlæsnings status' ,fi: 'Lataan tilaa' ,nb: 'Leser status' + ,he: 'טוען סטטוס' } ,'Loading food database' : { cs: 'Nahrávám databázi jídel' @@ -716,6 +737,7 @@ function init() { ,dk: 'Portion' ,fi: 'Annos' ,nb: 'Porsjon' + ,he: 'מנה' } ,'Size' : { cs: 'Rozměr' @@ -731,6 +753,7 @@ function init() { ,dk: 'Størrelse' ,fi: 'Koko' ,nb: 'Størrelse' + ,he: 'גודל' } ,'(none)' : { cs: '(Prázdný)' @@ -761,6 +784,7 @@ function init() { ,dk: 'Tomt resultat' ,fi: 'Ei tuloksia' ,nb: 'Tomt resultat' + ,he: 'אין תוצאה' } // ported reporting ,'Day to day' : { From 84254988aef02b4dc114a2c7cc29e2d7a214831a Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Thu, 17 Sep 2015 01:30:26 -0700 Subject: [PATCH 162/176] mock dialog instead of pulling in jquery-ui and messing up coverage stats --- tests/reports.test.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/reports.test.js b/tests/reports.test.js index 751db63f5df..5c09b130206 100644 --- a/tests/reports.test.js +++ b/tests/reports.test.js @@ -1,6 +1,7 @@ 'use strict'; require('should'); +var _ = require('lodash'); var benv = require('benv'); var read = require('fs').readFileSync; var serverSettings = require('./fixtures/default-server-settings'); @@ -162,6 +163,20 @@ describe('reports', function ( ) { self.$.fn.tipsy = function mockTipsy ( ) { }; + self.$.fn.dialog = function mockDialog (opts) { + function maybeCall (name, obj) { + if (obj[name] && obj[name].call) { + obj[name](); + } + + } + maybeCall('open', opts); + + _.forEach(opts.buttons, function (button) { + maybeCall('click', button); + }); + }; + var indexHtml = read(__dirname + '/../static/report/index.html', 'utf8'); self.$('body').html(indexHtml); @@ -214,7 +229,6 @@ describe('reports', function ( ) { benv.require(__dirname + '/../bundle/bundle.source.js'); benv.require(__dirname + '/../static/report/js/report.js'); - benv.require(__dirname + '/../static/bower_components/jquery-ui/jquery-ui.min.js'); done(); }); From 5feb5f840f62396e8f89042f1bde8ac3e0a89a12 Mon Sep 17 00:00:00 2001 From: avielf Date: Thu, 17 Sep 2015 11:39:38 +0300 Subject: [PATCH 163/176] More Hebrew --- lib/language.js | 75 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/lib/language.js b/lib/language.js index fdfb7af4bc9..ea8418c4250 100644 --- a/lib/language.js +++ b/lib/language.js @@ -15,6 +15,7 @@ function init() { , { code: 'en', language: 'English' } , { code: 'es', language: 'Español' } , { code: 'fr', language: 'Français' } + , { code: 'he', language: 'עברית' } , { code: 'hr', language: 'Hrvatski' } , { code: 'it', language: 'Italiano' } , { code: 'nb', language: 'Norsk (Bokmål)' } @@ -22,7 +23,6 @@ function init() { , { code: 'ro', language: 'Română' } , { code: 'sv', language: 'Svenska' } , { code: 'fi', language: 'Suomi' } - , { code: 'he', language: 'עברית' } ]; var translations = { @@ -75,7 +75,7 @@ function init() { ,nb: 'Tir' ,he: 'ג' }, - ',We' : { + ,'We' : { cs: 'St' ,de: 'Mi' ,es: 'Mie' @@ -568,6 +568,7 @@ function init() { ,dk: 'Top' ,fi: 'yläraja' ,nb: 'Topp' + ,he: 'למעלה' } ,'Show' : { cs: 'Zobraz' @@ -583,6 +584,7 @@ function init() { ,dk: 'Vis' ,fi: 'Näytä' ,nb: 'Vis' + ,he: 'הצג' } ,'Display' : { cs: 'Zobraz' @@ -662,6 +664,7 @@ function init() { ,dk: 'Indlæser mad database' ,fi: 'Lataan ruokatietokantaa' ,nb: 'Leser matdatabase' + ,he: 'טוען נתוני אוכל' } ,'not displayed' : { cs: 'není zobrazeno' @@ -677,6 +680,7 @@ function init() { ,dk: 'Vises ikke' ,fi: 'ei näytetä' ,nb: 'Vises ikke' + ,he: 'לא מוצג' } ,'Loading CGM data of' : { cs: 'Nahrávám CGM data' @@ -692,6 +696,7 @@ function init() { ,dk: 'Indlæser CGM-data for' ,fi: 'Lataan sensoritietoja: ' ,nb: 'Leser CGM-data for' + ,he: 'טוען נתוני חיישן סוכר של' } ,'Loading treatments data of' : { cs: 'Nahrávám data ošetření' @@ -707,6 +712,7 @@ function init() { ,dk: 'Indlæser data for' ,fi: 'Lataan toimenpidetietoja: ' ,nb: 'Leser behandlingsdata for' + ,he: 'טוען נתוני טיפולים של' } ,'Processing data of' : { cs: 'Zpracovávám data' @@ -722,6 +728,7 @@ function init() { ,dk: 'Behandler data for' ,fi: 'Käsittelen tietoja: ' ,nb: 'Behandler data for' + ,he: 'מעבד נתונים של' } ,'Portion' : { cs: 'Porce' @@ -769,6 +776,7 @@ function init() { ,dk: '(ingen)' ,fi: '(tyhjä)' ,nb: '(ingen)' + ,he: '(ללא)' } ,'Result is empty' : { cs: 'Prázdný výsledek' @@ -801,6 +809,7 @@ function init() { ,dk: 'Dag til dag' ,fi: 'Päivittäinen' ,nb: 'Dag til dag' + ,he: 'יום-יום' } ,'Daily Stats' : { cs: 'Denní statistiky' @@ -816,6 +825,7 @@ function init() { ,dk: 'Daglig statistik' ,fi: 'Päivittäiset tilastot' ,nb: 'Daglig statistikk' + ,he: 'סטטיסטיקה יומית' } ,'Percentile Chart' : { cs: 'Percentil' @@ -831,6 +841,7 @@ function init() { ,dk: 'Procentgraf' ,fi: 'Suhteellinen kuvaaja' ,nb: 'Prosentgraf' + ,he: 'טבלת עשירונים' } ,'Distribution' : { cs: 'Rozložení' @@ -846,6 +857,7 @@ function init() { ,dk: 'Distribution' ,fi: 'Jakauma' ,nb: 'Distribusjon' + ,he: 'פיזור' } ,'Hourly stats' : { cs: 'Statistika po hodinách' @@ -861,6 +873,7 @@ function init() { ,dk: 'Timestatistik' ,fi: 'Tunneittainen tilasto' ,nb: 'Timestatistikk' + ,he: 'סטטיסטיקה שעתית' } ,'Weekly success' : { cs: 'Statistika po týdnech' @@ -891,6 +904,7 @@ function init() { ,dk: 'Mangler data' ,fi: 'Tietoja ei saatavilla' ,nb: 'Mangler data' + ,he: 'אין מידע זמין' } ,'Low' : { cs: 'Nízká' @@ -906,6 +920,7 @@ function init() { ,dk: 'Lav' ,fi: 'Matala' ,nb: 'Lav' + ,he: 'נמוך' } ,'In Range' : { cs: 'V rozsahu' @@ -921,6 +936,7 @@ function init() { ,dk: 'Indenfor intervallet' ,fi: 'Tavoitealueella' ,nb: 'Innenfor intervallet' + ,he: 'בטווח' } ,'Period' : { cs: 'Období' @@ -936,6 +952,7 @@ function init() { ,dk: 'Period' ,fi: 'Aikaväli' ,nb: 'Periode' + he:, 'תקופה' } ,'High' : { cs: 'Vysoká' @@ -951,6 +968,7 @@ function init() { ,dk: 'Høj' ,fi: 'Korkea' ,nb: 'Høy' + ,he: 'גבוה' } ,'Average' : { cs: 'Průměrná' @@ -966,6 +984,7 @@ function init() { ,dk: 'Gennemsnit' ,fi: 'Keskiarvo' ,nb: 'Gjennomsnitt' + ,he: 'ממוצע' } ,'Low Quartile' : { cs: 'Nízký kvartil' @@ -981,6 +1000,7 @@ function init() { ,dk: 'Nedre kvartil' ,fi: 'Alin neljäsosa' ,nb: 'Nedre kvartil' + ,he: 'רבעון נמוך' } ,'Upper Quartile' : { cs: 'Vysoký kvartil' @@ -996,6 +1016,7 @@ function init() { ,dk: 'Øvre kvartil' ,fi: 'Ylin neljäsosa' ,nb: 'Øvre kvartil' + ,he: 'רבעון גבוה' } ,'Quartile' : { cs: 'Kvartil' @@ -1011,6 +1032,7 @@ function init() { ,dk: 'Kvartil' ,fi: 'Neljäsosa' ,nb: 'Kvartil' + ,he: 'רבעון' } ,'Date' : { cs: 'Datum' @@ -1026,6 +1048,7 @@ function init() { ,dk: 'Dato' ,fi: 'Päivämäärä' ,nb: 'Dato' + ,he: 'תאריך' } ,'Normal' : { cs: 'Normální' @@ -1056,6 +1079,7 @@ function init() { ,dk: 'Median' ,fi: 'Mediaani' ,nb: 'Median' + ,he: 'חציון' } ,'Readings' : { cs: 'Záznamů' @@ -1071,6 +1095,7 @@ function init() { ,dk: 'Aflæsning' ,fi: 'Lukemia' ,nb: 'Avlesning' + ,he: 'קריאות' } ,'StDev' : { cs: 'St. odchylka' @@ -1086,6 +1111,7 @@ function init() { ,dk: 'Standard afvigelse' ,fi: 'Keskijakauma' ,nb: 'Standardavvik' + ,he: 'סטיית תקן' } ,'Daily stats report' : { cs: 'Denní statistiky' @@ -1101,6 +1127,7 @@ function init() { ,dk: 'Daglig statistik rapport' ,fi: 'Päivittäinen tilasto' ,nb: 'Daglig statistikkrapport' + ,he: 'דוח סטטיסטיקה יומית' } ,'Glucose Percentile report' : { cs: 'Tabulka percentil glykémií' @@ -1131,6 +1158,7 @@ function init() { ,dk: 'Glukosefordeling' ,fi: 'Glukoosijakauma' ,nb: 'Glukosefordeling' + ,he: 'פיזור סוכר' } ,'days total' : { cs: 'dní celkem' @@ -1146,6 +1174,7 @@ function init() { ,dk: 'antal dage' ,fi: 'päivä yhteensä' ,nb: 'antall dager' + ,he: 'מספר ימים' } ,'Overall' : { cs: 'Celkem' @@ -1161,6 +1190,7 @@ function init() { ,dk: 'Overall' ,fi: 'Kaiken kaikkiaan' ,nb: 'Generelt' + ,he: 'סך הכל' } ,'Range' : { cs: 'Rozsah' @@ -1176,6 +1206,7 @@ function init() { ,dk: 'Interval' ,fi: 'Alue' ,nb: 'Intervall' + ,he: 'טווח' } ,'% of Readings' : { cs: '% záznamů' @@ -1191,6 +1222,7 @@ function init() { ,dk: '% af aflæsningerne' ,fi: '% lukemista' ,nb: '% af avlesningene' + ,he: 'אחוז קריאות' } ,'# of Readings' : { cs: 'počet záznamů' @@ -1206,6 +1238,7 @@ function init() { ,dk: 'Antal af aflæsninger' ,fi: 'Lukemien määrä' ,nb: 'Antall avlesninger' + ,he: 'מספר קריאות' } ,'Mean' : { cs: 'Střední hodnota' @@ -1221,6 +1254,7 @@ function init() { ,dk: 'Gennemsnit' ,fi: 'Keskiarvo' ,nb: 'Gjennomsnitt' + ,he: 'ממוצע' } ,'Standard Deviation' : { cs: 'Standardní odchylka' @@ -1236,6 +1270,7 @@ function init() { ,dk: 'Standardafgivelse' ,fi: 'Keskijakauma' ,nb: 'Standardavvik' + ,he: 'סטיית תקן' } ,'Max' : { cs: 'Max' @@ -1251,6 +1286,7 @@ function init() { ,dk: 'Max' ,fi: 'Maks' ,nb: 'Max' + ,he: 'מקסימאלי' } ,'Min' : { cs: 'Min' @@ -1266,6 +1302,7 @@ function init() { ,dk: 'Min' ,fi: 'Min' ,nb: 'Min' + ,he: 'מינימאלי' } ,'A1c estimation*' : { cs: 'Předpokládané HBA1c*' @@ -1281,6 +1318,7 @@ function init() { ,dk: 'Beregnet A1c-værdi ' ,fi: 'A1c arvio*' ,nb: 'Beregnet HbA1c' + ,he: 'משוער A1c' } ,'Weekly Success' : { cs: 'Týdenní úspěšnost' @@ -1311,6 +1349,7 @@ function init() { ,dk: 'Der er utilstrækkeligt data til at generere rapporten. Vælg flere dage.' ,fi: 'Raporttia ei voida luoda liian vähäisen tiedon vuoksi. Valitse useampia päiviä.' ,nb: 'Der er ikke nok data til å lage rapporten. Velg flere dager.' + ,he: 'לא נמצא מספיק מידע ליצירת הדוח. בחר ימים נוספים.' } // food editor ,'Using stored API secret hash' : { @@ -1372,6 +1411,7 @@ function init() { ,dk: 'Fejl: Database kan ikke indlæses' ,fi: 'Virhe: Tietokannan lataaminen epäonnistui' ,nb: 'Feil: Database kan ikke leses' + ,he: 'שגיאה: לא ניתן לטעון בסיס נתונים' } ,'Create new record' : { cs: 'Vytvořit nový záznam' @@ -1387,6 +1427,7 @@ function init() { ,dk: 'Danner ny post' ,fi: 'Luo uusi tallenne' ,nb: 'Lager ny registrering' + ,he: 'צור רשומה חדשה' } ,'Save record' : { cs: 'Uložit záznam' @@ -1402,6 +1443,7 @@ function init() { ,dk: 'Gemmer post' ,fi: 'Tallenna' ,nb: 'Lagrer registrering' + ,he: 'שמור רשומה' } ,'Portions' : { cs: 'Porcí' @@ -1417,6 +1459,7 @@ function init() { ,dk: 'Portioner' ,fi: 'Annokset' ,nb: 'Porsjoner' + ,he: 'מנות' } ,'Unit' : { cs: 'Jedn' @@ -1432,6 +1475,7 @@ function init() { ,dk: 'Enheder' ,fi: 'Yksikkö' ,nb: 'Enhet' + ,he: 'יחידות' } ,'GI' : { cs: 'GI' @@ -1462,6 +1506,7 @@ function init() { ,dk: 'Editere post' ,fi: 'Muokkaa tallennetta' ,nb: 'Editere registrering' + ,he: 'ערוך רשומה' } ,'Delete record' : { cs: 'Smazat záznam' @@ -1477,6 +1522,7 @@ function init() { ,dk: 'Slet post' ,fi: 'Tuhoa tallenne' ,nb: 'Slette registrering' + ,he: 'מחק רשומה' } ,'Move to the top' : { cs: 'Přesuň na začátek' @@ -1492,6 +1538,7 @@ function init() { ,dk: 'Gå til toppen' ,fi: 'Siirrä ylimmäksi' ,nb: 'Gå til toppen' + ,he: 'עבור למעלה' } ,'Hidden' : { cs: 'Skrytý' @@ -1507,6 +1554,7 @@ function init() { ,dk: 'Skjult' ,fi: 'Piilotettu' ,nb: 'Skjult' + ,he: 'מוסתר' } ,'Hide after use' : { cs: 'Skryj po použití' @@ -1522,6 +1570,7 @@ function init() { ,dk: 'Skjul efter brug' ,fi: 'Piilota käytön jälkeen' ,nb: 'Skjul etter bruk' + ,he: 'הסתר לאחר שימוש' } ,'Your API secret must be at least 12 characters long' : { cs: 'Vaše API heslo musí mít alespoň 12 znaků' @@ -1582,6 +1631,7 @@ function init() { ,dk: 'Status' ,fi: 'Tila' ,nb: 'Status' + ,he: 'מצב מערכת' } ,'Not loaded' : { cs: 'Nenačtený' @@ -1627,6 +1677,7 @@ function init() { ,dk: 'Din database' ,fi: 'Tietokantasi' ,nb: 'Din database' + ,he: 'בסיס הנתונים שלך' } ,'Filter' : { cs: 'Filtr' @@ -1642,6 +1693,7 @@ function init() { ,dk: 'Filter' ,fi: 'Suodatin' ,nb: 'Filter' + ,he: 'סנן' } ,'Save' : { cs: 'Ulož' @@ -1657,6 +1709,7 @@ function init() { ,dk: 'Gem' ,fi: 'Tallenna' ,nb: 'Lagre' + ,he: 'שמור' } ,'Clear' : { cs: 'Vymaž' @@ -1672,6 +1725,7 @@ function init() { ,dk: 'Rense' ,fi: 'Tyhjennä' ,nb: 'Tøm' + ,he: 'נקה' } ,'Record' : { cs: 'Záznam' @@ -1687,6 +1741,7 @@ function init() { ,dk: 'Post' ,fi: 'Tietue' ,nb: 'Registrering' + ,he: 'רשומה' } ,'Quick picks' : { cs: 'Rychlý výběr' @@ -1702,6 +1757,7 @@ function init() { ,dk: 'Hurtig valg' ,fi: 'Nopeat valinnat' ,nb: 'Hurtigvalg' + ,he: 'בחירה מהירה' } ,'Show hidden' : { cs: 'Zobraz skryté' @@ -1717,6 +1773,7 @@ function init() { ,dk: 'Vis skjulte' ,fi: 'Näytä piilotettu' ,nb: 'Vis skjulte' + ,he: 'הצג נתונים מוסתרים' } ,'Your API secret' : { cs: 'Vaše API heslo' @@ -1762,6 +1819,7 @@ function init() { ,dk: 'Behandling' ,fi: 'Hoitotoimenpiteet' ,nb: 'Behandlinger' + ,he: 'טיפולים' } ,'Time' : { cs: 'Čas' @@ -1777,6 +1835,7 @@ function init() { ,dk: 'Tid' ,fi: 'Aika' ,nb: 'Tid' + ,he: 'זמן' } ,'Event Type' : { cs: 'Typ události' @@ -1792,6 +1851,7 @@ function init() { ,dk: 'Hændelsestype' ,fi: 'Tapahtumatyyppi' ,nb: 'Type' + ,he: 'סוג אירוע' } ,'Blood Glucose' : { cs: 'Glykémie' @@ -1807,6 +1867,7 @@ function init() { ,dk: 'Glukoseværdi' ,fi: 'Verensokeri' ,nb: 'Blodsukker' + ,he: 'סוכר בדם' } ,'Entered By' : { cs: 'Zadal' @@ -1822,6 +1883,7 @@ function init() { ,dk: 'Indtastet af' ,fi: 'Tiedot syötti' ,nb: 'Lagt inn av' + ,he: 'הוזן על-ידי' } ,'Delete this treatment?' : { cs: 'Vymazat toto ošetření?' @@ -1837,6 +1899,7 @@ function init() { ,dk: 'Slet denne hændelse?' ,fi: 'Tuhoa tämä hoitotoimenpide?' ,nb: 'Slett denne hendelsen?' + ,he: 'למחוק רשומה זו?' } ,'Carbs Given' : { cs: 'Sacharidů' @@ -1852,6 +1915,7 @@ function init() { ,dk: 'Antal kulhydrater' ,fi: 'Hiilihydraatit' ,nb: 'Karbo' + ,he: 'פחמימות שנאכלו' } ,'Inzulin Given' : { cs: 'Inzulínu' @@ -1867,6 +1931,7 @@ function init() { ,dk: 'Insulin' ,fi: 'Insuliiniannos' ,nb: 'Insulin' + ,he: 'אינסולין שניתן' } ,'Event Time' : { cs: 'Čas události' @@ -1882,6 +1947,7 @@ function init() { ,dk: 'Tidspunkt for hændelsen' ,fi: 'Aika' ,nb: 'Tidspunkt for hendelsen' + ,he: 'זמן האירוע' } ,'Please verify that the data entered is correct' : { cs: 'Prosím zkontrolujte, zda jsou údaje zadány správně' @@ -1897,6 +1963,7 @@ function init() { ,dk: 'Venligst verificer at indtastet data er korrekt' ,fi: 'Varmista, että tiedot ovat oikein' ,nb: 'Vennligst verifiser at inntastet data er korrekt' + ,he: 'נא לוודא שהמידע שהוזן הוא נכון ומדוייק' } ,'BG' : { cs: 'Glykémie' @@ -2002,6 +2069,7 @@ function init() { ,dk: 'eller' ,fi: 'tai' ,nb: 'eller' + ,he: 'או' } ,'Add from database' : { cs: 'Přidat z databáze' @@ -2017,6 +2085,7 @@ function init() { ,dk: 'Tilføj fra database' ,fi: 'Lisää tietokannasta' ,nb: 'Legg til fra database' + ,he: 'הוסף מבסיס נתונים' } ,'Use carbs correction in calculation' : { cs: 'Použij korekci na sacharidy' @@ -2122,6 +2191,7 @@ function init() { ,dk: 'Insulin påkrævet' ,fi: 'Insuliinitarve' ,nb: 'Insulin nødvendig' + ,he: 'אינסולין נדרש' } ,'Carbs needed' : { cs: 'Potřebné sach' @@ -2137,6 +2207,7 @@ function init() { ,dk: 'Kulhydrater påkrævet' ,fi: 'Hiilihydraattitarve' ,nb: 'Karbohydrater nødvendig' + ,he: 'פחמימות נדרשות' } ,'Carbs needed if Insulin total is negative value' : { cs: 'Chybějící sacharidy v případě, že výsledek je záporný' From 35a9e729c4731f3ae9c8cae10a647e1e26d4de28 Mon Sep 17 00:00:00 2001 From: avielf Date: Thu, 17 Sep 2015 11:48:26 +0300 Subject: [PATCH 164/176] Removed redundant semicolum --- lib/language.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/language.js b/lib/language.js index ea8418c4250..7ea39687ace 100644 --- a/lib/language.js +++ b/lib/language.js @@ -74,7 +74,7 @@ function init() { ,fi: 'Ti' ,nb: 'Tir' ,he: 'ג' - }, + } ,'We' : { cs: 'St' ,de: 'Mi' From f3d2d1ec4e9f87ddcba9d60fa52b9ef157fdff09 Mon Sep 17 00:00:00 2001 From: avielf Date: Thu, 17 Sep 2015 11:53:34 +0300 Subject: [PATCH 165/176] Missing semicolon on 955 --- lib/language.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/language.js b/lib/language.js index 7ea39687ace..f75a36b353d 100644 --- a/lib/language.js +++ b/lib/language.js @@ -952,7 +952,7 @@ function init() { ,dk: 'Period' ,fi: 'Aikaväli' ,nb: 'Periode' - he:, 'תקופה' + ,he:, 'תקופה' } ,'High' : { cs: 'Vysoká' From 23ef15f57b996027df7b1eacba9be2f1cbe9b736 Mon Sep 17 00:00:00 2001 From: avielf Date: Thu, 17 Sep 2015 11:58:22 +0300 Subject: [PATCH 166/176] Update language.js --- lib/language.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/language.js b/lib/language.js index f75a36b353d..4a3ba93cbe7 100644 --- a/lib/language.js +++ b/lib/language.js @@ -952,7 +952,7 @@ function init() { ,dk: 'Period' ,fi: 'Aikaväli' ,nb: 'Periode' - ,he:, 'תקופה' + ,he: 'תקופה' } ,'High' : { cs: 'Vysoká' From 5a18725d34d1129e44c11dcb98314a7d911c2055 Mon Sep 17 00:00:00 2001 From: avielf Date: Thu, 17 Sep 2015 14:04:45 +0300 Subject: [PATCH 167/176] Log a Treatment screen Hebrew translastions --- lib/language.js | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/lib/language.js b/lib/language.js index b453ff7e1b5..03875e5023c 100644 --- a/lib/language.js +++ b/lib/language.js @@ -2328,6 +2328,7 @@ function init() { ,dk: 'Tid i minutter' ,fi: 'Aika minuuteissa' ,nb: 'Tid i minutter' + ,he: 'זמן בדקות' } ,'15 minutes later' : { cs: '15 min po' @@ -2343,6 +2344,7 @@ function init() { ,dk: '15 min senere' ,fi: '15 minuuttia myöhemmin' ,nb: '15 min senere' + ,he: 'רבע שעה מאוחר יותר' } ,'20 minutes later' : { cs: '20 min po' @@ -2358,6 +2360,7 @@ function init() { ,dk: '20 min senere' ,fi: '20 minuuttia myöhemmin' ,nb: '20 min senere' + ,he: 'עשרים דקות מאוחר יותר' } ,'30 minutes later' : { cs: '30 min po' @@ -2373,6 +2376,7 @@ function init() { ,dk: '30 min senere' ,fi: '30 minuuttia myöhemmin' ,nb: '30 min senere' + ,he: 'חצי שעה מאוחר יותר' } ,'45 minutes later' : { cs: '45 min po' @@ -2388,6 +2392,7 @@ function init() { ,dk: '45 min senere' ,fi: '45 minuuttia myöhemmin' ,nb: '45 min senere' + ,he: 'שלושת רבעי שעה מאוחר יותר' } ,'60 minutes later' : { cs: '60 min po' @@ -2403,6 +2408,7 @@ function init() { ,dk: '60 min senere' ,fi: '60 minuuttia myöhemmin' ,nb: '60 min senere' + ,he: 'שעה מאוחר יותר' } ,'Additional Notes, Comments' : { cs: 'Dalši poznámky, komentáře' @@ -2418,6 +2424,7 @@ function init() { ,dk: 'Ekstra noter, kommentarer' ,fi: 'Lisähuomiot, kommentit' ,nb: 'Ekstra notater, kommentarer' + ,he: 'הערות נוספות' } ,'RETRO MODE' : { cs: 'V MINULOSTI' @@ -2448,6 +2455,7 @@ function init() { ,dk: 'Nu' ,fi: 'Nyt' ,nb: 'Nå' + ,he: 'עכשיו' } ,'Other' : { cs: 'Jiný' @@ -2463,6 +2471,7 @@ function init() { ,dk: 'Øvrige' ,fi: 'Muu' ,nb: 'Annet' + ,he: 'אחר' } ,'Submit Form' : { cs: 'Odeslat formulář' @@ -2478,6 +2487,7 @@ function init() { ,dk: 'Gem hændelsen' ,fi: 'Lähetä tiedot' ,nb: 'Lagre' + ,he: 'שמור' } ,'Profile Editor' : { cs: 'Editor profilu' @@ -2493,6 +2503,7 @@ function init() { ,dk: 'Profil editor' ,fi: 'Profiilin muokkaus' ,nb: 'Profileditor' + ,he: 'ערוך פרופיל' } ,'Reports' : { cs: 'Výkazy' @@ -2688,6 +2699,7 @@ function init() { ,dk: 'Sensor' ,fi: 'Sensori' ,nb: 'Sensor' + ,he: 'חיישן סוכר' } ,'Finger' : { cs: 'Glukoměr' @@ -2703,6 +2715,7 @@ function init() { ,dk: 'Finger' ,fi: 'Sormi' ,nb: 'Finger' + ,he: 'אצבע' } ,'Manual' : { cs: 'Ručně' @@ -2718,6 +2731,7 @@ function init() { ,dk: 'Manuel' ,fi: 'Manuaalinen' ,nb: 'Manuell' + he:, 'ידני' } ,'Scale' : { cs: 'Měřítko' @@ -2748,6 +2762,7 @@ function init() { ,dk: 'Lineær' ,fi: 'Lineaarinen' ,nb: 'Lineær' + ,he: 'לינארי' } ,'Logarithmic' : { cs: 'logaritmické' @@ -2763,6 +2778,7 @@ function init() { ,dk: 'Logaritmisk' ,fi: 'Logaritminen' ,nb: 'Logaritmisk' + ,he: 'לוגריתמי' } ,'Silence for 30 minutes' : { cs: 'Ztlumit na 30 minut' @@ -2973,6 +2989,7 @@ function init() { ,dk: 'Log en hændelse' ,fi: 'Tallenna tapahtuma' ,nb: 'Logg en hendelse' + ,he: 'הזן רשומה' } ,'BG Check' : { cs: 'Kontrola glykémie' @@ -2988,6 +3005,7 @@ function init() { ,dk: 'BS kontrol' ,fi: 'Verensokerin tarkistus' ,nb: 'Blodsukkerkontroll' + ,he: 'בדיקת סוכר' } ,'Meal Bolus' : { cs: 'Bolus na jídlo' @@ -3003,6 +3021,7 @@ function init() { ,dk: 'Måltidsbolus' ,fi: 'Ruokailubolus' ,nb: 'Måltidsbolus' + ,he: 'בולוס ארוחה' } ,'Snack Bolus' : { cs: 'Bolus na svačinu' @@ -3018,6 +3037,7 @@ function init() { ,dk: 'Mellemmåltidsbolus' ,fi: 'Ruokakorjaus' ,nb: 'Mellommåltidsbolus' + ,he: 'בולוס ארוחת ביניים' } ,'Correction Bolus' : { cs: 'Bolus na glykémii' @@ -3033,6 +3053,7 @@ function init() { ,dk: 'Korrektionsbolus' ,fi: 'Korjausbolus' ,nb: 'Korreksjonsbolus' + ,he: 'בולוס תיקון' } ,'Carb Correction' : { cs: 'Přídavek sacharidů' @@ -3048,6 +3069,7 @@ function init() { ,dk: 'Kulhydratskorrektion' ,fi: 'Hiilihydraattikorjaus' ,nb: 'Karbohydratkorrigering' + ,he: 'בולוס פחמימות' } ,'Note' : { cs: 'Poznámka' @@ -3063,6 +3085,7 @@ function init() { ,dk: 'Note' ,fi: 'Merkintä' ,nb: 'Notat' + ,he: 'הערה' } ,'Question' : { cs: 'Otázka' @@ -3078,11 +3101,13 @@ function init() { ,dk: 'Spørgsmål' ,fi: 'Kysymys' ,nb: 'Spørsmål' + ,he: 'שאלה' } ,'Announcement' : { bg: 'Известяване' , fi: 'Tiedoitus' ,pt: 'Aviso' + ,he: 'הודעה' } ,'Exercise' : { cs: 'Cvičení' @@ -3098,6 +3123,7 @@ function init() { ,dk: 'Træning' ,fi: 'Fyysinen harjoitus' ,nb: 'Trening' + ,he: 'פעילות גופנית' } ,'Pump Site Change' : { cs: 'Výměna setu' @@ -3113,6 +3139,7 @@ function init() { ,dk: 'Skift insulin infusionssted' ,fi: 'Pumpun kanyylin vaihto' ,nb: 'Pumpebytte' + ,he: 'החלפת צינורית משאבה' } ,'Sensor Start' : { cs: 'Spuštění sensoru' @@ -3128,6 +3155,7 @@ function init() { ,dk: 'Sensorstart' ,fi: 'Sensorin aloitus' ,nb: 'Sensorstart' + ,he: 'אתחול חיישן סוכר' } ,'Sensor Change' : { cs: 'Výměna sensoru' @@ -3143,6 +3171,7 @@ function init() { ,dk: 'Sensor ombytning' ,fi: 'Sensorin vaihto' ,nb: 'Sensorbytte' + ,he: 'החלפת חיישן סוכר' } ,'Dexcom Sensor Start' : { cs: 'Spuštění sensoru' @@ -3158,6 +3187,7 @@ function init() { ,dk: 'Dexcom sensor start' ,fi: 'Sensorin aloitus' ,nb: 'Dexcom sensor start' + ,he: 'אתחול חיישן סוכר של דקסקום' } ,'Dexcom Sensor Change' : { cs: 'Výměna sensoru' @@ -3173,6 +3203,7 @@ function init() { ,dk: 'Dexcom sensor ombytning' ,fi: 'Sensorin vaihto' ,nb: 'Dexcom sensor bytte' + ,he: 'החלפת חיישן סוכר של דקסקום' } ,'Insulin Cartridge Change' : { cs: 'Výměna inzulínu' @@ -3188,6 +3219,7 @@ function init() { ,dk: 'Skift insulin beholder' ,fi: 'Insuliinisäiliön vaihto' ,nb: 'Skifte insulin beholder' + ,he: 'החלפת מחסנית אינסולין' } ,'D.A.D. Alert' : { cs: 'D.A.D. Alert' @@ -3203,6 +3235,7 @@ function init() { ,dk: 'Vuf Vuf! (Diabeteshundealarm!)' ,fi: 'Diabeteskoirahälytys' ,nb: 'Diabeteshundalarm' + ,he: 'ווף! ווף! התראת גשג' } ,'Glucose Reading' : { cs: 'Hodnota glykémie' @@ -3218,6 +3251,7 @@ function init() { ,dk: 'Glukose aflæsning' ,fi: 'Verensokeri' ,nb: 'Blodsukkermåling' + ,he: 'מדידת סוכר' } ,'Measurement Method' : { cs: 'Metoda měření' @@ -3233,6 +3267,7 @@ function init() { ,dk: 'Målemetode' ,fi: 'Mittaustapa' ,nb: 'Målemetode' + ,he: 'אמצעי מדידה' } ,'Meter' : { cs: 'Glukoměr' @@ -3248,6 +3283,7 @@ function init() { ,dk: 'Glukosemeter' ,fi: 'Sokerimittari' ,nb: 'Måleapparat' + ,he: 'מד סוכר' } ,'Insulin Given' : { cs: 'Inzulín' @@ -3263,6 +3299,7 @@ function init() { ,dk: 'Insulin dosis' ,fi: 'Insuliiniannos' ,nb: 'Insulin' + ,he: 'אינסולין שניתן' } ,'Amount in grams' : { cs: 'Množství v gramech' @@ -3278,6 +3315,7 @@ function init() { ,dk: 'Antal gram' ,fi: 'Määrä grammoissa' ,nb: 'Antall gram' + ,he: 'כמות בגרמים' } ,'Amount in units' : { cs: 'Množství v jednotkách' @@ -3293,6 +3331,7 @@ function init() { ,dk: 'Antal enheder' ,fi: 'Annos yksiköissä' ,nb: 'Antall enheter' + ,he: 'כמות ביחידות' } ,'View all treatments' : { cs: 'Zobraz všechny ošetření' @@ -3308,6 +3347,7 @@ function init() { ,dk: 'Vis behandlinger' ,fi: 'Katso kaikki hoitotoimenpiteet' ,nb: 'Vis behandlinger' + ,he: 'הצג את כל הטיפולים' } ,'Enable Alarms' : { cs: 'Povolit alarmy' @@ -3323,6 +3363,7 @@ function init() { ,dk: 'Aktivere alarmer' ,fi: 'Aktivoi hälytykset' ,nb: 'Aktiver alarmer' + ,he: 'הפעל התראות' } ,'When enabled an alarm may sound.' : { cs: 'Při povoleném alarmu zní zvuk' @@ -3338,6 +3379,7 @@ function init() { ,dk: 'Når aktiveret kan alarm lyde' ,fi: 'Aktivointi mahdollistaa äänihälytykset' ,nb: 'Når aktivert er alarmer aktive' + ,he: 'כשמופעל התראות יכולות להישמע.' } ,'Urgent High Alarm' : { cs: 'Urgentní vysoká glykémie' @@ -3353,6 +3395,7 @@ function init() { ,dk: 'Høj grænse overskredet' ,fi: 'Kriittinen korkea' ,nb: 'Kritisk høy alarm' + ,he: 'התראת גבוה דחופה' } ,'High Alarm' : { cs: 'Vysoká glykémie' @@ -3368,6 +3411,7 @@ function init() { ,dk: 'Høj grænse overskredet' ,fi: 'Korkea verensokeri' ,nb: 'Høy alarm' + ,he: 'התראת גבוה' } ,'Low Alarm' : { cs: 'Nízká glykémie' @@ -3383,6 +3427,7 @@ function init() { ,dk: 'Lav grænse overskredet' ,fi: 'Matala verensokeri' ,nb: 'Lav alarm' + ,he: 'התראת נמוך' } ,'Urgent Low Alarm' : { cs: 'Urgentní nízká glykémie' @@ -3398,6 +3443,7 @@ function init() { ,dk: 'Advarsel: Lav' ,fi: 'Kriittinen matala' ,nb: 'Kritisk lav alarm' + ,he: 'התראת נמוך דחופה' } ,'Stale Data: Warn' : { cs: 'Zastaralá data' @@ -4012,6 +4058,7 @@ function init() { ,dk: 'Kulhydratstid' ,fi: 'Syöntiaika' ,nb: 'Karbohydrattid' + ,he: 'זמן פחמימה' } ,'Language' : { cs: 'Jazyk' From 34a061a6d7c8972ea1a01a3c6e2c4a75eeffad01 Mon Sep 17 00:00:00 2001 From: avielf Date: Thu, 17 Sep 2015 14:10:44 +0300 Subject: [PATCH 168/176] Misplaced semicolon --- lib/language.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/language.js b/lib/language.js index 03875e5023c..d68a9ed66b7 100644 --- a/lib/language.js +++ b/lib/language.js @@ -2731,7 +2731,7 @@ function init() { ,dk: 'Manuel' ,fi: 'Manuaalinen' ,nb: 'Manuell' - he:, 'ידני' + ,he: 'ידני' } ,'Scale' : { cs: 'Měřítko' From 42da240567c5679e48f47eeaf440080c448f232a Mon Sep 17 00:00:00 2001 From: xpucuto Date: Thu, 17 Sep 2015 17:28:01 +0300 Subject: [PATCH 169/176] bulgarian language - 17.Sept.2015 --- lib/language.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/language.js b/lib/language.js index b453ff7e1b5..ef2b6a4fb31 100644 --- a/lib/language.js +++ b/lib/language.js @@ -1058,7 +1058,7 @@ function init() { ,pt: 'Normal' ,sv: 'Normal' ,ro: 'Normal' - ,bg: 'Нормално' + ,bg: 'Нормалнa' ,hr: 'Normalno' ,it: 'Normale' ,dk: 'Normal' @@ -4026,12 +4026,15 @@ function init() { } ,'Order' : { cs: 'Pořadí' + bg: 'Ред' } ,'oldest on top' : { cs: 'nejstarší nahoře' + ,bg: 'Старите най-отгоре' } ,'newest on top' : { cs: 'nejnovější nahoře' + ,bg: 'Новите най-отгоре' } }; From c6b06c8072e38c0e453cd7cfe66b5472615eedff Mon Sep 17 00:00:00 2001 From: xpucuto Date: Thu, 17 Sep 2015 17:47:42 +0300 Subject: [PATCH 170/176] Update language.js --- lib/language.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/language.js b/lib/language.js index ef2b6a4fb31..ba26e8b857a 100644 --- a/lib/language.js +++ b/lib/language.js @@ -4026,7 +4026,7 @@ function init() { } ,'Order' : { cs: 'Pořadí' - bg: 'Ред' + ,bg: 'Ред' } ,'oldest on top' : { cs: 'nejstarší nahoře' From 967c5c7b3cc1e6ab99c7a1913ad247f14de611aa Mon Sep 17 00:00:00 2001 From: Ben West Date: Thu, 17 Sep 2015 09:48:14 -0700 Subject: [PATCH 171/176] Make DELETE API more usable Thanks to @MilosKozak for these suggestions. * Don't crash if lookup by id does not yield any results * Report errors, if any * Allow DELETE by ID * Allow DELETE by wildcard, `*`, to delete all types. --- lib/api/entries/index.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/api/entries/index.js b/lib/api/entries/index.js index f56afc421d0..f08c96eef9c 100644 --- a/lib/api/entries/index.js +++ b/lib/api/entries/index.js @@ -246,10 +246,15 @@ function configure (app, wares, ctx) { api.get('/entries/:spec', function(req, res, next) { if (isId(req.params.spec)) { entries.getEntry(req.params.spec, function(err, entry) { + if (err) { return next(err); } res.entries = [entry]; res.entries_err = err; req.query.find = req.query.find || {}; - req.query.find.type = entry.type; + if (entry) { + req.query.find.type = entry.type; + } else { + res.entries_err = "No such id: '" + req.params.spec + "'"; + } next(); }); } else { @@ -581,12 +586,15 @@ curl -s -g 'http://localhost:1337/api/v1/times/20{14..15}/T{13..18}:{00..15}'.js */ api.delete('/entries/:spec', wares.verifyAuthorization, function (req, res, next) { // if ID, prepare to query for one record - if (isId(req.params.id)) { + if (isId(req.params.spec)) { prepReqModel(req, req.params.model); req.query = {find: {_id: req.params.spec}}; } else { req.params.model = req.params.spec; prepReqModel(req, req.params.model); + if (req.query.find.type == '*') { + delete req.query.find.type; + } } next( ); }, delete_records); From c0bd8c4ee9d1e52e005ce35eca712b1917f9d857 Mon Sep 17 00:00:00 2001 From: Sulka Haro Date: Thu, 17 Sep 2015 20:21:51 +0300 Subject: [PATCH 172/176] When loading profiles from Mongo, sort by the actual field that tells when the profile was created. Load only one profile to speed up the process and consume less resources. Removed old check for dia field existence from iob-cob days. --- lib/data.js | 5 +---- lib/profile.js | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/data.js b/lib/data.js index b7e0dda50c9..b9681e11d4b 100644 --- a/lib/data.js +++ b/lib/data.js @@ -295,15 +295,12 @@ function loadTreatments (data, ctx, callback) { } function loadProfile (data, ctx, callback) { - ctx.profile.list(function (err, results) { + ctx.profile.last(function (err, results) { if (!err && results) { - // There should be only one document in the profile collection with a DIA. If there are multiple, use the last one. var profiles = []; results.forEach(function (element) { if (element) { - if (element.dia) { profiles[0] = element; - } } }); data.profiles = profiles; diff --git a/lib/profile.js b/lib/profile.js index 2131b088642..617eec33dba 100644 --- a/lib/profile.js +++ b/lib/profile.js @@ -22,11 +22,11 @@ function storage (collection, ctx) { } function list (fn) { - return api( ).find({ }).sort({validfrom: -1}).toArray(fn); + return api( ).find({ }).sort({startDate: -1}).toArray(fn); } function last (fn) { - return api().find().sort({validfrom: -1}).limit(1).toArray(fn); + return api().find().sort({startDate: -1}).limit(1).toArray(fn); } function api () { From e2e876d3728d790d7060ecd45760e37b29fc9d7f Mon Sep 17 00:00:00 2001 From: Sulka Haro Date: Fri, 18 Sep 2015 07:57:45 +0300 Subject: [PATCH 173/176] Change the Mongo index to also use the actual field (thanks Jason!) --- lib/profile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/profile.js b/lib/profile.js index 617eec33dba..31d2e75e57c 100644 --- a/lib/profile.js +++ b/lib/profile.js @@ -37,7 +37,7 @@ function storage (collection, ctx) { api.create = create; api.save = save; api.last = last; - api.indexedFields = ['validfrom']; + api.indexedFields = ['startDate']; return api; } From 9411a6321f5cead1e6cd81b7e6eebd82db0116df Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Thu, 17 Sep 2015 22:25:08 -0700 Subject: [PATCH 174/176] === vs == --- lib/api/entries/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/api/entries/index.js b/lib/api/entries/index.js index f08c96eef9c..3e5cbb94d80 100644 --- a/lib/api/entries/index.js +++ b/lib/api/entries/index.js @@ -592,7 +592,7 @@ curl -s -g 'http://localhost:1337/api/v1/times/20{14..15}/T{13..18}:{00..15}'.js } else { req.params.model = req.params.spec; prepReqModel(req, req.params.model); - if (req.query.find.type == '*') { + if (req.query.find.type === '*') { delete req.query.find.type; } } From a0906d04ded492ea5ef3157fb41cfc5f09a15c8e Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Thu, 17 Sep 2015 22:54:40 -0700 Subject: [PATCH 175/176] version bump for 0.8.1 --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index f2dc60ab9a9..0511964f203 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "nightscout", - "version": "0.8.1-beta2", + "version": "0.8.1", "dependencies": { "jquery": "2.1.0", "jQuery-Storage-API": "~1.7.2", diff --git a/package.json b/package.json index a6b20979b22..d906ea3ffd0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Nightscout", - "version": "0.8.1-beta2", + "version": "0.8.1", "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", From 643a6a26f050e386c2e719eedb903fa7fa32d338 Mon Sep 17 00:00:00 2001 From: Jason Calabrese Date: Thu, 17 Sep 2015 23:10:38 -0700 Subject: [PATCH 176/176] remove drawer animation --- lib/client/browser-utils.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/client/browser-utils.js b/lib/client/browser-utils.js index fc7baf193a1..d39b501a2c3 100644 --- a/lib/client/browser-utils.js +++ b/lib/client/browser-utils.js @@ -66,11 +66,9 @@ function init ($) { function closeDrawer(id, callback) { lastOpenedDrawer = null; - $('html, body').animate({ scrollTop: 0 }); - $(id).animate({right: '-300px'}, 300, function () { - $(id).css('display', 'none'); - if (callback) { callback(); } - }); + $('html, body').css({ scrollTop: 0 }); + $(id).css({display: 'none', right: '-300px'}); + if (callback) { callback(); } } function openDrawer(id, prepare) { @@ -85,7 +83,7 @@ function init ($) { closeOpenDraw(function () { lastOpenedDrawer = id; if (prepare) { prepare(); } - $(id).css('display', 'block').animate({right: '0'}, 300); + $(id).css({display:'block', right: '0'}); }); }
    '+translate('Time')+''+translate('Readings')+'