aboutsummaryrefslogtreecommitdiff
path: root/web/app/DillerRpc.js
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-10-20 23:18:16 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2015-10-20 23:18:16 +0200
commit0266bdd60cb9cccf20a5ded3eba72ea833bee72d (patch)
treed727bad80aeaef673f48bbbc171fb4e9297b72fc /web/app/DillerRpc.js
parent73d272ffe8954b3169901eda74428bad3d2740fe (diff)
downloaddiller-server-0266bdd60cb9cccf20a5ded3eba72ea833bee72d.tar.gz
diller-server-0266bdd60cb9cccf20a5ded3eba72ea833bee72d.tar.bz2
diller-server-0266bdd60cb9cccf20a5ded3eba72ea833bee72d.tar.xz
diller-server-0266bdd60cb9cccf20a5ded3eba72ea833bee72d.zip
o Adding a webapp.
o Using di.js as dependency injection framework.
Diffstat (limited to 'web/app/DillerRpc.js')
-rw-r--r--web/app/DillerRpc.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/web/app/DillerRpc.js b/web/app/DillerRpc.js
new file mode 100644
index 0000000..a0c20fb
--- /dev/null
+++ b/web/app/DillerRpc.js
@@ -0,0 +1,41 @@
+function DillerRpc($http) {
+ function getDevices() {
+ var req = {};
+ req.method = 'get';
+ req.url = '/api/device';
+ return $http(req);
+ }
+
+ function getDevice(deviceId) {
+ var req = {};
+ req.method = 'get';
+ req.url = '/api/device/:deviceId';
+ req.url = req.url.replace(/:deviceId/, deviceId);
+ return $http(req);
+ }
+
+ function getValues(propertyId) {
+ var req = {};
+ req.method = 'get';
+ req.url = '/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);
+};