Skip to content

Instantly share code, notes, and snippets.

@ohcibi
Created February 12, 2013 18:17
Show Gist options
  • Save ohcibi/4771987 to your computer and use it in GitHub Desktop.
Save ohcibi/4771987 to your computer and use it in GitHub Desktop.
window.App = Ember.Application.create()
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
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'
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'
# 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", cdevice_id: "yyy1", room: 4}
{id: 2, name: "MyDimmer", cdevice_id: "yyy2", room: 1}
{id: 3, name: "MySwitch", cdevice_id: "yyy3", room: 6}
{id: 4, name: "MyOnOffMeter", cdevice_id: "yyy4", room: 3}
{id: 5, name: "MyThermostat", cdevice_id: "yyy5", room: 4}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment