# HG changeset patch # User Drew Perttula # Date 1528100501 0 # Node ID 067da1234c8efa8eda285421af0134e381b0a63e # Parent 178b11c9a429cdce0dd621bf4bf52bbb126b03e6 port /live to polymer2 and new n3 api, mostly Ignore-this: 9ad2163496af176fc2b2825209de92ac diff -r 178b11c9a429 -r 067da1234c8e light9/web/lib/bower.json --- a/light9/web/lib/bower.json Mon Jun 04 07:07:11 2018 +0000 +++ b/light9/web/lib/bower.json Mon Jun 04 08:21:41 2018 +0000 @@ -13,7 +13,7 @@ "jquery-ui": "~1.11.4", "jquery.columnizer": "https://github.com/adamwulf/Columnizer-jQuery-Plugin.git#^1.6.2", "knockout": "knockoutjs#^3.4.2", - "paper-button": "PolymerElements/paper-button#^2.1.0", + "paper-button": "PolymerElements/paper-button#^2.1.1", "paper-dialog": "PolymerElements/paper-dialog#^2.1.0", "paper-item": "PolymerElements/paper-item#2.1.0", "paper-listbox": "PolymerElements/paper-listbox#2.1.0", @@ -26,10 +26,18 @@ "shortcut": "http://www.openjs.com/scripts/events/keyboard_shortcuts/shortcut.js", "sylvester": "~0.1.3", "underscore": "~1.8.3", - "polymer": "Polymer/polymer#^2.0.0" + "polymer": "Polymer/polymer#^2.0.0", + "iron-flex-layout": "PolymerElements/iron-flex-layout#^2.0.3", + "iron-component-page": "PolymerElements/iron-component-page#^3.0.1", + "paper-header-panel": "PolymerElements/paper-header-panel#^2.1.0" }, "resolutions": { "webcomponentsjs": "^v1.1.0", - "polymer": "^2.0.0" + "polymer": "^2.0.0", + "iron-flex-layout": "^2.0.3", + "paper-button": "^2.1.1", + "iron-component-page": "^3.0.1", + "iron-doc-viewer": "^3.0.0", + "paper-header-panel": "^2.1.0" } } diff -r 178b11c9a429 -r 067da1234c8e light9/web/live/elements.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/light9/web/live/elements.html Mon Jun 04 08:21:41 2018 +0000 @@ -0,0 +1,259 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 178b11c9a429 -r 067da1234c8e light9/web/live/index.html --- a/light9/web/live/index.html Mon Jun 04 07:07:11 2018 +0000 +++ b/light9/web/live/index.html Mon Jun 04 08:21:41 2018 +0000 @@ -4,28 +4,8 @@ device control - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - diff -r 178b11c9a429 -r 067da1234c8e light9/web/live/live.coffee --- a/light9/web/live/live.coffee Mon Jun 04 07:07:11 2018 +0000 +++ b/light9/web/live/live.coffee Mon Jun 04 08:21:41 2018 +0000 @@ -1,8 +1,8 @@ log = console.log -Polymer - is: 'light9-live-control' - properties: +coffeeElementSetup(class Light9LiveControl extends Polymer.Element + @is: 'light9-live-control' + @getter_properties: device: { type: String } deviceAttr: { type: Object } max: { type: Number, value: 1 } @@ -11,11 +11,11 @@ immediateSlider: { notify: true, observer: 'onSlider' } sliderWriteValue: { type: Number } pickedChoice: { observer: 'onChange' } - observers: [ + @getter_observers: [ 'onChange(value)' ] ready: -> - + super.ready() onSlider: -> @value = @immediateSlider goBlack: -> @value = "#000000" onChange: (value) -> @@ -30,27 +30,29 @@ @value = '#000000' else @value = @immediateSlider = 0 +) -Polymer - is: "light9-live-device-control" - properties: +coffeeElementSetup(class Light9LiveDeviceControl extends Polymer.Element + @is: "light9-live-device-control" + @getter_properties: graph: { type: Object, notify: true } uri: { type: String, notify: true } deviceClass: { type: String, notify: true } deviceAttrs: { type: Array, notify: true } bgStyle: { type: String, computed: '_bgStyle(deviceClass)' } - observers: [ + @getter_observers: [ 'onGraph(graph)' ] _bgStyle: (deviceClass) -> hash = 0 + deviceClass = deviceClass.value for i in [(deviceClass.length-10)...deviceClass.length] hash += deviceClass.charCodeAt(i) hue = (hash * 8) % 360 accent = "hsl(#{hue}, 49%, 22%)" "background: linear-gradient(to right, rgba(31,31,31,0) 50%, #{accent} 100%);" onGraph: -> - @graph.runHandler(@update.bind(@), "#{@uri} update") + @graph.runHandler(@update.bind(@), "#{@uri.value} update") update: -> U = (x) => @graph.Uri(x) @@ -62,12 +64,12 @@ daRow = { uri: da dataType: dataType - showColorPicker: dataType == U(':color') + showColorPicker: dataType.equals(U(':color')) } - if dataType == 'http://light9.bigasterisk.com/color' + if dataType.equals(U(':color')) daRow.useColor = true - else if dataType == U(':choice') + else if dataType.equals(U(':choice')) daRow.useChoice = true choiceUris = _.sortBy(@graph.objects(da, U(':choice'))) daRow.choices = ({uri: x, label: @graph.labelOrTail(x)} for x in choiceUris) @@ -75,16 +77,16 @@ else daRow.useSlider = true daRow.max = 1 - if dataType == U(':angle') + if dataType.equals(U(':angle')) # varies daRow.max = 1 @push('deviceAttrs', daRow) - +) -Polymer - is: "light9-live-controls" - properties: +coffeeElementSetup(class Light9LiveControls extends Polymer.Element + @is: "light9-live-controls" + @getter_properties: graph: { type: Object, notify: true } client: { type: Object, notify: true } devices: { type: Array, notify: true } @@ -92,11 +94,12 @@ effectPreview: { type: String, notify: true } newEffectName: { type: String, notify: true } effect: { type: String, notify: true } # the one being edited, if any - observers: [ + @getter_observers: [ 'onGraph(graph)' 'onEffect(effect)' ] ready: -> + super.ready() @currentSettings = {} @effectPreview = JSON.stringify({}) @@ -104,7 +107,7 @@ window.gather = (sent) => [dev, devAttr, value] = sent[0] - key = dev + " " + devAttr + key = dev.value + " " + devAttr.value # this is a bug for zoom=0, since collector will default it to # stick at the last setting if we don't explicitly send the # 0. rx/ry similar though not the exact same deal because of @@ -149,16 +152,16 @@ U = (x) => @graph.Uri(x) - @effect = U(":effect") + "/#{uriName}" + @effect = U(U(":effect").value + "/#{uriName}") ctx = U("http://light9.bigasterisk.com/show/dance2017/effect/#{uriName}") - quad = (s, p, o) => {subject: s, predicate: p, object: o, graph: ctx} + quad = (s, p, o) => @graph.Quad(s, p, o, ctx) addQuads = [ quad(@effect, U('rdf:type'), U(':Effect')) quad(@effect, U('rdfs:label'), @graph.Literal(@newEffectName)) quad(@effect, U(':publishAttr'), U(':strength')) ] - settings = @graph.nextNumberedResources(@effect + '_set', @currentSettingsList().length) + settings = @graph.nextNumberedResources(@effect.value + '_set', @currentSettingsList().length) for row in @currentSettingsList() if row[2] == 0 or row[2] == '#000000' continue @@ -206,3 +209,4 @@ layoutMode: 'masonry', containerStyle: null })), 2000) +) \ No newline at end of file