changeset 173:0daa8cbbd8f6

handle compact/full uris better, but still not always right Ignore-this: 10d98f16a659f899528eb86411473b18
author drewp@bigasterisk.com
date Fri, 17 Apr 2015 02:00:15 -0700
parents 715c1c42185e
children ab98f8d72be0
files service/arduinoNode/static/index.html service/arduinoNode/static/output-widgets.html
diffstat 2 files changed, 45 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/service/arduinoNode/static/index.html	Fri Apr 17 01:03:52 2015 -0700
+++ b/service/arduinoNode/static/index.html	Fri Apr 17 02:00:15 2015 -0700
@@ -24,11 +24,52 @@
      };
     </script>
 
+    <script>
+     PolymerExpressions.prototype.tojson = function(input) {
+       return JSON.stringify(input);
+     };
+
+     // not well defined for uri prefixes that are string prefixes of each other
+     PolymerExpressions.prototype.compactUri = function(uri) {
+       if (uri === undefined) {
+         return uri;
+       }
+       for (var short of Object.keys(window.NS)) {
+         var prefix = window.NS[short];
+         if (uri.indexOf(prefix) == 0) {
+           return short + ':' + uri.substr(prefix.length);
+         }
+       }
+       return uri;
+     };
+    </script>
+    
     <polymer-element name="linked-uri" noscript attributes="href">
       <template>
         <a href="{{href}}">{{href}}</a>
       </template>
     </polymer-element>
+
+    <!-- subj/pred are compact uris -->
+    <polymer-element name="watched-subgraph" noscript attributes="subj pred">
+      <template>
+        <style>
+         .read { font-weight: bold; }
+        </style>
+          
+        <rdf-observe
+          graph="http://dash:9059/graph" xtodo="get host here"
+          subject="{{subj}}"
+          predicate="{{pred}}"
+          out="{{out}}">
+        </rdf-observe>
+        
+        <div>{{subj}}, {{pred}},
+          <span class="read">{{out[pred]['@value']}}</span>
+        </div>
+        
+      </template>
+    </polymer-element>
     
     <polymer-element name="arduinonode-boards" noscript>
       <template>
@@ -75,17 +116,9 @@
                     <div>watching:</div>
                     <ul>
                       <template repeat="{{prefix in dev.watchPrefixes}}">
-
-                        <!-- 
-                        <rdf-observe
-                          graph="http://dash:9059/graph" xtodo="get host here"
-                          subject="{{prefix[0]}}"
-                          predicate="{{prefix[1]}}"
-                          out="{{out}}">
-                        </rdf-observe>
-                        
-                        <div>{{prefix[0]}}, {{prefix[1]}}, {{out['room:temperatureF']['@value']}}</div>
-                         -->
+                        <watched-subgraph
+                          subj="{{prefix[0] | compactUri}}"
+                          pred="{{prefix[1] | compactUri}}"></watched-subgraph>
                       </template>
                     </ul>
                   </template>
--- a/service/arduinoNode/static/output-widgets.html	Fri Apr 17 01:03:52 2015 -0700
+++ b/service/arduinoNode/static/output-widgets.html	Fri Apr 17 02:00:15 2015 -0700
@@ -3,7 +3,7 @@
 <polymer-element name="output-widget" attributes="subj pred">
   <template>
     <core-ajax id="output" url="../output" method="POST"></core-ajax>
-    Set this device's {{pred}} to
+    Set this device's {{pred | compactUri}} to
   </template>
   <script>
    function ntriple(s, p, o) {