mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
Merge pull request #2657 from ps2/food-type
Add food type string to carb entry on graph.
This commit is contained in:
+51
-51
@@ -3,15 +3,15 @@
|
||||
var _ = require('lodash');
|
||||
var moment = require('moment-timezone');
|
||||
var times = require('../times');
|
||||
|
||||
|
||||
function init(client, $) {
|
||||
var boluscalc = { };
|
||||
|
||||
|
||||
var translate = client.translate;
|
||||
var storage = $.localStorage;
|
||||
var iob = client.plugins('iob');
|
||||
var cob = client.plugins('cob');
|
||||
|
||||
|
||||
var eventTime = $('#bc_eventTimeValue');
|
||||
var eventDate = $('#bc_eventDateValue');
|
||||
|
||||
@@ -26,7 +26,7 @@ function init(client, $) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
function maybePrevent (event) {
|
||||
if (event) {
|
||||
event.preventDefault();
|
||||
@@ -34,12 +34,12 @@ function init(client, $) {
|
||||
}
|
||||
|
||||
function isProfileEnabled(profiles) {
|
||||
return client.settings.enable.indexOf('profile') > -1
|
||||
return client.settings.enable.indexOf('profile') > -1
|
||||
&& client.settings.extendedSettings.profile
|
||||
&& client.settings.extendedSettings.profile.multiple
|
||||
&& profiles.length > 1;
|
||||
}
|
||||
|
||||
|
||||
function isTouch() {
|
||||
try { document.createEvent('TouchEvent'); return true; }
|
||||
catch (e) { return false; }
|
||||
@@ -75,24 +75,24 @@ function init(client, $) {
|
||||
sensorbg = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set BG
|
||||
if ($('#bc_bgfromsensor').is(':checked')) {
|
||||
$('#bc_bg').val(sensorbg ? sensorbg : '');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boluscalc.updateVisualisations = function updateVisualisations (sbx) {
|
||||
// update BG in GUI
|
||||
setBG(sbx.lastSGVEntry(), mergeDateAndTime().toDate());
|
||||
|
||||
|
||||
if (client.browserUtils.getLastOpenedDrawer !== '#boluscalcDrawer') {
|
||||
return;
|
||||
}
|
||||
if ($('#bc_nowtime').is(':checked')) {
|
||||
// Update time
|
||||
setDateAndTime();
|
||||
|
||||
|
||||
boluscalc.calculateInsulin();
|
||||
}
|
||||
};
|
||||
@@ -115,11 +115,11 @@ function init(client, $) {
|
||||
if (ele.attr('oldminutes') === '0' && merged.minutes() === 59) {
|
||||
merged.add(-1, 'hours');
|
||||
}
|
||||
|
||||
|
||||
setDateAndTime(merged);
|
||||
updateTime(ele, merged);
|
||||
boluscalc.eventTimeTypeChange();
|
||||
|
||||
|
||||
// update BG from sgv to this time
|
||||
setBG(findClosestSGVToPastTime(merged.toDate()), merged.toDate());
|
||||
|
||||
@@ -166,7 +166,7 @@ function init(client, $) {
|
||||
$('#bc_profile').append('<option val="' + p + '">' + p + '</option>');
|
||||
});
|
||||
$('#bc_profileLabel').toggle(isProfileEnabled(profiles));
|
||||
|
||||
|
||||
$('#bc_usebg').prop('checked','checked');
|
||||
$('#bc_usecarbs').prop('checked','checked');
|
||||
$('#bc_usecob').prop('checked','');
|
||||
@@ -185,21 +185,21 @@ function init(client, $) {
|
||||
boluscalc.updateVisualisations(client.sbx);
|
||||
boluscalc.calculateInsulin();
|
||||
};
|
||||
|
||||
|
||||
boluscalc.calculateInsulin = function calculateInsulin (event) {
|
||||
maybePrevent(event);
|
||||
boluscalc.gatherBoluscalcData( );
|
||||
boluscalc.updateGui(boluscalc.record);
|
||||
return boluscalc.record;
|
||||
};
|
||||
|
||||
|
||||
boluscalc.updateGui = function updateGui (record) {
|
||||
record = record || boluscalc.record;
|
||||
|
||||
if (record.eventTime === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var targetBGLow = record.targetBGLow;
|
||||
var targetBGHigh = record.targetBGHigh;
|
||||
var isf = record.isf;
|
||||
@@ -236,7 +236,7 @@ function init(client, $) {
|
||||
}
|
||||
$('#bc_inzulinbg').text(record.insulinbg.toFixed(2));
|
||||
$('#bc_inzulinbg').attr('title',
|
||||
'Target BG range: '+targetBGLow + ' - ' + targetBGHigh +
|
||||
'Target BG range: '+targetBGLow + ' - ' + targetBGHigh +
|
||||
'\nISF: ' + isf +
|
||||
'\nBG diff: ' + record.bgdiff.toFixed(1)
|
||||
);
|
||||
@@ -246,7 +246,7 @@ function init(client, $) {
|
||||
$('#bc_inzulinbg').text('');
|
||||
$('#bc_inzulinbg').attr('title', '');
|
||||
}
|
||||
|
||||
|
||||
// Show foods
|
||||
if (record.foods.length) {
|
||||
var html = '<table style="float:right;margin-right:20px;font-size:12px">';
|
||||
@@ -298,11 +298,11 @@ function init(client, $) {
|
||||
$('#bc_inzulincarbs').attr('title','');
|
||||
$('#bc_carbs').text('');
|
||||
}
|
||||
|
||||
|
||||
// Show Total
|
||||
$('#bc_rouding').text(record.roundingcorrection.toFixed(2));
|
||||
$('#bc_insulintotal').text(record.insulin.toFixed(2));
|
||||
|
||||
|
||||
// Carbs needed if too much iob or in range message when nothing entered and in range
|
||||
var outcome = record.bg - record.iob * isf;
|
||||
if (record.othercorrection === 0 && record.carbs === 0 && record.cob === 0 && record.bg > 0 && outcome > targetBGLow && outcome < targetBGHigh) {
|
||||
@@ -333,16 +333,16 @@ function init(client, $) {
|
||||
tempMark += tempMark ? ': ' : '';
|
||||
$('#bc_basal').text(tempMark + basal.totalbasal.toFixed(3));
|
||||
};
|
||||
|
||||
|
||||
boluscalc.gatherBoluscalcData = function gatherBoluscalcData() {
|
||||
boluscalc.record = {};
|
||||
var record = boluscalc.record;
|
||||
|
||||
|
||||
if (!client.sbx) {
|
||||
console.log('No sandbox data yet. Exiting gatherBoluscalcData()');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
record.profile = $('#bc_profile').val();
|
||||
if (!record.profile) {
|
||||
delete record.profile;
|
||||
@@ -350,7 +350,7 @@ function init(client, $) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Calculate event time from date & time
|
||||
record.eventTime = new Date();
|
||||
if ($('#bc_othertime').is(':checked')) {
|
||||
@@ -400,7 +400,7 @@ function init(client, $) {
|
||||
record.cob = roundTo(cob.cobTotal(client.sbx.data.treatments, client.sbx.data.devicestatus, client.sbx.data.profile, record.eventTime, record.profile).cob, 0.01);
|
||||
record.insulincob = roundTo(record.cob / ic, 0.01);
|
||||
}
|
||||
|
||||
|
||||
// Load BG
|
||||
record.bg = 0;
|
||||
record.insulinbg = 0;
|
||||
@@ -420,7 +420,7 @@ function init(client, $) {
|
||||
record.insulinbg = roundTo(record.bgdiff / isf, 0.01);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Load foods
|
||||
record.carbs = 0;
|
||||
record.foods = _.cloneDeep(foods);
|
||||
@@ -435,7 +435,7 @@ function init(client, $) {
|
||||
} else {
|
||||
record.gi = $('#bc_gi').val();
|
||||
}
|
||||
|
||||
|
||||
// Load Carbs
|
||||
record.insulincarbs = 0;
|
||||
if ($('#bc_usecarbs').is(':checked')) {
|
||||
@@ -447,7 +447,7 @@ function init(client, $) {
|
||||
}
|
||||
record.insulincarbs = roundTo(record.carbs / ic, 0.01);
|
||||
}
|
||||
|
||||
|
||||
// Corrections
|
||||
record.othercorrection = parseFloat($('#bc_othercorrection').val());
|
||||
|
||||
@@ -458,13 +458,13 @@ function init(client, $) {
|
||||
}
|
||||
record.insulin = roundTo(total, 0.05);
|
||||
record.roundingcorrection = record.insulin - total;
|
||||
|
||||
|
||||
// Carbs needed if too much iob
|
||||
record.carbsneeded = 0;
|
||||
if (record.insulin<0) {
|
||||
record.carbsneeded = Math.ceil(-total * ic);
|
||||
}
|
||||
|
||||
|
||||
console.log('Insulin calculation result: ',record);
|
||||
return record;
|
||||
};
|
||||
@@ -476,7 +476,7 @@ function init(client, $) {
|
||||
alert('Calculation not completed!');
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
data.enteredBy = $('#bc_enteredBy').val();
|
||||
data.eventType = 'Bolus Wizard';
|
||||
if ($('#bc_bg').val()!==0) {
|
||||
@@ -495,13 +495,13 @@ function init(client, $) {
|
||||
if ($('#bc_othertime').is(':checked')) {
|
||||
data.eventTime = mergeDateAndTime().toDate();
|
||||
}
|
||||
|
||||
|
||||
// replace boluscalc.eventTime by ISO string
|
||||
data.boluscalc.eventTime = data.boluscalc.eventTime.toISOString();
|
||||
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
boluscalc.submit = function submit(event) {
|
||||
var data = gatherData();
|
||||
if (data) {
|
||||
@@ -567,10 +567,10 @@ function init(client, $) {
|
||||
maybePrevent(event);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function quickpickChange(event) {
|
||||
var qpiselected = $('#bc_quickpick').val();
|
||||
|
||||
|
||||
if (qpiselected === null || qpiselected === '-1') { // (none)
|
||||
$('#bc_carbs').val(0);
|
||||
foods = [];
|
||||
@@ -580,14 +580,14 @@ function init(client, $) {
|
||||
foods = _.cloneDeep(qp.foods);
|
||||
$('#bc_addfoodarea').css('display','none');
|
||||
}
|
||||
|
||||
|
||||
boluscalc.calculateInsulin();
|
||||
maybePrevent(event);
|
||||
}
|
||||
|
||||
|
||||
function quickpickHideFood() {
|
||||
var qpiselected = $('#bc_quickpick').val();
|
||||
|
||||
|
||||
if (qpiselected >= 0) {
|
||||
var qp = quickpicks[qpiselected];
|
||||
if (qp.hideafteruse) {
|
||||
@@ -603,11 +603,11 @@ function init(client, $) {
|
||||
xhr.send(dataJson);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
boluscalc.calculateInsulin();
|
||||
maybePrevent(event);
|
||||
}
|
||||
|
||||
|
||||
var categories = [];
|
||||
var foodlist = [];
|
||||
var databaseloaded = false;
|
||||
@@ -616,7 +616,7 @@ function init(client, $) {
|
||||
, subcategory: ''
|
||||
, name: ''
|
||||
};
|
||||
|
||||
|
||||
boluscalc.loadFoodDatabase = function loadFoodDatabase(event, callback) {
|
||||
categories = [];
|
||||
foodlist = [];
|
||||
@@ -656,7 +656,7 @@ function init(client, $) {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
function fillForm(event) {
|
||||
$('#bc_filter_category').empty().append('<option value="">' + translate('(none)') + '</option>');
|
||||
Object.keys(categories).forEach( function eachCategory(s) {
|
||||
@@ -664,11 +664,11 @@ function init(client, $) {
|
||||
});
|
||||
filter.category = '';
|
||||
fillSubcategories();
|
||||
|
||||
|
||||
$('#bc_filter_category').change(fillSubcategories);
|
||||
$('#bc_filter_subcategory').change(doFilter);
|
||||
$('#bc_filter_name').on('input',doFilter);
|
||||
|
||||
|
||||
maybePrevent(event);
|
||||
return false;
|
||||
}
|
||||
@@ -685,7 +685,7 @@ function init(client, $) {
|
||||
}
|
||||
doFilter();
|
||||
}
|
||||
|
||||
|
||||
function doFilter(event) {
|
||||
if (event) {
|
||||
filter.category = $('#bc_filter_category').val();
|
||||
@@ -705,16 +705,16 @@ function init(client, $) {
|
||||
$('#bc_data').append('<option value="' + i +'">' + o + '</option>');
|
||||
}
|
||||
$('#bc_addportions').val('1');
|
||||
|
||||
|
||||
maybePrevent(event);
|
||||
}
|
||||
|
||||
|
||||
function addFoodFromDatabase(event) {
|
||||
if (!databaseloaded) {
|
||||
boluscalc.loadFoodDatabase(event, addFoodFromDatabase);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$('#bc_addportions').val('1');
|
||||
$('#bc_addfooddialog').dialog({
|
||||
width: 640
|
||||
@@ -754,7 +754,7 @@ function init(client, $) {
|
||||
return d.type === 'sgv' && d.mills <= time.getTime();
|
||||
});
|
||||
var focusPoint = _.last(nowData);
|
||||
|
||||
|
||||
if (!focusPoint || focusPoint.mills + times.mins(10).mills < time.getTime()) {
|
||||
return null;
|
||||
}
|
||||
@@ -775,7 +775,7 @@ function init(client, $) {
|
||||
boluscalc.calculateInsulin();
|
||||
maybePrevent(event);
|
||||
});
|
||||
|
||||
|
||||
$('#boluscalcDrawerToggle').click(boluscalc.toggleDrawer);
|
||||
$('#boluscalcDrawer').find('button').click(boluscalc.submit);
|
||||
$('#bc_eventTime input:radio').change(boluscalc.eventTimeTypeChange);
|
||||
|
||||
+68
-63
@@ -423,6 +423,10 @@ function init (client, d3) {
|
||||
arc_data[1].element = Math.round(treatment.carbs) + ' g';
|
||||
}
|
||||
|
||||
if (treatment.foodType) {
|
||||
arc_data[1].element = arc_data[1].element + " " + treatment.foodType;
|
||||
}
|
||||
|
||||
if (treatment.insulin > 0) {
|
||||
arc_data[3].element = Math.round(treatment.insulin * 100) / 100 + ' U';
|
||||
}
|
||||
@@ -454,9 +458,9 @@ function init (client, d3) {
|
||||
function isInRect(x,y,rect) {
|
||||
return !(x < rect.x || x > rect.x + rect.width || y < rect.y || y > rect.y + rect.height);
|
||||
}
|
||||
|
||||
|
||||
function appendTreatments(treatment, arc) {
|
||||
|
||||
|
||||
function boluscalcTooltip (treatment) {
|
||||
if (!treatment.boluscalc) {
|
||||
return '';
|
||||
@@ -478,11 +482,12 @@ function init (client, d3) {
|
||||
}
|
||||
return html;
|
||||
}
|
||||
|
||||
|
||||
function treatmentTooltip() {
|
||||
client.tooltip.transition().duration(TOOLTIP_TRANS_MS).style('opacity', .9);
|
||||
client.tooltip.html('<strong>' + translate('Time') + ':</strong> ' + client.formatTime(new Date(treatment.mills)) + '<br/>' + '<strong>' + translate('Treatment type') + ':</strong> ' + translate(client.careportal.resolveEventName(treatment.eventType)) + '<br/>' +
|
||||
(treatment.carbs ? '<strong>' + translate('Carbs') + ':</strong> ' + treatment.carbs + '<br/>' : '') +
|
||||
(treatment.absorptionTime > 0 ? '<strong>' + translate('Absorption Time') + ':</strong> ' + (Math.round( treatment.absorptionTime / 60.0 * 10) / 10) + 'h' + '<br/>' : '') +
|
||||
(treatment.insulin ? '<strong>' + translate('Insulin') + ':</strong> ' + treatment.insulin + '<br/>' : '') +
|
||||
(treatment.enteredinsulin ? '<strong>' + translate('Combo Bolus') + ':</strong> ' + treatment.enteredinsulin + 'U, ' + treatment.splitNow + '% : ' + treatment.splitExt + '%, ' + translate('Duration') + ': ' + treatment.duration + '<br/>' : '') +
|
||||
(treatment.glucose ? '<strong>' + translate('BG') + ':</strong> ' + treatment.glucose + (treatment.glucoseType ? ' (' + translate(treatment.glucoseType) + ')' : '') + '<br/>' : '') +
|
||||
@@ -499,9 +504,9 @@ function init (client, d3) {
|
||||
var insulinRect = { x: 0, y: 0, width: 0, height: 0 };
|
||||
var carbsRect = { x: 0, y: 0, width: 0, height: 0 };
|
||||
var operation;
|
||||
renderer.drag = d3.behavior.drag()
|
||||
.on('dragstart', function() {
|
||||
//console.log(treatment);
|
||||
renderer.drag = d3.behavior.drag()
|
||||
.on('dragstart', function() {
|
||||
//console.log(treatment);
|
||||
var windowWidth = $(client.tooltip).parent().parent().width();
|
||||
var left = d3.event.x + TOOLTIP_WIDTH < windowWidth ? d3.event.x : windowWidth - TOOLTIP_WIDTH - 10;
|
||||
client.tooltip.transition().duration(TOOLTIP_TRANS_MS).style('opacity', .9)
|
||||
@@ -602,17 +607,17 @@ function init (client, d3) {
|
||||
})
|
||||
.text(translate('Move insulin'));
|
||||
}
|
||||
|
||||
|
||||
chart().basals.attr('display','none');
|
||||
|
||||
|
||||
operation = 'Move';
|
||||
})
|
||||
.on('drag', function() {
|
||||
.on('drag', function() {
|
||||
//console.log(d3.event);
|
||||
client.tooltip.transition().style('opacity', .9);
|
||||
var x = Math.min(Math.max(0, d3.event.x), chart().charts.attr('width'));
|
||||
var y = Math.min(Math.max(0, d3.event.y), chart().focusHeight);
|
||||
|
||||
|
||||
operation = 'Move';
|
||||
if (isInRect(x, y, deleteRect) && isInRect(x, y, insulinRect)) {
|
||||
operation = 'Remove insulin';
|
||||
@@ -629,8 +634,8 @@ function init (client, d3) {
|
||||
newTime = new Date(chart().xScale.invert(x));
|
||||
var minDiff = times.msecs(newTime.getTime() - treatment.mills).mins.toFixed(0);
|
||||
client.tooltip.html(
|
||||
'<b>' + translate('Operation') + ':</b> ' + translate(operation) + '<br>'
|
||||
+ '<b>' + translate('New time') + ':</b> ' + newTime.toLocaleTimeString() + '<br>'
|
||||
'<b>' + translate('Operation') + ':</b> ' + translate(operation) + '<br>'
|
||||
+ '<b>' + translate('New time') + ':</b> ' + newTime.toLocaleTimeString() + '<br>'
|
||||
+ '<b>' + translate('Difference') + ':</b> ' + (minDiff > 0 ? '+' : '') + minDiff + ' ' + translate('mins')
|
||||
);
|
||||
|
||||
@@ -646,9 +651,9 @@ function init (client, d3) {
|
||||
'stroke-width': 2,
|
||||
'stroke': 'white'
|
||||
});
|
||||
|
||||
|
||||
})
|
||||
.on('dragend', function() {
|
||||
.on('dragend', function() {
|
||||
var newTreatment;
|
||||
chart().drag.selectAll('.drag-droparea').remove();
|
||||
hideTooltip();
|
||||
@@ -656,14 +661,14 @@ function init (client, d3) {
|
||||
case 'Move':
|
||||
if (window.confirm(translate('Change treatment time to %1 ?', { params: [newTime.toLocaleTimeString()] } ))) {
|
||||
client.socket.emit(
|
||||
'dbUpdate',
|
||||
{
|
||||
collection: 'treatments',
|
||||
'dbUpdate',
|
||||
{
|
||||
collection: 'treatments',
|
||||
_id: treatment._id,
|
||||
data: { created_at: newTime.toISOString() }
|
||||
data: { created_at: newTime.toISOString() }
|
||||
},
|
||||
function callback(result) {
|
||||
console.log(result);
|
||||
function callback(result) {
|
||||
console.log(result);
|
||||
chart().drag.selectAll('.arrow').transition().duration(5000).style('opacity', 0).remove();
|
||||
}
|
||||
);
|
||||
@@ -674,14 +679,14 @@ function init (client, d3) {
|
||||
case 'Remove insulin':
|
||||
if (window.confirm(translate('Remove insulin from treatment ?'))) {
|
||||
client.socket.emit(
|
||||
'dbUpdateUnset',
|
||||
{
|
||||
collection: 'treatments',
|
||||
'dbUpdateUnset',
|
||||
{
|
||||
collection: 'treatments',
|
||||
_id: treatment._id,
|
||||
data: { insulin: 1 }
|
||||
data: { insulin: 1 }
|
||||
},
|
||||
function callback(result) {
|
||||
console.log(result);
|
||||
function callback(result) {
|
||||
console.log(result);
|
||||
chart().drag.selectAll('.arrow').transition().duration(5000).style('opacity', 0).remove();
|
||||
}
|
||||
);
|
||||
@@ -692,14 +697,14 @@ function init (client, d3) {
|
||||
case 'Remove carbs':
|
||||
if (window.confirm(translate('Remove carbs from treatment ?'))) {
|
||||
client.socket.emit(
|
||||
'dbUpdateUnset',
|
||||
{
|
||||
collection: 'treatments',
|
||||
'dbUpdateUnset',
|
||||
{
|
||||
collection: 'treatments',
|
||||
_id: treatment._id,
|
||||
data: { carbs: 1 }
|
||||
data: { carbs: 1 }
|
||||
},
|
||||
function callback(result) {
|
||||
console.log(result);
|
||||
function callback(result) {
|
||||
console.log(result);
|
||||
chart().drag.selectAll('.arrow').transition().duration(5000).style('opacity', 0).remove();
|
||||
}
|
||||
);
|
||||
@@ -710,13 +715,13 @@ function init (client, d3) {
|
||||
case 'Remove':
|
||||
if (window.confirm(translate('Remove treatment ?'))) {
|
||||
client.socket.emit(
|
||||
'dbRemove',
|
||||
{
|
||||
collection: 'treatments',
|
||||
'dbRemove',
|
||||
{
|
||||
collection: 'treatments',
|
||||
_id: treatment._id
|
||||
},
|
||||
function callback(result) {
|
||||
console.log(result);
|
||||
function callback(result) {
|
||||
console.log(result);
|
||||
chart().drag.selectAll('.arrow').transition().duration(5000).style('opacity', 0).remove();
|
||||
}
|
||||
);
|
||||
@@ -727,11 +732,11 @@ function init (client, d3) {
|
||||
case 'Move insulin':
|
||||
if (window.confirm(translate('Change insulin time to %1 ?', { params: [newTime.toLocaleTimeString()] } ))) {
|
||||
client.socket.emit(
|
||||
'dbUpdateUnset',
|
||||
{
|
||||
collection: 'treatments',
|
||||
'dbUpdateUnset',
|
||||
{
|
||||
collection: 'treatments',
|
||||
_id: treatment._id,
|
||||
data: { insulin: 1 }
|
||||
data: { insulin: 1 }
|
||||
}
|
||||
);
|
||||
newTreatment = _.cloneDeep(treatment);
|
||||
@@ -740,13 +745,13 @@ function init (client, d3) {
|
||||
delete newTreatment.carbs;
|
||||
newTreatment.created_at = newTime.toISOString();
|
||||
client.socket.emit(
|
||||
'dbAdd',
|
||||
{
|
||||
collection: 'treatments',
|
||||
data: newTreatment
|
||||
'dbAdd',
|
||||
{
|
||||
collection: 'treatments',
|
||||
data: newTreatment
|
||||
},
|
||||
function callback(result) {
|
||||
console.log(result);
|
||||
function callback(result) {
|
||||
console.log(result);
|
||||
chart().drag.selectAll('.arrow').transition().duration(5000).style('opacity', 0).remove();
|
||||
}
|
||||
);
|
||||
@@ -757,11 +762,11 @@ function init (client, d3) {
|
||||
case 'Move carbs':
|
||||
if (window.confirm(translate('Change carbs time to %1 ?', { params: [newTime.toLocaleTimeString()] } ))) {
|
||||
client.socket.emit(
|
||||
'dbUpdateUnset',
|
||||
{
|
||||
collection: 'treatments',
|
||||
'dbUpdateUnset',
|
||||
{
|
||||
collection: 'treatments',
|
||||
_id: treatment._id,
|
||||
data: { carbs: 1 }
|
||||
data: { carbs: 1 }
|
||||
}
|
||||
);
|
||||
newTreatment = _.cloneDeep(treatment);
|
||||
@@ -770,13 +775,13 @@ function init (client, d3) {
|
||||
delete newTreatment.insulin;
|
||||
newTreatment.created_at = newTime.toISOString();
|
||||
client.socket.emit(
|
||||
'dbAdd',
|
||||
{
|
||||
collection: 'treatments',
|
||||
data: newTreatment
|
||||
'dbAdd',
|
||||
{
|
||||
collection: 'treatments',
|
||||
data: newTreatment
|
||||
},
|
||||
function callback(result) {
|
||||
console.log(result);
|
||||
function callback(result) {
|
||||
console.log(result);
|
||||
chart().drag.selectAll('.arrow').transition().duration(5000).style('opacity', 0).remove();
|
||||
}
|
||||
);
|
||||
@@ -854,7 +859,7 @@ function init (client, d3) {
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
renderer.drawTreatment = function drawTreatment(treatment, opts) {
|
||||
if (!treatment.carbs && !treatment.insulin) {
|
||||
return;
|
||||
@@ -889,10 +894,10 @@ function init (client, d3) {
|
||||
var comboareadata = [];
|
||||
var from = chart().brush.extent()[0].getTime();
|
||||
var to = Math.max(chart().brush.extent()[1].getTime(), client.sbx.time) + client.forecastTime;
|
||||
|
||||
|
||||
var date = from;
|
||||
var lastbasal = 0;
|
||||
|
||||
|
||||
if (!profile.activeProfileToTime(from)) {
|
||||
window.alert(translate('Wrong profile setting.\nNo profile defined to displayed time.\nRedirecting to profile editor to create new profile.'));
|
||||
try {
|
||||
@@ -957,7 +962,7 @@ function init (client, d3) {
|
||||
.x(function(d) { return chart().xScaleBasals(d.d); })
|
||||
.y0(chart().yScaleBasals(0))
|
||||
.y1(function(d) { return chart().yScaleBasals(d.b); });
|
||||
|
||||
|
||||
var g = chart().basals.append('g');
|
||||
|
||||
g.append('path')
|
||||
@@ -1025,7 +1030,7 @@ function init (client, d3) {
|
||||
if (client.profilefunctions.listBasalProfiles().length < 2) {
|
||||
return; // do not visualize profiles if there is only one
|
||||
}
|
||||
|
||||
|
||||
function profileTooltip (d) {
|
||||
return '<strong>'+translate('Time')+':</strong> ' + client.formatTime(new Date(d.mills)) + '<br/>' +
|
||||
(d.eventType ? '<strong>'+translate('Treatment type')+':</strong> ' + translate(client.careportal.resolveEventName(d.eventType)) + '<br/>' : '') +
|
||||
@@ -1041,7 +1046,7 @@ function init (client, d3) {
|
||||
var to = chart().brush.extent()[1].getTime();
|
||||
var mult = (to-from) / times.hours(24).msecs;
|
||||
from += times.mins(20 * mult).msecs;
|
||||
|
||||
|
||||
var mode = client.settings.extendedSettings.basal.render;
|
||||
var data = client.ddata.profileTreatments.slice();
|
||||
data.push({
|
||||
|
||||
@@ -123,6 +123,7 @@ function init() {
|
||||
(lastTreatment.targetTop ? '\nTarget Top: ' + lastTreatment.targetTop : '') +
|
||||
(lastTreatment.targetBottom ? '\nTarget Bottom: ' + lastTreatment.targetBottom : '') +
|
||||
(lastTreatment.carbs ? '\nCarbs: ' + lastTreatment.carbs + 'g' : '') +
|
||||
(lastTreatment.absorptionTime > 0 ? '\nAbsorption Time: ' + (Math.round(lastTreatment.absorptionTime / 60.0 * 10) / 10) + 'h' : '') +
|
||||
|
||||
(lastTreatment.insulin ? '\nInsulin: ' + sbx.roundInsulinForDisplayFormat(lastTreatment.insulin) + 'U' : '')+
|
||||
(lastTreatment.duration ? '\nDuration: ' + lastTreatment.duration + ' min' : '')+
|
||||
@@ -147,4 +148,4 @@ function isCurrent(last) {
|
||||
return ago !== -1 && ago < times.mins(10).msecs;
|
||||
}
|
||||
|
||||
module.exports = init;
|
||||
module.exports = init;
|
||||
|
||||
Reference in New Issue
Block a user