Mercurial > code > home > repos > homeauto
changeset 641:5fd7aef3b2b2
index page updates. include wifi badg data.
Ignore-this: e4cecff1c9886d17f64c281dd4f52c7b
author | drewp@bigasterisk.com |
---|---|
date | Wed, 14 Aug 2019 16:40:57 -0700 |
parents | 23ab244aa649 |
children | 0a39cb133ce5 |
files | service/wifi/index.html service/wifi/requirements.txt service/wifi/scrape.py |
diffstat | 3 files changed, 72 insertions(+), 79 deletions(-) [+] |
line wrap: on
line diff
--- a/service/wifi/index.html Mon Aug 12 16:46:52 2019 -0700 +++ b/service/wifi/index.html Wed Aug 14 16:40:57 2019 -0700 @@ -1,82 +1,74 @@ <!doctype html> <html> - <head> - <title>wifi</title> - <meta charset="utf-8" /> - <script src="/lib/polymer/1.0.9/webcomponentsjs/webcomponents-lite.min.js"></script> - <link rel="import" href="/lib/polymer/1.0.9/polymer/polymer.html"> - <script src="/lib/underscore-1.5.2.min.js"></script> - <link rel="import" href="/lib/polymer/1.0.9/iron-ajax/iron-ajax.html"> - <link rel="import" href="/rdf/n3+polymer/trig-store.html"> - </head> - <body> - <h1>Devices on wifi</h1> - <p><a href="../dhcpleases">go to dhcpleases</a></p> - <dom-module id="wifi-table"> - <template> - <iron-ajax auto url="graph" - handle-as="text" - last-response="{{ajaxResponse}}"></iron-ajax> - <trig-store id="ts" trig-input="{{ajaxResponse}}"></trig-store> + +<head> + <title>wifi</title> + <meta charset="utf-8"> + <script src="/lib/polymer/1.0.9/webcomponentsjs/webcomponents.min.js"></script> + <script src="/lib/require/require-2.3.3.js"></script> + <script src="/rdf/common_paths_and_ns.js"></script> + + <link rel="stylesheet" href="/rdf/browse/style.css"> + + <link rel="import" href="/rdf/streamed-graph.html"> + <link rel="import" href="/lib/polymer/1.0.9/polymer/polymer.html"> +</head> + +<body class="rdfBrowsePage"> + <template id="t" is="dom-bind"> + <style> + body { + background: black; + color: white; + } + a { + color: #b1b1fd; + text-shadow: 1px 1px 0px #0400ff94; + text-decoration-color: #00007714; + } + #subjectRequest { + width: 50em; + } + </style> + + <streamed-graph url="/sse_collector/graph/network" graph="{{graph}}"></streamed-graph> + <div id="out"> + </div> - <table> - <tr> - <th>name</th> - <th>MAC</th> - <th>Connected</th> - </tr> - <template is="dom-repeat" items="{{devices}}"> - <tr> - <td>{{item.deviceName}}</td> - <td>{{item.mac}}</td> - <td>{{item.connectedAgo}}</td> - </tr> - </template> - </table> - </template> - - <script> - HTMLImports.whenReady(function () { - Polymer({ - is: "wifi-table", - ready: function() { - this.$.ts.addEventListener('store-changed', this.storeChanged.bind(this)); - this.devices = []; - }, - storeChanged: function(ev) { - var store = ev.detail.value; - var find = function(s, p, o) { return store.findAllGraphs(s, p, o); }; - var findOne = function(s, p, o) { - var rows = find(s, p, o); - return rows[0]; - }; + <script type="module"> + import { render } from '/lib/lit-html/1.0.0/lit-html.js'; + import { graphView } from './wifi.js'; + const sg = document.querySelector('streamed-graph'); + + const out = document.querySelector('#out'); + const startPainting = () => { + if (!sg.graph || !sg.graph.graph) { + setTimeout(startPainting, 100); + return; + } + + let dirty = true; - this.devices = []; - - find(null, "room:connectedToNetwork", "http://bigasterisk.com/wifiAccessPoints" - ).forEach(function(row) { - var out = { - mac: N3.Util.getLiteralValue( - findOne(row.subject, "room:macAddress", null).object), - connectedAgo: N3.Util.getLiteralValue( - findOne(row.subject, "room:connectedAgo", null).object) - - }; - try { - var dev = findOne(row.subject, "room:deviceName", null).object; - out.deviceName = N3.Util.getLiteralValue(dev); - } catch(e) { + const repaint = () => { + if (!dirty) { + return; + } + render(graphView(sg.graph.graph), out); + dirty = false; + }; - } - - this.devices.push(out); - }.bind(this)); - this.devices = _.sortBy(this.devices, 'deviceName'); - } - }); - }); - </script> - </dom-module> - <wifi-table></wifi-table> - </body> + sg.addEventListener('graph-changed', (ev) => { + dirty = true; + requestAnimationFrame(repaint); + }); + repaint(); + }; + setTimeout(startPainting, 10); + </script> + </template> + <script> + + </script> +</body> + </html>
--- a/service/wifi/requirements.txt Mon Aug 12 16:46:52 2019 -0700 +++ b/service/wifi/requirements.txt Wed Aug 14 16:40:57 2019 -0700 @@ -12,5 +12,5 @@ cycloneerr patchablegraph==0.5.0 rdfdb==0.8.0 -standardservice==0.4.0 +standardservice==0.6.0
--- a/service/wifi/scrape.py Mon Aug 12 16:46:52 2019 -0700 +++ b/service/wifi/scrape.py Wed Aug 14 16:40:57 2019 -0700 @@ -64,10 +64,11 @@ if row['contype'] in ['2.4G', '5G']: orbi = macUri(row['conn_orbi_mac']) - triples.add((orbi, ROOM['wifiBand'], - ROOM['wifiBand/%s' % row['contype']])) + ct = ROOM['wifiBand/%s' % row['contype']] triples.add((uri, ROOM['connectedToAp'], orbi)) + triples.add((uri, ROOM['wifiBand'], ct)) triples.add((orbi, RDF.type, ROOM['AccessPoint'])) + triples.add((orbi, ROOM['wifiBand'], ct)) triples.add((orbi, ROOM['macAddress'], Literal(row['conn_orbi_mac'].lower()))) triples.add((orbi, RDFS.label, Literal(row['conn_orbi_name'])))