mirror of
https://github.com/bckelley/cgm-remote-monitor.git
synced 2026-08-24 03:14:12 -05:00
Add runtime state tracking to Nightscout, where client now checks if the server has loaded initial data from Mongo before the user is directed to the UI
This commit is contained in:
@@ -32,6 +32,7 @@ function configure (app, wares, env, ctx) {
|
||||
, settings: settings
|
||||
, extendedSettings: extended
|
||||
, authorized: ctx.authorization.authorize(authToken)
|
||||
, runtimeState: ctx.runtimeState
|
||||
};
|
||||
|
||||
var badge = 'http://img.shields.io/badge/Nightscout-OK-green';
|
||||
|
||||
@@ -62,6 +62,12 @@ client.init = function init (callback) {
|
||||
, url: src
|
||||
, headers: client.headers()
|
||||
}).done(function success (serverSettings) {
|
||||
if (serverSettings.runtimeState !== 'loaded') {
|
||||
console.log('Server is still loading data');
|
||||
$('#loadingMessageText').html('Server is loading data, retrying load in 2 seconds');
|
||||
window.setTimeout(window.Nightscout.client.init(), 2000);
|
||||
return;
|
||||
}
|
||||
client.settingsFailed = false;
|
||||
console.log('Application appears to be online');
|
||||
$('#centerMessagePanel').hide();
|
||||
|
||||
@@ -67,8 +67,6 @@ function init (ctx) {
|
||||
|
||||
var prop = sbx.properties.ar2;
|
||||
|
||||
console.log('ar2', prop);
|
||||
|
||||
if (prop && prop.level) {
|
||||
const notify = {
|
||||
level: prop.level
|
||||
|
||||
@@ -75,6 +75,7 @@ function init (ctx) {
|
||||
, require('./timeago')(ctx)
|
||||
, require('./basalprofile')(ctx)
|
||||
, require('./dbsize')(ctx)
|
||||
, require('./runtimestate')(ctx)
|
||||
];
|
||||
|
||||
plugins.registerServerDefaults = function registerServerDefaults () {
|
||||
|
||||
@@ -45,6 +45,7 @@ function init () {
|
||||
reset();
|
||||
|
||||
sbx.runtimeEnvironment = 'server';
|
||||
sbx.runtimeState = ctx.runtimeState;
|
||||
sbx.time = Date.now();
|
||||
sbx.settings = env.settings;
|
||||
sbx.data = ctx.ddata.clone();
|
||||
|
||||
@@ -6,6 +6,11 @@ var UPDATE_THROTTLE = 5000;
|
||||
|
||||
function boot (env, language) {
|
||||
|
||||
function startBoot(ctx, next) {
|
||||
ctx.runtimeState = 'booting';
|
||||
next();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Check Node version.
|
||||
// Latest Node 8 LTS and Latest Node 10 LTS are recommended and supported.
|
||||
@@ -255,6 +260,10 @@ function boot (env, language) {
|
||||
ctx.bus.emit('data-processed');
|
||||
});
|
||||
|
||||
ctx.bus.on('data-processed', function processed ( ) {
|
||||
ctx.runtimeState = 'loaded';
|
||||
});
|
||||
|
||||
ctx.bus.on('notification', ctx.pushnotify.emitNotification);
|
||||
|
||||
next( );
|
||||
@@ -289,12 +298,14 @@ function boot (env, language) {
|
||||
return next();
|
||||
}
|
||||
|
||||
ctx.runtimeState = 'booted';
|
||||
ctx.bus.uptime( );
|
||||
|
||||
next( );
|
||||
}
|
||||
|
||||
return require('bootevent')( )
|
||||
.acquire(startBoot)
|
||||
.acquire(checkNodeVersion)
|
||||
.acquire(checkEnv)
|
||||
.acquire(augmentSettings)
|
||||
|
||||
+1
-1
@@ -167,7 +167,7 @@ function init () {
|
||||
}
|
||||
|
||||
//TODO: getting sent in status.json, shouldn't be
|
||||
settings.DEFAULT_FEATURES = ['bgnow', 'delta', 'direction', 'timeago', 'devicestatus', 'upbat', 'errorcodes', 'profile', 'dbsize'];
|
||||
settings.DEFAULT_FEATURES = ['bgnow', 'delta', 'direction', 'timeago', 'devicestatus', 'upbat', 'errorcodes', 'profile', 'dbsize', 'runtimestate'];
|
||||
|
||||
var wasSet = [];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user