aboutsummaryrefslogtreecommitdiff
path: root/web/static/app/DillerRpc.js
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-10-25 00:33:41 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2015-10-25 01:47:52 +0200
commite8ec4001ce1297d5a3db6d3fc8af8de47daa6a61 (patch)
tree839d9c1da0c2b1db539c104d9aacc8c8e62a3dcd /web/static/app/DillerRpc.js
parent0266bdd60cb9cccf20a5ded3eba72ea833bee72d (diff)
downloaddiller-server-e8ec4001ce1297d5a3db6d3fc8af8de47daa6a61.tar.gz
diller-server-e8ec4001ce1297d5a3db6d3fc8af8de47daa6a61.tar.bz2
diller-server-e8ec4001ce1297d5a3db6d3fc8af8de47daa6a61.tar.xz
diller-server-e8ec4001ce1297d5a3db6d3fc8af8de47daa6a61.zip
wip
Diffstat (limited to 'web/static/app/DillerRpc.js')
-rw-r--r--web/static/app/DillerRpc.js43
1 files changed, 43 insertions, 0 deletions
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);
+};