summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--www/js/DataModel.js7
-rw-r--r--www/js/EventModalCtrl.js124
-rw-r--r--www/js/MonitorModalCtrl.js78
3 files changed, 150 insertions, 59 deletions
diff --git a/www/js/DataModel.js b/www/js/DataModel.js
index 575f369c..24aabd69 100644
--- a/www/js/DataModel.js
+++ b/www/js/DataModel.js
@@ -9,10 +9,10 @@
angular.module('zmApp.controllers')
- .service('NVRDataModel', ['$ionicPlatform', '$http', '$q', '$ionicLoading', '$ionicBackdrop', '$fileLogger', 'zm', '$rootScope', '$ionicContentBanner', '$timeout', '$cordovaPinDialog', '$ionicPopup', '$localstorage', '$state', '$ionicNativeTransitions', '$translate', '$cordovaSQLite',
+ .service('NVRDataModel', ['$ionicPlatform', '$http', '$q', '$ionicLoading', '$ionicBackdrop', '$fileLogger', 'zm', '$rootScope', '$ionicContentBanner', '$timeout', '$cordovaPinDialog', '$ionicPopup', '$localstorage', '$state', '$translate', '$cordovaSQLite',
function ($ionicPlatform, $http, $q, $ionicLoading, $ionicBackdrop, $fileLogger,
zm, $rootScope, $ionicContentBanner, $timeout, $cordovaPinDialog,
- $ionicPopup, $localstorage, $state, $ionicNativeTransitions, $translate) {
+ $ionicPopup, $localstorage, $state, $translate) {
var currentServerMultiPortSupported = false;
@@ -694,7 +694,8 @@ angular.module('zmApp.controllers')
if ($rootScope.platformOS == 'desktop')
$state.go(state, p1, p2);
else
- $ionicNativeTransitions.stateGo(state, p1, p2);
+ $state.go(state, p1, p2);
+ // $ionicNativeTransitions.stateGo(state, p1, p2);
},
// used when an empty server profile is created
diff --git a/www/js/EventModalCtrl.js b/www/js/EventModalCtrl.js
index cf77aa3d..eb78573a 100644
--- a/www/js/EventModalCtrl.js
+++ b/www/js/EventModalCtrl.js
@@ -3,7 +3,7 @@
/* jslint browser: true*/
/* global saveAs, cordova,StatusBar,angular,console,ionic, moment, Chart */
-angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$rootScope', 'zm', 'NVRDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce', 'carouselUtils', '$ionicPopup', '$translate', '$filter', 'SecuredPopups', function ($scope, $rootScope, zm, NVRDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce, carouselUtils, $ionicPopup, $translate, $filter, SecuredPopups) {
+angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$rootScope', 'zm', 'NVRDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce', 'carouselUtils', '$ionicPopup', '$translate', '$filter', 'SecuredPopups', '$cordovaFile',function ($scope, $rootScope, zm, NVRDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce, carouselUtils, $ionicPopup, $translate, $filter, SecuredPopups, $cordovaFile) {
var playerReady = false;
@@ -520,7 +520,7 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro
noBackdrop: true,
duration: 2000
});
- NVRDataModel.log("Error saving image: " + e.message);
+ //NVRDataModel.log("Error saving image: " + e.message);
//console.log("***ERROR");
}
@@ -880,37 +880,80 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro
noBackdrop: true,
duration: zm.httpTimeout
});
+
+
var url = $scope.selectEventUrl;
- NVRDataModel.log("saveNow: File path to grab is " + url);
-
- 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]
- );
- // carouselUtils.setStop(curState);
- } catch (e) {
-
- SaveError(e.message);
- // carouselUtils.setStop(curState);
+ NVRDataModel.log(">>saveNow: File path to grab is " + url);
+
+ if ($rootScope.platformOS != 'desktop') {
+
+ var album = 'zmNinja';
+ NVRDataModel.debug ("Trying to save image to album: "+album);
+ cordova.plugins.photoLibrary.requestAuthorization(
+ function () {
+ //url = "https://picsum.photos/200/300/?random";
+
+ var fileTransfer = new FileTransfer();
+ var urle = encodeURI(url);
+ var fname = "zmninja.jpg";
+
+ fileTransfer.download(urle, cordova.file.dataDirectory + fname,
+ function(entry){
+ NVRDataModel.debug("local download complete: " + entry.toURL());
+ NVRDataModel.debug("Now trying to move it to album");
+ cordova.plugins.photoLibrary.saveImage(entry.toURL(), album,
+ function (cameraRollAssetId) {
+ SaveSuccess();
+ $cordovaFile.removeFile(cordova.file.dataDirectory, fname)
+ .then (
+ function () {
+ NVRDataModel.debug ("file removed from data directory");
+ },
+ function (e) {
+ NVRDataModel.debug ("could not delete temp file: "+JSON.stringify(e));
+ }
+ );
+
+
+ }, function (err) {
+ NVRDataModel.debug ("Saving error:" + JSON.stringify(err));
+ SaveError();
+
+ });
+
+ },
+ function(err) { console.log ("error downloading:"+JSON.stringify(err));}, false, {});
+
+
+
+
+ // User gave us permission to his library, retry reading it!
+ },
+ function (err) {
+ // User denied the access
+ NVRDataModel.debug ("Permission not granted");
+ SaveError();
+ }, // if options not provided, defaults to {read: true}.
+
+ {
+ read: true,
+ write: true
}
- } else {
+ );
+
+ }
+ else {
+ 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,/, '');
var fname = $scope.relativePath + $scope.slides[$scope.slideIndex].img + ".png";
fname = fname.replace(/\//, "-");
@@ -920,15 +963,18 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro
saveAs(blob, fname);
SaveSuccess();
});
+ };
+
+ try {
+ img.src = url;
+ console.log ("DESKTOP SAVING IMAGE SOURCE");
+ } catch (e) {
+ SaveError(e.message);
}
- };
- try {
- img.src = url;
- // console.log ("SAVING IMAGE SOURCE");
- } catch (e) {
- SaveError(e.message);
}
- }
+
+ }
+
}
$scope.reloadView = function () {
@@ -2144,4 +2190,4 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro
return number;
}
-}]);
+}]); \ No newline at end of file
diff --git a/www/js/MonitorModalCtrl.js b/www/js/MonitorModalCtrl.js
index 3d765aed..55e15f3a 100644
--- a/www/js/MonitorModalCtrl.js
+++ b/www/js/MonitorModalCtrl.js
@@ -3,7 +3,7 @@
/* jslint browser: true*/
/* global saveAs, cordova,StatusBar,angular,console,ionic, moment, imagesLoaded, chrome */
-angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$rootScope', 'zm', 'NVRDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce', 'carouselUtils', '$ionicPopup', 'SecuredPopups', '$translate', function ($scope, $rootScope, zm, NVRDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce, carouselUtils, $ionicPopup, SecuredPopups, $translate) {
+angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$rootScope', 'zm', 'NVRDataModel', '$ionicSideMenuDelegate', '$timeout', '$interval', '$ionicModal', '$ionicLoading', '$http', '$state', '$stateParams', '$ionicHistory', '$ionicScrollDelegate', '$q', '$sce', 'carouselUtils', '$ionicPopup', 'SecuredPopups', '$translate', '$cordovaFile', function ($scope, $rootScope, zm, NVRDataModel, $ionicSideMenuDelegate, $timeout, $interval, $ionicModal, $ionicLoading, $http, $state, $stateParams, $ionicHistory, $ionicScrollDelegate, $q, $sce, carouselUtils, $ionicPopup, SecuredPopups, $translate, $cordovaFile) {
$scope.animationInProgress = false;
$scope.imageFit = true;
@@ -1183,6 +1183,64 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$
NVRDataModel.log("SavetoPhone:Trying to save image from " + url);
+ if ($rootScope.platformOS != 'desktop') {
+ var album = 'zmNinja';
+ NVRDataModel.debug ("Trying to save image to album: "+album);
+ cordova.plugins.photoLibrary.requestAuthorization(
+ function () {
+ //url = "https://picsum.photos/200/300/?random";
+
+ var fileTransfer = new FileTransfer();
+ var urle = encodeURI(url);
+ var fname = "zmninja.jpg";
+
+ fileTransfer.download(urle, cordova.file.dataDirectory + fname,
+ function(entry){
+ NVRDataModel.debug("local download complete: " + entry.toURL());
+ NVRDataModel.debug("Now trying to move it to album");
+ cordova.plugins.photoLibrary.saveImage(entry.toURL(), album,
+ function (cameraRollAssetId) {
+ SaveSuccess();
+ $cordovaFile.removeFile(cordova.file.dataDirectory, fname)
+ .then (
+ function () {
+ NVRDataModel.debug ("file removed from data directory");
+ },
+ function (e) {
+ NVRDataModel.debug ("could not delete temp file: "+JSON.stringify(e));
+ }
+ );
+
+
+ }, function (err) {
+ NVRDataModel.debug ("Saving error:" + JSON.stringify(err));
+ SaveError();
+
+ });
+
+ },
+ function(err) { console.log ("error downloading:"+JSON.stringify(err));}, false, {});
+
+
+
+
+ // User gave us permission to his library, retry reading it!
+ },
+ function (err) {
+ // User denied the access
+ NVRDataModel.debug ("Permission not granted");
+ SaveError();
+ }, // if options not provided, defaults to {read: true}.
+
+ {
+ read: true,
+ write: true
+ }
+ );
+ }
+
+ else {
+
var img = new Image();
img.onload = function () {
// console.log("********* ONLOAD");
@@ -1195,21 +1253,6 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$
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]
- );
- } catch (e) {
-
- SaveError(e.message);
- }
- } else {
-
var fname = $scope.monitorName + "-" +
moment().format('MMM-DD-YY_HH-mm-ss') + ".png";
canvas.toBlob(function (blob) {
@@ -1217,7 +1260,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$
SaveSuccess();
});
- }
+
};
try {
img.src = url;
@@ -1227,6 +1270,7 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$
}
}
+ }
$scope.constructSingleStream = function () {