Skip to content

Commit

Permalink
Merge from upstream (#1)
Browse files Browse the repository at this point in the history
* npm update, no nodejs changes are needed because we use specify 8.9.x (nightscout#3154)

* Upstream npm bug `Cannot read property '0' of undefined` fixed. Use npm 5.6.x when available (nightscout#3190)

* npm update, no nodejs changes are needed because we use specify 8.9.x

* upgrade to npm 5.6.x because upstream npm issue (issue 17858) has been fixed in npm 5.6.0

* upgrade node to 8.9.x and use npm 5.6.x for travis

* node 8.9.x does not work with thravis, fixing to nodejs 8.9.3

* install npm@latest for travis and print version number of npm

* upgarde .nvmrdc to 8.9.x and another go of letting travis ci use the correct node version (5.6.x)

* Removing last remnants of Bower, which is not used anymore

* Fixes a long-standing bug where the plugin pill visualization didn't update immediately when new data was loaded

* Moved server-specific sources to their own folder. Removed some unused code as per Codacy reports

* Remove the compare report (which is hidden from users, anyway)

* Fix tests

* Links for both Clock Views

* * Disable bundle analyzer for now
* Prevent saving numeric profile names, which seems to break the profile storage and there's no obvious way to fix

* Add "Check for Updates" link (nightscout#3206)

Link to http://nightscout.github.io/pages/update-fork/ added to the
main info panel.

* update russian (nightscout#3209)

* Update Mongo Driver to 3.0 series and have it retry connecting to Mongo in case the socket goes down for much longer

* Fix Mongo connection string test

* Italian language

* Fix

* Fix PUMP_WARN_ON_SUSPEND in README.md

* if no value, return 0 (nightscout#3332)

* Add "Views" section (nightscout#3211)

* Italian Language (nightscout#3244)

* fix expected outcome

* fix expected outcome

* fix

* Italian language

* Fix

* Removed git-rev due to unclear benefit. Removed unused dependencies.

* de fix

* Add clock view structure to nav

* Tweak CSS for clock view nav

* Add clock view nav elements to language.js

* Match dev progress in language.js

* Revert removing forever (apologies; must have tested the the wrong branch in Heroku, leading me to think it's auto-injected if needed).

* Fix "dispalyed" typo

Fix typo for hover tip for "Raw BG" display in the settings drawer.

* Change Reporting screen default to "newest on top"

Many email GUI's place newest on top, less scrolling, adjusting my nightscout to do that too, since I have to keep clicking it anyways! -dboland

* english translation was ok, fixing extra space in dutch translation

* update docs to reflect changes in alexa backend requiring SSL type selection

* update dutch language. reapply nightscout#3405 to dev

* GVI outlier detedtion: time before and after

nightscout#3194

* npm update / mongo fix / small fixes (nightscout#3413)

* npm update and test if nodejs 9.x (currently 9.7.1) also works

* explicit node version in .travis.yml

* add webpack-cli

* UglifyJsPlugin is deprecated in webpack 4. It's used as --optimize-minimize as default

* improve Readme

* update some more

* fix typo in .travis.yml and remove node 9.7.1 because Travis does not seem to support it

* upgrade simple-statistics.

Use standardDeviation instead of standard_deviation. Other functions are not changed.
try node 9 on travis

* downgrade async to 1.5.2 to see if that makes the test work again

* downgrade async module and fix tests

* npm update

* update npm in package.json

* restore RMS in glucosedistribution

* remove unused total
use SI units (L instead of l, min instead of m)

* improve mongo

* apply fix suggested by Paul Andrel @stavlor, see https://gitter.im/nightscout/public?at=5ab542f135dd17022e92891a

* npm update

* fix mongodb, remove ancient npm versions. azure has 5.7
j

* revert to simple-stats 0.7.0

* add bundle-dev option to package.json

* fix distribution test

* upgrade nvm version for travis to latest nvm.

once node 8 and node 9 ship with npm > 5.6.0 we should remove this. see npm/npm#17858 for details

* Use new id if received one is invalid.

* Fix a memory leak in Nightscout chart (nightscout#3500)

The chart would create SVG objects for treatment event records, then
later recreate them without deleting the old ones. This resulted in a
huge number of duplicates accumulating, which (in my setup) would cause
a crash due to excessive memory usage and DOM size in about a day.

* Fix Temp Targets so mgdl will always be used to ensure safety, proper display on the client. (nightscout#3549)

mmol units from clients and values under 20 will be treated as mmol and converted to mgdl

* Add translations for 2HR (nightscout#3553)

* Activity data collection baseline implementation & swagger fixes (nightscout#3442)

* First pass at adding a new activity data collection & API to Nightscout

* Attempt of fixing /api-docs.html
Converted swagger.yaml to OpenAPI 3.0 format using:
https://github.com/Mermade/swagger2openapi
https://mermade.org.uk/openapi-converter
Conversion / Validation engine v2.11.5
Web frontend version v1.3.8

* add swagger-ui-dist and exported swagger.json

* add swagger-config.yaml

* move swagger-ui to static folder, update static/api-docs.html (based on swagger-ui-dist, without bower)

* move swagger.json to static

* add tokenbased authentication

* token based authentication

* add json webtokens for swagger

* npm update, add swagger-ui-dist and expose that to webroot swagger-ui-dist

* remove swagger-config.yaml (not needed)

* Fix swagger and upgrade to openapi3 (and npm update) (nightscout#3366)

* fix swagger and upgrade to openapi3, reapply changes of issue nightscout#3345

* use nightscout icon for swagger ui

* Comment out deprecated API call

* Adds the If-Modified-Since header parsing to api/v1/enties/:spec: calls (nightscout#3571)

* Alexa translations (nightscout#3532)

* More alexa translatable texts and german translations.

* More alexa translatable texts and german translations.

* More alexa translatable texts and german translations.

* More alexa translatable texts and german translations.

* adding pump battery age pill (nightscout#3459)

* adding Loop as automated uploader (nightscout#3403)

Loop is also an automated uploader of treatments.  Had an issue where temp basals set by Loop and uploaded to treatments were auto-snoozing BG alarms.  This should resolve.

* Fix clock scaling (nightscout#3355)

* Update simple clock scaling

Brings clock.html in line with clock-color.html, in terms of proper viewport scaling. Also adds "minutes ago" text on stale data, which I think is appropriate even in this stripped-down view.

* Fix bgclock scaling

Bring bgclock.html in line with the other clock views, in terms of proper viewport scaling.

* fix typo

* Fix tooltips in drawer (nightscout#3400)

* fix tooltips in drawer, this was a regression from the bower to webpack upgrade

* fix css path

* Fixing packaging after merges from PRs

* German language fixes

* TDD average on daytoday report

* Fix TT units

* Updated alexa plugin setup to reflect current Alexa dev portal

* drop Node 9 support, upgrade to Node 8.11.3 and 10.5.0

* npm update

* temporary disable distrubition test, because it breaks travis

* Various updates to fix Azure deploys.

Fix npm version 5.6.x.
Reverse the --production and --scripts-prepend-node-path arguments on npm install.
Use graceful-fs@4.1.11 to solve missing internal/util/types in postinstall.
Remove blank line in webpack.config.js as a dummy commit for postinstall testing.

* Remove graceful-fs.

* merging nightscout#3642 broke dev
"cipm can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync.

* fix dev branch

* fix npm-shrinkwrap.json

* temporary disable Node 10 build in .travis.yml

* Test editing display txt.

* Don't add sensor state to displayLong.

* Added new pill type.

* Added new sensor state pill type.

* Added new pill plugin to plugins index.

* Fixed syntax errors.

* Added getPrefs back.

* Fixed misnamed variable error.

* Fixes issue nightscout#3660 (nightscout#3661)

* Fixed handling some initial conditions with no data.

* Handle case of no data in updateVis

* Fixed sortBy parameter.

* Test setting devicestatus count to 20.

* Fixed some sensorInfo data errors.

* Always keep one hour of devicestatus.

* Keep 24 hours of devicestatus in advanced mode, otherwise one hour.

* Include xdrip-js in device types.

* Added short cgm state string.

* Convert timestamp to moment for latest comparison.

* Removed count = 1 limit for devicestatus.

* count = 1 is not the issue.
logging the number of devicestatus entries sent to new clients.

* More debug.

* Fixed debug.

* More debug.

* More debug.

* Fixed devicestatus member name to xdripjs.

* Fixed null dereference.

* Fixed xdripjs filter value.

* Added info line for sensor state.

* Cleaned up debug.

* Removed unnecessary code changes.

* Added additional status fields.

* Fixed syntax error.

* Fixed lastStateTime bug.

* Fixed undefined variable error.

* Added many additional xdrip-js fields.

* Fixed format issues.

* Fix booterrors after move it to server dir

This used to work in 0.10.2, but moving booterror to server dir created a bug. Caused by commit nightscout@0515760#diff-2006a43ba7f8c96ac8368a989f56bd8c
@sulkaharo committed on 27 Dec 2017

* make error message more clear for users

* improve readme instructions for installation

* add more clear message to mongo-storage-test.js as well

* stick to latest mongodb client 3.0.x (currently 3.0.11), to avoid warnings about useNewUrlParser DeprecationWarnings

Using mongodb 3.1 will generate `(node:29452) DeprecationWarning: current URL string parser is deprecated,
and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.`

Starting from next Nightscout release mongodb://localhost/test_db should not be used, and only use mongodb://localhost:27017/test_db so changing it in the Makefile already

More info:
- https://stackoverflow.com/questions/50448272/avoid-current-url-string-parser-is-deprecated-warning-by-setting-usenewurlpars
- https://mongodb.github.io/node-mongodb-native/driver-articles/mongoclient.html

* Added alarm thresholds.

* Added warnBatV preference for xdrip-js plugin.

* upgrade supertest

* enable Node 10 for Travis

* Make notification title match event.

* upgrade mocha and other packages

* increase timeout for hasauth.test.js

because it times out with 40000ms on Travis with Node 10. See https://travis-ci.org/PieterGit/cgm-remote-monitor/jobs/401307860

not ok 192 pluginbase does stuff
  AssertionError: expected -1 to be above -1
      at Assertion.fail (node_modules/should/cjs/should.js:275:17)
      at Assertion.value (node_modules/should/cjs/should.js:356:19)
      at containsLine (tests/hashauth.test.js:163:41)
      at Window.mockConfirm [as alert] (tests/hashauth.test.js:165:7)
      at Object.u.addBasals (tmp/js/bundle.js:9:2577816)
      at Object.o.scroll (tmp/js/bundle.js:9:2485436)
      at V (tmp/js/bundle.js:9:3092518)
      at Timeout.e [as _onTimeout] (tmp/js/bundle.js:9:3106675)
# tests 192
# pass 191
# fail 1

* Added session start info.

* upgrade sgvdata because it has security issues and is not compatible with Node 9 and Node 10

* only allow node 8.9.x in package.json

* use latest version of Node 8 available

* Only alert state transitions once.

* Add mmol support to OpenAPS temp targets (nightscout#3670)

* Fixes issue nightscout#3660

* Fix OpenAPS temporary targets using mg/dl on mmol users

* Fixes a bug with saving

* Fix changed entry data order in API

* Clean formatting

* Fix mmol conversion on treatment save

* Speech plugin (nightscout#3325)

* Plugin to speak out CGM values as they arrive

* Formatting improvements

* Support using the actual lang for speech

* Added readme, prettified code

* Small speech fix, make DEVICESTATUS_ADVANCED on by default

* Added state notification interval preference.

* add mongodb port number to mqtt.test.js

* switch back to sgvdata 0.0.2 for Nightscout 0.10.3 release

* drop Node 10 (and Node 9) support for the 0.10.3 release in the documenation.

* More debug.

* Fixed lastStateNotification persistance.

* fix mqtt.test.js because of changed mongodb url

* Added exception to notify interval if the state changes to a different state.

* reverting to mocha 3.5.3 for 0.10.3 release,

current Nightscout code is not compatible with mocha: 5.2.0.
note most of the Nightscout 0.10.3 cycle mocha  "~3.1.2" was used.
note Nightscout 0.10.2 release also used  "~3.1.2"

* Updated defaults and README for xdrip-js plugin.

* Fixed xdrip-js README link.

* Fixed spelling in README

* improve windows instructions

* prepare coverage shield for next release (need to change it back after the release)

* Changed to consistently use CGM instead of Sensor of G5.

* Change initial device status render to use 10 most recent updates from each device, rather than just 1

* Removed session age if no valid data is available instead of N/A.

* Devicestatus splitting was accidentally creating an array of arrays and thus never working right, fixed

* Fixes nightscout#3679

* temporary disable speechPlugin because it can't be disabled and is enabled by default

* fix the openaps/loop auto-trearment filter

* upgrade minimed-connect-to-nightscout from git://github.com/mddub/minimed-connect-to-nightscout.git to a proper npm released version 1.1.1

also run a npmupdate which upgraded webpack, compression and uglify-js

before PR: found 24 vulnerabilities (3 low, 15 moderate, 5 high, 1 critical) in 13366 scanned packages
after PR: found 16 vulnerabilities (2 low, 9 moderate, 4 high, 1 critical) in 13361 scanned packages

* Fix speech plugin activation detection

* Fixed Swedish typos

* upgrades, moment-locales-webpack-plugin integration, easier bundle-analyzer

1. webpack 4.16.0 gives problem with report test on Windows
```
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 (E:\Git\src\cgm-remote-monitor\tmp\js\bundle.js:1:5989)
```

2. a lot of moment-locales are packacked with webpack. Limit to language that are availble in Nightscout

3. make it possible to use `npm run bundle-analyzer` so that webpack.config.js does not have to be changed

* make Dutch translations 100%

* Made swedish 100% + a few corrections

* Update language.js

* Add translate tag to "Clock Views:

* Resolve language conflicts

* resolve conflicts and add dutch translations

* Update GER Teil 1

bis Zeile 6862

* Update GER Teil 2

* Update SV aus nightscout#3714 (whooze)

* Update .gitignore

* changed double quotes to single

* resolve npm audit security fixes (nightscout#3721)

* 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 04f1f39.

* Revert "more lodash modularization"

This reverts commit c4fa530.

* remove forever dependency

* Revert "Revert "more lodash modularization""

This reverts commit b13c274.

* 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 moment/moment#1407 (comment)

* upgrade webpack to 4.16.2

* Update package.json

* azure fixes related to webpack

move webpack to devDependencies, install webpack-command instead of webpack-cli

* speech and  Warning, Pump Battery Low Alarm issue during Clock testing... (nightscout#3709)

* Fix Warning, Pump Battery Low Alarm cannot be disabled

* fix Clock Views language.js

* see if this will solve the problems with the speech plugin detection at the client

* fix dutch spelling

* translate Clock Views:

* disable again

* Update language.js

* fix azure problems

if use latest nodejs on Azure

if it want yargs, we'll give it

> Nightscout@0.10.3-dev-20180723 postinstall D:\home\site\wwwroot
> webpack --mode production --config webpack.config.js && npm run-script update-buster

module.js:549
    throw err;
    ^

Error: Cannot find module 'yargs'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (D:\home\site\wwwroot\node_modules\webpack\bin\webpack.js:16:13)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3

* install yargs for azure

* increase SCM_COMMAND_IDLE_TIMEOUT (default 60, 1 minute), to 300 seconds / 5 minutes

Azure deploy fails with message Thread was being aborted.
This happens when the deploy commands take too long to execute. You can resolve this by setting the
SCM_COMMAND_IDLE_TIMEOUT app setting to 900 (900 seconds, 15 minutes) for your app in the Azure portal.
Thanks https://github.com/kemmis/Panda and projectkudu/kudu#2089 (comment)

* update docs for Azure hosting (if anybody really wants it)

* Server-side localization fixes, better speech api use (nightscout#3724)

* Adds API to plugin manager that calls plugins to visualize alarms

* Refactoring how the translation object is managed after discovering every server-side plugin had it's own instance of the translations and the language code wasn't propagated to any code that generated alarms

* Add more missing translations

* Some more localization fixes
Update Finnish to 100% localized
Change Mongo connection to not stop retrying connecting

* Better scaling for mmol
Fix bug in detecting new BG values

* Delta calculation was the wrong way round :D

* add missing dutch translations

* Have tests bail early & tell Mocha to exit at the end of the run

* Try if Travis likes running tests one by one better

* Enable blocking IO for Travis

* Added the language list to README

* Temporarily disable code coverage reporting from Travis

* Update Italian Translation

* Typo

* Removed whitespaces

* Update language.js

Changed a few numbers to words in the Hebrew translation

* Update language.js

Added more hebrew translations

* fix duplicate 'min ago' in languages.js

thanks @whooze for the report (source: https://gitter.im/nightscout/public?at=5b5b9ac412f1be71375ea448 )

* npm update and require node 8.11.x in package.json

* Fixes speech considering minutes a meters in Finnish

* Update on Swedish (nightscout#3741)

* RO translation June, 27th 2018 (nightscout#3739)

RO translation June, 27th 2018

* Update danish to line 8562

* Update language.js

fixed error

* make tooltip bolder and only show 3 significant digits for remaining insulin

* fix bold fonts in tooltips labels

cherry picking from nightscout#3746

* hide forecast type if no value

* Update Danish localizations (nightscout#3747)

* Update language.js

Update danish translation to line 10100

* Update language.js

fixed a bug

* Update language.js (nightscout#3748)

* Update language.js

Update danish translation to 10745

* Update language.js

Fixed translation bug

* Update BG translation (nightscout#3752)

* Update BG translation

* alexa doesn't support Bulgarian language

* Update language.js

Fixing formatting

* Couple localizations

* cs translations

* remove duplicate

* Update language.js

Rest of Danish translation

* Change Travis over to OS X based VM, as that seems to produce a more stable build environment. Disable Node 10 build for now (we can test locally for that and we're not defining 10 as a valid hosting version for now)

* add hebrew translations

merge nightscout#3738 and resolve merge conflicts

* make languages.js clean again

change tabs to spaces, remove spaces from the end of lines

* .

* . (nightscout#3759)

* Update Hebrew localizations

Update Hebrew localizations

* Update Hebrew localizations (nightscout#3758)

* Update language.js

Added the remaining Hebrew translations I worked on

* Update language.js

* Update language.js

* Update language.js

* Update language.js

* updates polish translations

* fix food save (nightscout#3768)

2018-08-04T10:25:32.244096+00:00 app[web.1]: Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters
2018-08-04T10:25:32.244099+00:00 app[web.1]:     at new ObjectID (/app/node_modules/bson/lib/bson/objectid.js:50:11)
2018-08-04T10:25:32.244101+00:00 app[web.1]:     at Function.save (/app/lib/server/food.js:14:15)
2018-08-04T10:25:32.244103+00:00 app[web.1]:     at /app/lib/api/food/index.js:59:18
2018-08-04T10:25:32.244105+00:00 app[web.1]:     at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
2018-08-04T10:25:32.244106+00:00 app[web.1]:     at next (/app/node_modules/express/lib/router/route.js:137:13)
2018-08-04T10:25:32.244107+00:00 app[web.1]:     at check (/app/lib/authorization/index.js:182:9)
2018-08-04T10:25:32.244109+00:00 app[web.1]:     at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
2018-08-04T10:25:32.244110+00:00 app[web.1]:     at next (/app/node_modules/express/lib/router/route.js:137:13)
2018-08-04T10:25:32.244111+00:00 app[web.1]:     at Route.dispatch (/app/node_modules/express/lib/router/route.js:112:3)
2018-08-04T10:25:32.244113+00:00 app[web.1]:     at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
2018-08-04T10:25:32.249694+00:00 heroku[router]: at=info method=PUT path="/api/v1/food/" host=xxx.herokuapp.com request_id=yyy fwd="zzz" dyno=web.1 connect=0ms service=20ms status=500 bytes=1026 protocol=https

* fix food loading

* Tag matafiles with 0.10.3-master-20180805

* Fixes the site for iOS 9 and older

* Name too long, please switch back to BWP
  • Loading branch information
bassettb authored Sep 2, 2018
1 parent 55c89a3 commit 0c46592
Show file tree
Hide file tree
Showing 118 changed files with 13,734 additions and 7,169 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ coverage/
npm-debug.log
*.heapsnapshot

/tmp
/tmp
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.9.1
8.11.x
14 changes: 11 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
language: node_js
sudo: required
dist: trusty
os: osx
node_js:
- "8.9.1"
- "8"
before_install:
- if [[ `npm --version` != "5.8.0" ]]; then npm install -g npm@latest; npm --version; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
# https://github.com/Homebrew/homebrew-core/issues/26358
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew unlink python; fi
# "brew install" can succeed but return 1 if it has "caveats".
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install mongodb || true; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew services start mongodb; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install docker || true; fi
matrix:
fast_finish: true
services:
Expand Down
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Nightscout tests/builds/analysis
TESTS=tests/*.js
MONGO_CONNECTION?=mongodb://localhost/test_db
MONGO_CONNECTION?=mongodb://localhost:27017/test_db
CUSTOMCONNSTR_mongo_settings_collection?=test_settings
CUSTOMCONNSTR_mongo_collection?=test_sgvs
MONGO_SETTINGS=MONGO_CONNECTION=${MONGO_CONNECTION} \
Expand Down Expand Up @@ -40,12 +40,18 @@ report:
(npm install codacy-coverage && cat ${ANALYZED} | \
YOURPACKAGE_COVERAGE=1 ./node_modules/codacy-coverage/bin/codacy-coverage.js) || echo "NO COVERAGE"

test_onebyone:
python -c 'import os,sys,fcntl; flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);'
$(foreach var,$(wildcard tests/*.js),${MONGO_SETTINGS} ${MOCHA} --timeout 30000 --exit --bail -R tap $(var);)

test:
${MONGO_SETTINGS} ${MOCHA} --timeout 30000 -R tap ${TESTS}
${MONGO_SETTINGS} ${MOCHA} --timeout 30000 --exit --bail -R tap ${TESTS}

travis:
NODE_ENV=test ${MONGO_SETTINGS} \
${ISTANBUL} cover ${MOCHA} --report lcovonly -- --timeout 5000 -R tap ${TESTS}
python -c 'import os,sys,fcntl; flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);'
# NODE_ENV=test ${MONGO_SETTINGS} \
# ${ISTANBUL} cover ${MOCHA} --report lcovonly -- --timeout 5000 -R tap ${TESTS}
$(foreach var,$(wildcard tests/*.js),${MONGO_SETTINGS} ${MOCHA} --timeout 30000 --exit --bail -R tap $(var);)

docker_release:
# Get the version from the package.json file
Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: ./node_modules/.bin/forever --minUptime 100 -c node server.js
web: node server.js
64 changes: 51 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ low values, which can be cleared by any watcher of the data.
Community maintained fork of the
[original cgm-remote-monitor][original].

[![Coverage Status](https://coveralls.io/repos/github/nightscout/cgm-remote-monitor/badge.svg?branch=dev)](https://coveralls.io/github/nightscout/cgm-remote-monitor?branch=dev)
[![Coverage Status](https://coveralls.io/repos/github/nightscout/cgm-remote-monitor/badge.svg?branch=master)](https://coveralls.io/github/nightscout/cgm-remote-monitor?branch=master)

[build-img]: https://img.shields.io/travis/nightscout/cgm-remote-monitor.svg
[build-url]: https://travis-ci.org/nightscout/cgm-remote-monitor
[dependency-img]: https://img.shields.io/david/nightscout/cgm-remote-monitor.svg
[dependency-url]: https://david-dm.org/nightscout/cgm-remote-monitor
[coverage-img]: https://img.shields.io/coveralls/nightscout/cgm-remote-monitor/dev.svg
[coverage-url]: https://coveralls.io/github/nightscout/cgm-remote-monitor?branch=dev
[coverage-url]: https://coveralls.io/github/nightscout/cgm-remote-monitor?branch=master
[codacy-img]: https://www.codacy.com/project/badge/f79327216860472dad9afda07de39d3b
[codacy-url]: https://www.codacy.com/app/Nightscout/cgm-remote-monitor
[gitter-img]: https://img.shields.io/badge/Gitter-Join%20Chat%20%E2%86%92-1dce73.svg
Expand All @@ -58,6 +58,7 @@ Community maintained fork of the
- [Alarms](#alarms)
- [Core](#core)
- [Predefined values for your browser settings (optional)](#predefined-values-for-your-browser-settings-optional)
- [Views](#views)
- [Plugins](#plugins)
- [Default Plugins](#default-plugins)
- [`delta` (BG Delta)](#delta-bg-delta)
Expand Down Expand Up @@ -87,6 +88,7 @@ Community maintained fork of the
- [`pump` (Pump Monitoring)](#pump-pump-monitoring)
- [`openaps` (OpenAPS)](#openaps-openaps)
- [`loop` (Loop)](#loop-loop)
- [`xdrip-js` (xDrip-js)](#xdrip-js-xdrip-js)
- [`alexa` (Amazon Alexa)](#alexa-amazon-alexa)
- [`cors` (CORS)](#cors-cors)
- [Extended Settings](#extended-settings)
Expand All @@ -95,25 +97,44 @@ Community maintained fork of the
- [Treatment Profile](#treatment-profile)
- [Setting environment variables](#setting-environment-variables)
- [Vagrant install](#vagrant-install)
- [Installation on Windows](#installation-on-windows)
- [More questions?](#more-questions)
- [License](#license)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# Install

Requirements:
Supported configurations:

- [Node.js](http://nodejs.org/) 8.9.0 LTS (use [Install instructions for Node](https://nodejs.org/en/download/package-manager/) or `setup.sh`)
If you plan to use Nightscout, we recommend using [Heroku](http://openaps.readthedocs.io/en/latest/docs/While%20You%20Wait%20For%20Gear/nightscout-setup.html#nightscout-setup-with-heroku), as Nightscout can reach the usage limits of the free Azure plan and cause it to shut down for hours or days. If you end up needing a paid tier, the $7/mo Heroku plan is also much cheaper than the first paid tier of Azure. Currently, the only added benefit to choosing the $7/mo Heroku plan vs the free Heroku plan is a section showing site use metrics for performance (such as response time). This has limited benefit to the average Nightscout user. In short, Heroku is the free and best option for Nightscout hosting.

Clone this repo then install dependencies into the root of the project:
- [Nightscout Setup with Heroku] (http://openaps.readthedocs.io/en/latest/docs/While%20You%20Wait%20For%20Gear/nightscout-setup.html#nightscout-setup-with-heroku) (recommended)
- [Nightscout Setup with Microsoft Azure] (http://www.nightscout.info/wiki/faqs-2/azure-2) (not recommended, please
[switch from Azure to Heroku](http://openaps.readthedocs.io/en/latest/docs/While%20You%20Wait%20For%20Gear/nightscout-setup.html#switching-from-azure-to-heroku) )
- Linux based install (Debian, Ubuntu, Raspbian) install with own Node.JS and MongoDB install (see software requirements below)
- Windows based install with own Node.JS and MongoDB install (see software requirements below)

Software requirements:

- [Node.js](http://nodejs.org/) Latest Node 8 LTS (Node 8.11.3 or later). Use [Install instructions for Node](https://nodejs.org/en/download/package-manager/) or use `setup.sh`)
- [MongoDB](https://www.mongodb.com/download-center?jmp=nav#community) 3.x or later. MongoDB 2.4 is only supported for Raspberry Pi.

As a non-root user clone this repo then install dependencies into the root of the project:

```bash
$ npm install
```

If deploying the software to Microsoft Azure, you must set *WEBSITE_NODE_DEFAULT_VERSION* in the app settings to *8.9.0* **before** you deploy the latest Nightscout or the site deployment will likely fail. Other hosting environments do not require this setting.
Installation notes for Microsoft Azure, Windows and Node 10:

- If deploying the software to Microsoft Azure, you must set ** in the app settings for *WEBSITE_NODE_DEFAULT_VERSION* and *SCM_COMMAND_IDLE_TIMEOUT* **before** you deploy the latest Nightscout or the site deployment will likely fail. Other hosting environments do not require this setting. Please use:
```
WEBSITE_NODE_DEFAULT_VERSION=8.11.1
SCM_COMMAND_IDLE_TIMEOUT=300
```
- See [install MongoDB, Node.js, and Nightscouton a single Windows system](https://github.com/jaylagorio/Nightscout-on-Windows-Server). if you want to host your Nightscout outside of the cloud. Although the instructions are intended for Windows Server the procedure is compatible with client versions of Windows such as Windows 7 and Windows 10.
- If you deploy to Windows and want to develop or test you need to install [Cygwin] (https://www.cygwin.com/) (use [setup-x86_64.exe] (https://www.cygwin.com/setup-x86_64.exe) and make sure to install `build-essential` package. Test your configuration by executing `make` and check if all tests are ok.
- There may be some issues with Node 10.6.0 or later with Nightscout. Node 10 support will be in the 0.11 release. Please don't use Nightscout with (Node 9 or) Node 10 at this moment.

# Usage

Expand Down Expand Up @@ -214,6 +235,7 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm
* `MONGO_DEVICESTATUS_COLLECTION`(`devicestatus`) - The collection used to store device status information such as uploader battery
* `MONGO_PROFILE_COLLECTION`(`profile`) - The collection used to store your profiles
* `MONGO_FOOD_COLLECTION`(`food`) - The collection used to store your food database
* `MONGO_ACTIVITY_COLLECTION`(`activity`) - The collection used to store activity data
* `PORT` (`1337`) - The port that the node.js application will listen on.
* `HOSTNAME` - The hostname that the node.js application will listen on, null by default for any hostname for IPv6 you may need to use `::`.
* `SSL_KEY` - Path to your ssl key file, so that ssl(https) can be enabled directly in node.js
Expand All @@ -228,20 +250,28 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm
* `NIGHT_MODE` (`off`) - possible values `on` or `off`
* `SHOW_RAWBG` (`never`) - possible values `always`, `never` or `noise`
* `CUSTOM_TITLE` (`Nightscout`) - Usually name of T1
* `THEME` (`default`) - possible values `default` or `colors`
* `THEME` (`default`) - possible values `default`, `colors`, or `colorblindfriendly`
* `ALARM_TIMEAGO_WARN` (`on`) - possible values `on` or `off`
* `ALARM_TIMEAGO_WARN_MINS` (`15`) - minutes since the last reading to trigger a warning
* `ALARM_TIMEAGO_URGENT` (`on`) - possible values `on` or `off`
* `ALARM_TIMEAGO_URGENT_MINS` (`30`) - minutes since the last reading to trigger a urgent alarm
* `SHOW_PLUGINS` - enabled plugins that should have their visualizations shown, defaults to all enabled
* `SHOW_FORECAST` (`ar2`) - plugin forecasts that should be shown by default, supports space delimited values such as `"ar2 openaps"`
* `LANGUAGE` (`en`) - language of Nightscout. If not available english is used
* Currently supported language codes are: bg (Български), cs (Čeština), de (Deutsch), dk (Dansk), el (Ελληνικά), en (English), es (Español), fi (Suomi), fr (Français), he (עברית), hr (Hrvatski), it (Italiano), ko (한국어), nb (Norsk (Bokmål)), nl (Nederlands), pl (Polski), pt (Português (Brasil)), ro (Română), ru (Русский), sk (Slovenčina), sv (Svenska), zh_cn (中文(简体)), zh_tw (中文(繁體))
* `SCALE_Y` (`log`) - The type of scaling used for the Y axis of the charts system wide.
* The default `log` (logarithmic) option will let you see more detail towards the lower range, while still showing the full CGM range.
* The `linear` option has equidistant tick marks, the range used is dynamic so that space at the top of chart isn't wasted.
* The `log-dynamic` is similar to the default `log` options, but uses the same dynamic range and the `linear` scale.
* `EDIT_MODE` (`on`) - possible values `on` or `off`. Enable or disable icon allowing enter treatments edit mode

### Views

There are a few alternate web views available that display a simplified BG stream. Append any of these to your Nightscout URL:
* `/clock.html` - Shows current BG. Grey text on a black background.
* `/bgclock.html` - Shows current BG, trend arrow, and time of day. Grey text on a black background.
* `/clock-color.html` - Shows current BG and trend arrow. White text on a background that changes color to indicate current BG threshold (green = in range; blue = below range; yellow = above range; red = urgent below/above).

### Plugins

Plugins are used extend the way information is displayed, how notifications are sent, alarms are triggered, and more.
Expand Down Expand Up @@ -377,7 +407,7 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm
Generic Pump Monitoring for OpenAPS, MiniMed Connect, RileyLink, t:slim, with more on the way
* Requires `DEVICESTATUS_ADVANCED="true"` to be set
* `PUMP_ENABLE_ALERTS` (`false`) - Set to `true` to enable notifications for Pump battery and reservoir.
* `PUMP_WARNONSUSPEND` (`false`) - Set to `true` to get an alarm when the pump is suspended.
* `PUMP_WARN_ON_SUSPEND` (`false`) - Set to `true` to get an alarm when the pump is suspended.
* `PUMP_FIELDS` (`reservoir battery`) - The fields to display by default. Any of the following fields: `reservoir`, `battery`, `clock`, `status`, and `device`
* `PUMP_RETRO_FIELDS` (`reservoir battery clock`) - The fields to display in retro mode. Any of the above fields.
* `PUMP_WARN_CLOCK` (`30`) - The number of minutes ago that needs to be exceed before an alert is triggered.
Expand Down Expand Up @@ -408,9 +438,19 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm
* `LOOP_URGENT` (`60`) - The number of minutes since the last loop that needs to be exceeded before an urgent alarm is triggered
* Add `loop` to `SHOW_FORECAST` to show forecasted BG.

##### `xdrip-js` (xDrip-js)
Integrated xDrip-js monitoring, uses these extended settings:
* Requires `DEVICESTATUS_ADVANCED="true"` to be set
* `XDRIP-JS_ENABLE_ALERTS` (`false`) - Set to `true` to enable notifications when CGM state is not OK or battery voltages fall below threshold.
* `XDRIP-JS_STATE_NOTIFY_INTRVL` (`0.5`) - Set to number of hours between CGM state notifications
* `XDRIP-JS_WARN_BAT_V` (`300`) - The voltage of either transmitter battery, a warning will be triggered when dropping below this threshold.

##### `alexa` (Amazon Alexa)
Integration with Amazon Alexa, [detailed setup instructions](lib/plugins/alexa-plugin.md)

##### `speech` (Speech)
Speech synthesis plugin. When enabled, speaks out the blood glucose values, IOB and alarms. Note you have to set the LANGUAGE setting on the server to get all translated alarms.

##### `cors` (CORS)
Enabled [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) so other websites can make request to your Nightscout site, uses these extended settings:
* `CORS_ALLOW_ORIGIN` (`*`) - The list of sites that are allow to make requests
Expand All @@ -419,6 +459,8 @@ To learn more about the Nightscout API, visit https://YOUR-SITE.com/api-docs.htm
Some plugins support additional configuration using extra environment variables. These are prefixed with the name of the plugin and a `_`. For example setting `MYPLUGIN_EXAMPLE_VALUE=1234` would make `extendedSettings.exampleValue` available to the `MYPLUGIN` plugin.

Plugins only have access to their own extended settings, all the extended settings of client plugins will be sent to the browser.

* `DEVICESTATUS_ADVANCED` (`true`) - Defaults to true. Users who only have a single device uploading data to Nightscout can set this to false to reduce the data use of the site.

#### Pushover
In addition to the normal web based alarms, there is also support for [Pushover](https://pushover.net/) based alarms and notifications.
Expand Down Expand Up @@ -518,10 +560,6 @@ The setup script will install OS packages then run `npm install`.
The Vagrant VM serves to your host machine only on 192.168.33.10, you can access
the web interface on [http://192.168.33.10:1337](http://192.168.33.10:1337)

## Installation on Windows

If you have access to local computing resources and want to maintain more control over your data, you can host Nightscout and its database outside of the cloud. Windows Server supports MongoDB, Node.js, and Nightscout [installed on a single system](https://github.com/jaylagorio/Nightscout-on-Windows-Server). Although the instructions are intended for Windows Server the procedure is compatible with client versions of Windows such as Windows 7 and Windows 10.

More questions?
---------------

Expand Down
19 changes: 13 additions & 6 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var _ = require('lodash');
var _get = require('lodash/get');
var express = require('express');
var compression = require('compression');
var bodyParser = require('body-parser');
Expand All @@ -24,12 +24,12 @@ function create(env, ctx) {
app.locals.cachebuster = fs.readFileSync(process.cwd() + '/tmp/cacheBusterToken').toString().trim();

if (ctx.bootErrors && ctx.bootErrors.length > 0) {
app.get('*', require('./lib/booterror')(ctx));
app.get('*', require('./lib/server/booterror')(ctx));
return app;
}

if (env.settings.isEnabled('cors')) {
var allowOrigin = _.get(env, 'extendedSettings.cors.allowOrigin') || '*';
var allowOrigin = _get(env, 'extendedSettings.cors.allowOrigin') || '*';
console.info('Enabled CORS, allow-origin:', allowOrigin);
app.use(function allowCrossDomain(req, res, next) {
res.header('Access-Control-Allow-Origin', allowOrigin);
Expand Down Expand Up @@ -101,9 +101,9 @@ function create(env, ctx) {
// pebble data
app.get('/pebble', ctx.pebble);

// expose swagger.yaml
app.get('/swagger.yaml', function(req, res) {
res.sendFile(__dirname + '/swagger.yaml');
// expose swagger.json
app.get('/swagger.json', function(req, res) {
res.sendFile(__dirname + '/swagger.json');
});

/*
Expand Down Expand Up @@ -141,6 +141,13 @@ function create(env, ctx) {
// serve the static content
app.use(staticFiles);

var swaggerFiles = express.static(env.swagger_files, {
maxAge: maxAge
});

// serve the static content
app.use('/swagger-ui-dist', swaggerFiles);

var tmpFiles = express.static('tmp', {
maxAge: maxAge
});
Expand Down
Loading

0 comments on commit 0c46592

Please sign in to comment.