summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.xml3
-rw-r--r--package.json8
-rw-r--r--www/js/DataModel.js54
-rw-r--r--www/js/EventCtrl.js44
-rw-r--r--www/js/EventModalCtrl.js14
-rw-r--r--www/js/EventsGraphsCtrl.js7
-rw-r--r--www/js/LoginCtrl.js14
-rw-r--r--www/js/MenuController.js14
-rw-r--r--www/js/MonitorCtrl.js13
-rw-r--r--www/js/MonitorModalCtrl.js40
-rw-r--r--www/js/NewsCtrl.js9
-rw-r--r--www/js/WizardCtrl.js7
-rwxr-xr-xwww/js/app.js216
13 files changed, 340 insertions, 103 deletions
diff --git a/config.xml b/config.xml
index e6c7ab45..d950c4b3 100644
--- a/config.xml
+++ b/config.xml
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
-<widget android-packageName="com.pliablepixels.zmninja_pro" id="com.pliablepixels.zmninja_pro" ios-CFBundleIdentifier="com.pliablepixels.zmninja-pro" version="1.3.025" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
+<widget android-packageName="com.pliablepixels.zmninja_pro" id="com.pliablepixels.zmninja_pro" ios-CFBundleIdentifier="com.pliablepixels.zmninja-pro" version="1.3.026" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>zmNinja</name>
<description>
High performance ZoneMinder client
@@ -164,6 +164,7 @@
<variable name="ANDROID_SUPPORT_ANNOTATIONS_VERSION" value="27.+" />
</plugin>
<plugin name="cordova-plugin-certificates" spec="^0.6.4" />
+ <plugin name="cordova-plugin-advanced-http" spec="^2.0.1" />
<engine name="android" spec="^6.4.0" />
<engine name="ios" spec="~4.5.5" />
</widget>
diff --git a/package.json b/package.json
index 3e96e1fd..cd735462 100644
--- a/package.json
+++ b/package.json
@@ -56,15 +56,18 @@
"cordova-plugin-ionic-webview": {
"ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
},
- "cordova-plugin-certificates": {}
+ "cordova-plugin-certificates": {},
+ "cordova-plugin-advanced-http": {}
}
},
"dependencies": {
"clivas": "^0.2.0",
"com.telerik.plugins.nativepagetransitions": "^0.6.5",
"cordova-android": "^6.4.0",
+ "cordova-ios": "~4.5.5",
"cordova-library-helper-pp-fork": "^1.0.1",
"cordova-plugin-add-swift-support": "^1.7.2",
+ "cordova-plugin-advanced-http": "^2.0.1",
"cordova-plugin-android-fingerprint-auth": "^1.4.0",
"cordova-plugin-android-permissions": "^1.0.0",
"cordova-plugin-app-version": "^0.1.9",
@@ -102,8 +105,7 @@
"minimist": "^1.2.0",
"mkdirp": "^0.5.1",
"phonegap-plugin-mobile-accessibility": "^1.0.5",
- "phonegap-plugin-push": "^2.1.3",
- "cordova-ios": "~4.5.5"
+ "phonegap-plugin-push": "^2.1.3"
},
"devDependencies": {
"bower": "^1.8.4",
diff --git a/www/js/DataModel.js b/www/js/DataModel.js
index 24aabd69..a92b5453 100644
--- a/www/js/DataModel.js
+++ b/www/js/DataModel.js
@@ -308,7 +308,8 @@ angular.module('zmApp.controllers')
var apiurl = loginData.apiurl;
var myurl = apiurl + '/configs/viewByName/ZM_MIN_STREAMING_PORT.json';
$http.get(myurl)
- .success(function (data) {
+ .then(function (data) {
+ data = data.data;
//console.log ("GOT " + JSON.stringify(data));
if (data.config && data.config.Value) {
@@ -324,8 +325,8 @@ angular.module('zmApp.controllers')
d.resolve(configParams.ZM_MIN_STREAMING_PORT);
return (d.promise);
- })
- .error(function (err) {
+ },
+ function (err) {
configParams.ZM_MIN_STREAMING_PORT = 0;
log("ZM_MIN_STREAMING_PORT not supported");
setCurrentServerMultiPortSupported(false);
@@ -1822,14 +1823,14 @@ angular.module('zmApp.controllers')
var myurl = apiurl + '/configs/viewByName/ZM_EVENT_IMAGE_DIGITS.json';
debug("Config URL for digits is:" + myurl);
$http.get(myurl)
- .success(function (data) {
+ .then(function (data) {
+ data = data.data;
log("ZM_EVENT_IMAGE_DIGITS is " + data.config.Value);
configParams.ZM_EVENT_IMAGE_DIGITS = data.config.Value;
d.resolve(configParams.ZM_EVENT_IMAGE_DIGITS);
return (d.promise);
- })
- .error(function (err) {
+ },function (err) {
log("Error retrieving ZM_EVENT_IMAGE_DIGITS" + JSON.stringify(err), "error");
log("Taking a guess, setting ZM_EVENT_IMAGE_DIGITS to 5");
// FIXME: take a plunge and keep it at 5?
@@ -1857,12 +1858,13 @@ angular.module('zmApp.controllers')
var myurl = apiurl + '/configs/viewByName/ZM_PATH_ZMS.json';
debug("Config URL for ZMS PATH is:" + myurl);
$http.get(myurl)
- .success(function (data) {
+ .then(function (data) {
+ data = data.data;
configParams.ZM_PATH_ZMS = data.config.Value;
d.resolve(configParams.ZM_PATH_ZMS);
return (d.promise);
- })
- .error(function (error) {
+ },
+ function (error) {
log("Can't retrieving ZM_PATH_ZMS: " + JSON.stringify(error));
d.resolve("");
return (d.promise);
@@ -2049,8 +2051,9 @@ angular.module('zmApp.controllers')
debug("ZMS Multiport reported: " + zmsPort);
debug("Monitor URL to fetch is:" + myurl);
$http.get(myurl /*,{timeout:15000}*/ )
- .success(function (data) {
+ .then(function (data) {
// console.log("HTTP success got " + JSON.stringify(data.monitors));
+ data = data.data;
monitors = data.monitors;
@@ -2069,7 +2072,8 @@ angular.module('zmApp.controllers')
debug("Inside getMonitors, will also regen connkeys");
debug("Now trying to get multi-server data, if present");
$http.get(apiurl + "/servers.json")
- .success(function (data) {
+ .then(function (data) {
+ data = data.data;
// We found a server list API, so lets make sure
// we get the hostname as it will be needed for playback
log("multi server list loaded" + JSON.stringify(data));
@@ -2241,8 +2245,8 @@ angular.module('zmApp.controllers')
// now get packery hide if applicable
reloadMonitorDisplayStatus();
d.resolve(monitors);
- })
- .error(function (err) {
+ },
+ function (err) {
log("multi server list loading error");
multiservers = [];
@@ -2285,8 +2289,8 @@ angular.module('zmApp.controllers')
$ionicLoading.hide();
log("Monitor load was successful, loaded " + monitors.length + " monitors");
- })
- .error(function (err) {
+ },
+ function (err) {
//console.log("HTTP Error " + err);
log("Monitor load failed " + JSON.stringify(err), "error");
// To keep it simple for now, I'm translating an error
@@ -2322,7 +2326,8 @@ angular.module('zmApp.controllers')
$http({
url: myurl,
method: 'GET',
- transformResponse: undefined
+ transformResponse: undefined,
+ responseType:'text',
})
// $http.get(myurl)
.then(function (textsucc) {
@@ -2521,14 +2526,15 @@ angular.module('zmApp.controllers')
//var myurl = (monitorId == 0) ? apiurl + "/events.json?page=1" : apiurl + "/events/index/MonitorId:" + monitorId + ".json?page=1";
var d = $q.defer();
$http.get(myurl)
- .success(function (data) {
+ .then(function (data) {
+ data = data.data;
$ionicLoading.hide();
//console.log ("**** EVENTS PAGES I GOT "+JSON.stringify(data));
//console.log("**** PAGE COUNT IS " + data.pagination.pageCount);
d.resolve(data.pagination);
return d.promise;
- })
- .error(function (error) {
+ },
+ function (error) {
$ionicLoading.hide();
// console.log("*** ERROR GETTING TOTAL PAGES ***");
log("Error retrieving page count of events " + JSON.stringify(error), "error");
@@ -2598,7 +2604,8 @@ angular.module('zmApp.controllers')
//console.log (">>>>>Constructed URL " + myurl);
$http.get(myurl /*,{timeout:15000}*/ )
- .success(function (data) {
+ .then(function (data) {
+ data = data.data;
if (loadingStr != 'none') $ionicLoading.hide();
//myevents = data.events;
myevents = data.events.reverse();
@@ -2610,8 +2617,8 @@ angular.module('zmApp.controllers')
d.resolve(myevents);
return d.promise;
- })
- .error(function (err) {
+ },
+ function (err) {
if (loadingStr != 'none') $ionicLoading.hide();
displayBanner('error', ['error retrieving event list', 'please try again']);
//console.log("HTTP Events error " + err);
@@ -2863,7 +2870,8 @@ angular.module('zmApp.controllers')
debug("Logging out using API method");
$http.get(loginData.apiurl + '/host/logout.json', {
timeout: 7000,
- transformResponse: undefined
+ transformResponse: undefined,
+ responseType:'text',
})
.then(function (s) {
debug("Logout returned... ");
diff --git a/www/js/EventCtrl.js b/www/js/EventCtrl.js
index 0d825eb4..8ce922e3 100644
--- a/www/js/EventCtrl.js
+++ b/www/js/EventCtrl.js
@@ -257,8 +257,8 @@ angular.module('zmApp.controllers')
var apiurl = NVRDataModel.getLogin().apiurl + '/events/' + eid + '.json';
$http.get(apiurl)
- .success(function (data) {})
- .error(function (err) {});
+ .then(function (data) {},
+ function (err) {});
}
@@ -1655,7 +1655,8 @@ angular.module('zmApp.controllers')
return $http.delete(apiDelete)
- .success(function (data) {
+ .then(function (data) {
+ data = data.data;
$ionicLoading.hide();
NVRDataModel.debug("delete output: " + JSON.stringify(data));
@@ -1685,8 +1686,8 @@ angular.module('zmApp.controllers')
//doRefresh();
- })
- .error(function (data) {
+ },
+ function (data) {
$ionicLoading.hide();
NVRDataModel.debug("delete error: " + JSON.stringify(data));
NVRDataModel.displayBanner('error', [$translate.instant('kDeleteEventError1'), $translate.instant('kDeleteEventError2')]);
@@ -1764,7 +1765,8 @@ angular.module('zmApp.controllers')
NVRDataModel.debug("consoleEvents API:" + apiurl);
$http.get(apiurl)
- .success(function (data) {
+ .then(function (data) {
+ data = data.data;
NVRDataModel.debug(JSON.stringify(data));
$scope.hours = [];
var p = data.results;
@@ -1799,7 +1801,8 @@ angular.module('zmApp.controllers')
apiurl = ld.apiurl + "/events/consoleEvents/1%20day" + af + ".json";
NVRDataModel.debug("consoleEvents API:" + apiurl);
$http.get(apiurl)
- .success(function (data) {
+ .then(function (data) {
+ data = data.data;
NVRDataModel.debug(JSON.stringify(data));
$scope.days = [];
var p = data.results;
@@ -1831,7 +1834,8 @@ angular.module('zmApp.controllers')
apiurl = ld.apiurl + "/events/consoleEvents/1%20week" + af + ".json";
NVRDataModel.debug("consoleEvents API:" + apiurl);
$http.get(apiurl)
- .success(function (data) {
+ .then(function (data) {
+ data = data.data;
NVRDataModel.debug(JSON.stringify(data));
$scope.weeks = [];
var p = data.results;
@@ -1864,7 +1868,8 @@ angular.module('zmApp.controllers')
apiurl = ld.apiurl + "/events/consoleEvents/1%20month" + af + ".json";
NVRDataModel.debug("consoleEvents API:" + apiurl);
$http.get(apiurl)
- .success(function (data) {
+ .then(function (data) {
+ data = data.data;
NVRDataModel.debug(JSON.stringify(data));
$scope.months = [];
var p = data.results;
@@ -2035,7 +2040,8 @@ angular.module('zmApp.controllers')
var myurl = loginData.apiurl + '/events/' + event.Event.Id + ".json";
NVRDataModel.log("API for event details" + myurl);
$http.get(myurl)
- .success(function (data) {
+ .then(function (data) {
+ data = data.data;
$scope.FrameArray = data.event.Frame;
// $scope.slider_options.scale=[];
@@ -2070,8 +2076,8 @@ angular.module('zmApp.controllers')
oldEvent = event;
//console.log (JSON.stringify(data));
- })
- .error(function (err) {
+ },
+ function (err) {
NVRDataModel.log("Error retrieving detailed frame API " + JSON.stringify(err));
NVRDataModel.displayBanner('error', ['could not retrieve frame details', 'please try again']);
});
@@ -2147,7 +2153,8 @@ angular.module('zmApp.controllers')
var myurl_frames = loginData.apiurl + '/events/' + event.Event.Id + ".json";
NVRDataModel.log("API for event details" + myurl_frames);
$http.get(myurl_frames)
- .success(function (data) {
+ .then(function (data) {
+ data = data.data;
$scope.FrameArray = data.event.Frame;
// $scope.slider_options.scale=[];
@@ -2166,8 +2173,8 @@ angular.module('zmApp.controllers')
}
//console.log (JSON.stringify(data));
- })
- .error(function (err) {
+ },
+ function (err) {
NVRDataModel.log("Error retrieving detailed frame API " + JSON.stringify(err));
NVRDataModel.displayBanner('error', [$translate.instant('kErrorFrameBanner'), $translate.instant('kErrorPleaseTryAgain')]);
});
@@ -2208,7 +2215,8 @@ angular.module('zmApp.controllers')
var myurl2 = loginData.apiurl + '/events/' + event.Event.Id + ".json";
NVRDataModel.log("API for event details" + myurl2);
$http.get(myurl2)
- .success(function (data) {
+ .then(function (data) {
+ data = data.data;
$scope.FrameArray = data.event.Frame;
// $scope.slider_options.scale=[];
$scope.slider_options.scale = [];
@@ -2229,8 +2237,8 @@ angular.module('zmApp.controllers')
}
//console.log (JSON.stringify(data));
- })
- .error(function (err) {
+ },
+ function (err) {
NVRDataModel.log("Error retrieving detailed frame API " + JSON.stringify(err));
NVRDataModel.displayBanner('error', [$translate.instant('kErrorFrameBanner'), $translate.instant('kErrorPleaseTryAgain')]);
});
diff --git a/www/js/EventModalCtrl.js b/www/js/EventModalCtrl.js
index 32d89b87..422b66b9 100644
--- a/www/js/EventModalCtrl.js
+++ b/www/js/EventModalCtrl.js
@@ -402,9 +402,10 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro
// pass: loginData.password
}
})
- .success(function (resp) {
+ .then(function (resp) {
// NVRDataModel.debug ("processEvent success:"+JSON.stringify(resp));
+ resp = resp.data;
if (resp.result == "Ok") {
if (resp.status) $scope.currentProgress.progress = resp.status.progress;
@@ -439,8 +440,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro
NVRDataModel.debug("so I'm regenerating Connkey to " + $scope.connKey);*/
}
- })
- .error(function (resp) {
+ },
+ function (resp) {
NVRDataModel.debug("processEvent error:" + JSON.stringify(resp));
//eventQueryHandle = $timeout (function(){checkEvent();}, zm.eventPlaybackQuery);
@@ -1547,7 +1548,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro
});
return $http.delete(apiDelete)
- .success(function (data) {
+ .then(function (data) {
+ data = data.data;
$ionicLoading.hide();
// NVRDataModel.debug("delete output: " + JSON.stringify(data));
@@ -1577,8 +1579,8 @@ angular.module('zmApp.controllers').controller('EventModalCtrl', ['$scope', '$ro
//doRefresh();
- })
- .error(function (data) {
+ },
+ function (data) {
$ionicLoading.hide();
NVRDataModel.debug("delete error: " + JSON.stringify(data));
NVRDataModel.displayBanner('error', [$translate.instant('kDeleteEventError1'), $translate.instant('kDeleteEventError2')]);
diff --git a/www/js/EventsGraphsCtrl.js b/www/js/EventsGraphsCtrl.js
index bfffb351..cad2cc0b 100644
--- a/www/js/EventsGraphsCtrl.js
+++ b/www/js/EventsGraphsCtrl.js
@@ -190,12 +190,13 @@ angular.module('zmApp.controllers').controller('zmApp.EventsGraphsCtrl', ['$ioni
// console.log("Monitor event URL:" + url);
NVRDataModel.log("EventGraph: composed url is " + url);
$http.get(url /*,{timeout:15000}*/ )
- .success(function (data) {
+ .then(function (data) {
+ data = data.data;
NVRDataModel.debug("Event count for monitor" +
monitors[j].Monitor.Id + " is " + data.pagination.count);
$scope.chart.data.datasets[0].data[j] = data.pagination.count;
- })
- .error(function (data) {
+ },
+ function (data) {
// ideally I should be treating it as an error
// but what I am really doing now is treating it like no events
// works but TBD: make this into a proper error handler
diff --git a/www/js/LoginCtrl.js b/www/js/LoginCtrl.js
index 9410b276..d7548258 100644
--- a/www/js/LoginCtrl.js
+++ b/www/js/LoginCtrl.js
@@ -672,8 +672,9 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r
NVRDataModel.log("Validating APIs at " + apiurl);
$http.get(apiurl)
- .success(function (data) {
+ .then(function (data) {
+ data = data.data;
NVRDataModel.getTimeZone(true);
var loginStatus = $translate.instant('kExploreEnjoy') + " " + $rootScope.appName + "!";
EventServer.refresh();
@@ -688,7 +689,8 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r
NVRDataModel.log("ZM relative cgi-path: " + zm_cgi + ", you entered: " + user_cgi);
$http.get(ld.streamingurl + "/zms")
- .success(function (data) {
+ .then(function (data) {
+ data = data.data;
NVRDataModel.debug("Urk! cgi-path returned success, but it should not have come here");
loginStatus = $translate.instant('kLoginStatusNoCgi');
@@ -717,8 +719,8 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r
});
}
- })
- .error(function (error, status) {
+ },
+ function (error, status) {
// If its 5xx, then the cgi-bin path is valid
// if its 4xx then the cgi-bin path is not valid
@@ -757,8 +759,8 @@ angular.module('zmApp.controllers').controller('zmApp.LoginCtrl', ['$scope', '$r
});
});
- })
- .error(function (error) {
+ },
+ function (error) {
NVRDataModel.displayBanner('error', [$translate.instant('kBannerAPICheckFailed'), $translate.instant('kBannerPleaseCheck')]);
NVRDataModel.log("API login error " + JSON.stringify(error));
diff --git a/www/js/MenuController.js b/www/js/MenuController.js
index 995abba3..8de4aeb3 100644
--- a/www/js/MenuController.js
+++ b/www/js/MenuController.js
@@ -119,8 +119,9 @@ angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$io
NVRDataModel.log("Validating APIs at " + apiurl);
$http.get(apiurl)
- .success(function (data) {
+ .then(function (data) {
+ data = data.data;
NVRDataModel.getTimeZone(true);
var loginStatus = $translate.instant('kExploreEnjoy') + " " + $rootScope.appName + "!";
EventServer.refresh();
@@ -135,7 +136,8 @@ angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$io
NVRDataModel.log("ZM relative cgi-path: " + zm_cgi + ", you entered: " + user_cgi);
$http.get(ld.streamingurl + "/zms")
- .success(function (data) {
+ .then(function (data) {
+ data = data.data;
NVRDataModel.debug("Urk! cgi-path returned success, but it should not have come here");
loginStatus = $translate.instant('kLoginStatusNoCgi');
@@ -183,8 +185,8 @@ angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$io
});
- })
- .error(function (error, status) {
+ },
+ function (error, status) {
// If its 5xx, then the cgi-bin path is valid
// if its 4xx then the cgi-bin path is not valid
@@ -233,8 +235,8 @@ angular.module('zmApp.controllers').controller('MenuController', ['$scope', '$io
});
});
- })
- .error(function (error) {
+ },
+ function (error) {
NVRDataModel.displayBanner('error', [$translate.instant('kBannerAPICheckFailed'), $translate.instant('kBannerPleaseCheck')]);
NVRDataModel.log("API login error " + JSON.stringify(error));
diff --git a/www/js/MonitorCtrl.js b/www/js/MonitorCtrl.js
index 38bdf765..881d6a2c 100644
--- a/www/js/MonitorCtrl.js
+++ b/www/js/MonitorCtrl.js
@@ -181,10 +181,10 @@ angular.module('zmApp.controllers')
}
})
- .success(function () {
+ .then(function () {
NVRDataModel.debug("MonitorCtrl: Not restarting ZM - Make sure you have the patch installed in MonitorsController.php or this won't work");
- })
- .error(function (data, status, headers, config) {
+ },
+ function (data, status, headers, config) {
NVRDataModel.debug("MonitorCtrl: Error changing monitor " + JSON.stringify(data));
$scope.monfunc.myfailedIds.push(item);
});
@@ -419,7 +419,8 @@ angular.module('zmApp.controllers')
NVRDataModel.debug("MonitorCtrl:monitorStateCheck: " + apiMonCheck);
//console.log("**** ZMC CHECK " + apiMonCheck);
$http.get(apiMonCheck)
- .success(function (data) {
+ .then(function (data) {
+ data = data.data;
NVRDataModel.debug("MonitorCtrl: monitor check state returned: " + JSON.stringify(data));
if (data.statustext.indexOf("not running") > -1) {
$scope.monitors[j].Monitor.isRunning = "false";
@@ -438,8 +439,8 @@ angular.module('zmApp.controllers')
}
$scope.monitors[j].Monitor.isRunningText = data.statustext;
- })
- .error(function (data) {
+ },
+ function (data) {
NVRDataModel.debug("MonitorCtrl: Error->monitor check state returned: " +
JSON.stringify(data));
NVRDataModel.displayBanner('error', [$translate.instant('kErrorRetrievingState'), $translate.instant('kPleaseTryAgain')]);
diff --git a/www/js/MonitorModalCtrl.js b/www/js/MonitorModalCtrl.js
index fe8f822d..5bb8952a 100644
--- a/www/js/MonitorModalCtrl.js
+++ b/www/js/MonitorModalCtrl.js
@@ -853,17 +853,18 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$
});
- req.success(function (resp) {
+ req.then(function (resp) {
//console.log("SUCCESS: " + JSON.stringify(resp));
$ionicLoading.hide();
- });
-
- req.error(function (resp) {
+ },
+ function (resp) {
$ionicLoading.hide();
//console.log("ERROR: " + JSON.stringify(resp));
NVRDataModel.log("Error sending PTZ:" + JSON.stringify(resp), "error");
});
+
+
}
$scope.getZoomLevel = function () {
@@ -1446,14 +1447,16 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$
}
});
- req.success(function (resp) {
+ req.then(function (resp) {
+ resp = resp.data;
if (resp.result == "Ok" && ndx != -1) {
var ld = NVRDataModel.getLogin();
var apiurl = ld.apiurl + "/events/" + resp.status.event + ".json";
//console.log ("API " + apiurl);
$http.get(apiurl)
- .success(function (data) {
+ .then(function (data) {
+ data = data.data;
if ($scope.MontageMonitors[ndx].eventUrlTime != data.event.Event.StartTime) {
var element = angular.element(document.getElementById($scope.MontageMonitors[ndx].Monitor.Id + "-timeline"));
@@ -1467,19 +1470,21 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$
}
- })
- .error(function (data) {
+ },
+ function (data) {
$scope.MontageMonitors[ndx].eventUrlTime = "-";
});
}
- });
+ },
- req.error(function (resp) {
+ function (resp) {
//console.log("ERROR: " + JSON.stringify(resp));
NVRDataModel.log("Error sending event command " + JSON.stringify(resp), "error");
});
+
+
}
$scope.toggleListMenu = function () {
@@ -1544,7 +1549,8 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$
var ld = NVRDataModel.getLogin();
var url = ld.apiurl + "/monitors/" + mid + ".json";
$http.get(url)
- .success(function (data) {
+ .then(function (data) {
+ data = data.data;
$scope.isControllable = data.monitor.Monitor.Controllable;
// *** Only for testing - comment out //
@@ -1559,8 +1565,8 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$
NVRDataModel.debug("configurePTZ : getting controllable data " + myurl);
$http.get(myurl)
- .success(function (data) {
-
+ .then(function (data) {
+ data = data.data;
// *** Only for testing - comment out - start//
/*data.Control.Control.CanSleep = '1';
data.Control.Control.CanWake = '1';
@@ -1722,8 +1728,8 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$
}
NVRDataModel.log("ConfigurePTZ Modal: ControlDB reports PTZ command to be " + $scope.ptzMoveCommand);
- })
- .error(function (data) {
+ },
+ function (data) {
// console.log("** Error retrieving move PTZ command");
NVRDataModel.log("ConfigurePTZ : Error retrieving PTZ command " + JSON.stringify(data), "error");
});
@@ -1731,8 +1737,8 @@ angular.module('zmApp.controllers').controller('MonitorModalCtrl', ['$scope', '$
} else {
NVRDataModel.log("configurePTZ " + mid + " is not PTZ controllable");
}
- })
- .error(function (data) {
+ },
+ function (data) {
// console.log("** Error retrieving move PTZ command");
NVRDataModel.log("configurePTZ : Error retrieving PTZ command " + JSON.stringify(data), "error");
});
diff --git a/www/js/NewsCtrl.js b/www/js/NewsCtrl.js
index 6be6aa0e..f18722d9 100644
--- a/www/js/NewsCtrl.js
+++ b/www/js/NewsCtrl.js
@@ -87,16 +87,19 @@ angular.module('zmApp.controllers').controller('zmApp.NewsCtrl', ['$scope', '$ro
$scope.newsItems = [];
- $http.get(zm.blogUrl, {
+ $http.get(zm.blogUrl/*, {
transformResponse: function (d, h) {
var trunc = "])}while(1);</x>";
d = d.substr(trunc.length);
return d;
}
- })
- .success(function (datastr) {
+ }*/)
+ .then(function (datastr) {
+ datastr = datastr.data;
+ var trunc = "])}while(1);</x>";
+ datastr= datastr.substr(trunc.length);
// console.log ("DATA:"+data);
//
var data = JSON.parse(datastr);
diff --git a/www/js/WizardCtrl.js b/www/js/WizardCtrl.js
index 6ce8ea1b..e6cfed4c 100644
--- a/www/js/WizardCtrl.js
+++ b/www/js/WizardCtrl.js
@@ -41,7 +41,8 @@ angular.module('zmApp.controllers').controller('zmApp.WizardCtrl', ['$scope', '$
view: "console"
}
})
- .success(function (data, status, headers) {
+ .then(function (data, status, headers) {
+ data = data.data;
//console.log("LOOKING FOR " + zm.loginScreenString);
//console.log("DATA RECEIVED " + JSON.stringify(data));
if (data.indexOf(zm.loginScreenString) == -1) {
@@ -58,8 +59,8 @@ angular.module('zmApp.controllers').controller('zmApp.WizardCtrl', ['$scope', '$
d.reject(false);
return d.promise;
}
- })
- .error(function (error) {
+ },
+ function (error) {
//console.log("************ERROR");
$scope.wizard.portalValidText = $translate.instant('kPortalDetectionFailed');
$scope.wizard.portalColor = "#e74c3c";
diff --git a/www/js/app.js b/www/js/app.js
index 97132a21..dfcade8f 100755
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -264,7 +264,6 @@ angular.module('zmApp', [
})
-
// credit https://gist.github.com/Zren/beaafd64f395e23f4604
.directive('mouseWheelScroll', function ($timeout) {
@@ -322,7 +321,7 @@ angular.module('zmApp', [
//console.log ("requestConfig is " + JSON.stringify(requestConfig));
imageLoadingDataShare.set(1);
$http(requestConfig)
- .success(function (data) {
+ .then(function (data) {
//console.log ("Inside HTTP after Calling " + requestConfig.url);
//console.log ("data got " + JSON.stringify(data));
@@ -763,6 +762,9 @@ angular.module('zmApp', [
NVRDataModel.setLastUpdateCheck(moment().toISOString());
// $localstorage.set("lastUpdateCheck", moment().toISOString());
//console.log ("FULL STRING " + success.data.tag_name);
+
+ // console.log ("^^^^^^^^^^^^^ GOT: " + JSON.stringify(success));
+
var res = success.data.tag_name.match("v(.*)");
zmUpdateVersion = res[1];
var currentVersion = NVRDataModel.getAppVersion();
@@ -792,7 +794,7 @@ angular.module('zmApp', [
}
})
- .success(function (datastr) {
+ .then(function (datastr) {
var data = JSON.parse(datastr);
$rootScope.newBlogPost = "";
@@ -1059,10 +1061,11 @@ angular.module('zmApp', [
$http({
- method:'POST',
+ method:'post',
url: loginAPI,
timeout:httpDelay,
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
+ responseType:'text',
transformResponse: undefined,
transformRequest: function(obj) {
var str = [];
@@ -1242,7 +1245,7 @@ angular.module('zmApp', [
//NVRDataModel.debug ("*** AUTH LOGIN URL IS " + loginData.url);
$http({
- method: 'POST',
+ method: 'post',
timeout: httpDelay,
//withCredentials: true,
url: loginData.url + '/index.php',
@@ -1266,8 +1269,9 @@ angular.module('zmApp', [
view: "console"
}
})
- .success(function (data, status, headers) {
+ .then(function (data, status, headers) {
// console.log(">>>>>>>>>>>>>> PARALLEL POST SUCCESS");
+ data = data.data;
$ionicLoading.hide();
// Coming here does not mean success
@@ -1324,8 +1328,8 @@ angular.module('zmApp', [
return (d.promise);
- })
- .error(function (error, status) {
+ },
+ function (error, status) {
// console.log(">>>>>>>>>>>>>> PARALLEL POST ERROR");
$ionicLoading.hide();
@@ -2255,6 +2259,202 @@ angular.module('zmApp', [
};
}]);
+
+ $provide.decorator('$http', ['$delegate', '$q', function($delegate, $q) {
+ // create function which overrides $http function
+ var $http = $delegate;
+
+ var wrapper = function () {
+
+
+
+ var url;
+ var method;
+
+ url = arguments[0].url;
+ method = arguments[0].method;
+
+
+
+ console.log ("+++++ IN WRAPPER WITH "+method+" for "+url);
+
+ var isOutgoingRequest = /^(http|https):\/\//.test(url);
+
+
+ if (window.cordova && isOutgoingRequest) {
+ console.log ("**** -->"+method+"<-- using native HTTP with:"+url);
+ console.log ("ARGUMENTS="+JSON.stringify(arguments));
+ var d = $q.defer();
+
+ var options = {
+ method: method,
+ data: arguments[0].data,
+ headers: arguments[0].headers,
+ timeout: arguments[0].timeout,
+ responseType: arguments[0].responseType
+
+ };
+
+ /* RGUMENTS={"0":{"method":"POST","timeout":7000,"url":"8889/zm/index.php","headers":{"Content-Type":"application/x-www-form-urlencoded","Accept":"application/json"},"data":{"action":"logout","view":"login"}}}*/
+
+ cordova.plugin.http.sendRequest(encodeURI(url),options,
+ function (succ) {
+ console.log ("*** Inside native HTTP success with:"+JSON.stringify(succ));
+
+ try {
+
+
+ if (options.responseType =='text')
+ d.resolve({"data":succ.data});
+ else
+ d.resolve({"data":JSON.parse(succ.data)});
+ return d.promise;
+
+ }
+ catch (e) {
+ d.resolve({"data":succ.data});
+ return d.promise;
+ }
+
+ },
+ function (err) {
+ console.log ("*** Inside native HTTP error");
+ d.reject(err);
+ return d.promise;
+ });
+ return d.promise;
+
+ }
+ else {
+ console.log ("**** "+method+" using XHR HTTP for "+url);
+ return $http.apply($http, arguments);
+ }
+
+
+ };
+
+ Object.keys($http).forEach( function (key) {
+
+ console.log ("----> "+key+" IS "+typeof($http[key]));
+ });
+
+
+
+ Object.keys($http).filter(function (key) {
+ return (typeof $http[key] === 'function');
+ }).forEach(function (key) {
+ wrapper[key] = function () {
+
+ // Apply global changes to arguments, or perform other
+ // nefarious acts.
+
+ // console.log ("KEY="+key);
+
+ return $http[key].apply($http, arguments);
+ };
+ });
+ console.log ("*** WRAPPING EASY");
+ $delegate.get = function (url,config) {
+
+ return wrapper(angular.extend(config || {}, {
+ method: 'get',
+ url: url
+ }));
+ };
+
+ $delegate.post = function (url,config) {
+
+ return wrapper(angular.extend(config || {}, {
+ method: 'post',
+ url: url
+ }));
+ };
+
+ $delegate.delete = function (url,config) {
+
+ return wrapper(angular.extend(config || {}, {
+ method: 'delete',
+ url: url
+ }));
+ };
+
+
+ return wrapper;
+
+/*
+ $delegate.post = function(args) {
+ var isOutgoingRequest = /^(http|https):\/\//.test(args);
+
+ if (window.cordova && isOutgoingRequest) {
+ console.log ("**** POST using native HTTP2 with:"+args);
+ console.log ("POST ARGUMENTS="+JSON.stringify(arguments));
+ var d = $q.defer();
+
+ var options = {
+ method: 'post',
+
+ };
+
+ cordova.plugin.http.sendRequest(args,options,
+ function (succ) {
+ console.log ("*** POST Inside native HTTP success");
+
+ d.resolve({"data":JSON.parse(succ.data)});
+ return d.promise;
+ },
+ function (err) {
+ console.log ("*** POST Inside native HTTP error");
+ d.reject(err);
+ return d.promise;
+ });
+ return d.promise;
+
+ }
+ else {
+ console.log ("**** POST using XHR HTTP with "+args);
+ return originalPost.apply(this, arguments);
+ }
+
+ };
+
+ $delegate.get = function(args) {
+ var isOutgoingRequest = /^(http|https):\/\//.test(args);
+ if (window.cordova && isOutgoingRequest) {
+ console.log ("**** using native HTTP2 with:"+args);
+ console.log ("ARGUMENTS="+JSON.stringify(arguments));
+ var d = $q.defer();
+
+ var options = {
+ method: 'get',
+
+ };
+
+ cordova.plugin.http.sendRequest(args,options,
+ function (succ) {
+ console.log ("*** GET Inside native HTTP success");
+
+ d.resolve({"data":JSON.parse(succ.data)});
+ return d.promise;
+ },
+ function (err) {
+ console.log ("*** GET Inside native HTTP error");
+ d.reject(err);
+ return d.promise;
+ });
+ return d.promise;
+
+ }
+ else {
+ console.log ("**** GET using XHR HTTP with:"+args);
+ return originalGet.apply(this, arguments);
+ }
+
+ };
+
+ return $delegate;
+ */
+ }]);
+
// If you do this, Allow Origin can't be *
$httpProvider.defaults.withCredentials = true;
$httpProvider.interceptors.push('timeoutHttpIntercept');