diff options
| author | PliablePixels <pliablepixels@gmail.com> | 2015-06-26 11:25:06 -0400 |
|---|---|---|
| committer | PliablePixels <pliablepixels@gmail.com> | 2015-06-26 11:25:06 -0400 |
| commit | 0e83a778b541591ef468d7ebda1493a000a545e5 (patch) | |
| tree | e891381b97791d98edbbd70af4963606d494e659 /www/js/DataModel.js | |
| parent | 9972b3e9171a400d7fc239385b3e1e8c3fd1b9bc (diff) | |
Added option to keep screen on when viewing footage, also cleaned up invocation of cordova plugins when in desktop - it now checks so spurious errors don't show in logs
Diffstat (limited to 'www/js/DataModel.js')
| -rw-r--r-- | www/js/DataModel.js | 56 |
1 files changed, 54 insertions, 2 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js index 1c19948d..d1470685 100644 --- a/www/js/DataModel.js +++ b/www/js/DataModel.js @@ -22,7 +22,8 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion 'streamingurl': "", 'maxFPS': "3", // image streaming FPS 'montageQuality': "50", // montage streaming quality in % - 'useSSL':false // "1" if HTTPS + 'useSSL':false, // "1" if HTTPS + 'keepAwake':true // don't dim/dim during live view }; return { @@ -103,6 +104,12 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion } + if (window.localStorage.getItem("keepAwake") != undefined) { + var awakevalue = window.localStorage.getItem("keepAwake"); + loginData.keepAwake = (awakevalue == "1") ? true:false; + console.log("keepAwake " + loginData.keepAwake); + + } monitorsLoaded = 0; console.log("Getting out of ZMDataModel init"); @@ -110,15 +117,57 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion }, isLoggedIn: function () { - if (loginData.username != "" && loginData.password != "" && loginData.url != "" && loginData.apiurl != "") { + if (loginData.username != "" && loginData.password != "" && loginData.url != "" && loginData.apiurl != "") { return 1; } else return 0; {} }, + getLogin: function () { return loginData; }, + + getKeepAwake: function () { + return (loginData.keepAwake == '1') ? true:false; + }, + + //------------------------------------------------------------------ + // switches screen to 'always on' or 'auto' + //------------------------------------------------------------------ + setAwake: function(val) + { + + + console.log ("**** setAwake called with:" + val); + if (val) + { + + if (window.cordova != undefined) + { + window.plugins.insomnia.keepAwake(); + } + else + { + console.log ("Skipping insomnia, cordova does not exist"); + } + } + else + { + if (window.cordova != undefined) + { + window.plugins.insomnia.allowSleepAgain(); + } + else + { + console.log ("Skipping insomnia, cordova does not exist"); + } + + + } + + }, + setLogin: function (newLogin) { loginData = newLogin; @@ -128,6 +177,7 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion window.localStorage.setItem("apiurl", loginData.apiurl); window.localStorage.setItem("streamingurl", loginData.streamingurl); window.localStorage.setItem("useSSL", loginData.useSSL?"1":"0"); + window.localStorage.setItem("keepAwake", loginData.keepAwake?"1":"0"); window.localStorage.setItem("maxMontage", loginData.maxMontage); window.localStorage.setItem("montageQuality", loginData.montageQuality); @@ -350,6 +400,8 @@ angular.module('zmApp.controllers').service('ZMDataModel', ['$http', '$q', '$ion monitorsLoaded = loaded; }, + + //----------------------------------------------------------------------------- // Given a monitor Id it returns the monitor name // FIXME: Can I do a better job with associative arrays? |
