Mercurial > code > home > repos > light9
changeset 1643:77eaccba654e
try to fix timeline sending empty ctx to rdfdb
Ignore-this: f778183e90f073b9914d9b6736560d99
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Sat, 10 Jun 2017 07:17:20 +0000 |
parents | 8603ab0b9fa8 |
children | 9f7e31bf3f0c |
files | light9/rdfdb/rdflibpatch.py light9/web/effects/effects.coffee light9/web/graph.coffee light9/web/live/live.coffee light9/web/rdfdbclient.coffee light9/web/timeline/timeline.coffee |
diffstat | 6 files changed, 33 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/rdfdb/rdflibpatch.py Sat Jun 10 07:15:07 2017 +0000 +++ b/light9/rdfdb/rdflibpatch.py Sat Jun 10 07:17:20 2017 +0000 @@ -70,6 +70,7 @@ def graphFromNQuad(text): g1 = ConjunctiveGraph() + # text might omit ctx on some lines. rdflib just puts in a bnode, which shows up later. g1.parse(data=text, format='nquads') return g1
--- a/light9/web/effects/effects.coffee Sat Jun 10 07:15:07 2017 +0000 +++ b/light9/web/effects/effects.coffee Sat Jun 10 07:17:20 2017 +0000 @@ -4,7 +4,7 @@ graph: {type: Object} effectClasses: { type: Array } ready: -> - @graph.runHandler(@getClasses.bind(@)) + @graph.runHandler(@getClasses.bind(@), 'getClasses') getClasses: -> U = (x) => @graph.Uri(x)
--- a/light9/web/graph.coffee Sat Jun 10 07:15:07 2017 +0000 +++ b/light9/web/graph.coffee Sat Jun 10 07:17:20 2017 +0000 @@ -71,6 +71,9 @@ runHandler: (func, label) -> # what if we have this func already? duplicate is safe? + if not label? + throw new Error("missing label") + h = new Handler(func, label) @handlerStack[@handlerStack.length - 1].innerHandlers.push(h) console.time("handler #{label}") @@ -127,10 +130,10 @@ @clearGraph() if @patchSenderUrl - @_client = new RdfDbClient(@patchSenderUrl, @clearGraph.bind(@), + @_client = new RdfDbClient(@patchSenderUrl, @_clearGraphOnNewConnection.bind(@), @_applyPatch.bind(@), @setStatus) - clearGraph: -> # for debugging + clearGraph: -> # just deletes the statements; watchers are unaffected. if @graph? @_applyPatch({addQuads: [], delQuads: @graph.find()}) @@ -139,7 +142,11 @@ @graph = N3.Store() @_addPrefixes(@prefixes) @cachedFloatValues = new Map(); - + + _clearGraphOnNewConnection: -> # must not send a patch to the server! + log('graph: clearGraphOnNewConnection') + @clearGraph() + log('graph: clearGraphOnNewConnection done') _addPrefixes: (prefixes) -> @graph.addPrefixes(prefixes) @@ -175,6 +182,13 @@ applyAndSendPatch: (patch) -> if !Array.isArray(patch.addQuads) || !Array.isArray(patch.delQuads) throw new Error("corrupt patch: #{patch}") + + for qs in [patch.addQuads, patch.delQuads] + for q in qs + if not q.graph? + throw new Error("corrupt patch: #{q}") + + log('graph: patch', patch) @_applyPatch(patch) @_client.sendPatch(patch) if @_client
--- a/light9/web/live/live.coffee Sat Jun 10 07:15:07 2017 +0000 +++ b/light9/web/live/live.coffee Sat Jun 10 07:17:20 2017 +0000 @@ -157,7 +157,7 @@ @newEffectName = '' onGraph: -> - @graph.runHandler(@update.bind(@)) + @graph.runHandler(@update.bind(@), 'controls') resendAll: -> for llc in @getElementsByTagName("light9-live-control") llc.resend()
--- a/light9/web/rdfdbclient.coffee Sat Jun 10 07:15:07 2017 +0000 +++ b/light9/web/rdfdbclient.coffee Sat Jun 10 07:17:20 2017 +0000 @@ -52,7 +52,7 @@ class window.RdfDbClient # Send and receive patches from rdfdb - constructor: (@patchSenderUrl, @clearGraph, @applyPatch, @setStatus) -> + constructor: (@patchSenderUrl, @clearGraphOnNewConnection, @applyPatch, @setStatus) -> @_patchesToSend = [] @_lastPingMs = -1 @_patchesReceived = 0 @@ -77,7 +77,7 @@ #{ping}ms") sendPatch: (patch) -> - console.log('queue patch to server ', patchSizeSummary(patch)) + console.log('rdfdbclient: queue patch to server ', patchSizeSummary(patch)) @_patchesToSend.push(patch) @_updateStatus() @_continueSending() @@ -89,17 +89,17 @@ @ws = new WebSocket(fullUrl) @ws.onopen = => - log('connected to', fullUrl) + log('rdfdbclient: connected to', fullUrl) @_updateStatus() - @clearGraph() + @clearGraphOnNewConnection() @_pingLoop() @ws.onerror = (e) => - log('ws error ' + e) + log('rdfdbclient: ws error ' + e) @ws.onclose() @ws.onclose = => - log('ws close') + log('rdfdbclient: ws close') @_updateStatus() clearTimeout(@_reconnectionTimeout) if @_reconnectionTimeout? @_reconnectionTimeout = setTimeout(@_newConnection.bind(@), 1000) @@ -134,7 +134,7 @@ sendOne = (patch, cb) => toJsonPatch(patch, (json) => - log('send patch to server, ' + json.length + ' bytes') + log('rdfdbclient: send patch to server, ' + json.length + ' bytes') @ws.send(json) @_patchesSent++ @_updateStatus()
--- a/light9/web/timeline/timeline.coffee Sat Jun 10 07:15:07 2017 +0000 +++ b/light9/web/timeline/timeline.coffee Sat Jun 10 07:17:20 2017 +0000 @@ -285,7 +285,7 @@ song: { type: String, notify: true } zoomInX: { type: Object, notify: true } rows: { value: [0...ROW_COUNT] } - zoom: { type: Object, notify: true, observer: 'onZoom' } + zoom: { type: Object, notify: true, observer: 'onZoom' } # viewState.zoomSpec zoomFlattened: { type: Object, notify: true } onZoom: -> updateZoomFlattened = -> @@ -364,6 +364,7 @@ desiredWidthX = @offsetWidth * .3 desiredWidthT = @zoomInX.invert(desiredWidthX) - @zoomInX.invert(0) + desiredWidthT = Math.min(desiredWidthT, @zoom.duration() - dropTime) for i in [0...4] pt = points[i] @@ -630,6 +631,9 @@ editAttr: (song, note, attr, value) -> U = (x) => @graph.Uri(x) + if not song? + log("can't edit inline attr yet, no song") + return quad = (s, p, o) => {subject: s, predicate: p, object: o, graph: song} existingColorScaleSetting = null @@ -650,7 +654,7 @@ @graph.applyAndSendPatch(patch) addHandler: -> - @graph.runHandler(@update.bind(@)) + @graph.runHandler(@update.bind(@), "update inline attrs #{@uri}") update: -> #console.time('attrs update')