changeset 1709:15babcd58d48

update collector web to new n3js Ignore-this: e68cc63a9a7a5828c5d2f3a82a38bc6f
author Drew Perttula <drewp@bigasterisk.com>
date Thu, 03 May 2018 06:31:18 +0000
parents 8d3569829198
children 05248a7c2c51
files light9/collector/web/index.html light9/web/resource-display.html
diffstat 2 files changed, 13 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/light9/collector/web/index.html	Tue May 01 07:43:35 2018 +0000
+++ b/light9/collector/web/index.html	Thu May 03 06:31:18 2018 +0000
@@ -3,12 +3,12 @@
   <head>
     <title>collector</title>
     <meta charset="utf-8" />
-    <script src="/lib/webcomponentsjs/webcomponents-lite.min.js"></script>
+    <script src="/node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.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="/node_modules/n3/n3-browser.js"></script> 
     <script src="/lib/async/dist/async.js"></script>
     <script src="/lib/underscore/underscore-min.js"></script>
 
@@ -62,7 +62,7 @@
                is: "light9-collector-device",
                properties: {
                    graph: {type: Object, notify: true},
-                   uri: {type: String, notify: true},
+                   uri: {type: Object, notify: true},
                    attrs: {type: Array, notify: true},
                },
                observers: [
@@ -70,7 +70,7 @@
                ],
                initUpdates: function(updates) {
                    updates.addListener(function(msg) {
-                       if (msg.outputAttrsSet && msg.outputAttrsSet.dev == this.uri) {
+                       if (msg.outputAttrsSet && msg.outputAttrsSet.dev == this.uri.value) {
                            this.set('attrs', msg.outputAttrsSet.attrs);
                            this.attrs.forEach(function(row) {
                                row.valClass = row.val == 255 ? 'full' : (row.val ? 'nonzero' : '');
@@ -141,8 +141,10 @@
                        return this.graph.Uri(x);
                    };
                    this.set('devices', []);
-                   _.uniq(_.sortBy(this.graph.subjects(U('rdf:type'), U(':DeviceClass'))), true).forEach(function(dc) {
-                       _.sortBy(this.graph.subjects(U('rdf:type'), dc)).forEach(function(dev) {
+
+                   let classes = this.graph.subjects(U('rdf:type'), U(':DeviceClass'));
+                   _.uniq(_.sortBy(classes, 'value'), true).forEach(function(dc) {
+                       _.sortBy(this.graph.subjects(U('rdf:type'), dc), 'value').forEach(function(dev) {
                            this.push('devices', dev);
                        }.bind(this));
                    }.bind(this));
--- a/light9/web/resource-display.html	Tue May 01 07:43:35 2018 +0000
+++ b/light9/web/resource-display.html	Thu May 03 06:31:18 2018 +0000
@@ -14,7 +14,7 @@
          zpadding: 2px;
      }
     </style>
-    <span class$="[[resClasses]]"><a href="{{uri}}">
+    <span class$="[[resClasses]]"><a href="{{uri.value}}">
       <!-- type icon goes here -->
       {{label}}
     </a></span>
@@ -42,7 +42,7 @@
        is: "resource-display",
        properties: {
            graph: { type: Object },
-           uri: { type: String },
+           uri: { type: Object }, // Use .value for the string
            label: { type: String },
            rename: { type: Boolean },
            minor: { type: Boolean },
@@ -55,7 +55,7 @@
        },
        onUri: function(graph, uri) {
            if (!this.graph) return;
-           this.graph.runHandler(this.setLabel.bind(this), `label ${this.uri}`);
+           this.graph.runHandler(this.setLabel.bind(this), `label ${this.uri.value}`);
        },
        setLabel: function() {
            if (!this.uri) {
@@ -69,7 +69,7 @@
                this.label = null;
            }
            if (!this.label) {
-               this.label = this.uri.replace(/.*\//, '');
+               this.label = this.uri.value.replace(/.*\//, '');
            }
        },
        onRename: function() {
@@ -91,7 +91,7 @@
                var label = this.graph.Uri('rdfs:label');
                var ctxs = this.graph.contextsWithPattern(this.uri, label, null);
                if (ctxs.length != 1) {
-                   throw new Error(`${ctxs.length} label stmts for ${this.uri}`);
+                   throw new Error(`${ctxs.length} label stmts for ${this.uri.label}`);
                }
                this.graph.patchObject(this.uri, label,
                                       this.graph.Literal(this.renameTo),