diff options
Diffstat (limited to 'www')
| -rwxr-xr-x | www/js/DataModel.js | 8 | ||||
| -rw-r--r-- | www/js/EventServer.js | 37 | ||||
| -rwxr-xr-x | www/js/app.js | 3 |
3 files changed, 38 insertions, 10 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js index a76bf2d3..f23a17f6 100755 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -20,7 +20,9 @@ angular.module('zmApp.controllers') var zmAppVersion = "unknown"; var isBackground = false; var justResumed = false; + var timeSinceResumed = -1; var monitorsLoaded = 0; + //var montageSize = 3; var monitors = []; @@ -1247,6 +1249,12 @@ angular.module('zmApp.controllers') setJustResumed: function (val) { justResumed = val; + if (val) { timeSinceResumed = moment();} + }, + + getTimeSinceResumed: function () { + // will be -1 if never resumed + return timeSinceResumed; }, stopNetwork: function (str) { diff --git a/www/js/EventServer.js b/www/js/EventServer.js index e4bf4c92..0440c33a 100644 --- a/www/js/EventServer.js +++ b/www/js/EventServer.js @@ -115,13 +115,13 @@ angular.module('zmApp.controllers') // console.log ("WS TYPEOF="+ typeof ws); // console.log ("WS="+JSON.stringify(ws)); - if (typeof ws !== 'undefined') + /*if (typeof ws !== 'undefined') { NVRDataModel.debug("websocket already initialized --Forcing close"); ws.close(true); ws=undefined; - } + }*/ NVRDataModel.log("Initializing Websocket with URL " + loginData.eventServer ); @@ -152,18 +152,37 @@ angular.module('zmApp.controllers') NVRDataModel.debug("Websocket Errorhandler called"); - $timeout(function() - { - var eserr = $translate.instant('kEventServerConnErr'); - NVRDataModel.displayBanner('error', [eserr]); - }, 1000); // leave time for transitions + var timeElapsedSinceResume = NVRDataModel.getTimeSinceResumed(); + + if (timeElapsedSinceResume == -1 ) { + // so we display error + timeElapsedSinceResume = moment().subtract('1',hour); + } + + var duration = moment.duration(moment().diff(timeElapsedSinceResume)).asSeconds().toFixed(1); + + NVRDataModel.debug (">> time since resumed is "+duration+" seconds"); + + if (duration > zm.waitTimeTillResume) { + + $timeout(function() + { + var eserr = $translate.instant('kEventServerConnErr'); + NVRDataModel.displayBanner('error', [eserr]); + }, 1000); // leave time for transitions + + } + else { + NVRDataModel.debug ("ES error happened "+timeElapsedSinceResume+" secs after resume, maybe fake, lets wait..."); + } + - if (typeof ws !== 'undefined'){ + /*if (typeof ws !== 'undefined'){ NVRDataModel.debug ("-->Forcing socket close"); ws.close(true); - } + }*/ ws = undefined; diff --git a/www/js/app.js b/www/js/app.js index 947c25f4..a4ead43a 100755 --- a/www/js/app.js +++ b/www/js/app.js @@ -107,7 +107,8 @@ angular.module('zmApp', [ thumbWidth:200, alarmStatusTime: 10000, eventServerErrorDelay:5000, // time to wait till I report initial connect errors - zmVersionCheckNag: 30 * 24 // in hrs + zmVersionCheckNag: 30 * 24, // in hrs + waitTimeTillResume: 5 // in sec, for ES error }) |
