diff service/tomatoWifi/index.html @ 175:c81a451f9b26

rewrites for better graph export, removal of dhcp reader Ignore-this: ecc5280b15d66020412f82ad84862074
author drewp@bigasterisk.com
date Sun, 03 May 2015 17:21:20 -0700
parents
children 6c42d528898b
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/service/tomatoWifi/index.html	Sun May 03 17:21:20 2015 -0700
@@ -0,0 +1,79 @@
+<!doctype html>
+<html>
+  <head>
+    <title>dhcp leases</title>
+    <meta charset="utf-8" />
+    <script src="/lib/polymer/0.8/webcomponentsjs/webcomponents-lite.min.js"></script>
+    <script src="/lib/underscore-1.5.2.min.js"></script>
+    <link rel="import" href="/rdf/n3+polymer/trig-store.html">
+    <link rel="import" href="/lib/polymer/0.8/iron-ajax/iron-ajax.html">
+  </head>
+  <body>
+    <h1>Devices on wifi</h1>
+
+    <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>
+
+        <table>
+          <tr>
+            <th>name</th>
+            <th>MAC</th>
+            <th>Connected</th>
+          </tr>
+          <template is="x-repeat" items="{{devices}}">
+            <tr>
+              <td>{{item.deviceName}}</td>
+              <td>{{item.mac}}</td>
+              <td>{{item.connectedAgo}}</td>
+            </tr>
+          </template>
+        </table>
+      </template>
+    </dom-module>
+    
+    <script>
+     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];
+         };
+
+         this.devices = [];
+         
+         find(null, "room:connected", "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) {
+
+           }           
+           
+           this.devices.push(out);
+         }.bind(this));
+         this.devices = _.sortBy(this.devices, 'deviceName');
+       }
+     });
+    </script>
+    <wifi-table></wifi-table>
+  </body>
+</html>