forked from nightscout/cgm-remote-monitor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from nightscout/dev
Dev
- Loading branch information
Showing
37 changed files
with
3,841 additions
and
1,497 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
8.12.x | ||
8.x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
'use strict'; | ||
|
||
var moment = require('moment'); | ||
|
||
var cleanentriesdb = { | ||
name: 'cleanentriesdb' | ||
, label: 'Clean Mongo entries (glucose entries) database' | ||
, pluginType: 'admin' | ||
}; | ||
|
||
function init() { | ||
return cleanentriesdb; | ||
} | ||
|
||
module.exports = init; | ||
|
||
cleanentriesdb.actions = [ | ||
{ | ||
name: 'Delete all documents from entries collection older than 180 days' | ||
, description: 'This task removes all documents from entries collection that are older than 180 days. Useful when uploader battery status is not properly updated.' | ||
, buttonLabel: 'Delete old documents' | ||
, confirmText: 'Delete old documents from entries collection?' | ||
, preventClose: true | ||
} | ||
]; | ||
|
||
cleanentriesdb.actions[0].init = function init(client, callback) { | ||
var translate = client.translate; | ||
var $status = $('#admin_' + cleanentriesdb.name + '_0_status'); | ||
|
||
$status.hide(); | ||
|
||
var numDays = '<br/>' | ||
+ '<label for="admin_entries_days">' | ||
+ translate('Number of Days to Keep:') | ||
+ ' <input id="admin_entries_days" value="180" size="3" min="1"/>' | ||
+ '</label>'; | ||
|
||
$('#admin_' + cleanentriesdb.name + '_0_html').html(numDays); | ||
|
||
if (callback) { callback(); } | ||
}; | ||
|
||
cleanentriesdb.actions[0].code = function deleteOldRecords(client, callback) { | ||
var translate = client.translate; | ||
var $status = $('#admin_' + cleanentriesdb.name + '_0_status'); | ||
var numDays = Number($('#admin_entries_days').val()); | ||
|
||
if (isNaN(numDays) || (numDays < 3)) { | ||
alert(translate('%1 is not a valid number - must be more than 2', { params: [$('#admin_entries_days').val()] })); | ||
if (callback) { callback(); } | ||
return; | ||
} | ||
var endDate = moment().subtract(numDays, 'days'); | ||
|
||
if (!client.hashauth.isAuthenticated()) { | ||
alert(translate('Your device is not authenticated yet')); | ||
if (callback) { | ||
callback(); | ||
} | ||
return; | ||
} | ||
|
||
$status.hide().text(translate('Deleting records ...')).fadeIn('slow'); | ||
$.ajax('/api/v1/entries/?find[date][$lte]=' + endDate.valueOf(), { | ||
method: 'DELETE' | ||
, headers: client.headers() | ||
, success: function (retVal) { | ||
$status.hide().text(translate('%1 records deleted',{ params: [retVal.n] })).fadeIn('slow'); | ||
} | ||
, error: function () { | ||
$status.hide().text(translate('Error')).fadeIn('slow'); | ||
} | ||
}).done(function success () { | ||
if (callback) { callback(); } | ||
}).fail(function fail() { | ||
if (callback) { callback(); } | ||
}); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
'use strict'; | ||
|
||
var moment = require('moment'); | ||
|
||
var cleantreatmentsdb = { | ||
name: 'cleantreatmentsdb' | ||
, label: 'Clean Mongo treatments database' | ||
, pluginType: 'admin' | ||
}; | ||
|
||
function init() { | ||
return cleantreatmentsdb; | ||
} | ||
|
||
module.exports = init; | ||
|
||
cleantreatmentsdb.actions = [ | ||
{ | ||
name: 'Delete all documents from treatments collection older than 180 days' | ||
, description: 'This task removes all documents from treatments collection that are older than 180 days. Useful when uploader battery status is not properly updated.' | ||
, buttonLabel: 'Delete old documents' | ||
, confirmText: 'Delete old documents from treatments collection?' | ||
, preventClose: true | ||
} | ||
]; | ||
|
||
cleantreatmentsdb.actions[0].init = function init(client, callback) { | ||
var translate = client.translate; | ||
var $status = $('#admin_' + cleantreatmentsdb.name + '_0_status'); | ||
|
||
$status.hide(); | ||
|
||
var numDays = '<br/>' | ||
+ '<label for="admin_treatments_days">' | ||
+ translate('Number of Days to Keep:') | ||
+ ' <input id="admin_treatments_days" value="180" size="3" min="1"/>' | ||
+ '</label>'; | ||
|
||
$('#admin_' + cleantreatmentsdb.name + '_0_html').html(numDays); | ||
|
||
if (callback) { callback(); } | ||
}; | ||
|
||
cleantreatmentsdb.actions[0].code = function deleteOldRecords(client, callback) { | ||
var translate = client.translate; | ||
var $status = $('#admin_' + cleantreatmentsdb.name + '_0_status'); | ||
var numDays = Number($('#admin_treatments_days').val()); | ||
|
||
if (isNaN(numDays) || (numDays < 3)) { | ||
alert(translate('%1 is not a valid number - must be more than 2', { params: [$('#admin_treatments_days').val()] })); | ||
if (callback) { callback(); } | ||
return; | ||
} | ||
var endDate = moment().subtract(numDays, 'days'); | ||
var dateStr = endDate.format('YYYY-MM-DD'); | ||
|
||
if (!client.hashauth.isAuthenticated()) { | ||
alert(translate('Your device is not authenticated yet')); | ||
if (callback) { | ||
callback(); | ||
} | ||
return; | ||
} | ||
|
||
$status.hide().text(translate('Deleting records ...')).fadeIn('slow'); | ||
$.ajax('/api/v1/treatments/?find[created_at][$lte]=' + dateStr, { | ||
method: 'DELETE' | ||
, headers: client.headers() | ||
, success: function (retVal) { | ||
$status.hide().text(translate('%1 records deleted',{ params: [retVal.n] })).fadeIn('slow'); | ||
} | ||
, error: function () { | ||
$status.hide().text(translate('Error')).fadeIn('slow'); | ||
} | ||
}).done(function success () { | ||
if (callback) { callback(); } | ||
}).fail(function fail() { | ||
if (callback) { callback(); } | ||
}); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.