Skip to content

Instantly share code, notes, and snippets.

@ohcibi
Last active December 13, 2015 18:59
Show Gist options
  • Select an option

  • Save ohcibi/4959783 to your computer and use it in GitHub Desktop.

Select an option

Save ohcibi/4959783 to your computer and use it in GitHub Desktop.

Revisions

  1. ohcibi revised this gist Feb 15, 2013. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions init.coffee
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,21 @@ Ember.Handlebars.registerBoundHelper 'forMoreThanOneIn', (collection) ->
    return "Compound"


    window.App = Ember.Application.create
    rootElement: "#QiviconBasicClient"
    App.Router.map -> @resource 'rooms'
    App.IndexRoute = Ember.Route.extend redirect: -> @transitionTo 'rooms'
    App.ApplicationRoute = Ember.Route.extend
    setupController: -> @controllerFor('rooms').set 'model', App.Room.find()

    # Controllers
    App.RoomsController = Ember.ArrayController.extend
    sortProperties: ['room_id']
    # Routes
    App.RoomsRoute = Ember.Route.extend
    model: -> App.Room.find()

    # Models
    App.Store = DS.Store.extend
    revision: 11
    adapter: DS.FixtureAdapter
  2. ohcibi revised this gist Feb 15, 2013. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions init.coffee
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,9 @@
    Ember.Handlebars.registerBoundHelper 'forMoreThanOneIn', (collection) ->
    alert collection.toArray()
    return elseFn() if collection.length == 1
    return "Compound"


    App.Store = DS.Store.extend
    revision: 11
    adapter: DS.FixtureAdapter
  3. ohcibi created this gist Feb 15, 2013.
    51 changes: 51 additions & 0 deletions init.coffee
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    App.Store = DS.Store.extend
    revision: 11
    adapter: DS.FixtureAdapter
    App.Room = DS.Model.extend
    room_id: DS.attr 'string'
    name: DS.attr 'string'
    devices: DS.hasMany 'App.CompoundDevice'
    App.CompoundDevice = DS.Model.extend
    name: DS.attr 'string'
    type: DS.attr 'string'
    compound_device_id: DS.attr 'string'
    room: DS.belongsTo 'App.Room'
    devices: DS.hasMany 'App.Device'
    App.Device = DS.Model.extend
    device_class: DS.attr 'string'
    device_name: DS.attr 'string'
    device_id: DS.attr 'string'
    states: DS.hasMany 'App.DeviceState'
    compound_device: DS.belongsTo 'App.CompoundDevice'
    App.DeviceState = DS.Model.extend
    name: DS.attr 'string'
    value: DS.attr 'string'
    device: DS.belongsTo 'App.Device'

    # Fixtures
    App.Room.FIXTURES = [
    {id: 1, name: "Wohnzimmer" , room_id: "hz_1" , devices: [2]}
    {id: 2, name: "Schlafzimmer" , room_id: "hz_2"}
    {id: 3, name: "Küche" , room_id: "hz_3" , devices: [4]}
    {id: 4, name: "Bad" , room_id: "hz_4" , devices: [1, 5]}
    {id: 5, name: "Flur" , room_id: "hz_5"}
    {id: 6, name: "Garten" , room_id: "hz_6" , devices: [3]}
    ]

    App.CompoundDevice.FIXTURES = [
    {id: 1, name: "MyContactDetector" , type: "ContactDetector" , compound_device_id: "yyy1", room: 4 , devices: [1]}
    {id: 2, name: "MyDimmer" , type: "DimmableSocket" , compound_device_id: "yyy2", room: 1 , devices: [2]}
    {id: 3, name: "MySwitch" , type: "OnOffSocket" , compound_device_id: "yyy3", room: 6 , devices: [3]}
    {id: 4, name: "MyOnOffMeter" , type: "OnOffMeter" , compound_device_id: "yyy4", room: 3 , devices: [4, 5]}
    {id: 5, name: "MyThermostat" , type: "Thermostat" , compound_device_id: "yyy5", room: 4 , devices: [6, 7, 8]}
    ]

    App.Device.FIXTURES = [
    {id: 1, device_class: "binarySensor" , name: "ContactDetector" , device_id: "xxx1" , states: [1] , compound_device: 1}
    {id: 2, device_class: "multiLevelSwitch" , name: "DimmableSocket" , device_id: "xxx2" , states: [2, 3], compound_device: 2}
    {id: 3, device_class: "binarySwitch" , name: "OnOffSocket" , device_id: "xxx3" , states: [4] , compound_device: 3}
    {id: 4, device_class: "binarySwitch" , name: "EnergyMeter" , device_id: "xxx4" , states: [5] , compound_device: 4}
    {id: 5, device_class: "meter" , name: "EnergyMeter" , device_id: "xxx5" , states: [6, 7], compound_device: 4}
    {id: 6, device_class: "multiLevelSensor" , name: "TemperatureSensor", device_id: "xxx6" , states: [8] , compound_device: 5}
    {id: 7, device_class: "multiLevelSensor" , name: "HumiditySensor" , device_id: "xxx7" , states: [9] , compound_device: 5}
    {id: 8, device_class: "temperatureActuator", name: "Thermostat" , device_id: "xxx8" , states: [10] , compound_device: 5}