mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-19 00:20:26 +00:00
Updated persistence
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
angular.module('amazonechobridge', [])
|
||||
.service('bridgeService', ["$http", function ($http) {
|
||||
var self = this;
|
||||
this.state = {base: window.location.origin + "/api/devices/", devices: [], error: ""};
|
||||
this.state = {base: window.location.origin + "/api/devices", upnpbase: window.location.origin + "/upnp/configaddress", devices: [], error: ""};
|
||||
|
||||
this.viewDevices = function () {
|
||||
this.state.error = "";
|
||||
@@ -21,6 +21,24 @@ angular.module('amazonechobridge', [])
|
||||
);
|
||||
};
|
||||
|
||||
this.viewConfigAddress = function () {
|
||||
this.state.error = "";
|
||||
return $http.get(this.state.upnpbase).then(
|
||||
function (response) {
|
||||
self.state.upnpconfigaddress = response.data;
|
||||
},
|
||||
function (error) {
|
||||
if (error.data) {
|
||||
self.state.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.";
|
||||
}
|
||||
console.log(error);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
this.addDevice = function (id, name, type, onUrl, offUrl) {
|
||||
this.state.error = "";
|
||||
if (id) {
|
||||
@@ -87,6 +105,7 @@ angular.module('amazonechobridge', [])
|
||||
|
||||
.controller('ViewingController', ["$scope", "bridgeService", function ($scope, bridgeService) {
|
||||
bridgeService.viewDevices();
|
||||
bridgeService.viewConfigAddress();
|
||||
$scope.bridge = bridgeService.state;
|
||||
$scope.deleteDevice = function (device) {
|
||||
bridgeService.deleteDevice(device.id);
|
||||
|
||||
Reference in New Issue
Block a user