diff service/wifi/index.html @ 1223:34de6cfa0b6b

rename historical 'tomatoWifi' Ignore-this: 8a3f1f261df50e8029cf9de5b11a6896 darcs-hash:1b2345513349fd24e5b3992141f0b0f72ad43910
author drewp <drewp@bigasterisk.com>
date Sat, 30 Mar 2019 16:58:08 -0700
parents
children 996a00d72979
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/service/wifi/index.html	Sat Mar 30 16:58:08 2019 -0700
@@ -0,0 +1,82 @@
+<!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>
+
+        <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];
+           };
+
+           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>
+    </dom-module>
+    <wifi-table></wifi-table>
+  </body>
+</html>