From c8fb93eeb69dd9b88c5018db14a3abf5eb717956 Mon Sep 17 00:00:00 2001 From: Admin Date: Mon, 5 Oct 2015 16:19:09 -0500 Subject: [PATCH] Add testing and error pop ups where needed. --- pom.xml | 2 +- src/main/resources/public/index.html | 2 +- src/main/resources/public/scripts/app.js | 63 +++++++++++------------- 3 files changed, 31 insertions(+), 36 deletions(-) diff --git a/pom.xml b/pom.xml index bb09aa3..7947834 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.bwssystems.HABridge ha-bridge - 0.4.6 + 0.4.7 jar HA Bridge diff --git a/src/main/resources/public/index.html b/src/main/resources/public/index.html index 35f7ca2..8822b29 100644 --- a/src/main/resources/public/index.html +++ b/src/main/resources/public/index.html @@ -36,7 +36,7 @@ diff --git a/src/main/resources/public/scripts/app.js b/src/main/resources/public/scripts/app.js index fcd4be6..74f36f0 100644 --- a/src/main/resources/public/scripts/app.js +++ b/src/main/resources/public/scripts/app.js @@ -72,7 +72,7 @@ app.factory('BridgeSettings', function() { return BridgeSettings; }); -app.service('bridgeService', function ($http, BridgeSettings) { +app.service('bridgeService', function ($http, $window, BridgeSettings) { var self = this; self.BridgeSettings = BridgeSettings; this.state = {base: window.location.origin + "/api/devices", upnpbase: window.location.origin + "/upnp/settings", devices: [], device: [], error: ""}; @@ -110,10 +110,9 @@ app.service('bridgeService', function ($http, BridgeSettings) { }, function (error) { if (error.data) { - self.state.error = error.data.message; + $window.alert("Load Bridge Settings Error: " + error.data.message); } else { - self.state.error = "If you're not seeing any settings, you may be running into problems with CORS. " + - "You can work around this by running a fresh launch of Chrome with the --disable-web-security flag."; + $window.alert("Load Bridge Settings Error: unknown"); } console.log(error); } @@ -128,12 +127,10 @@ app.service('bridgeService', function ($http, BridgeSettings) { }, function (error) { if (error.data) { - self.state.error = error.data.message; + $window.alert("Get Vera Devices Error: " + error.data.message); } else { - self.state.error = "If you're not seeing any address, you may be running into problems with CORS. " + - "You can work around this by running a fresh launch of Chrome with the --disable-web-security flag."; + $window.alert("Get Vera Devices Error: unknown"); } - console.log(error); } ); }; @@ -146,12 +143,10 @@ app.service('bridgeService', function ($http, BridgeSettings) { }, function (error) { if (error.data) { - self.state.error = error.data.message; + $window.alert("Get Vera Scenes Error: " + error.data.message); } else { - self.state.error = "If you're not seeing any address, you may be running into problems with CORS. " + - "You can work around this by running a fresh launch of Chrome with the --disable-web-security flag."; + $window.alert("Get Vera Scenes Error: unknown"); } - console.log(error); } ); }; @@ -176,9 +171,9 @@ app.service('bridgeService', function ($http, BridgeSettings) { }, function (error) { if (error.data) { - self.state.error = error.data.message; + $window.alert("Edit Device Error: " + error.data.message); } - console.log(error); + $window.alert("Edit Device Error: unknown"); } ); } else { @@ -199,9 +194,9 @@ app.service('bridgeService', function ($http, BridgeSettings) { }, function (error) { if (error.data) { - self.state.error = error.data.message; + $window.alert("Add new Device Error: " + error.data.message); } - console.log(error); + $window.alert("Add new Device Error: unknown"); } ); } @@ -217,7 +212,7 @@ app.service('bridgeService', function ($http, BridgeSettings) { if (error.data) { self.state.error = error.data.message; } - console.log(error); + $window.alert("Delete Device Error: unknown"); } ); }; @@ -227,7 +222,7 @@ app.service('bridgeService', function ($http, BridgeSettings) { }; }); -app.controller('ViewingController', function ($scope, $location, $http, bridgeService, BridgeSettings) { +app.controller('ViewingController', function ($scope, $location, $http, $window, bridgeService, BridgeSettings) { $scope.BridgeSettings = bridgeService.BridgeSettings; bridgeService.viewDevices(); @@ -246,19 +241,19 @@ app.controller('ViewingController', function ($scope, $location, $http, bridgeSe if(device.httpVerb == "PUT") $http.put(device.onUrl, device.contentBody).then( function (response) { - $scope.responsedata = response.data; + $window.alert("Request Exceuted: " + response.statusText); }, function (error) { - console.log(error); + $window.alert("Request Error: " + error.data.message); } ); else if(device.httpVerb == "POST") $http.post(device.onUrl, device.contentBody).then( function (response) { - $scope.responsedata = response.data; + $window.alert("Request Exceuted: " + response.statusText); }, function (error) { - console.log(error); + $window.alert("Request Error: " + error.data.message); } ); else @@ -268,19 +263,19 @@ app.controller('ViewingController', function ($scope, $location, $http, bridgeSe if(device.httpVerb == "PUT") $http.put(device.offUrl, device.contentBodyOff).then( function (response) { - $scope.responsedata = response.data; + $window.alert("Request Exceuted: " + response.statusText); }, function (error) { - console.log(error); + $window.alert("Request Error: " + error.data.message); } ); else if(device.httpVerb == "POST") $http.post(device.offUrl, device.contentBody).then( function (response) { - $scope.responsedata = response.data; + $window.alert("Request Exceuted: " + response.statusText); }, function (error) { - console.log(error); + $window.alert("Request Error: " + error.data.message); } ); else @@ -372,19 +367,19 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer if(device.httpVerb == "PUT") $http.put(device.onUrl, device.contentBody).then( function (response) { - $scope.responsedata = response.data; + $window.alert("Request Exceuted: " + response.statusText); }, function (error) { - console.log(error); + $window.alert("Request Error: " + error.data.message); } ); else if(device.httpVerb == "POST") $http.post(device.onUrl, device.contentBody).then( function (response) { - $scope.responsedata = response.data; + $window.alert("Request Exceuted: " + response.statusText); }, function (error) { - console.log(error); + $window.alert("Request Error: " + error.data.message); } ); else @@ -394,19 +389,19 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer if(device.httpVerb == "PUT") $http.put(device.offUrl, device.contentBodyOff).then( function (response) { - $scope.responsedata = response.data; + $window.alert("Request Exceuted: " + response.statusText); }, function (error) { - console.log(error); + $window.alert("Request Error: " + error.data.message); } ); else if(device.httpVerb == "POST") $http.post(device.offUrl, device.contentBody).then( function (response) { - $scope.responsedata = response.data; + $window.alert("Request Exceuted: " + response.statusText); }, function (error) { - console.log(error); + $window.alert("Request Error: " + error.data.message); } ); else