From f4586bd7cb9b5a477f2e11a2006d569f139f092c Mon Sep 17 00:00:00 2001 From: pliablepixels Date: Wed, 25 May 2016 16:57:25 -0400 Subject: #261 - started translating controllers Former-commit-id: 7d22c2f293051e0e9e0b88429365b19581350961 --- www/js/EventCtrl.js | 6 +- www/js/EventModalCtrl.js | 1219 ++++++++++++++++++------------------- www/js/EventServerSettingsCtrl.js | 10 +- www/js/EventsModalGraphCtrl.js | 6 +- www/js/LogCtrl.js | 8 +- www/js/LoginCtrl.js | 171 +----- www/js/MonitorCtrl.js | 34 +- www/js/MonitorModalCtrl.js | 55 +- 8 files changed, 697 insertions(+), 812 deletions(-) (limited to 'www/js') diff --git a/www/js/EventCtrl.js b/www/js/EventCtrl.js index 94a471ab..b972b33e 100644 --- a/www/js/EventCtrl.js +++ b/www/js/EventCtrl.js @@ -865,7 +865,7 @@ angular.module('zmApp.controllers') }) .error(function (err) { ZMDataModel.zmLog("Error retrieving detailed frame API " + JSON.stringify(err)); - ZMDataModel.displayBanner('error', ['could not retrieve frame details', 'please try again']); + ZMDataModel.displayBanner('error', [$translate.instant('kErrorFrameBanner'), $translate.instant('kErrorPleaseTryAgain')]); }); } @@ -929,7 +929,7 @@ angular.module('zmApp.controllers') }) .error(function (err) { ZMDataModel.zmLog("Error retrieving detailed frame API " + JSON.stringify(err)); - ZMDataModel.displayBanner('error', ['could not retrieve frame details', 'please try again']); + ZMDataModel.displayBanner('error', [$translate.instant('kErrorFrameBanner'), $translate.instant('kErrorPleaseTryAgain')]); }); @@ -1333,7 +1333,7 @@ angular.module('zmApp.controllers') var loadingStr = ""; if ($scope.search.text != "") { - var toastStr = "Searching page " + eventsPage; + var toastStr = $translate.instant('kToastSearchingPage') + eventsPage; $ionicLoading.show({ maxwidth: 100, scope: $scope, diff --git a/www/js/EventModalCtrl.js b/www/js/EventModalCtrl.js index ced6229c..3783ff72 100644 --- a/www/js/EventModalCtrl.js +++ b/www/js/EventModalCtrl.js @@ -14,27 +14,31 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro var nphTimer; var eventQueryHandle; $scope.loginData = ZMDataModel.getLogin(); - $scope.currentRate='-'; + $scope.currentRate = '-'; var timeFormat = 'MM/DD/YYYY HH:mm:ss'; - + var framearray = { - - labels:[], + + labels: [], datasets: [{ //label: '# of Votes', backgroundColor: 'rgba(242, 12, 12, 0.5)', borderColor: 'rgba(242, 12, 12, 0.5)', data: [], }] - }; - - var frameoptions=[]; - - + }; + + var frameoptions = []; + + var eventImageDigits = 5; // failsafe - $scope.currentProgress = {progress:0}; - $scope.sliderProgress = {progress:0}; + $scope.currentProgress = { + progress: 0 + }; + $scope.sliderProgress = { + progress: 0 + }; ZMDataModel.getKeyConfigParams(0) .then(function (data) { //console.log ("***GETKEY: " + JSON.stringify(data)); @@ -70,20 +74,20 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }); var ld = ZMDataModel.getLogin(); - - $scope.currentStreamMode = ld.gapless ? 'gapless':'single'; + + $scope.currentStreamMode = ld.gapless ? 'gapless' : 'single'; ZMDataModel.zmLog("Using stream mode " + $scope.currentStreamMode); - ZMDataModel.zmDebug ("EventModalCtrl called from " + $ionicHistory.currentStateName()); + ZMDataModel.zmDebug("EventModalCtrl called from " + $ionicHistory.currentStateName()); // This is not needed for event mode - + ZMDataModel.zmDebug("Setting playback to " + $scope.streamMode); $rootScope.validMonitorId = $scope.monitors[0].Monitor.Id; - ZMDataModel.getAuthKey($rootScope.validMonitorId,(Math.floor((Math.random() * 999999) + 1)).toString()) + ZMDataModel.getAuthKey($rootScope.validMonitorId, (Math.floor((Math.random() * 999999) + 1)).toString()) .then(function (success) { $ionicLoading.hide(); $rootScope.authSession = success; @@ -98,85 +102,80 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro ZMDataModel.zmLog("Modal: Error returned Stream authentication construction. Retaining old value of: " + $rootScope.authSession); }); - - + + //------------------------------------------------------- // we use this to reload the connkey if authkey changed //------------------------------------------------------ - - - $rootScope.$on("auth-success", function () { - - ZMDataModel.zmDebug("EventModalCtrl: Re-login detected, resetting everything & re-generating connkey"); - ZMDataModel.stopNetwork("Auth-Success inside EventModalCtrl"); - $scope.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); - //console.log ("********* OFFSET FROM AUTH SUCC"); - $timeout( function () { sendCommand('14',$scope.connKey, '&offset='+$scope.currentProgress.progress);},500); - //$timeout.cancel(eventQueryHandle); - //eventQueryHandle = $timeout (function(){checkEvent();}, zm.eventPlaybackQuery); - - - + + + $rootScope.$on("auth-success", function () { + + ZMDataModel.zmDebug("EventModalCtrl: Re-login detected, resetting everything & re-generating connkey"); + ZMDataModel.stopNetwork("Auth-Success inside EventModalCtrl"); + $scope.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); + //console.log ("********* OFFSET FROM AUTH SUCC"); + $timeout(function () { + sendCommand('14', $scope.connKey, '&offset=' + $scope.currentProgress.progress); + }, 500); + //$timeout.cancel(eventQueryHandle); + //eventQueryHandle = $timeout (function(){checkEvent();}, zm.eventPlaybackQuery); + + + }); - + //------------------------------------------------------- // tap to pause //------------------------------------------------------ - $scope.togglePause = function () - { + $scope.togglePause = function () { $scope.isPaused = !$scope.isPaused; - ZMDataModel.zmDebug ("Paused is " + $scope.isPaused); - - - sendCommand ( $scope.isPaused? '1':'2',$scope.connKey); - + ZMDataModel.zmDebug("Paused is " + $scope.isPaused); + + + sendCommand($scope.isPaused ? '1' : '2', $scope.connKey); + }; - + //------------------------------------------------------- // This is what we call every zm.EventQueryInterval // it really only queries to get status to it can display // zms takes care of the display //------------------------------------------------------ - function checkEvent() - { + function checkEvent() { //console.log ("Event timer"); //console.log ("Event timer"); $scope.checkEventOn = true; - if ($scope.defaultVideo !== undefined && $scope.defaultVideo !='') - { - console.log ("playing video, not using zms, skipping event commands"); - } - else - { - processEvent('99',$scope.connKey); + if ($scope.defaultVideo !== undefined && $scope.defaultVideo != '') { + console.log("playing video, not using zms, skipping event commands"); + } else { + processEvent('99', $scope.connKey); } } - - - function sendCommand(cmd,connkey,extras,rq) - { + + + function sendCommand(cmd, connkey, extras, rq) { var d = $q.defer(); - - if ($scope.defaultVideo !== undefined && $scope.defaultVideo !='') - { - console.log ("playing video, not using zms, skipping event commands"); + + if ($scope.defaultVideo !== undefined && $scope.defaultVideo != '') { + console.log("playing video, not using zms, skipping event commands"); d.resolve(true); return (d.promise); } - - - - var loginData = ZMDataModel.getLogin(); - console.log ("Sending CGI command to " + loginData.url); - var rqtoken = rq? rq:"stream"; - var myauthtoken = $rootScope.authSession.replace("&auth=",""); + + + + var loginData = ZMDataModel.getLogin(); + console.log("Sending CGI command to " + loginData.url); + var rqtoken = rq ? rq : "stream"; + var myauthtoken = $rootScope.authSession.replace("&auth=", ""); //&auth= - $http({ + $http({ method: 'POST', /*timeout: 15000,*/ url: loginData.url + '/index.php', @@ -190,14 +189,13 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p])); var foo = str.join("&"); - if (extras) - { - foo = foo + extras; - //console.log("EXTRAS****SUB RETURNING " + foo); + if (extras) { + foo = foo + extras; + //console.log("EXTRAS****SUB RETURNING " + foo); } - console.log ("CGI subcommand="+foo); + console.log("CGI subcommand=" + foo); return foo; - + }, data: { @@ -206,146 +204,144 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro connkey: connkey, command: cmd, auth: myauthtoken, - // user: loginData.username, - // pass: loginData.password + // user: loginData.username, + // pass: loginData.password } }) - .then (function (resp) { - ZMDataModel.zmDebug ("sendCmd response:"+JSON.stringify(resp)); - d.resolve(resp); - return (d.promise); - - - }, + .then(function (resp) { + ZMDataModel.zmDebug("sendCmd response:" + JSON.stringify(resp)); + d.resolve(resp); + return (d.promise); + + + }, function (resp) { - ZMDataModel.zmDebug ("sendCmd error:"+JSON.stringify(resp)); - d.reject (resp); - return (d.promise); - }); - - return (d.promise); + ZMDataModel.zmDebug("sendCmd error:" + JSON.stringify(resp)); + d.reject(resp); + return (d.promise); + }); + + return (d.promise); } - - - function processEvent(cmd,connkey) - { - - if ($scope.blockSlider) - { - console.log ("Not doing ZMS Command as slider is depressed..."); + + + function processEvent(cmd, connkey) { + + if ($scope.blockSlider) { + console.log("Not doing ZMS Command as slider is depressed..."); return; } - + var loginData = ZMDataModel.getLogin(); - console.log ("sending process Event command to " + loginData.url); - var myauthtoken = $rootScope.authSession.replace("&auth=",""); + console.log("sending process Event command to " + loginData.url); + var myauthtoken = $rootScope.authSession.replace("&auth=", ""); //&auth= - var req = $http({ - method: 'POST', - /*timeout: 15000,*/ - url: loginData.url + '/index.php', - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - //'Accept': '*/*', - }, - transformRequest: function (obj) { - var str = []; - for (var p in obj) - str.push(encodeURIComponent(p) + "=" + - encodeURIComponent(obj[p])); - var foo = str.join("&"); - console.log("****processEvent subcommands RETURNING " + foo); - return foo; - }, + var req = $http({ + method: 'POST', + /*timeout: 15000,*/ + url: loginData.url + '/index.php', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + //'Accept': '*/*', + }, + transformRequest: function (obj) { + var str = []; + for (var p in obj) + str.push(encodeURIComponent(p) + "=" + + encodeURIComponent(obj[p])); + var foo = str.join("&"); + console.log("****processEvent subcommands RETURNING " + foo); + return foo; + }, - data: { - view: "request", - request: "stream", - connkey: connkey, - command: cmd, - auth: myauthtoken, - // user: loginData.username, - // pass: loginData.password - } - }); - - req.success (function (resp) { - // ZMDataModel.zmDebug ("processEvent success:"+JSON.stringify(resp)); - - if (resp.result=="Ok") - { - - $scope.currentProgress.progress = resp.status.progress; - $scope.eventId = resp.status.event; - $scope.d_eventId = $scope.eventId; - $scope.currentRate = resp.status.rate; - - - if ($scope.currentProgress.progress > $scope.currentEventDuration) $scope.currentProgress.progress = $scope.currentEventDuration; - $scope.progressText = "At " + $scope.currentProgress.progress + "s of " + $scope.currentEventDuration+"s"; - - $scope.sliderProgress.progress = $scope.currentProgress.progress; - - // lets not do this and use zms to move forward or back - // as this code conflicts with fast rev etc - //if (Math.floor(resp.status.progress) >=$scope.currentEventDuration) - - - - //$timeout (checkEvent(), zm.eventPlaybackQuery); - //eventQueryHandle = $timeout (function(){checkEvent();}, zm.eventPlaybackQuery); - - } - else // resp.result was messed up - - { - ZMDataModel.zmDebug("Hmm I found an error " + JSON.stringify(resp)); - //window.stop(); - $scope.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); - - // console.log (JSON.stringify(resp)); - $timeout( function () { sendCommand('14',$scope.connKey, '&offset='+$scope.currentProgress.progress);},500); - ZMDataModel.zmDebug ("so I'm regenerating Connkey to " + $scope.connKey); - //eventQueryHandle = $timeout (function(){checkEvent();}, zm.eventPlaybackQuery); - } - }); - - - req.error (function (resp) { - ZMDataModel.zmDebug ("processEvent error:"+JSON.stringify(resp)); + data: { + view: "request", + request: "stream", + connkey: connkey, + command: cmd, + auth: myauthtoken, + // user: loginData.username, + // pass: loginData.password + } + }); + + req.success(function (resp) { + // ZMDataModel.zmDebug ("processEvent success:"+JSON.stringify(resp)); + + if (resp.result == "Ok") { + + $scope.currentProgress.progress = resp.status.progress; + $scope.eventId = resp.status.event; + $scope.d_eventId = $scope.eventId; + $scope.currentRate = resp.status.rate; + + + if ($scope.currentProgress.progress > $scope.currentEventDuration) $scope.currentProgress.progress = $scope.currentEventDuration; + $scope.progressText = "At " + $scope.currentProgress.progress + "s of " + $scope.currentEventDuration + "s"; + + $scope.sliderProgress.progress = $scope.currentProgress.progress; + + // lets not do this and use zms to move forward or back + // as this code conflicts with fast rev etc + //if (Math.floor(resp.status.progress) >=$scope.currentEventDuration) + + + + //$timeout (checkEvent(), zm.eventPlaybackQuery); //eventQueryHandle = $timeout (function(){checkEvent();}, zm.eventPlaybackQuery); - - }); - + + } else // resp.result was messed up + + { + ZMDataModel.zmDebug("Hmm I found an error " + JSON.stringify(resp)); + //window.stop(); + $scope.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); + + // console.log (JSON.stringify(resp)); + $timeout(function () { + sendCommand('14', $scope.connKey, '&offset=' + $scope.currentProgress.progress); + }, 500); + ZMDataModel.zmDebug("so I'm regenerating Connkey to " + $scope.connKey); + //eventQueryHandle = $timeout (function(){checkEvent();}, zm.eventPlaybackQuery); + } + }); + + + req.error(function (resp) { + ZMDataModel.zmDebug("processEvent error:" + JSON.stringify(resp)); + //eventQueryHandle = $timeout (function(){checkEvent();}, zm.eventPlaybackQuery); + + }); + } function onPause() { - + // $interval.cancel(modalIntervalHandle); // FIXME: Do I need to setAwake(false) here? $interval.cancel(eventQueryHandle); - ZMDataModel.zmLog ("EventModalCtrl: paused, killing timer"); - + ZMDataModel.zmLog("EventModalCtrl: paused, killing timer"); + } function onResume() { ZMDataModel.zmDebug("EventModalCtrl: Modal resume called"); - - $rootScope.modalRand = Math.floor((Math.random() * 100000) + 1); + + $rootScope.modalRand = Math.floor((Math.random() * 100000) + 1); } - - - - + + + + $scope.finishedLoadingImage = function () { // console.log("***Monitor image FINISHED Loading***"); @@ -353,24 +349,26 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }; - $scope.enableSliderBlock = function() - { + $scope.enableSliderBlock = function () { $scope.blockSlider = true; }; - - $scope.youChangedSlider = function() - { - + + $scope.youChangedSlider = function () { + console.log("YOU changed " + $scope.sliderProgress.progress); $scope.currentProgress.progress = $scope.sliderProgress.progress; - $timeout( function () { sendCommand('14',$scope.connKey, '&offset='+$scope.currentProgress.progress);},500); + $timeout(function () { + sendCommand('14', $scope.connKey, '&offset=' + $scope.currentProgress.progress); + }, 500); // give this command some time to complete - $timeout (function(){$scope.blockSlider = false;},1500); - + $timeout(function () { + $scope.blockSlider = false; + }, 1500); + }; - - + + //----------------------------------------------------------------------- @@ -398,144 +396,130 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro } - $scope.jumpToOffsetInEvent = function() - { + $scope.jumpToOffsetInEvent = function () { // streamReq.send( streamParms+"&command="+CMD_SEEK+"&offset="+offset ); }; - + //----------------------------------------------------------------------- // Saves a snapshot of the monitor image to phone storage //----------------------------------------------------------------------- - $scope.saveEventImageToPhone = function (onlyAlarms) - { - - if ($scope.loginData.useNphZmsForEvents) - { - ZMDataModel.zmLog ("Use ZMS stream to save to phone"); + $scope.saveEventImageToPhone = function (onlyAlarms) { + + if ($scope.loginData.useNphZmsForEvents) { + ZMDataModel.zmLog("Use ZMS stream to save to phone"); saveEventImageToPhoneZms(onlyAlarms); - - - } - else - { + + + } else { saveEventImageToPhone(onlyAlarms); } - - + + }; - function saveEventImageToPhoneZms(onlyAlarms) - { + function saveEventImageToPhoneZms(onlyAlarms) { // The strategy here is to build the array now so we can grab frames // $scope.currentProgress.progress is the seconds where we are - // $scope.eventId is the event Id - + // $scope.eventId is the event Id + $scope.isPaused = true; - + $ionicLoading.show({ template: "please wait...", noBackdrop: true, duration: zm.httpTimeout }); - sendCommand('1',$scope.connKey). - then (function (resp) - { - - // console.log ("PAUSE ANSWER IS " + JSON.stringify(resp)); - $scope.currentProgress.progress = resp.data.status.progress; - // console.log ("STEP 0 progress is " + $scope.currentProgress.progress); - $scope.slides = []; - - var apiurl = $scope.loginData.apiurl + "/events/" + $scope.eventId + ".json"; - ZMDataModel.zmDebug ("prepared to get frame details using " + apiurl); - $http.get(apiurl) - .then (function (success) - { - - var event = success.data.event; + sendCommand('1', $scope.connKey). + then(function (resp) { + + // console.log ("PAUSE ANSWER IS " + JSON.stringify(resp)); + $scope.currentProgress.progress = resp.data.status.progress; + // console.log ("STEP 0 progress is " + $scope.currentProgress.progress); + $scope.slides = []; + + var apiurl = $scope.loginData.apiurl + "/events/" + $scope.eventId + ".json"; + ZMDataModel.zmDebug("prepared to get frame details using " + apiurl); + $http.get(apiurl) + .then(function (success) { + + var event = success.data.event; + + event.Event.BasePath = computeBasePath(event); + event.Event.relativePath = computeRelativePath(event); + $scope.playbackURL = $scope.loginData.url; + $scope.eventBasePath = event.Event.BasePath; + $scope.relativePath = event.Event.relativePath; + + // now lets get approx frame # + + var totalTime = event.Event.Length; + var totalFrames = event.Event.Frames; + + var myFrame = Math.round(totalFrames / totalTime * $scope.currentProgress.progress); + + // console.log ("STEP 0: playback " + $scope.playbackURL + " total time " + totalTime + " frames " + totalFrames); + + if (myFrame > totalFrames) myFrame = totalFrames; + + // console.log ("STEP 0 myFrame is " + myFrame); + // console.log ("DUMPING " + JSON.stringify(event)); + $scope.mycarousel.index = myFrame; + // console.log ("STEP 1 : Computed index as "+ $scope.mycarousel.index); + var i; + for (i = 1; i <= event.Frame.length; i++) { + var fname = padToN(i, eventImageDigits) + "-capture.jpg"; + // console.log ("Building " + fname); + + // console.log ("DUMPING ONE " + JSON.stringify(event.Frame[i-1])); + // onlyAlarms means only copy alarmed frames + if (onlyAlarms) { + if (event.Frame[i - 1] && event.Frame[i - 1].Type == 'Alarm') { + $scope.slides.push({ + id: i, + img: fname, + }); + } + } else // push all frames + { + $scope.slides.push({ + id: i, + img: fname, + }); + } + } + // console.log ("STEP 2 : calling Save Event To Phone"); + $ionicLoading.hide(); + saveEventImageToPhone(onlyAlarms); - event.Event.BasePath = computeBasePath(event); - event.Event.relativePath = computeRelativePath(event); - $scope.playbackURL = $scope.loginData.url; - $scope.eventBasePath = event.Event.BasePath; - $scope.relativePath = event.Event.relativePath; - // now lets get approx frame # - - var totalTime = event.Event.Length; - var totalFrames = event.Event.Frames; - - var myFrame = Math.round(totalFrames/totalTime * $scope.currentProgress.progress); - - // console.log ("STEP 0: playback " + $scope.playbackURL + " total time " + totalTime + " frames " + totalFrames); - - if (myFrame > totalFrames) myFrame = totalFrames; - - // console.log ("STEP 0 myFrame is " + myFrame); - // console.log ("DUMPING " + JSON.stringify(event)); - $scope.mycarousel.index = myFrame; - // console.log ("STEP 1 : Computed index as "+ $scope.mycarousel.index); - var i; - for (i = 1; i <= event.Frame.length; i++) { - var fname = padToN(i, eventImageDigits) + "-capture.jpg"; - // console.log ("Building " + fname); - - // console.log ("DUMPING ONE " + JSON.stringify(event.Frame[i-1])); - // onlyAlarms means only copy alarmed frames - if (onlyAlarms) - { - if (event.Frame[i-1] && event.Frame[i-1].Type == 'Alarm') - { - $scope.slides.push({ - id: i, - img: fname, - }); - } - } - else // push all frames - { - $scope.slides.push({ - id: i, - img: fname, + }, + function (err) { + $ionicLoading.hide(); + ZMDataModel.zmLog("snapshot API Error: Could not get frames " + JSON.stringify(err)); + + $ionicLoading.show({ + template: "error retrieving frames", + noBackdrop: true, + duration: 4000 }); - } - } - // console.log ("STEP 2 : calling Save Event To Phone"); - $ionicLoading.hide(); - saveEventImageToPhone(onlyAlarms); - - + }); }, - function (err) - { - $ionicLoading.hide(); - ZMDataModel.zmLog ("snapshot API Error: Could not get frames " + JSON.stringify(err)); - - $ionicLoading.show({ - template: "error retrieving frames", - noBackdrop: true, - duration: 4000 - }); - }); - }, - - function (err) - { - ZMDataModel.zmDebug ("Error pausing stream before snapshot " + JSON.stringify(err)); - $ionicLoading.hide(); - } - + + function (err) { + ZMDataModel.zmDebug("Error pausing stream before snapshot " + JSON.stringify(err)); + $ionicLoading.hide(); + } + ); // then - - + + } - function saveEventImageToPhone(onlyAlarms) - { + function saveEventImageToPhone(onlyAlarms) { var curState = carouselUtils.getStop(); carouselUtils.setStop(true); @@ -545,8 +529,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro ZMDataModel.zmDebug("ModalCtrl: SaveEventImageToPhone called"); var canvas, context, imageDataUrl, imageData; var loginData = ZMDataModel.getLogin(); - - + + // for alarms only if (onlyAlarms) $scope.mycarousel.index = 0; var url = $scope.playbackURL + '/index.php?view=image&rand=' + $rootScope.rand + "&path=" + $scope.relativePath + $scope.slides[$scope.mycarousel.index].img; @@ -561,7 +545,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $rootScope.zmPopup = $ionicPopup.show({ template: '
Frame: {{slideIndex+1}} of {{slideLastIndex+1}}

', - title: 'Select '+ (onlyAlarms?'Alarmed ':'')+'frame to save', + title: 'Select ' + (onlyAlarms ? 'Alarmed ' : '') + 'frame to save', subTitle: 'use left and right arrows to change', scope: $scope, cssClass: 'popup80', @@ -635,62 +619,61 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }] }); - function saveNow() - { + function saveNow() { $ionicLoading.show({ - template: "saving snapshot...", - noBackdrop: true, - duration: zm.httpTimeout + template: "saving snapshot...", + noBackdrop: true, + duration: zm.httpTimeout }); var url = $scope.selectEventUrl; - ZMDataModel.zmLog ("saveNow: File path to grab is " + url); + ZMDataModel.zmLog("saveNow: File path to grab is " + url); - var img = new Image(); - img.onload = function () { + var img = new Image(); + img.onload = function () { // console.log("********* ONLOAD"); - canvas = document.createElement('canvas'); - canvas.width = img.width; - canvas.height = img.height; - context = canvas.getContext('2d'); - context.drawImage(img, 0, 0); - - imageDataUrl = canvas.toDataURL('image/jpeg', 1.0); - imageData = imageDataUrl.replace(/data:image\/jpeg;base64,/, ''); - - if ($rootScope.platformOS != "desktop") { - try { - - cordova.exec( - SaveSuccess, - SaveError, - 'Canvas2ImagePlugin', - 'saveImageDataToLibrary', [imageData] - ); + canvas = document.createElement('canvas'); + canvas.width = img.width; + canvas.height = img.height; + context = canvas.getContext('2d'); + context.drawImage(img, 0, 0); + + imageDataUrl = canvas.toDataURL('image/jpeg', 1.0); + imageData = imageDataUrl.replace(/data:image\/jpeg;base64,/, ''); + + if ($rootScope.platformOS != "desktop") { + try { + + cordova.exec( + SaveSuccess, + SaveError, + 'Canvas2ImagePlugin', + 'saveImageDataToLibrary', [imageData] + ); // carouselUtils.setStop(curState); - } catch (e) { + } catch (e) { - SaveError(e.message); + SaveError(e.message); // carouselUtils.setStop(curState); - } - } else { - - - var fname = $scope.relativePath+$scope.slides[$scope.slideIndex].img + ".png"; - fname = fname.replace(/\//,"-"); - fname = fname.replace(/\.jpg/,''); - - canvas.toBlob(function (blob) { - saveAs(blob, fname); - SaveSuccess(); - }); - } - }; - try { - img.src = url; + } + } else { + + + var fname = $scope.relativePath + $scope.slides[$scope.slideIndex].img + ".png"; + fname = fname.replace(/\//, "-"); + fname = fname.replace(/\.jpg/, ''); + + canvas.toBlob(function (blob) { + saveAs(blob, fname); + SaveSuccess(); + }); + } + }; + try { + img.src = url; // console.log ("SAVING IMAGE SOURCE"); - } catch (e) { - SaveError(e.message); - } + } catch (e) { + SaveError(e.message); + } } } @@ -704,7 +687,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.scaleImage = function () { $scope.imageFit = !$scope.imageFit; - // console.log("Switching image style to " + $scope.imageFit); + // console.log("Switching image style to " + $scope.imageFit); }; $scope.$on('$ionicView.enter', function () { @@ -714,47 +697,44 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro }); - $scope.$on('modal.shown', function (e,m) { - + $scope.$on('modal.shown', function (e, m) { + if (m.id != 'footage') - + return; - + var ld = ZMDataModel.getLogin(); $scope.loginData = ZMDataModel.getLogin(); - + $scope.singleImageQuality = ld.singleImageQuality; $scope.blockSlider = false; $scope.checkEventOn = false; //$scope.singleImageQuality = 100; - - - + + + //$scope.commandURL = $scope.currentEvent.Event.baseURL+"/index.php"; - // ZMDataModel.zmLog (">>>>>>>>>>>>>>>>>>ZMS url command is " + $scope.commandURL); - + // ZMDataModel.zmLog (">>>>>>>>>>>>>>>>>>ZMS url command is " + $scope.commandURL); + currentEvent = $scope.currentEvent; - - console.log ("Current Event " + JSON.stringify(currentEvent)); - $scope.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); - ZMDataModel.zmDebug ("Generated Connkey:" + $scope.connKey); - + + console.log("Current Event " + JSON.stringify(currentEvent)); + $scope.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); + ZMDataModel.zmDebug("Generated Connkey:" + $scope.connKey); + $scope.currentFrame = 1; $scope.isPaused = false; //console.log ("CURRENT EVENT " + JSON.stringify($scope.currentEvent)); $scope.currentEventDuration = Math.floor($scope.currentEvent.Event.Length); //console.log ($scope.event.Event.Frames); - if (currentEvent && currentEvent.Event) - { + if (currentEvent && currentEvent.Event) { //console.log ("************ CALLING PREPARE MODAL ***********"); prepareModalEvent(currentEvent.Event.Id); - if (ld.useNphZmsForEvents) - { - $timeout (function() { - - if ($scope.modal.isShown()) - { - ZMDataModel.zmLog (">>>Starting checkAllEvents interval..."); + if (ld.useNphZmsForEvents) { + $timeout(function () { + + if ($scope.modal.isShown()) { + ZMDataModel.zmLog(">>>Starting checkAllEvents interval..."); //eventQueryHandle = $timeout (checkEvent(), zm.eventPlaybackQuery); @@ -762,93 +742,93 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro eventQueryHandle = $interval(function () { checkEvent(); // console.log ("Refreshing Image..."); - }.bind(this),zm.eventPlaybackQuery); + }.bind(this), zm.eventPlaybackQuery); + } else { + ZMDataModel.zmLog(">>>Modal was exited, not starting checkAllEvents"); } - else - { - ZMDataModel.zmLog (">>>Modal was exited, not starting checkAllEvents"); - } - - },5000); + + }, 5000); } - + } - - - - - - + + + + + + }); - + //var current_data; - function drawGraph() - { - - + function drawGraph() { + + var cv = document.getElementById("eventchart"); var ctx = cv.getContext("2d"); - - + + frameoptions = { - responsive:true, - legend:false, - title: {display:false, text: ""}, - scales: { - yAxes: [{ - display:false, - scaleLabel: { - display:false, - labelString:'value', - } - + responsive: true, + legend: false, + title: { + display: false, + text: "" + }, + scales: { + yAxes: [{ + display: false, + scaleLabel: { + display: false, + labelString: 'value', + } + }], - xAxes: [{ - type:'time', - display:false, - time: { - - format:timeFormat, - tooltipFormat: 'll HH:mm', - min:framearray.datasets[0].data[0].x, - max:framearray.datasets[0].data[framearray.datasets[0].data.length-1].x , - displayFormats: { - + xAxes: [{ + type: 'time', + display: false, + time: { + + format: timeFormat, + tooltipFormat: 'll HH:mm', + min: framearray.datasets[0].data[0].x, + max: framearray.datasets[0].data[framearray.datasets[0].data.length - 1].x, + displayFormats: { + + } + }, + scaleLabel: { + display: false, + labelString: '' } - }, - scaleLabel: { - display: false, - labelString: '' - } - + }] } }; - - - $timeout(function() { - - - var myChart = new Chart(ctx, { - type: 'line', - data: framearray, - options: frameoptions, - }); + + + $timeout(function () { + + + var myChart = new Chart(ctx, { + type: 'line', + data: framearray, + options: frameoptions, + }); }); } - - $scope.$on('modal.removed', function (e,m) { + + $scope.$on('modal.removed', function (e, m) { $interval.cancel(eventQueryHandle); if (m.id != 'footage') return; - - + + $scope.isModalActive = false; - - ZMDataModel.zmDebug ("Modal removed - killing connkey"); - sendCommand(17,$scope.connKey); + + ZMDataModel.zmDebug("Modal removed - killing connkey"); + sendCommand(17, $scope.connKey); //$timeout (function(){ZMDataModel.stopNetwork("Modal removed inside EventModalCtrl");},400); // Execute action @@ -857,85 +837,88 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro // Playback speed adjuster $scope.adjustSpeed = function (val) { - - if ($scope.defaultVideo !== undefined && $scope.defaultVideo !='' ) - { - + + if ($scope.defaultVideo !== undefined && $scope.defaultVideo != '') { + $ionicLoading.show({ - template: "Please use video player controls for H264 events. ZoneMinder doesn't yet support zms controls", - noBackdrop: true, - duration: 3000 + template: "Please use video player controls for H264 events. ZoneMinder doesn't yet support zms controls", + noBackdrop: true, + duration: 3000 }); return; } - + var ld = ZMDataModel.getLogin(); - - if (ld.useNphZmsForEvents) - { - + + if (ld.useNphZmsForEvents) { + var cmd; $scope.isPaused = false; - switch (val) - { - case 'ff': cmd= 4; break; - case 'fr': cmd= 7; break; - case 'np': cmd= 2; break; - case 'p' : cmd= 1; $scope.isPaused = true; break; - default : cmd=0; + switch (val) { + case 'ff': + cmd = 4; + break; + case 'fr': + cmd = 7; + break; + case 'np': + cmd = 2; + break; + case 'p': + cmd = 1; + $scope.isPaused = true; + break; + default: + cmd = 0; } - + $ionicLoading.show({ - template: "please wait...", - noBackdrop: true, - duration: zm.httpTimeout - }); - + template: "please wait...", + noBackdrop: true, + duration: zm.httpTimeout + }); + sendCommand(cmd, $scope.connKey) - .then (function (success) - { + .then(function (success) { $ionicLoading.hide(); }, - function (err) - { + function (err) { $ionicLoading.hide(); - ZMDataModel.zmDebug ("Error in adjust speed: " + JSON.stringify(err)); + ZMDataModel.zmDebug("Error in adjust speed: " + JSON.stringify(err)); } - ); - - - } - - else // not using nph + ); + + + } else // not using nph { - + switch (val) { - case "super": - $scope.eventSpeed = 20 / $scope.event.Event.Frames; - carouselUtils.setDuration($scope.eventSpeed); - break; - case "normal": - $scope.eventSpeed = $scope.event.Event.Length / $scope.event.Event.Frames; - //$scope.eventSpeed = 5; - carouselUtils.setDuration($scope.eventSpeed); - - break; - case "faster": - $scope.eventSpeed = $scope.eventSpeed / 2; - if ($scope.eventSpeed < 20 / $scope.event.Event.Frames) - $scope.eventSpeed = 10 / $scope.event.Event.Frames; - carouselUtils.setDuration($scope.eventSpeed); - break; - case "slower": - $scope.eventSpeed = $scope.eventSpeed * 2; - carouselUtils.setDuration($scope.eventSpeed); - - break; - default: + case "super": + $scope.eventSpeed = 20 / $scope.event.Event.Frames; + carouselUtils.setDuration($scope.eventSpeed); + break; + case "normal": + $scope.eventSpeed = $scope.event.Event.Length / $scope.event.Event.Frames; + //$scope.eventSpeed = 5; + carouselUtils.setDuration($scope.eventSpeed); + + break; + case "faster": + $scope.eventSpeed = $scope.eventSpeed / 2; + if ($scope.eventSpeed < 20 / $scope.event.Event.Frames) + $scope.eventSpeed = 10 / $scope.event.Event.Frames; + carouselUtils.setDuration($scope.eventSpeed); + break; + case "slower": + $scope.eventSpeed = $scope.eventSpeed * 2; + carouselUtils.setDuration($scope.eventSpeed); + + break; + default: - } + } ZMDataModel.zmDebug("Set playback speed to " + $scope.eventSpeed); $ionicLoading.show({ @@ -947,26 +930,28 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro showDelay: 0 }); } - + }; $scope.toggleGapless = function () { - // console.log(">>>>>>>>>>>>>>GAPLESS TOGGLE INSIDE MODAL"); + // console.log(">>>>>>>>>>>>>>GAPLESS TOGGLE INSIDE MODAL"); $scope.loginData.gapless = !$scope.loginData.gapless; ZMDataModel.setLogin($scope.loginData); - + ZMDataModel.zmDebug("EventModalCtrl: gapless has changed resetting everything & re-generating connkey"); - ZMDataModel.stopNetwork("EventModalCtrl-toggle gapless"); - ZMDataModel.zmDebug ("Regenerating connkey as gapless has changed"); - // console.log ("********* OFFSET FROM TOGGLE GAPLESS"); - $scope.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); - $timeout( function () { sendCommand('14',$scope.connKey, '&offset='+$scope.currentProgress.progress);},500); - //$timeout.cancel(eventQueryHandle); - //eventQueryHandle = $timeout (function(){checkEvent();}, zm.eventPlaybackQuery); - + ZMDataModel.stopNetwork("EventModalCtrl-toggle gapless"); + ZMDataModel.zmDebug("Regenerating connkey as gapless has changed"); + // console.log ("********* OFFSET FROM TOGGLE GAPLESS"); + $scope.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); + $timeout(function () { + sendCommand('14', $scope.connKey, '&offset=' + $scope.currentProgress.progress); + }, 500); + //$timeout.cancel(eventQueryHandle); + //eventQueryHandle = $timeout (function(){checkEvent();}, zm.eventPlaybackQuery); + }; @@ -1013,21 +998,20 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro } - $scope.zoomImage = function (val) - { + $scope.zoomImage = function (val) { var zl = parseInt($ionicScrollDelegate.$getByHandle("imgscroll").getScrollPosition().zoom); - if (zl == 1 && val == -1) - { - ZMDataModel.zmDebug ("Already zoomed out max"); + if (zl == 1 && val == -1) { + ZMDataModel.zmDebug("Already zoomed out max"); return; } - - - zl+=val; - ZMDataModel.zmDebug ("Zoom level is " + zl); $ionicScrollDelegate.$getByHandle("imgscroll").zoomTo(zl,true); - + + + zl += val; + ZMDataModel.zmDebug("Zoom level is " + zl); + $ionicScrollDelegate.$getByHandle("imgscroll").zoomTo(zl, true); + }; - + //-------------------------------------------------------- //Navigate to next/prev event in full screen mode @@ -1042,36 +1026,30 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro //console.log("Image is zoomed in - not honoring swipe"); return; } - - if (ld.useNphZmsForEvents) - { + + if (ld.useNphZmsForEvents) { ZMDataModel.zmLog("using zms to move "); jumpToEventZms($scope.connKey, dirn); - // sendCommand ( dirn==1?'13':'12',$scope.connKey); - - } - else - { + // sendCommand ( dirn==1?'13':'12',$scope.connKey); + + } else { jumpToEvent(eid, dirn); } - + //console.log("JUMPING"); - + }; $scope.jumpToEvent = function (eid, dirn) { - // console.log("jumptoevent"); + // console.log("jumptoevent"); var ld = ZMDataModel.getLogin(); - if (ld.useNphZmsForEvents) - { + if (ld.useNphZmsForEvents) { ZMDataModel.zmLog("using zms to move "); jumpToEventZms($scope.connKey, dirn); - // sendCommand ( dirn==1?'13':'12',$scope.connKey); - - } - else - { + // sendCommand ( dirn==1?'13':'12',$scope.connKey); + + } else { jumpToEvent(eid, dirn); } @@ -1106,7 +1084,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro function outWithOld() { ZMDataModel.zmLog("ModalCtrl:Stopping network pull..."); - ZMDataModel.stopNetwork("EventModalCtrl-out with old"); + ZMDataModel.stopNetwork("EventModalCtrl-out with old"); $scope.animationInProgress = true; // give digest time for image to swap // 100 should be enough @@ -1126,52 +1104,52 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro } - - + + function jumpToEventZms(connkey, dirn) { - - - if ($scope.defaultVideo !== undefined && $scope.defaultVideo !='' ) - { - + + + if ($scope.defaultVideo !== undefined && $scope.defaultVideo != '') { + $ionicLoading.show({ - template: "Event navigation is not available with video feeds. ZoneMinder doesn't yet support them", - noBackdrop: true, - duration: 3000 + template: "Event navigation is not available with video feeds. ZoneMinder doesn't yet support them", + noBackdrop: true, + duration: 3000 }); return; - + } - var cmd = dirn==1?'13':'12'; + var cmd = dirn == 1 ? '13' : '12'; $scope.d_eventId = "..."; - ZMDataModel.zmDebug ("Sending " + cmd + " to " + connkey); - + ZMDataModel.zmDebug("Sending " + cmd + " to " + connkey); + $ionicLoading.show({ - template: "switching events..", - noBackdrop: true, - duration: zm.httpTimeout - }); - - console.log ("Send command connkey: "+connkey); - sendCommand ( cmd,connkey) - .then ( - function (success) - { - //console.log ("jump success " + JSON.stringify(success)); - $ionicLoading.hide(); - }, - function (error) { - + template: "switching events..", + noBackdrop: true, + duration: zm.httpTimeout + }); + + console.log("Send command connkey: " + connkey); + sendCommand(cmd, connkey) + .then( + function (success) { + //console.log ("jump success " + JSON.stringify(success)); + $ionicLoading.hide(); + }, + function (error) { + ZMDataModel.zmDebug("Hmm jump error " + JSON.stringify(error)); - ZMDataModel.stopNetwork("EventModalCtrl-jumptoEventZms error"); - $scope.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); - // console.log ("********* OFFSET FROM JUMPTOEVENTZMS ERROR"); - $timeout( function () { sendCommand('14',$scope.connKey, '&offset='+$scope.currentProgress.progress);},500); - ZMDataModel.zmDebug ("so I'm regenerating Connkey to " + $scope.connKey); + ZMDataModel.stopNetwork("EventModalCtrl-jumptoEventZms error"); + $scope.connKey = (Math.floor((Math.random() * 999999) + 1)).toString(); + // console.log ("********* OFFSET FROM JUMPTOEVENTZMS ERROR"); + $timeout(function () { + sendCommand('14', $scope.connKey, '&offset=' + $scope.currentProgress.progress); + }, 500); + ZMDataModel.zmDebug("so I'm regenerating Connkey to " + $scope.connKey); //$timeout.cancel(eventQueryHandle); - // eventQueryHandle = $timeout (function(){checkEvent();}, zm.eventPlaybackQuery); + // eventQueryHandle = $timeout (function(){checkEvent();}, zm.eventPlaybackQuery); $ionicLoading.hide(); - }); + }); var slidein; var slideout; if (dirn == 1) { @@ -1188,25 +1166,25 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro function outWithOld() { - - + + $timeout(function () { element.removeClass(slideout); element.addClass(slidein) .one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', inWithNew); - + }, 200); } function inWithNew() { element.removeClass(slidein); - - + + } } - - + + //-------------------------------------------------------- // utility function //-------------------------------------------------------- @@ -1316,17 +1294,17 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro .then(function (success) { - // console.log ("DUCCESS::"+JSON.stringify(success)); + // console.log ("DUCCESS::"+JSON.stringify(success)); var event = success.data.event; currentEvent = event; event.Event.BasePath = computeBasePath(event); event.Event.relativePath = computeRelativePath(event); - - event.Event.streamingURL = ZMDataModel.getStreamingURL (event.Event.MonitorId); - // event.Event.baseURL = ZMDataModel.getBaseURL (event.Event.MonitorId); + + event.Event.streamingURL = ZMDataModel.getStreamingURL(event.Event.MonitorId); + // event.Event.baseURL = ZMDataModel.getBaseURL (event.Event.MonitorId); event.Event.baseURL = loginData.url; - event.Event.imageMode = ZMDataModel.getImageMode (event.Event.MonitorId); + event.Event.imageMode = ZMDataModel.getImageMode(event.Event.MonitorId); //console.log (JSON.stringify( success)); $scope.eventName = event.Event.Name; @@ -1341,11 +1319,11 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro event.Event.DefaultVideo = ""; $scope.defaultVideo = event.Event.DefaultVideo; - - console.log ("loginData is " + JSON.stringify($scope.loginData)); - console.log ("Event ID is " + $scope.eventId); - console.log ("video is " + $scope.defaultVideo); - + + console.log("loginData is " + JSON.stringify($scope.loginData)); + console.log("Event ID is " + $scope.eventId); + console.log("video is " + $scope.defaultVideo); + neighborEvents(event.Event.Id) .then(function (success) { @@ -1364,13 +1342,13 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro event.Event.video = {}; var videoURL; - + if (event.Event.imageMode == 'path') videoURL = event.Event.baseURL + "/events/" + event.Event.relativePath + event.Event.DefaultVideo; else - videoURL = event.Event.baseURL + "/index.php?view=view_video&eid="+event.Event.Id; + videoURL = event.Event.baseURL + "/index.php?view=view_video&eid=" + event.Event.Id; - console.log("************** VIDEO IS " + videoURL); + console.log("************** VIDEO IS " + videoURL); //console.log("************** VIDEO IS " + videoURL); event.Event.video.config = { @@ -1460,25 +1438,30 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro //$scope.FrameArray = event.Frame; // $scope.slider_options.scale=[]; - // $scope.slider_modal_options.scale = []; + // $scope.slider_modal_options.scale = []; // lets framearray.datasets[0].data = []; for (i = 0; i < event.Frame.length; i++) { - - var ts=moment(event.Frame[i].TimeStamp).format(timeFormat); - + + var ts = moment(event.Frame[i].TimeStamp).format(timeFormat); + //console.log ("pushing s:" + event.Frame[i].Score+" t:"+ts); - - framearray.datasets[0].data.push({x:ts, y:event.Frame[i].Score}); + + framearray.datasets[0].data.push({ + x: ts, + y: event.Frame[i].Score + }); framearray.labels.push(""); - - + + } $scope.totalEventTime = Math.round(parseFloat(event.Event.Length)) - 1; $scope.currentEventTime = 0; - - $timeout (function() {drawGraph();},500); + + $timeout(function () { + drawGraph(); + }, 500); }, function (err) { ZMDataModel.zmLog("Error retrieving detailed frame API " + JSON.stringify(err)); @@ -1493,19 +1476,19 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro $scope.$watch('ionRange.index', function () { // $scope.mycarousel.index = parseInt($scope.ionRange.index) - 1; - + if (carouselUtils.getStop() == true) return; - - //console.log ("***ION RANGE CHANGED TO " + $scope.mycarousel.index); + + //console.log ("***ION RANGE CHANGED TO " + $scope.mycarousel.index); }); } if (typeof $scope.mycarousel !== 'undefined') { $scope.$watch('mycarousel.index', function () { - - if (currentEvent && $scope.ionRange.index == parseInt(currentEvent.Event.Frames -1)) { + + if (currentEvent && $scope.ionRange.index == parseInt(currentEvent.Event.Frames - 1)) { playbackFinished(); } // end of playback from quick scrub @@ -1513,7 +1496,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro if ($scope.event && $scope.ionRange.index == parseInt($scope.event.Event.Frames) - 1) { if (!$scope.modal || $scope.modal.isShown() == false) { - // console.log("quick scrub playback over"); + // console.log("quick scrub playback over"); carouselUtils.setStop(true); $scope.ionRange.index = 0; $scope.mycarousel.index = 1; @@ -1547,6 +1530,6 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro return number; } - -}]); \ No newline at end of file + +}]); diff --git a/www/js/EventServerSettingsCtrl.js b/www/js/EventServerSettingsCtrl.js index e2456c2b..057ae245 100644 --- a/www/js/EventServerSettingsCtrl.js +++ b/www/js/EventServerSettingsCtrl.js @@ -2,7 +2,7 @@ /* jslint browser: true*/ /* global cordova,StatusBar,angular,console */ -angular.module('zmApp.controllers').controller('zmApp.EventServerSettingsCtrl', ['$scope', '$ionicSideMenuDelegate', 'zm', '$stateParams', 'EventServer', '$ionicHistory', '$rootScope', '$state', 'message', 'ZMDataModel', '$ionicPlatform','$ionicPopup', '$timeout', function ($scope, $ionicSideMenuDelegate, zm, $stateParams, EventServer, $ionicHistory, $rootScope, $state, message, ZMDataModel, $ionicPlatform, $ionicPopup, $timeout) { +angular.module('zmApp.controllers').controller('zmApp.EventServerSettingsCtrl', ['$scope', '$ionicSideMenuDelegate', 'zm', '$stateParams', 'EventServer', '$ionicHistory', '$rootScope', '$state', 'message', 'ZMDataModel', '$ionicPlatform','$ionicPopup', '$timeout', '$translate', function ($scope, $ionicSideMenuDelegate, zm, $stateParams, EventServer, $ionicHistory, $rootScope, $state, message, ZMDataModel, $ionicPlatform, $ionicPopup, $timeout, $translate) { $scope.openMenu = function () { $ionicSideMenuDelegate.toggleLeft(); }; @@ -59,21 +59,23 @@ angular.module('zmApp.controllers').controller('zmApp.EventServerSettingsCtrl', + + $rootScope.zmPopup = $ionicPopup.show({ scope: $scope, - template: ' Event view Montage view ', + template: ''+ $translate.instant('kEventView')+' Montage view ', title: 'View to navigate to:', subTitle: 'currently set to: ' + ld.onTapScreen, buttons: [ { - text: 'Cancel', + text: $translate.instant('kButtonCancel'), }, { - text: 'OK', + text: $translate.instant('kButtonOk'), onTap: function (e) { ld.onTapScreen = $scope.myopt.selectedState; diff --git a/www/js/EventsModalGraphCtrl.js b/www/js/EventsModalGraphCtrl.js index 899b83ae..43fef865 100644 --- a/www/js/EventsModalGraphCtrl.js +++ b/www/js/EventsModalGraphCtrl.js @@ -6,7 +6,7 @@ -angular.module('zmApp.controllers').controller('EventsModalGraphCtrl', ['$scope', '$rootScope', 'zm', 'ZMDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce', 'carouselUtils', '$ionicPopup', function ($scope, $rootScope, zm, ZMDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce, carouselUtils, $ionicPopup) { +angular.module('zmApp.controllers').controller('EventsModalGraphCtrl', ['$scope', '$rootScope', 'zm', 'ZMDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce', 'carouselUtils', '$ionicPopup', '$translate', function ($scope, $rootScope, zm, ZMDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce, carouselUtils, $ionicPopup, $translate) { @@ -158,7 +158,7 @@ angular.module('zmApp.controllers').controller('EventsModalGraphCtrl', ['$scope' labels: [], datasets: [ { - label: 'Score', + label: $translate.instant('kScore'), fill:true, backgroundColor: 'rgba(129, 207, 224, 1.0)', borderColor: 'rgb(92, 147, 159)', @@ -183,7 +183,7 @@ angular.module('zmApp.controllers').controller('EventsModalGraphCtrl', ['$scope' labels: [], datasets: [ { - label: 'Score', + label: $translate.instant ('kScore'), backgroundColor: 'rgba(129, 207, 224, 1.0)', borderColor: 'rgba(129, 207, 224, 1.0)', hoverBackgroundColor: 'rgba(248, 148, 6,1.0)', diff --git a/www/js/LogCtrl.js b/www/js/LogCtrl.js index 84ab820c..83857d75 100644 --- a/www/js/LogCtrl.js +++ b/www/js/LogCtrl.js @@ -2,7 +2,7 @@ /* jslint browser: true*/ /* global saveAs, cordova,StatusBar,angular,console,moment */ -angular.module('zmApp.controllers').controller('zmApp.LogCtrl', ['$scope', '$rootScope','zm', '$ionicModal', 'ZMDataModel', '$ionicSideMenuDelegate', '$fileLogger', '$cordovaEmailComposer', '$ionicPopup', '$timeout', '$ionicHistory', '$state', '$interval', '$ionicLoading', function ($scope, $rootScope,zm, $ionicModal, ZMDataModel, $ionicSideMenuDelegate, $fileLogger, $cordovaEmailComposer, $ionicPopup, $timeout, $ionicHistory, $state, $interval, $ionicLoading) { +angular.module('zmApp.controllers').controller('zmApp.LogCtrl', ['$scope', '$rootScope','zm', '$ionicModal', 'ZMDataModel', '$ionicSideMenuDelegate', '$fileLogger', '$cordovaEmailComposer', '$ionicPopup', '$timeout', '$ionicHistory', '$state', '$interval', '$ionicLoading', '$tranaslate', function ($scope, $rootScope,zm, $ionicModal, ZMDataModel, $ionicSideMenuDelegate, $fileLogger, $cordovaEmailComposer, $ionicPopup, $timeout, $ionicHistory, $state, $interval, $ionicLoading, $translate) { $scope.openMenu = function () { $ionicSideMenuDelegate.toggleLeft(); }; @@ -74,8 +74,8 @@ angular.module('zmApp.controllers').controller('zmApp.LogCtrl', ['$scope', '$roo $scope.sendEmail = function (logstring) { $ionicPopup.confirm({ - title: 'Sensitive Information', - template: $rootScope.appName+' will modify the logs when creating the final output to remove sensitive data like urls and passwords. However it is eventually your responsibility to make sure there is no sensitive data in the logs. Please make sure you review and edit the logs before you send it out.' + title: $translate.instant('kSensitiveTitle'), + template: $rootScope.appName+' '+$translate.instant('kSensitiveBody') }) .then(function (res) { if (res) sendEmailReally(logstring); @@ -153,7 +153,7 @@ saveAs(blob, fname); //console.log ("GETTING LOGS"); $ionicLoading.show({ - template: "retrieving logs...", + template: $translate.instant('kLoading'), noBackdrop: true, duration: zm.loadingTimeout }); diff --git a/www/js/LoginCtrl.js b/www/js/LoginCtrl.js index d551743e..f973bf5c 100644 --- a/www/js/LoginCtrl.js +++ b/www/js/LoginCtrl.js @@ -2,7 +2,7 @@ /* jslint browser: true*/ /* global cordova,StatusBar,angular,console,alert,URI */ -angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$rootScope', 'zm', '$ionicModal', 'ZMDataModel', '$ionicSideMenuDelegate', '$ionicPopup', '$http', '$q', '$ionicLoading', 'zmAutoLogin', '$cordovaPinDialog', 'EventServer', '$ionicHistory', '$state', '$ionicActionSheet', 'SecuredPopups', '$localstorage', '$stateParams', function ($scope, $rootScope, zm, $ionicModal, ZMDataModel, $ionicSideMenuDelegate, $ionicPopup, $http, $q, $ionicLoading, zmAutoLogin, $cordovaPinDialog, EventServer, $ionicHistory, $state, $ionicActionSheet, SecuredPopups, $localstorage, $stateParams) { +angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$rootScope', 'zm', '$ionicModal', 'ZMDataModel', '$ionicSideMenuDelegate', '$ionicPopup', '$http', '$q', '$ionicLoading', 'zmAutoLogin', '$cordovaPinDialog', 'EventServer', '$ionicHistory', '$state', '$ionicActionSheet', 'SecuredPopups', '$localstorage', '$stateParams', '$translate', function ($scope, $rootScope, zm, $ionicModal, ZMDataModel, $ionicSideMenuDelegate, $ionicPopup, $http, $q, $ionicLoading, zmAutoLogin, $cordovaPinDialog, EventServer, $ionicHistory, $state, $ionicActionSheet, SecuredPopups, $localstorage, $stateParams, $translate) { $scope.openMenu = function () { $ionicSideMenuDelegate.toggleLeft(); }; @@ -49,19 +49,19 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r if (as.length < 2) { $rootScope.zmPopup= SecuredPopups.show('alert',{ - title: 'Error', - template: 'You need to have at least 2 distinct configurations created for a fallback' + title: $translate.instant('kError'), + template: $translate.instant('kFallback2Configs') }); return; } - var ab = [{text:'Clear'}]; + var ab = [{text:$translate.instant('kClear')}]; var ld = ZMDataModel.getLogin(); as.forEach(function(item) { if (item != ld.serverName) ab.push({text:item});}); var sheet = $ionicActionSheet.show({ buttons: ab, - titleText: 'Select fallback', - cancelText: 'Cancel', + titleText: $translate.instant('kSelectFallback'), + cancelText: $translate.instant('kCancel'), cancel: function() {}, buttonClicked: function (index) { @@ -86,16 +86,16 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r $scope.serverActionSheet = function () { var hideSheet = $ionicActionSheet.show({ buttons: serverbuttons, - destructiveText: 'Delete', - titleText: 'Manage Server Groups', - cancelText: 'Cancel', + destructiveText: $translate.instant('kDelete'), + titleText: $translate.instant('kManageServerGroups'), + cancelText: $translate.instant('kCancel'), cancel: function () { // add cancel code.. }, buttonClicked: function (index) { //console.log ("YOU WANT " + serverbuttons[index].text + " INDEX " + index); - if (serverbuttons[index].text == 'Add...') + if (serverbuttons[index].text == $translate.instant('kServerAdd')+"...") { $scope.loginData = angular.copy(ZMDataModel.getDefaultLoginObject()); @@ -148,7 +148,7 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r ZMDataModel.setLogin($scope.loginData); availableServers = Object.keys(ZMDataModel.getServerGroups()); - serverbuttons = [{text:'Add...'}]; + serverbuttons = [{text:$translate.instant('kServerAdd')+"..."}]; for (var servIter = 0; servIter < availableServers.length; servIter++) { serverbuttons.push({ text: availableServers[servIter] @@ -157,7 +157,7 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r } } else { - ZMDataModel.displayBanner('error', ['Cannot delete, need at least one']); + ZMDataModel.displayBanner('error', [$translate.instant('kBannerCannotDeleteNeedOne')]); } return true; } @@ -195,7 +195,7 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r oldName = ld.serverName; availableServers = Object.keys(ZMDataModel.getServerGroups()); - serverbuttons = [{text:"Add..."}]; + serverbuttons = [{text:$translate.instant('kServerAdd')+"..."}]; for (var servIter = 0; servIter < availableServers.length; servIter++) { serverbuttons.push({ text: availableServers[servIter] @@ -257,8 +257,9 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r { event.preventDefault(); $rootScope.zmPopup = SecuredPopups.show('alert',{ - title: 'Please Save', - template: 'You have changed from ' + oldName + ' to ' + ld.serverName + '. Please save this profile first.' + title: $translate.instant('kPleaseSave'), + template: $translate.instant('kProfileChangeNotification', {oldName: oldName, newName:ld.serverName}) + }); } @@ -270,120 +271,8 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r // Make a noble attempt at deciphering - $scope.detectCgi = function() - { - - if ($scope.loginData.url == "") - { - $rootScope.zmPopup = SecuredPopups.show('show',{ - title: 'Portal not configured', - cssClass: 'popup90', - template: "Please fill in your login details as well as portal URL and save it before you try to detect the cgi-path", - buttons: [{text: 'Ok'}] - - }); - return; - - } - - if ( $rootScope.authSession == 'undefined') - { - $rootScope.zmPopup = SecuredPopups.show('show',{ - title: 'Not logged in', - cssClass: 'popup90', - template: "It doesn't look like you are logged in. For detection to work, you must fill in your login details, portal URL and then tap on Save. Then come back to this feature.", - buttons: [{text: 'Ok'}] - - }); - return; - } - - var defaultText = "

Typical values:
ubuntu: http://server/zm/cgi-bin
centos/fedora: http://server/zm/cgi-bin-zm/"; - - if ($scope.loginData.url.slice(-1) == '/') { - $scope.loginData.url = $scope.loginData.url.slice(0, -1); - - } - - ZMDataModel.getPathZms() - .then (function (data) - { - // coming here means we were able to login - $scope.loginData.url = addhttp($scope.loginData.url); - if ($scope.loginData.useSSL) - $scope.loginData.url = $scope.loginData.url.replace("http:", "https:"); - - var c=URI.parse($scope.loginData.url); - var p1,p2,p3,text; - p1 =""; - p2 =""; - - if (c.userinfo) - p1 = c.userinfo+"@"; - if (c.port) - p2 = ":"+c.port; - - var baseUri = c.scheme+"://"+p1+c.host+p2; - var dtext = baseUri + data.toLowerCase().trim(); - dtext = dtext.substr(0, dtext.lastIndexOf("/")); - - // have we already set the right path? - if (dtext == $scope.loginData.streamingurl.toLowerCase()) - { - text = "It looks like you have already set your cgi-path correctly to " + dtext +", which is what ZoneMinder reports too"; - - $rootScope.zmPopup = SecuredPopups.show('show',{ - title: 'cgi-bin settings', - cssClass: 'popup90', - template: text, - buttons: [{text: 'Ok'}] - - }); - - } - else - { - text = "Zoneminder reports your cgi-bin path as "+dtext+", while you have it set as "+$scope.loginData.streamingurl.toLowerCase(); - - $rootScope.zmPopup = SecuredPopups.show('show',{ - title: 'cgi-bin settings', - cssClass: 'popup90', - template: text, - buttons: [{text: 'Ok', type:'button-positive'},{text:'Use suggestion',type:'button-balanced', onTap:function(e) {$scope.loginData.streamingurl=dtext;}}, /*{text:'try harder', onTap:function(e) {tryHarder();}}*/] - - }); - } - - - - - }, - function (error) - { - ZMDataModel.zmDebug ("Could not get PATH_ZMS:"+JSON.stringify(error)); - var text = "(could not detect cgi-path, try coming back here after setting up your portal url and credentials correctly, and saving)

"+defaultText; - $rootScope.zmPopup = SecuredPopups.show('alert',{ - title: 'cgi-bin settings', - cssClass: 'popup90', - - template: text - }); - - }); - - - - }; - function tryHarder() - { - $rootScope.zmPopup = SecuredPopups.show('alert',{ - title: 'Harder', - cssClass: 'popup90', - template: "trying harder" - }); - } - + //-------------------------------------------------------------------------- // When PIN is enabled, this is called to specify a PIN // FIXME: Get rid of cordovaPinDialog. It's really not needed @@ -392,12 +281,12 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r ZMDataModel.zmLog("Password prompt"); if ($scope.loginData.usePin) { $scope.loginData.pinCode = ""; - $cordovaPinDialog.prompt('Enter PIN', 'PIN Protect').then( + $cordovaPinDialog.prompt($translate.instant('kEnterPin'), $translate.instant('kPinProtect')).then( function (result1) { // console.log (JSON.stringify(result1)); if (result1.input1 && result1.buttonIndex == 1) { - $cordovaPinDialog.prompt('Reconfirm PIN', 'PIN Protect') + $cordovaPinDialog.prompt($translate.instant('kReconfirmPin'), $translate.instant('kPinProtect')) .then(function (result2) { if (result1.input1 == result2.input1) { ZMDataModel.zmLog("Pin code match"); @@ -405,7 +294,7 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r } else { ZMDataModel.zmLog("Pin code mismatch"); $scope.loginData.usePin = false; - ZMDataModel.displayBanner('error', ['Pin code mismatch']); + ZMDataModel.displayBanner('error', [$translate.instant('kBannerPinMismatch')]); } }, function (error) { @@ -632,7 +521,7 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r .finally ( function (ans) { - zmAutoLogin.doLogin("") + zmAutoLogin.doLogin("") // Do the happy menu only if authentication works // if it does not work, there is an emitter for auth // fail in app.js that will be called to show an error @@ -659,7 +548,7 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r $http.get(apiurl) .success(function (data) { - var loginStatus = "Please explore the menu and enjoy "+$rootScope.appName+"!"; + var loginStatus = $translate.instant('kExploreEnjoy')+" "+$rootScope.appName+"!"; EventServer.refresh(); @@ -676,7 +565,7 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r $http.get(ld.streamingurl + "/zms") .success(function (data) { ZMDataModel.zmDebug("Urk! cgi-path returned success, but it should not have come here"); - loginStatus = "Login validated, but could not validate cgi-path. If live streams don't work please check your cgi-bin path or try using the discover feature"; + loginStatus = $translate.instant('kLoginStatusNoCgi'); ZMDataModel.zmDebug ("refreshing API version..."); ZMDataModel.getAPIversion() @@ -708,13 +597,13 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r // if its 4xx then the cgi-bin path is not valid if (status < 500) { - loginStatus = "The cgi-bin path you entered may be wrong. I can't make sure, but if your live views don't work, please review your cgi path or try using the discover feature."; + loginStatus = $translate.instant('kLoginStatusNoCgiAlt'); } if (showalert) { $rootScope.zmPopup = SecuredPopups.show('alert',{ - title: 'Login validated', + title: $translate.instant('kLoginValidatedTitle'), template: loginStatus }).then(function (res) { @@ -742,12 +631,12 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r }) .error(function (error) { - ZMDataModel.displayBanner('error', ['ZoneMinder API check failed', 'Please check API settings']); + ZMDataModel.displayBanner('error', [$translate.instant('kBannerAPICheckFailed'), $translate.instant('kBannerPleaseCheck')]); ZMDataModel.zmLog("API login error " + JSON.stringify(error)); $rootScope.zmPopup= SecuredPopups.show('alert',{ - title: 'Login validated but API failed', - template: 'Please check your API settings' + title: $translate.instant('kLoginValidAPIFailedTitle'), + template: $translate.instant('kBannerPleaseCheck') }); }); }); @@ -766,8 +655,8 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r if (!$scope.loginData.serverName) { $rootScope.zmPopup = $ionicPopup.alert({ - title: 'Error', - template: 'Server Name cannot be empty', + title: $translate.instant('kError'), + template: $translate.instant('kServerEmptyError'), }) .then(function (res) { return; diff --git a/www/js/MonitorCtrl.js b/www/js/MonitorCtrl.js index 6e6282ed..ab3631aa 100644 --- a/www/js/MonitorCtrl.js +++ b/www/js/MonitorCtrl.js @@ -6,8 +6,8 @@ // refer to comments in EventCtrl for the modal stuff. They are almost the same angular.module('zmApp.controllers') - .controller('zmApp.MonitorCtrl', ['$ionicPopup', 'zm', '$scope', 'ZMDataModel', 'message', '$ionicSideMenuDelegate', '$ionicLoading', '$ionicModal', '$state', '$http', '$rootScope', '$timeout','$ionicHistory', '$ionicPlatform', - function ($ionicPopup, zm, $scope, ZMDataModel, message, $ionicSideMenuDelegate, $ionicLoading, $ionicModal, $state, $http, $rootScope, $timeout, $ionicHistory, $ionicPlatform) { + .controller('zmApp.MonitorCtrl', ['$ionicPopup', 'zm', '$scope', 'ZMDataModel', 'message', '$ionicSideMenuDelegate', '$ionicLoading', '$ionicModal', '$state', '$http', '$rootScope', '$timeout','$ionicHistory', '$ionicPlatform', '$translate', + function ($ionicPopup, zm, $scope, ZMDataModel, message, $ionicSideMenuDelegate, $ionicLoading, $ionicModal, $state, $http, $rootScope, $timeout, $ionicHistory, $ionicPlatform, $translate) { //----------------------------------------------------------------------- @@ -26,8 +26,8 @@ angular.module('zmApp.controllers') if ($scope.monitors.length == 0) { $rootScope.zmPopup= $ionicPopup.alert({ - title: "No Monitors found", - template: "Please check your credentials" + title: $translate.instant('kNoMonitors'), + template: $translate.instant('kPleaseCheckCredentials') }); $ionicHistory.nextViewOptions({ disableBack: true @@ -111,27 +111,27 @@ angular.module('zmApp.controllers') $scope.monFunctions = [ { - text: "Modect", + text: $translate.instant('kMonModect'), value: "Modect" }, { - text: "Mocord", + text: $translate.instant('kMonMocord'), value: "Mocord" }, { - text: "Record", + text: $translate.instant('kMonRecord'), value: "Record" }, { - text: "Nodect", + text:$translate.instant('kMonNodect'), value: "Nodect" }, { - text: "Monitor", + text: $translate.instant('kMonMonitor'), value: "Monitor" }, { - text: "None", + text: $translate.instant('kMonNone'), value: "None" } ]; @@ -146,15 +146,15 @@ angular.module('zmApp.controllers') template: 'Enabled {{item.text}} ', - title: 'Change Settings for ' + monitorName, + title: $translate.instant('kChangeSettingsFor') + ' '+monitorName, buttons: [ { - text: 'Cancel', + text: $translate.instant('kButtonCancel'), }, { - text: 'Save', + text:$translate.instant('kButtonSave'), onTap: function (e) { ZMDataModel.zmDebug("MonitorCtrl:changeConfig selection:" + $scope.monfunc.myenabled + @@ -169,7 +169,7 @@ angular.module('zmApp.controllers') isEnabled = ($scope.monfunc.myenabled == true) ? '1' : '0'; $ionicLoading.show({ - template: "Applying changes. Please wait...", + template:$translate.instant('kApplyingChanges')+"...", noBackdrop: true, duration: zm.largeHttpTimeout, }); @@ -231,7 +231,7 @@ angular.module('zmApp.controllers') ZMDataModel.zmDebug("MonitorCtrl: Error changing monitor " + JSON.stringify(data)); $ionicLoading.hide(); $ionicLoading.show({ - template: "Error changing Monitor. Please check ZM logs...", + template: $translate.instant('kErrorChangingMonitors')+"...", noBackdrop: true, duration: 3000, }); @@ -339,7 +339,7 @@ angular.module('zmApp.controllers') $scope.modal = modal; $ionicLoading.show({ - template: "please wait...", + template: $translate.instant('kPleaseWait')+"...", noBackdrop: true, duration: zm.loadingTimeout }); @@ -423,7 +423,7 @@ angular.module('zmApp.controllers') .error(function (data) { ZMDataModel.zmDebug("MonitorCtrl: Error->monitor check state returned: " + JSON.stringify(data)); - ZMDataModel.displayBanner('error', ['error retrieving state', 'Please try again']); + ZMDataModel.displayBanner('error', [$translate.instant('kErrorRetrievingState'), $translate.instant('kPleaseTryAgain')]); $scope.monitors[j].Monitor.isRunning = "error"; $scope.monitors[j].Monitor.color = zm.monitorErrorColor; $scope.monitors[j].Monitor.char = "ion-help-circled"; diff --git a/www/js/MonitorModalCtrl.js b/www/js/MonitorModalCtrl.js index d62839d2..ddc2f3e2 100644 --- a/www/js/MonitorModalCtrl.js +++ b/www/js/MonitorModalCtrl.js @@ -5,7 +5,7 @@ -angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$rootScope', 'zm', 'ZMDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce', 'carouselUtils', '$ionicPopup', 'SecuredPopups', function ($scope, $rootScope, zm, ZMDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce, carouselUtils, $ionicPopup, SecuredPopups) { +angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$rootScope', 'zm', 'ZMDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce', 'carouselUtils', '$ionicPopup', 'SecuredPopups', '$translate', function ($scope, $rootScope, zm, ZMDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce, carouselUtils, $ionicPopup, SecuredPopups, $translate) { @@ -21,7 +21,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ $rootScope.authSession = "undefined"; $ionicLoading.show({ - template: 'negotiating stream authentication...', + template: $translate.instant('kNegotiatingStreamAuth')+'...', animation: 'fade-in', showBackdrop: true, duration: zm.loadingTimeout, @@ -206,7 +206,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ $scope.showPTZ = !$scope.showPTZ; } else { $ionicLoading.show({ - template: "PTZ not configured for this monitor", + template: $translate.instant('kPTZnotConfigured'), noBackdrop: true, duration: 3000, }); @@ -260,7 +260,12 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ return; } - var status = ["idle", "pre-alarm","alarmed","alert","record"]; + var status = [$translate.instant('kMonIdle'), + $translate.instant('kMonPreAlarm'), + $translate.instant('kMonAlarmed'), + $translate.instant('kMonAlert'), + $translate.instant('kMonRecord') + ]; //console.log ("Inside Modal timer..."); var apiurl = ZMDataModel.getLogin().apiurl; var alarmurl = apiurl+"/monitors/alarm/id:"+$scope.monitorId+"/command:status.json"; @@ -345,7 +350,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ if (!$scope.ptzMoveCommand) { $ionicLoading.show({ - template: "Not Ready for PTZ", + template: $translate.instant('kPTZNotReady'), noBackdrop: true, duration: 2000, }); @@ -380,7 +385,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ //console.log("PTZDATA is " + JSON.stringify(ptzData)); $ionicLoading.hide(); $ionicLoading.show({ - template: "please wait...", + template: $translate.instant('kPleaseWait')+"...", noBackdrop: true, duration: zm.loadingTimeout, }); @@ -388,7 +393,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ var loginData = ZMDataModel.getLogin(); $ionicLoading.hide(); $ionicLoading.show({ - template: "Sending PTZ..", + template: $translate.instant('kSendingPTZ')+"...", noBackdrop: true, duration: zm.loadingTimeout, }); @@ -571,7 +576,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ function SaveSuccess() { $ionicLoading.show({ - template: "done!", + template: $translate.instant('kDone'), noBackdrop: true, duration: 1000 }); @@ -580,7 +585,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ function SaveError(e) { $ionicLoading.show({ - template: "error - could not save", + template: $translate.instant('kErrorSave'), noBackdrop: true, duration: 2000 }); @@ -599,17 +604,17 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ { $rootScope.zmPopup = SecuredPopups.show('show',{ title: 'Confirm', - template: "Are you sure you want to force an alarm for Monitor:"+$scope.monitorName+"?", + template: $translate.instant('kForceAlarmConfirm')+$scope.monitorName+"?", buttons: [ { - text: 'Yes', + text: $translate.instant('kButtonYes'), onTap: function(e) { enableAlarm(mid, mode); } }, { - text: 'No', + text: $translate.instant('kButtonNo'), onTap: function (e) { return; @@ -629,7 +634,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ var alarmurl = apiurl+"/monitors/alarm/id:"+mid+"/command:"+c+".json"; ZMDataModel.zmLog ("Invoking " + alarmurl); - var status = mode? "forcing alarm": "cancelling alarm"; + var status = mode? $translate.instant('kForcingAlarm'): $translate.instant('kCancellingAlarm'); $ionicLoading.show({ template: status, noBackdrop: true, @@ -639,7 +644,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ $http.get(alarmurl) .then (function (data) { $ionicLoading.show({ - template: "success", + template: $translate.instant('kSuccess'), noBackdrop: true, duration: 2000, }); @@ -647,7 +652,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ function (error) { $ionicLoading.show({ - template: "error - please make sure your API supports this feature", + template: $translate.instant('kAlarmAPIError'), noBackdrop: true, duration: 3000, }); @@ -666,6 +671,12 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ $scope.stateColor = function() { + var status = [$translate.instant('kMonIdle'), + $translate.instant('kMonPreAlarm'), + $translate.instant('kMonAlarmed'), + $translate.instant('kMonAlert'), + $translate.instant('kMonRecord') + ]; //console.log ("***MONSTATUS**"+$scope.monStatus+"**"); var color=""; switch ($scope.monStatus) @@ -673,19 +684,19 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ case "": color="background-color:none"; break; - case "idle": + case status[0]: color="background-color:#4B77BE"; break; - case "pre-alarm": + case status[1]: color="background-color:#e67e22"; break; - case "alarmed": + case status[2]: color="background-color:#D91E18"; break; - case "alert": + case status[3]: color="background-color:#e67e22"; break; - case "record": + case status[4]: color="background-color:#26A65B"; break; } @@ -700,7 +711,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ $scope.saveImageToPhone = function (mid) { $ionicLoading.show({ - template: "saving snapshot...", + template: $translate.instant('kSavingSnapshot')+'...', noBackdrop: true, duration: zm.httpTimeout }); @@ -839,7 +850,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$ if (disp) { $ionicLoading.hide(); $ionicLoading.show({ - template: "please wait...", + template: $translate.instant('kPleaseWait')+'...', noBackdrop: true, duration: zm.loadingTimeout, }); -- cgit v1.2.3