1223
|
1 <!doctype html>
|
|
2 <html>
|
|
3 <head>
|
|
4 <title>wifi</title>
|
|
5 <meta charset="utf-8" />
|
|
6 <script src="/lib/polymer/1.0.9/webcomponentsjs/webcomponents-lite.min.js"></script>
|
|
7 <link rel="import" href="/lib/polymer/1.0.9/polymer/polymer.html">
|
|
8 <script src="/lib/underscore-1.5.2.min.js"></script>
|
|
9 <link rel="import" href="/lib/polymer/1.0.9/iron-ajax/iron-ajax.html">
|
|
10 <link rel="import" href="/rdf/n3+polymer/trig-store.html">
|
|
11 </head>
|
|
12 <body>
|
|
13 <h1>Devices on wifi</h1>
|
|
14 <p><a href="../dhcpleases">go to dhcpleases</a></p>
|
|
15 <dom-module id="wifi-table">
|
|
16 <template>
|
|
17 <iron-ajax auto url="graph"
|
|
18 handle-as="text"
|
|
19 last-response="{{ajaxResponse}}"></iron-ajax>
|
|
20 <trig-store id="ts" trig-input="{{ajaxResponse}}"></trig-store>
|
|
21
|
|
22 <table>
|
|
23 <tr>
|
|
24 <th>name</th>
|
|
25 <th>MAC</th>
|
|
26 <th>Connected</th>
|
|
27 </tr>
|
|
28 <template is="dom-repeat" items="{{devices}}">
|
|
29 <tr>
|
|
30 <td>{{item.deviceName}}</td>
|
|
31 <td>{{item.mac}}</td>
|
|
32 <td>{{item.connectedAgo}}</td>
|
|
33 </tr>
|
|
34 </template>
|
|
35 </table>
|
|
36 </template>
|
|
37
|
|
38 <script>
|
|
39 HTMLImports.whenReady(function () {
|
|
40 Polymer({
|
|
41 is: "wifi-table",
|
|
42 ready: function() {
|
|
43 this.$.ts.addEventListener('store-changed', this.storeChanged.bind(this));
|
|
44 this.devices = [];
|
|
45 },
|
|
46 storeChanged: function(ev) {
|
|
47 var store = ev.detail.value;
|
|
48 var find = function(s, p, o) { return store.findAllGraphs(s, p, o); };
|
|
49 var findOne = function(s, p, o) {
|
|
50 var rows = find(s, p, o);
|
|
51 return rows[0];
|
|
52 };
|
|
53
|
|
54 this.devices = [];
|
|
55
|
|
56 find(null, "room:connected", "http://bigasterisk.com/wifiAccessPoints"
|
|
57 ).forEach(function(row) {
|
|
58 var out = {
|
|
59 mac: N3.Util.getLiteralValue(
|
|
60 findOne(row.subject, "room:macAddress", null).object),
|
|
61 connectedAgo: N3.Util.getLiteralValue(
|
|
62 findOne(row.subject, "room:connectedAgo", null).object)
|
|
63
|
|
64 };
|
|
65 try {
|
|
66 var dev = findOne(row.subject, "room:deviceName", null).object;
|
|
67 out.deviceName = N3.Util.getLiteralValue(dev);
|
|
68 } catch(e) {
|
|
69
|
|
70 }
|
|
71
|
|
72 this.devices.push(out);
|
|
73 }.bind(this));
|
|
74 this.devices = _.sortBy(this.devices, 'deviceName');
|
|
75 }
|
|
76 });
|
|
77 });
|
|
78 </script>
|
|
79 </dom-module>
|
|
80 <wifi-table></wifi-table>
|
|
81 </body>
|
|
82 </html>
|