Changeset - 013cbd7a0f08
[Not reviewed]
default
0 6 0
Drew Perttula - 8 years ago 2017-06-03 09:20:04
drewp@bigasterisk.com
choice-type attrs in live
Ignore-this: 6c762ec4b8f93c4700edbb080990eb5f
6 files changed with 30 insertions and 21 deletions:
0 comments (0 inline, 0 general)
bin/collector
Show inline comments
 
@@ -32,7 +32,11 @@ def parseJsonMessage(msg):
 
    body = json.loads(msg)
 
    settings = []
 
    for device, attr, value in body['settings']:
 
        settings.append((URIRef(device), URIRef(attr), Literal(value)))
 
        if isinstance(value, basestring) and value.startswith('http'):
 
            value = URIRef(value)
 
        else:
 
            value = Literal(value)
 
        settings.append((URIRef(device), URIRef(attr), value))
 
    return body['client'], body['clientSession'], settings, body['sendTime']
 

	
 
def startZmq(port, collector):
light9/collector/device.py
Show inline comments
 
@@ -104,6 +104,7 @@ def toOutputAttrs(deviceType, deviceAttr
 
            return 3
 
        if deviceAttrSettings.get(attr) == L9['g2']:
 
            return 10
 
        return 0
 
        
 
    if deviceType == L9['ChauvetColorStrip']:
 
        r, g, b = rgbAttr(L9['color'])
light9/web/graph.coffee
Show inline comments
 
@@ -253,6 +253,13 @@ class window.SyncedGraph
 
  uriValue: (s, p) ->
 
    @_singleValue(s, p)
 

	
 
  labelOrTail: (uri) ->
 
    try
 
      @graph.stringValue(uri, @graph.Uri('rdfs:label'))
 
    catch
 
      words = uri.split('/')
 
      words[words.length-1]
 

	
 
  objects: (s, p) ->
 
    @_autoDeps.askedFor(s, p, null, null)
 
    quads = @graph.findByIRI(s, p)
light9/web/live/index.html
Show inline comments
 
@@ -43,9 +43,10 @@
 
          <button on-click="goBlack">black</button>
 
        </template>
 
        <template is="dom-if" if="{{deviceAttr.useChoice}}">
 
          <select size="10">
 
          <select size$="{{deviceAttr.choiceSize}}" value="{{pickedChoice::change}}">
 
            <option value="">None</option>
 
            <template is="dom-repeat" items="{{deviceAttr.choices}}">
 
              <option>item {{item}}</option>
 
              <option value="{{item.uri}}">{{item.label}}</option>
 
            </template>
 
          </select>
 
        </template>
light9/web/live/live.coffee
Show inline comments
 
@@ -10,6 +10,7 @@ Polymer
 
    
 
    immediateSlider: { notify: true, observer: 'onSlider' }
 
    pickedColor: { observer: 'onPickedColor' }
 
    pickedChoice: { observer: 'onChange' }
 
  observers: [
 
    'onChange(value)'
 
    ]
 
@@ -19,9 +20,6 @@ Polymer
 
  onSlider: -> @value = @immediateSlider
 
  goWhite: -> @value = "#ffffff"
 
  goBlack: -> @value = "#000000"
 
  onChoice: (ev) ->
 
    console.log('ch', ev)
 
  
 
  onChange: (value) ->
 
    @lastSent = [[@device, @deviceAttr.uri, value]]
 
    @resend()
 
@@ -38,7 +36,6 @@ Polymer
 
  properties:
 
    graph: { type: Object, notify: true }
 
    uri: { type: String, notify: true }
 
    label: { type: String, notify: true }
 
    deviceClass: { type: String, notify: true }
 
    deviceAttrs: { type: Array, notify: true }
 
  observers: [
 
@@ -48,13 +45,7 @@ Polymer
 
    @graph.runHandler(@update.bind(@), "#{@uri} update")
 
  update: ->
 
    U = (x) => @graph.Uri(x)
 

	
 
    @zlabel = (try
 
        @graph.stringValue(@uri, U('rdfs:label'))
 
      catch
 
        words = @uri.split('/')
 
        words[words.length-1]
 
        )
 
    
 
    @deviceClass = @graph.uriValue(@uri, U('rdf:type'))
 
    
 
    @deviceAttrs = []
 
@@ -70,9 +61,10 @@ Polymer
 

	
 
      else if dataType == U(':choice')
 
        daRow.useChoice = true
 
        daRow.choices = @graph.objects(da, U(':choice'))
 
        choiceUris = _.sortBy(@graph.objects(da, U(':choice')))
 
        daRow.choices = ({uri: x, label: @graph.labelOrTail(x)} for x in choiceUris)
 
        daRow.choiceSize = Math.min(choiceUris.length + 1, 10)
 
      else
 

	
 
        daRow.useSlider = true
 
        daRow.max = 1
 
        if dataType == U(':angle')
light9/web/resource-display.html
Show inline comments
 
@@ -38,8 +38,8 @@
 
   Polymer({
 
       is: "resource-display",
 
       properties: {
 
           graph: { type: Object },
 
           uri: { type: String },
 
           graph: { type: Object, notify: true },
 
           uri: { type: String, notify: true },
 
           label: { type: String },
 
           rename: { type: Boolean },
 
           renameTo: { type: String, notify: true },
 
@@ -48,10 +48,14 @@
 
           this.graph.runHandler(this.setLabel.bind(this), `label ${this.uri}`);
 
       },
 
       setLabel: function() {
 
           this.label = this.graph.stringValue(this.uri,
 
                                               this.graph.Uri('rdfs:label'));
 
           try {
 
             this.label = this.graph.stringValue(this.uri,
 
                                                 this.graph.Uri('rdfs:label'));
 
           } catch(e) {
 
               this.label = null;
 
           }
 
           if (!this.label) {
 
               this.label = this.uri;
 
               this.label = this.uri || "<no uri>";
 
           }
 
       },
 
       onRename: function() {
0 comments (0 inline, 0 general)