Skip to content

Commit

Permalink
Sanitize data from manual careportal entries so only fields with actu…
Browse files Browse the repository at this point in the history
…al data are sent to the server (nightscout#5619)
  • Loading branch information
sulkaharo authored May 5, 2020
1 parent 7c5a69d commit 9236771
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/client/careportal.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,17 @@ function init (client, $) {
, duration: times.msecs(parse_duration($('#duration').val())).mins < 1 ? $('#duration').val() : times.msecs(parse_duration($('#duration').val())).mins
, percent: $('#percent').val()
, profile: $('#profile').val()
, preBolus: parseInt($('#preBolus').val())
, preBolus: $('#preBolus').val()
, notes: $('#notes').val()
, units: client.settings.units
};

data.preBolus = parseInt(data.preBolus);

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

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

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

careportal.save = function save (event) {
Expand Down

0 comments on commit 9236771

Please sign in to comment.