Changeset - 616b22296156
[Not reviewed]
default
0 2 0
Drew Perttula - 8 years ago 2017-06-03 19:59:45
drewp@bigasterisk.com
collector web view use resource-display
Ignore-this: 5c0ee3c970bcd4160069e10009f34b0c
2 files changed with 13 insertions and 12 deletions:
0 comments (0 inline, 0 general)
light9/collector/web/index.html
Show inline comments
 
@@ -4,12 +4,13 @@
 
    <title>collector</title>
 
    <meta charset="utf-8" />
 
    <script src="/lib/webcomponentsjs/webcomponents-lite.min.js"></script>
 
    <link rel="import" href="/lib/polymer/polymer.html">
 
    <link rel="import" href="/lib/iron-ajax/iron-ajax.html">
 
    <link rel="import" href="../rdfdb-synced-graph.html">
 
    <link rel="import" href="../resource-display.html">
 
    <script src="/lib/N3.js-pull61/browser/n3-browser.js"></script>
 
    <script src="/lib/async/dist/async.js"></script>
 
    <script src="/lib/underscore/underscore-min.js"></script>
 

	
 
    <link rel="stylesheet"  href="/style.css">
 
    <style>
 
@@ -22,23 +23,27 @@
 
      <template>
 
        <style>
 
         :host {
 
             display: block;
 
             break-inside: avoid-column;
 
         }
 
         h3 {
 
             margin-top: 2px;
 
             margin-bottom: 0;
 
         }
 
         td.nonzero {
 
             background: #310202;
 
             color: #e25757;
 
         }
 
         td.full {
 
             background: #2b0000;
 
             color: red;
 
             font-weight: bold;
 
         }
 
        </style>
 
        <h3>{{label}}</h3>
 
        <h3><resource-display graph="{{graph}}" uri="{{uri}}"></resource-display></h3>
 
        <table class="borders">
 
          <tr>
 
            <th>output attr</th>
 
            <th>value</th>
 
            <th>output chan</th>
 
          </tr>
 
@@ -55,35 +60,27 @@
 
       HTMLImports.whenReady(function () {
 
           Polymer({
 
               is: "light9-collector-device",
 
               properties: {
 
                   graph: {type: Object, notify: true},
 
                   uri: {type: String, notify: true},
 
                   label: {type: String, notify: true},
 
                   attrs: {type: Array, notify: true},
 
               },
 
               observers: [
 
                   "setLabel(graph, uri)",
 
                   "initUpdates(updates)",
 
               ],
 
               initUpdates: function(updates) {
 
                   updates.addListener(function(msg) {
 
                       if (msg.outputAttrsSet && msg.outputAttrsSet.dev == this.uri) {
 
                           this.set('attrs', msg.outputAttrsSet.attrs);
 
                           this.attrs.forEach(function(row) {
 
                               row.valClass = row.val == 255 ? 'full' : (row.val ? 'nonzero' : '');
 
                           });
 
                       }
 
                   }.bind(this));
 
               },
 
               setLabel: function(graph, uri) {
 
                   this.label = uri.replace(/.*\//, '');
 
                   graph.runHandler(function() {
 
                       this.label = graph.stringValue(uri, graph.Uri('rdfs:label'));
 
                   }.bind(this), 'setLabel');
 
               }
 
           });
 
       });
 
      </script>
 
    </dom-module>
 

	
 

	
light9/web/resource-display.html
Show inline comments
 
@@ -35,30 +35,34 @@
 
    </template>
 
  </template>
 
  <script>
 
   Polymer({
 
       is: "resource-display",
 
       properties: {
 
           graph: { type: Object, notify: true },
 
           uri: { type: String, notify: true },
 
           graph: { type: Object },
 
           uri: { type: String },
 
           label: { type: String },
 
           rename: { type: Boolean },
 
           renameTo: { type: String, notify: true },
 
       },
 
       ready: function() {
 
           this.graph.runHandler(this.setLabel.bind(this), `label ${this.uri}`);
 
       },
 
       setLabel: function() {
 
           if (!this.uri) {
 
               this.label = "<no uri>";
 
               return;
 
           }
 
           try {
 
             this.label = this.graph.stringValue(this.uri,
 
                                                 this.graph.Uri('rdfs:label'));
 
           } catch(e) {
 
               this.label = null;
 
           }
 
           if (!this.label) {
 
               this.label = this.uri || "<no uri>";
 
               this.label = this.uri.replace(/.*\//, '');
 
           }
 
       },
 
       onRename: function() {
 
           this.renameTo = this.label;
 
           this.querySelector("#renameDialog").open();
 
           this.querySelector("#renameTo").setSelectionRange(0, -1);
0 comments (0 inline, 0 general)