mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
* upgrade mocha from 3.5.3 to 5.0.5 This resolves these security issues Low Regular Expression Denial of Service Package debug Dependency of mocha [dev] Path mocha > debug More info https://nodesecurity.io/advisories/534 Critical Command Injection Package growl Dependency of mocha [dev] Path mocha > growl More info https://nodesecurity.io/advisories/146 * upgrade mocha and start modularizing lodash to make sure tests pass * more lodash modularization * upgrade mqtt to 2.18.3 * allow npm 6.2 * upgrade share2nightscout-bridge * incorporate express-extension-to-accept into Nightscout the packages seems not maintained (github page is 404) and has a security issue with mime package. so upgraded and included into Nightscout code. if somebody knows a more efficient way of programming this with express4 please PR * update jsdom for security fixes * prevent wrapping of hour labels by removing the space * Revert "update jsdom for security fixes" This reverts commit 04f1f39d636d8d79c6b01b5f298f9a6cea3dc645. * Revert "more lodash modularization" This reverts commit c4fa5304db9f16b94f15c2b44793a5a11d595885. * remove forever dependency * Revert "Revert "more lodash modularization"" This reverts commit b13c274ebff0b5c3a48ffc0e610ca85a9f8d25bc. * fix report.test.js with newer packages sometimes a fix is very easy. This is to prevent: ``` Deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info. Arguments: [0] _isAMomentObject: true, _isUTC: true, _useUTC: true, _l: undefined, _i: T00:00:00, _f: undefined, _strict: undefined, _locale: [object Object] Error at Function.createFromInputFallback (XXX\cgm-remote-monitor\tmp\js\bundle.js:117408:98) at configFromString (XXX\cgm-remote-monitor\tmp\js\bundle.js:119456:15) ``` We must use ISO8601 formatted strings and not use slashes in dates, see https://github.com/moment/moment/issues/1407#issuecomment-155630060 * upgrade webpack to 4.16.2 * Update package.json
87 lines
2.3 KiB
JavaScript
87 lines
2.3 KiB
JavaScript
'use strict';
|
|
|
|
var _find = require('lodash/find');
|
|
var _each = require('lodash/each');
|
|
|
|
function init() {
|
|
var allPlugins = [
|
|
require('./subjects')()
|
|
, require('./roles')()
|
|
, require('./cleanstatusdb')()
|
|
, require('./futureitems')()
|
|
];
|
|
|
|
function plugins(name) {
|
|
if (name) {
|
|
return _find(allPlugins, {name: name});
|
|
} else {
|
|
return plugins;
|
|
}
|
|
}
|
|
|
|
plugins.eachPlugin = function eachPlugin(f) {
|
|
_each(allPlugins, f);
|
|
};
|
|
|
|
plugins.createHTML = function createHTML(client) {
|
|
var translate = client.translate;
|
|
plugins.eachPlugin(function addHtml(p) {
|
|
var fs = $('<fieldset>');
|
|
$('#admin_placeholder').append(fs);
|
|
fs.append($('<legend>').append(translate(p.label)));
|
|
for (var i = 0; i < p.actions.length; i++) {
|
|
if (i !== 0) {
|
|
fs.append('<hr>');
|
|
}
|
|
var a = p.actions[i];
|
|
// add main plugin html
|
|
if (a.name) {
|
|
fs.append($('<b>').css('text-decoration','underline').append(translate(a.name)));
|
|
fs.append('<br>');
|
|
}
|
|
fs.append($('<i>').append(translate(a.description)));
|
|
fs.append($('<div>').attr('id','admin_' + p.name + '_' + i + '_html'));
|
|
fs.append($('<button>').addClass('adminButton').attr('plugin',p.name).attr('action',i).append(translate(a.buttonLabel)));
|
|
fs.append($('<span>').attr('id','admin_' + p.name + '_' + i + '_status'));
|
|
if (a.init) {
|
|
a.init(client);
|
|
}
|
|
}
|
|
// add css
|
|
if (p.css) {
|
|
$('<style>')
|
|
.prop('type', 'text/css')
|
|
.html(p.css)
|
|
.appendTo('head');
|
|
}
|
|
});
|
|
$('.adminButton').click(plugins.doAction);
|
|
};
|
|
|
|
plugins.doAction = function doAction(event) {
|
|
var Nightscout = window.Nightscout;
|
|
var plugin = $(this).attr('plugin');
|
|
var action = $(this).attr('action');
|
|
var a = plugins(plugin).actions[action];
|
|
var ok = true;
|
|
if (a.confirmText) {
|
|
ok = window.confirm(Nightscout.client.translate(a.confirmText));
|
|
}
|
|
if (ok) {
|
|
console.log('Running action', action, 'on plugin', plugin);
|
|
a.code(Nightscout.client);
|
|
|
|
if (!a.preventClose) {
|
|
$(this).css('display', 'none');
|
|
}
|
|
}
|
|
if (event) {
|
|
event.preventDefault();
|
|
}
|
|
};
|
|
|
|
return plugins();
|
|
|
|
}
|
|
|
|
module.exports = init; |