changeset 195:9ce1214e4534

polymer updates Ignore-this: f4f88b324b54abf90af6dc5360910041
author drewp@bigasterisk.com
date Sun, 30 Aug 2015 11:53:25 -0700
parents 35e07a9f3287
children 2f8ba398f958
files service/dhcpleases/index.html service/tomatoWifi/index.html
diffstat 2 files changed, 87 insertions(+), 112 deletions(-) [+]
line wrap: on
line diff
--- a/service/dhcpleases/index.html	Sun Aug 30 11:46:37 2015 -0700
+++ b/service/dhcpleases/index.html	Sun Aug 30 11:53:25 2015 -0700
@@ -3,51 +3,14 @@
   <head>
     <title>dhcp leases</title>
     <meta charset="utf-8" />
-    <script src="/lib/polymer/0.8/webcomponentsjs/webcomponents-lite.min.js"></script>
+    <script src="/lib/polymer/1.0.9/webcomponentsjs/webcomponents-lite.min.js"></script>
     <script src="/lib/underscore-1.5.2.min.js"></script>
-    <script src="/lib/n3/0.4.2/n3-browser-drewp.js"></script>
-    <link rel="import" href="/lib/polymer/0.8/iron-ajax/iron-ajax.html">
+    <link rel="import" href="/rdf/n3+polymer/trig-store.html">
+    <link rel="import" href="/lib/polymer/1.0.9/iron-ajax/iron-ajax.html">
   </head>
   <body>
-
-    <script>
-     Polymer({
-       is: "trig-store",
-       prefixes: {
-         room: 'http://projects.bigasterisk.com/room/',
-         rdfs: 'http://www.w3.org/2000/01/rdf-schema#'
-       },
-       properties: {
-         trigInput: {
-           type: String,
-           observer: 'trigInputChanged'
-         },
-         store: {
-           // set to a new store each time trig is updated
-           type: Object,
-           default: N3.Store(),
-           notify: true
-         }
-       },
-       trigInputChanged: function(trig, _old) {
-         var newStore = N3.Store();
-         newStore.addPrefixes(this.prefixes);
-         var parser = N3.Parser({format: 'TriG'});
-         parser.parse(trig, function(error, triple, prefixes) {
-           if (error !== null) {
-             console.log(error);
-             return;
-           } 
-           newStore.addTriple(triple);
-         }.bind(this));
-         console.log("filled store with", newStore.size, "triples");
-         this.store = newStore;
-
-       }
-     })
-    </script>
-
     <h1>Active dhcp leases</h1>
+    <p><a href="../wifi">go to wifi</a></p>
 
     <dom-module id="dhcp-table">
       <template>
@@ -58,41 +21,50 @@
         <trig-store id="ts" trig-input="{{ajaxResponse}}"></trig-store>
 
         <table>
-          <template is="x-repeat" items="{{devices}}">
-            <tr><td>{{item.dhcpHostname}}</td> <td>{{item.ip}}</td></tr>
+          <template is="dom-repeat" items="{{devices}}">
+            <tr>
+              <td>{{item.dhcpHostname}}</td>
+              <td>{{item.ip}}</td>
+              <td>{{item.mac}}</td>
+            </tr>
           </template>
         </table>
       </template>
     </dom-module>
     
     <script>
-     Polymer({
-       is: "dhcp-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];
-         };
+     HTMLImports.whenReady(function () {
+       Polymer({
+         is: "dhcp-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:dhcpHostname", null).forEach(function(row) {
-           var out = {dhcpHostname: N3.Util.getLiteralValue(row.object)}
-           var lease = findOne(null, "room:ethernetAddress",
-                               row.subject).subject;
-           var ip = findOne(lease, "room:assignedIp", null).object;
-           out.ip = N3.Util.getLiteralValue(
-             findOne(ip, "rdfs:label", null).object);
-           this.devices.push(out);
-         }.bind(this));
-         this.devices = _.sortBy(this.devices, 'dhcpHostname');
-       }
+           this.devices = [];
+           
+           find(null, "room:dhcpHostname", null).forEach(function(row) {
+             var out = {dhcpHostname: N3.Util.getLiteralValue(row.object)}
+             var lease = findOne(null, "room:ethernetAddress",
+                                 row.subject).subject;
+             out.ip = N3.Util.getLiteralValue(
+               findOne(findOne(lease, "room:assignedIp", null).object,
+                       "rdfs:label", null).object);
+             out.mac = N3.Util.getLiteralValue(
+               findOne(findOne(lease, "room:ethernetAddress", null).object,
+                       "room:macAddress", null).object);
+             this.devices.push(out);
+           }.bind(this));
+           this.devices = _.sortBy(this.devices, 'dhcpHostname');
+         }
+       });
      });
     </script>
     <dhcp-table></dhcp-table>
--- a/service/tomatoWifi/index.html	Sun Aug 30 11:46:37 2015 -0700
+++ b/service/tomatoWifi/index.html	Sun Aug 30 11:53:25 2015 -0700
@@ -3,14 +3,15 @@
   <head>
     <title>wifi</title>
     <meta charset="utf-8" />
-    <script src="/lib/polymer/0.8/webcomponentsjs/webcomponents-lite.min.js"></script>
+    <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">
-    <link rel="import" href="/lib/polymer/0.8/iron-ajax/iron-ajax.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"
@@ -24,7 +25,7 @@
             <th>MAC</th>
             <th>Connected</th>
           </tr>
-          <template is="x-repeat" items="{{devices}}">
+          <template is="dom-repeat" items="{{devices}}">
             <tr>
               <td>{{item.deviceName}}</td>
               <td>{{item.mac}}</td>
@@ -33,47 +34,49 @@
           </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];
-         };
+      
+      <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 = [];
+           
+           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>
+             }           
+             
+             this.devices.push(out);
+           }.bind(this));
+           this.devices = _.sortBy(this.devices, 'deviceName');
+         }
+       });
+       });
+      </script>
+    </dom-module>
     <wifi-table></wifi-table>
   </body>
 </html>