From e8ec4001ce1297d5a3db6d3fc8af8de47daa6a61 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 25 Oct 2015 00:33:41 +0200 Subject: wip --- web/static/app/DillerRpc.js | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 web/static/app/DillerRpc.js (limited to 'web/static/app/DillerRpc.js') diff --git a/web/static/app/DillerRpc.js b/web/static/app/DillerRpc.js new file mode 100644 index 0000000..de90aee --- /dev/null +++ b/web/static/app/DillerRpc.js @@ -0,0 +1,43 @@ +function DillerRpc($http, DillerConfig) { + var baseUrl = DillerConfig.baseUrl; + + function getDevices() { + var req = {}; + req.method = 'get'; + req.url = baseUrl + '/api/device'; + return $http(req); + } + + function getDevice(deviceId) { + var req = {}; + req.method = 'get'; + req.url = baseUrl + '/api/device/:deviceId'; + req.url = req.url.replace(/:deviceId/, deviceId); + return $http(req); + } + + function getValues(propertyId) { + var req = {}; + req.method = 'get'; + req.url = baseUrl + '/api/property/:propertyId/values'; + req.url = req.url.replace(/:propertyId/, propertyId); + return $http(req); + } + + return { + getDevices: getDevices, + getDevice: getDevice, + getValues: getValues + }; +} + +DillerRpcResolve = {}; +DillerRpcResolve.getDevices = function(DillerRpc) { + return DillerRpc.getDevices(); +}; +DillerRpcResolve.getDevice = function(DillerRpc, $route) { + return DillerRpc.getDevice($route.current.params.deviceId); +}; +DillerRpcResolve.getValues = function(DillerRpc, $route) { + return DillerRpc.getValues($route.current.params.propertyId); +}; -- cgit v1.2.3