mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-19 00:20:26 +00:00
Updated test methods for special PUT/POST calls. Cleaned up device.db
file write to not keep junk around.
This commit is contained in:
@@ -182,6 +182,8 @@ app.service('bridgeService', function ($http, BridgeSettings) {
|
||||
}
|
||||
);
|
||||
} else {
|
||||
if(type == null || type == "")
|
||||
type = "switch";
|
||||
return $http.post(this.state.base, {
|
||||
name: name,
|
||||
deviceType: type,
|
||||
@@ -241,14 +243,46 @@ app.controller('ViewingController', function ($scope, $location, $http, bridgeSe
|
||||
};
|
||||
$scope.testUrl = function (device, type) {
|
||||
if(type == "on") {
|
||||
if(device.httpVerb == "PUT" || device.httpVerb == "POST")
|
||||
$http.put(device.onUrl, device.contentBody);
|
||||
if(device.httpVerb == "PUT")
|
||||
$http.put(device.onUrl, device.contentBody).then(
|
||||
function (response) {
|
||||
$scope.responsedata = response.data;
|
||||
},
|
||||
function (error) {
|
||||
console.log(error);
|
||||
}
|
||||
);
|
||||
else if(device.httpVerb == "POST")
|
||||
$http.post(device.onUrl, device.contentBody).then(
|
||||
function (response) {
|
||||
$scope.responsedata = response.data;
|
||||
},
|
||||
function (error) {
|
||||
console.log(error);
|
||||
}
|
||||
);
|
||||
else
|
||||
window.open(device.onUrl, "_blank");
|
||||
}
|
||||
else {
|
||||
if(device.httpVerb == "PUT" || device.httpVerb == "POST")
|
||||
$http.put(device.offUrl, device.contentBodyOff);
|
||||
if(device.httpVerb == "PUT")
|
||||
$http.put(device.offUrl, device.contentBodyOff).then(
|
||||
function (response) {
|
||||
$scope.responsedata = response.data;
|
||||
},
|
||||
function (error) {
|
||||
console.log(error);
|
||||
}
|
||||
);
|
||||
else if(device.httpVerb == "POST")
|
||||
$http.post(device.offUrl, device.contentBody).then(
|
||||
function (response) {
|
||||
$scope.responsedata = response.data;
|
||||
},
|
||||
function (error) {
|
||||
console.log(error);
|
||||
}
|
||||
);
|
||||
else
|
||||
window.open(device.offUrl, "_blank");
|
||||
}
|
||||
@@ -335,14 +369,46 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer
|
||||
|
||||
$scope.testUrl = function (url) {
|
||||
if(type == "on") {
|
||||
if(device.httpVerb == "PUT" || device.httpVerb == "POST")
|
||||
$http.put(device.onUrl, device.contentBody);
|
||||
if(device.httpVerb == "PUT")
|
||||
$http.put(device.onUrl, device.contentBody).then(
|
||||
function (response) {
|
||||
$scope.responsedata = response.data;
|
||||
},
|
||||
function (error) {
|
||||
console.log(error);
|
||||
}
|
||||
);
|
||||
else if(device.httpVerb == "POST")
|
||||
$http.post(device.onUrl, device.contentBody).then(
|
||||
function (response) {
|
||||
$scope.responsedata = response.data;
|
||||
},
|
||||
function (error) {
|
||||
console.log(error);
|
||||
}
|
||||
);
|
||||
else
|
||||
window.open(device.onUrl, "_blank");
|
||||
}
|
||||
else {
|
||||
if(device.httpVerb == "PUT" || device.httpVerb == "POST")
|
||||
$http.put(device.offUrl, device.contentBodyOff);
|
||||
if(device.httpVerb == "PUT")
|
||||
$http.put(device.offUrl, device.contentBodyOff).then(
|
||||
function (response) {
|
||||
$scope.responsedata = response.data;
|
||||
},
|
||||
function (error) {
|
||||
console.log(error);
|
||||
}
|
||||
);
|
||||
else if(device.httpVerb == "POST")
|
||||
$http.post(device.offUrl, device.contentBody).then(
|
||||
function (response) {
|
||||
$scope.responsedata = response.data;
|
||||
},
|
||||
function (error) {
|
||||
console.log(error);
|
||||
}
|
||||
);
|
||||
else
|
||||
window.open(device.offUrl, "_blank");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user