changeset 1218:c571a45c944f

split console web component Ignore-this: 1af5e69fff09e7e5680ffb25e9236fc0 darcs-hash:7acb2532595a2073de5bb224ef708e57b84dc99d
author drewp <drewp@bigasterisk.com>
date Sat, 23 Mar 2019 13:57:44 -0700
parents c21f433ddbac
children bff11263c71e
files service/rfid_pn532_py/index.html service/rfid_pn532_py/rfid-console.html service/rfid_pn532_py/rfid.py
diffstat 3 files changed, 92 insertions(+), 92 deletions(-) [+]
line wrap: on
line diff
--- a/service/rfid_pn532_py/index.html	Sat Mar 23 04:38:07 2019 -0700
+++ b/service/rfid_pn532_py/index.html	Sat Mar 23 13:57:44 2019 -0700
@@ -30,99 +30,9 @@
        sensor: 'http://bigasterisk.com/homeauto/sensor/',
      };
     </script>
-    <link rel="import" href="/lib/polymer/1.0.9/iron-ajax/iron-ajax.html">
-    <link rel="import" href="/rdf/streamed-graph.html">
-    <link rel="import" href="/lib/polymer/1.0.9/polymer/polymer.html">
-    <link rel="import" href="/rdf/rdf-oneshot.html">
-    <link rel="import" href="/rdf/rdf-uri.html">
+    <link rel="import" href="rfid-console.html">
   </head>
   <body>
-    <dom-module id="rfid-control">
-      <style>
-       button {
-           min-width: 60px;
-           min-height: 40px;
-       }
-       table {
-           border-collapse: collapse;
-       }
-       
-       td, th {
-           border: 1px solid gray;
-       }
-      </style>
-      <template>
-        <div>
-          <streamed-graph url="graph/events" graph="{{graph}}"></streamed-graph>
-          <!-- also get a graph of users so we can look up cards -->
-        </div>
-        
-        <iron-ajax id="rewrite" url="rewrite" method="POST"></iron-ajax>
-        
-        Current reads: 
-        <table>
-          <tr><th>Card UID</th><th>Card text</th><th></th></tr>
-          <template is="dom-repeat" items="{{currentReads}}">
-            <tr>
-              <td>{{item.uidDisplay}}</td>
-              <td>{{item.text}}</td>
-              <td>
-                <div id="form">
-                  <button on-click="rewrite">Rewrite</button>
-                </div>
-              </td>
-            </tr>
-          </template>
-        </table>
-        
-      </template>
-      <script>
-       HTMLImports.whenReady(function () {
-         Polymer({
-           is: 'rfid-control',
-           properties: {
-             graph: { type: Object, notify: true, observer: "_onGraph" },
-             currentReads: { type: Array, value: [] },
-           },
-           behaviors: [BigastUri],
-           _onGraph: function(graph) {
-             if (!graph.graph) return;
-             const env = graph.graph.store.rdf;
-
-             this.splice('currentReads', 0, this.currentReads.length);
-             graph.graph.quadStore.quads(
-               {subject: env.createNamedNode('room:frontDoorWindowRfid'),
-                predicate: env.createNamedNode('room:reading'),
-               },
-               (q) => {
-                 graph.graph.quadStore.quads(
-                   {subject: q.object,
-                    predicate: env.createNamedNode('room:cardText'),
-                   },
-                   (q2) => {
-                     this.push(
-                       'currentReads', {
-                         'cardUid': q.object,
-                         'uidDisplay': q.object.toString().replace(/.*\//, ""),
-                         'text': q2.object.toString()
-                       });
-                   });
-               });
-           },
-           rewrite: function(ev) {
-             const cardUid = ev.model.item.cardUid;
-
-             // ask for user first
-
-             this.$.rewrite.contentType = "application/json";
-             this.$.rewrite.body = {'cardUid': cardUid.toString(),
-                                    'user': "some foaf"};
-             this.$.rewrite.generateRequest();
-           }
-         });
-       });
-      </script>
-    </dom-module>
     <rfid-control></rfid-control>
   </body>
 </html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/service/rfid_pn532_py/rfid-console.html	Sat Mar 23 13:57:44 2019 -0700
@@ -0,0 +1,90 @@
+<link rel="import" href="/lib/polymer/1.0.9/iron-ajax/iron-ajax.html">
+<link rel="import" href="/lib/polymer/1.0.9/polymer/polymer.html">
+<link rel="import" href="/rdf/rdf-oneshot.html">
+<link rel="import" href="/rdf/rdf-uri.html">
+<link rel="import" href="/rdf/streamed-graph.html">
+
+<dom-module id="rfid-control">
+  <style>
+   button {
+       min-width: 60px;
+       min-height: 40px;
+   }
+   table {
+       border-collapse: collapse;
+   }
+   
+   td, th {
+       border: 1px solid gray;
+   }
+  </style>
+  <template>
+    <div>
+      <streamed-graph url="graph/events" graph="{{graph}}"></streamed-graph>
+      <!-- also get a graph of users so we can look up cards -->
+    </div>
+    
+    <iron-ajax id="rewrite" url="rewrite" method="POST"></iron-ajax>
+    
+    Current reads: 
+    <table>
+      <tr><th>Card UID</th><th>Card text</th><th></th></tr>
+      <template is="dom-repeat" items="{{currentReads}}">
+        <tr>
+          <td>{{item.uidDisplay}}</td>
+          <td>{{item.text}}</td>
+          <td>
+            <div id="form">
+              <button on-click="rewrite">Rewrite</button>
+            </div>
+          </td>
+        </tr>
+      </template>
+    </table>
+    
+  </template>
+  <script>
+   Polymer({
+     is: 'rfid-control',
+     properties: {
+       graph: { type: Object, notify: true, observer: "_onGraph" },
+       currentReads: { type: Array, value: [] },
+     },
+     behaviors: [BigastUri],
+     _onGraph: function(graph) {
+       if (!graph.graph) return;
+       const env = graph.graph.store.rdf;
+
+       this.splice('currentReads', 0, this.currentReads.length);
+       graph.graph.quadStore.quads(
+         {subject: env.createNamedNode('room:frontDoorWindowRfid'),
+          predicate: env.createNamedNode('room:reading'),
+         },
+         (q) => {
+           graph.graph.quadStore.quads(
+             {subject: q.object,
+              predicate: env.createNamedNode('room:cardText'),
+             },
+             (q2) => {
+               this.push(
+                 'currentReads', {
+                   'cardUid': q.object,
+                   'uidDisplay': q.object.toString().replace(/.*\//, ""),
+                   'text': q2.object.toString()
+                 });
+             });
+         });
+     },
+     rewrite: function(ev) {
+       const cardUid = ev.model.item.cardUid;
+
+       // ask for user first
+
+       this.$.rewrite.contentType = "application/json";
+       this.$.rewrite.body = {'cardUid': cardUid.toString(),
+                              'user': "some foaf"};
+       this.$.rewrite.generateRequest();
+     }
+   });
+  </script>
+</dom-module>
--- a/service/rfid_pn532_py/rfid.py	Sat Mar 23 04:38:07 2019 -0700
+++ b/service/rfid_pn532_py/rfid.py	Sat Mar 23 13:57:44 2019 -0700
@@ -190,7 +190,7 @@
 
     port = 10012
     reactor.listenTCP(port, cyclone.web.Application([
-        (r"/()", cyclone.web.StaticFileHandler,
+        (r"/(|.+\.html)", cyclone.web.StaticFileHandler,
          {"path": ".", "default_filename": "index.html"}),
         (r"/graph", CycloneGraphHandler, {'masterGraph': masterGraph}),
         (r"/graph/events", CycloneGraphEventsHandler,