Files
@ 15babcd58d48
Branch filter:
Location: light9/light9/collector/web/index.html - annotation
15babcd58d48
5.2 KiB
text/html
update collector web to new n3js
Ignore-this: e68cc63a9a7a5828c5d2f3a82a38bc6f
Ignore-this: e68cc63a9a7a5828c5d2f3a82a38bc6f
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 15babcd58d48 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 616b22296156 15babcd58d48 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c8cffe82b537 c8cffe82b537 c8cffe82b537 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 616b22296156 d372508bec98 616b22296156 616b22296156 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 616b22296156 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 15babcd58d48 60e559cb1a5e c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 15babcd58d48 60e559cb1a5e c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 15babcd58d48 15babcd58d48 15babcd58d48 15babcd58d48 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 c1bf296b0a74 | <!doctype html>
<html>
<head>
<title>collector</title>
<meta charset="utf-8" />
<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="/node_modules/n3/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>
td { white-space: nowrap; }
</style>
</head>
<body>
<dom-module id="light9-collector-device">
<template>
<style>
:host {
display: block;
break-inside: avoid-column;
}
h3 {
margin-top: 12px;
margin-bottom: 0;
}
td.nonzero {
background: #310202;
color: #e25757;
}
td.full {
background: #2b0000;
color: red;
font-weight: bold;
}
</style>
<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>
<template is="dom-repeat" items="{{attrs}}">
<tr>
<td>{{item.attr}}</td>
<td class$="{{item.valClass}}">{{item.val}} →</td>
<td>{{item.chan}}</td>
</tr>
</template>
</template>
<script>
HTMLImports.whenReady(function () {
Polymer({
is: "light9-collector-device",
properties: {
graph: {type: Object, notify: true},
uri: {type: Object, notify: true},
attrs: {type: Array, notify: true},
},
observers: [
"initUpdates(updates)",
],
initUpdates: function(updates) {
updates.addListener(function(msg) {
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' : '');
});
}
}.bind(this));
},
});
});
</script>
</dom-module>
<dom-module id="light9-collector-ui">
<template>
<rdfdb-synced-graph graph="{{graph}}"></rdfdb-synced-graph>
<h1>Collector <a href="stats">[stats]</a></h1>
<h2>Devices</h2>
<div style="column-width: 18em">
<template is="dom-repeat" items="{{devices}}">
<light9-collector-device
graph="{{graph}}" updates="{{updates}}"
uri="{{item}}"></light9-collector-device>
</template>
</div>
</template>
<script>
class Updates {
constructor() {
this.listeners = [];
}
addListener(cb) {
this.listeners.push(cb);
}
onMessage(msg) {
this.listeners.forEach(function(lis) {
lis(msg);
});
}
}
HTMLImports.whenReady(function () {
Polymer({
is: "light9-collector-ui",
properties: {
graph: {type: Object, notify: true},
updates: {type: Object, notify: true},
devices: {type: Array},
},
observers: [
'onGraph(graph)',
],
ready: function() {
this.updates = new Updates();
var sock = new WebSocket(
window.location.href.replace(/^http/, 'ws') + 'updates');
sock.onmessage = function(ev) {
this.updates.onMessage(JSON.parse(ev.data));
}.bind(this);
},
onGraph: function(graph) {
this.graph.runHandler(this.findDevices.bind(this), 'findDevices');
},
findDevices: function() {
var U = function(x) {
return this.graph.Uri(x);
};
this.set('devices', []);
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));
}
});
});
</script>
</dom-module>
<light9-collector-ui></light9-collector-ui>
</body>
</html>
|