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/app/DillerRpc.js | 41 ------------------ web/app/app.js | 60 -------------------------- web/app/templates/device.html | 21 ---------- web/app/templates/front-page.html | 24 ----------- web/app/templates/property.html | 36 ---------------- web/index.html | 24 ----------- web/static/app/DillerRpc.js | 43 +++++++++++++++++++ web/static/app/app.css | 3 ++ web/static/app/app.js | 72 ++++++++++++++++++++++++++++++++ web/static/app/templates/device.html | 34 +++++++++++++++ web/static/app/templates/front-page.html | 23 ++++++++++ web/static/app/templates/property.html | 42 +++++++++++++++++++ web/templates/index.jade | 52 +++++++++++++++++++++++ web/templates/wat.html | 25 +++++++++++ 14 files changed, 294 insertions(+), 206 deletions(-) delete mode 100644 web/app/DillerRpc.js delete mode 100644 web/app/app.js delete mode 100644 web/app/templates/device.html delete mode 100644 web/app/templates/front-page.html delete mode 100644 web/app/templates/property.html delete mode 100644 web/index.html create mode 100644 web/static/app/DillerRpc.js create mode 100644 web/static/app/app.css create mode 100644 web/static/app/app.js create mode 100644 web/static/app/templates/device.html create mode 100644 web/static/app/templates/front-page.html create mode 100644 web/static/app/templates/property.html create mode 100644 web/templates/index.jade create mode 100644 web/templates/wat.html (limited to 'web') diff --git a/web/app/DillerRpc.js b/web/app/DillerRpc.js deleted file mode 100644 index a0c20fb..0000000 --- a/web/app/DillerRpc.js +++ /dev/null @@ -1,41 +0,0 @@ -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); -}; diff --git a/web/app/app.js b/web/app/app.js deleted file mode 100644 index cd14ae5..0000000 --- a/web/app/app.js +++ /dev/null @@ -1,60 +0,0 @@ -(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); - } - - angular - .module('Diller', ['ngRoute']) - .config(config) - .service('DillerRpc', DillerRpc); -})(); diff --git a/web/app/templates/device.html b/web/app/templates/device.html deleted file mode 100644 index ae028b5..0000000 --- a/web/app/templates/device.html +++ /dev/null @@ -1,21 +0,0 @@ -
- -

- {{ctrl.device.key}} - device -

- - - -

Properties

- - -
diff --git a/web/app/templates/front-page.html b/web/app/templates/front-page.html deleted file mode 100644 index 1846dea..0000000 --- a/web/app/templates/front-page.html +++ /dev/null @@ -1,24 +0,0 @@ -
- -

- Diller - All your sensor data are belong to us -

- -

Devices

- - - - - - - - - - - - -
Key
- {{d.key}} -
-
diff --git a/web/app/templates/property.html b/web/app/templates/property.html deleted file mode 100644 index 65a66e8..0000000 --- a/web/app/templates/property.html +++ /dev/null @@ -1,36 +0,0 @@ -
- -

- {{ctrl.device.key}} - device -

- -

- {{ctrl.property.key}} - property -

- - - -

Latest Values

- - - - - - - - - - - - - - -
TimestampValue
{{v.timestamp | date:'medium'}}{{v.value}}
- -
diff --git a/web/index.html b/web/index.html deleted file mode 100644 index b591e55..0000000 --- a/web/index.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - -Loading Diller ... - - 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); +}; diff --git a/web/static/app/app.css b/web/static/app/app.css new file mode 100644 index 0000000..090ac5e --- /dev/null +++ b/web/static/app/app.css @@ -0,0 +1,3 @@ +nav.navbar { + margin-bottom: 2rem; +} 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); +})(); diff --git a/web/static/app/templates/device.html b/web/static/app/templates/device.html new file mode 100644 index 0000000..b466fdc --- /dev/null +++ b/web/static/app/templates/device.html @@ -0,0 +1,34 @@ +
+ +

+ {{ctrl.device.key}} + device +

+ + + +

Properties

+ + + + + + + + + + + + + + +
RegisteredKey
+ {{p.created_timestamp | date:'medium'}} + + {{p.key}} +
+
diff --git a/web/static/app/templates/front-page.html b/web/static/app/templates/front-page.html new file mode 100644 index 0000000..68026c3 --- /dev/null +++ b/web/static/app/templates/front-page.html @@ -0,0 +1,23 @@ +
+ +

Devices

+ + + + + + + + + + + + + + +
RegisteredKey
+ {{d.created_timestamp | date:'medium'}} + + {{d.key}} +
+
diff --git a/web/static/app/templates/property.html b/web/static/app/templates/property.html new file mode 100644 index 0000000..5f925e7 --- /dev/null +++ b/web/static/app/templates/property.html @@ -0,0 +1,42 @@ +
+ +

+ {{ctrl.device.key}} + device +

+ +

+ {{ctrl.property.key}} + property +

+ + + +

Latest Values

+ + + + + + + + + + + + + + + + + + + + +
TimestampValue
{{v.timestamp | date:'medium'}}{{v.value}}
{{v.timestamp | date:'medium'}}{{v.value}}
+ +
diff --git a/web/templates/index.jade b/web/templates/index.jade new file mode 100644 index 0000000..025354e --- /dev/null +++ b/web/templates/index.jade @@ -0,0 +1,52 @@ +doctype html + +html(lang='en') + head + meta(charset='utf-8') + meta(name="viewport", content="width=device-width, initial-scale=1") + meta(http-equiv="x-ua-compatible", content="ie=edge") + + base(href!=baseUrl) + + script(src="bower_components/jquery/dist/jquery.js", type="application/javascript") + script(src="bower_components/bootstrap/dist/js/bootstrap.js", type="application/javascript") + link(rel="stylesheet", href="bower_components/bootstrap/dist/css/bootstrap.css") + script(src="bower_components/angular/angular.js", type="application/javascript") + script(src="bower_components/angular-route/angular-route.js", type="application/javascript") + script(src="bower_components/lodash/lodash.js", type="application/javascript") + + script(src="app/DillerRpc.js", type="application/javascript") + script(src="app/app.js", type="application/javascript") + link(href="app/app.css", rel="stylesheet") + + body(ng-app="Diller") + .container + nav.navbar.navbar-dark.bg-inverse + a.navbar-brand(href='#/') Diller + ul.nav.navbar-nav + li.nav-item + a.nav-link(href='#/') Devices + + // + + span(ng-view) Loading Diller ... diff --git a/web/templates/wat.html b/web/templates/wat.html new file mode 100644 index 0000000..fd504a7 --- /dev/null +++ b/web/templates/wat.html @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + +Loading Diller ... + + -- cgit v1.2.3