Skip to content

Commit

Permalink
Add testing and error pop ups where needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
bwssytems committed Oct 5, 2015
1 parent 1602ed0 commit c8fb93e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 36 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.bwssystems.HABridge</groupId>
<artifactId>ha-bridge</artifactId>
<version>0.4.6</version>
<version>0.4.7</version>
<packaging>jar</packaging>

<name>HA Bridge</name>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li><a href="http://www.bwssystems.com" target="_blank">Developed by BWS Systems</a></li>
<li><a href="http://www.amazon.com/echo" target="_blank">Amazon Echo</a></li>
<li><a href="">HA Bridge Version 0.4.6</a></li>
<li><a href="">HA Bridge Version 0.4.7</a></li>
</ul>
</li>
</ul>
Expand Down
63 changes: 29 additions & 34 deletions src/main/resources/public/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: ""};
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}
);
};
Expand All @@ -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);
}
);
};
Expand All @@ -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 {
Expand All @@ -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");
}
);
}
Expand All @@ -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");
}
);
};
Expand All @@ -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();
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit c8fb93e

Please sign in to comment.