aboutsummaryrefslogtreecommitdiff
path: root/web/static/app/app.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/app.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/app.js')
-rw-r--r--web/static/app/app.js72
1 files changed, 72 insertions, 0 deletions
diff --git a/web/static/app/app.js b/web/static/app/app.js
new file mode 100644
index 0000000..5274362
--- /dev/null
+++ b/web/static/app/app.js
@@ -0,0 +1,72 @@
+(function () {
+ function FrontPageController(devices) {
+ var ctrl = this;
+
+ ctrl.devices = devices.data.devices;
+ }
+
+ function DeviceController(device) {
+ var ctrl = this;
+
+ ctrl.device = device.data.device;
+ }
+
+ function PropertyController($route, device, values) {
+ var ctrl = this;
+
+ ctrl.device = device.data.device;
+ ctrl.property = _.find(ctrl.device.properties, {id: $route.current.params.propertyId});
+ ctrl.values = values.data.values;
+ }
+
+ function config($routeProvider, $locationProvider) {
+ $routeProvider
+ .when('/', {
+ controller: FrontPageController,
+ controllerAs: 'ctrl',
+ templateUrl: 'app/templates/front-page.html',
+ resolve: {
+ devices: DillerRpcResolve.getDevices
+ }
+ })
+ .when('/device/:deviceId', {
+ controller: DeviceController,
+ controllerAs: 'ctrl',
+ templateUrl: 'app/templates/device.html',
+ resolve: {
+ device: DillerRpcResolve.getDevice
+ }
+ })
+ .when('/device/:deviceId/property/:propertyId', {
+ controller: PropertyController,
+ controllerAs: 'ctrl',
+ templateUrl: 'app/templates/property.html',
+ resolve: {
+ device: DillerRpcResolve.getDevice,
+ values: DillerRpcResolve.getValues
+ }
+ })
+ .otherwise({
+ redirectTo: '/'
+ });
+
+ //$locationProvider.html5Mode(true);
+ }
+
+ function DillerConfig() {
+ var head = document.getElementsByTagName('head')[0];
+ var base = head.getElementsByTagName('base')[0];
+ console.log('base =', base);
+ var baseUrl = base.href.replace(/\/$/, '');
+ console.log('baseUrl =', baseUrl);
+ return {
+ baseUrl: baseUrl
+ };
+ }
+
+ angular
+ .module('Diller', ['ngRoute'])
+ .config(config)
+ .service('DillerConfig', DillerConfig)
+ .service('DillerRpc', DillerRpc);
+})();