make profile history and multiple profiles optional

This commit is contained in:
MilosKozak
2015-11-09 21:21:36 +01:00
parent 86691d94e2
commit 447e4e0d4d
10 changed files with 41 additions and 8 deletions
+3
View File
@@ -230,6 +230,9 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm
* `AR2_CONE_FACTOR` (`2`) - to adjust size of cone, use `0` for a single line.
* `simplealarms` (Simple BG Alarms) - Uses `BG_HIGH`, `BG_TARGET_TOP`, `BG_TARGET_BOTTOM`, `BG_LOW` thresholds to generate alarms.
* Enabled by default if 1 of these thresholds is set **OR** `ALARM_TYPES` includes `simple`.
* `profile` (Treatment Profile) - Add link to Profile Editor and allow to enter treatment profile settings. Also uses the extended setting:
* `PROFILE_HISTORY` (`off`) - possible values `on` or `off`. Enable/disable NS ability to keep history of your profiles (still experimental)
* `PROFILE_MULTIPLE` (`off`) - possible values `on` or `off`. Enable/disable NS ability to handle and switch between multiple treatment profiles
#### Built-in/Example Plugins:
+2
View File
@@ -158,6 +158,8 @@ function findExtendedSettings (envs) {
extended[enable] = exts;
var ext = _.camelCase(env.substring(split + 1).toLowerCase());
if (!isNaN(value)) { value = Number(value); }
if (typeof value === 'string' && value.toLowerCase() === 'on') { value = true; }
if (typeof value === 'string' && value.toLowerCase() === 'off') { value = false; }
exts[ext] = value;
}
}
+8 -1
View File
@@ -33,6 +33,13 @@ function init(client, $, plugins) {
}
}
function isProfileEnabled(profiles) {
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; }
@@ -154,7 +161,7 @@ function init(client, $, plugins) {
profiles.forEach(function (p) {
$('#bc_profile').append('<option val="' + p + '">' + p + '</option>');
});
$('#bc_profileLabel').toggle(profiles.length > 1);
$('#bc_profileLabel').toggle(isProfileEnabled(profiles));
$('#bc_usebg').prop('checked','checked');
$('#bc_usecarbs').prop('checked','checked');
+2
View File
@@ -781,6 +781,8 @@ client.init = function init(serverSettings, plugins) {
$('.foodcontrol').toggle(client.settings.enable.indexOf('food') > -1);
// hide cob control if not enabled
$('.cobcontrol').toggle(client.settings.enable.indexOf('cob') > -1);
// hide profile controls if not enabled
$('.profilecontrol').toggle(client.settings.enable.indexOf('profile') > -1);
container.toggleClass('has-minor-pills', plugins.hasShownType('pill-minor', client.settings));
function prepareData ( ) {
+3 -2
View File
@@ -30,8 +30,9 @@ function init() {
, require('./sensorage')()
, require('./basalprofile')()
, require('./upbat')()
, require('./careportal')()
, require('./boluscalc')()
, require('./careportal')() // fake plugin to show/hide
, require('./boluscalc')() // fake plugin to show/hide
, require('./profile')() // fake plugin to hold extended settings
];
var serverDefaultPlugins = [
+16
View File
@@ -0,0 +1,16 @@
'use strict';
// this is just a fake plugin to hold extended settings
function init() {
var profile = {
name: 'profile'
, label: 'Profile'
, pluginType: 'fake'
};
return profile;
}
module.exports = init;
+1 -1
View File
@@ -77,7 +77,7 @@ function init ( ) {
}
//TODO: getting sent in status.json, shouldn't be
settings.DEFAULT_FEATURES = ['delta', 'direction', 'upbat', 'errorcodes'];
settings.DEFAULT_FEATURES = ['delta', 'direction', 'upbat', 'errorcodes', 'profile'];
var wasSet = [];
+1 -1
View File
@@ -82,7 +82,7 @@
<form id="settings-form">
<ul class="navigation">
<li><a href="/report/index.html" target="reports" class="translate">Reports</a></li>
<li><a id="editprofilelink" href="/profile/index.html" target="profileeditor" class="translate">Profile Editor</a></li>
<li class="profilecontrol"><a id="editprofilelink" href="/profile/index.html" target="profileeditor" class="translate">Profile Editor</a></li>
<li class="foodcontrol"><a id="editfoodlink" href="/food/index.html" target="foodeditor" class="translate">Food Editor</a></li>
<li><a id="admintoolslink" href="/admin/index.html" target="admintools" class="translate">Admin Tools</a></li>
</ul>
+2 -3
View File
@@ -60,7 +60,7 @@
</fieldset>
<fieldset class="browserSettings">
<legend>
<legend id="pe_history" style="display:none">
<span class="translate">Database records</span>:
<select id="pe_databaserecords"></select>
&nbsp;
@@ -71,7 +71,6 @@
<img id="pe_records_clone" title="Clone this record to new" class="titletranslate" style="cursor:pointer" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACSklEQVQ4T5VTYU9SYRR+zn0vXhDEFyRBXcpmbZnZsOXsI2xpVnNcv/ilufET8h/oL8h/gN/aWhs2yjKt26rPSvUh5yQodQlqgKQCd5fbLg2jxlycT+/OOc85z/OcvYSa8MoRLqimUEuzOSgwBl0nFFUtW1K1J/Ho6Hxtr/H2yQqnarJ3fFHucNnC57tdXIUJhydl6CAwIhwfFXCwf5hUC6XpjYXAQgUcUngRzkxlgHc0Kl+57I443S7s5VQwxqCVCYVSGfkTFSQQmsQmHGVzKJ78nJMs2izBohRg8ZFB293iSPQPdPOiqiOdyiGdysdKmp4t64LXxlu9otUKTVdhkSSUjgooHOez7R1uvr2bA10cfx66cb0n3GS14tPHrWz6R34i+fT2m6q0rruv7tvs9gdOtxNk0mA2SRB0gqVZwGb8AOSbXIkMDV+Qt7cy2IinJ+LRWxWNf5ur+Kx2vub0OABRg2QSIYqEr/EMaHjqrdJ/tce/upqIxR76B/8FVzySFc7MzWvtnW6vyjSAAFFgyBkSrt17n7jU1+ldjcVn1x+PzNTZzkWLTXF5zvmYmaEslCEIxnUE7H07AA1NvVPaO9r8X5Kpic+Pfp+oNvpCH/R6rKo5GphUIq1Oh7y++T2wv/LHvLNAtTXqHX8Zkqyt4XQ6M73/emzuf4GnDLg/wu0tbYliqTifWhqZbniAAfCMLs/oRMHU0s26VzjTA6PI/QqXJC1BxAZ3XwSSjbA4/UyesWU/Y2Jw51mgIRmnA4ytXXcU385iINYIg1+OJdcoyf/hkgAAAABJRU5ErkJggg==">
&nbsp;
</legend>
<br>
<dl>
<b title="Start of record validity" class="titletranslate"><span class="translate">Record valid from</span>: </b>
@@ -80,7 +79,7 @@
</dl>
<fieldset class="browserSettings pe_stored_profile">
<legend>
<legend id="pe_multiple" style="display:none">
<b><span class="translate">Stored profiles</span>: </b>
<select id="pe_profiles">
</select>
+3
View File
@@ -147,6 +147,9 @@
}
function initeditor() {
$('#pe_history').toggle(client.settings.extendedSettings.profile && client.settings.extendedSettings.profile.history);
$('#pe_multiple').toggle(client.settings.extendedSettings.profile && client.settings.extendedSettings.profile.multiple);
// Load timezones
timezoneInput.empty();
moment.tz.names().forEach(function addTz(tz) {