# HG changeset patch
# User drewp@bigasterisk.com
# Date 1465681237 0
# Node ID 8a9a9b58a4e21a9987a61a8c2f65999e993e1f26
# Parent ba6594263fa7b2d1f3857bc2fd1f1ba5aa71af66
live page now knows that collector needs all settings on each request
Ignore-this: 79ad8d1e001b98b6fce6d14f75f92745
diff -r ba6594263fa7 -r 8a9a9b58a4e2 light9/web/light9-collector-client.html
--- a/light9/web/light9-collector-client.html Sat Jun 11 21:29:06 2016 +0000
+++ b/light9/web/light9-collector-client.html Sat Jun 11 21:40:37 2016 +0000
@@ -17,6 +17,7 @@
ready: function() {
this.self = this;
var self = this;
+ this.lastSent = [];
self.$.put.addEventListener(
'error', function() { self.status = 'err'; });
@@ -29,7 +30,7 @@
self.status = 'ready';
},
ping: function() {
- this.send([]);
+ this.send(this.lastSent);
},
send: function(settings) {
this.$.put.body = JSON.stringify({
@@ -37,6 +38,7 @@
"client": window.location.href,
"clientSession": this.clientSession});
this.$.put.generateRequest();
+ this.lastSent = settings.slice();
}
});
diff -r ba6594263fa7 -r 8a9a9b58a4e2 light9/web/live/index.html
--- a/light9/web/live/index.html Sat Jun 11 21:29:06 2016 +0000
+++ b/light9/web/live/index.html Sat Jun 11 21:40:37 2016 +0000
@@ -106,7 +106,6 @@
diff -r ba6594263fa7 -r 8a9a9b58a4e2 light9/web/live/live.coffee
--- a/light9/web/live/live.coffee Sat Jun 11 21:29:06 2016 +0000
+++ b/light9/web/live/live.coffee Sat Jun 11 21:40:37 2016 +0000
@@ -3,7 +3,6 @@
Polymer
is: 'light9-live-control'
properties:
- client: { type: Object }
device: { type: String }
deviceAttr: { type: Object }
max: { type: Number, value: 1 }
@@ -25,7 +24,6 @@
@lastSent = [[@device, @deviceAttr.uri, value]]
@resend()
resend: ->
- @client.send(@lastSent)
window.gather(@lastSent)
clear: ->
if @deviceAttr.useColor
@@ -38,6 +36,7 @@
is: "light9-live-controls"
properties:
graph: { type: Object, notify: true }
+ client: { type: Object, notify: true }
devices: { type: Array, notify: true }
currentSettings: { type: Object, notify: true } # dev+attr: [dev, attr, value]
effectPreview: { type: String, notify: true }
@@ -56,6 +55,14 @@
else
@currentSettings[key] = [dev, devAttr, value]
@effectPreview = JSON.stringify(v for k,v of @currentSettings)
+
+ @debounce('send', @sendAll.bind(@), 2)
+
+ currentSettingsList: -> (v for k,v of @currentSettings)
+
+ sendAll: ->
+ @client.send(@currentSettingsList())
+
saveNewEffect: ->
uriName = @newEffectName.replace(/[^a-zA-Z0-9_]/g, '')
return if not uriName.length
@@ -71,8 +78,8 @@
quad(effectUri, U('rdfs:label'), @graph.Literal(@newEffectName))
quad(effectUri, U(':publishAttr'), U(':strength'))
]
- settings = @graph.nextNumberedResources(effectUri + '_set', Object.keys(@currentSettings).length)
- for _, row of @currentSettings
+ settings = @graph.nextNumberedResources(effectUri + '_set', @currentSettingsList().length)
+ for row in @currentSettingsList()
if row[2] == 0 or row[2] == '#000000'
continue
setting = settings.shift()
@@ -90,6 +97,7 @@
patch = {addQuads: addQuads, delQuads: []}
log('save', patch)
@graph.applyAndSendPatch(patch)
+ @newEffectName = ''
onGraph: ->
@graph.runHandler(@update.bind(@))