From 595e5f9d32c9dda8f7b6c0dd5e7e4fba4693eca4 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 20 Mar 2013 17:08:14 +0100 Subject: basic Ember.js setup --- public/js/app.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 public/js/app.js (limited to 'public/js/app.js') diff --git a/public/js/app.js b/public/js/app.js new file mode 100644 index 0000000..238f29e --- /dev/null +++ b/public/js/app.js @@ -0,0 +1,16 @@ +App = Ember.Application.create({ + LOG_TRANSITIONS: true, + rootElement: '#container' +}); + + +App.ApplicationRoute = Ember.Route.extend({ + setupController: function(controller) { + // `controller` is the instance of ApplicationController + controller.set('title', "Hello world!"); + } +}); + +App.ApplicationController = Ember.Controller.extend({ + appName: 'My First Example' +}); \ No newline at end of file -- cgit v1.2.3 From 877364c24ef9c7954f0e193456bb3f2d39169977 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Mon, 25 Mar 2013 10:26:49 +0100 Subject: First try --- public/js/app.js | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) (limited to 'public/js/app.js') diff --git a/public/js/app.js b/public/js/app.js index 238f29e..97ed43e 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -3,14 +3,69 @@ App = Ember.Application.create({ rootElement: '#container' }); +// Router +App.Router.map(function() { + this.resource('switchboards', function() { + this.resource('switchboard', { path: ':switchboard_id' }); + }); +}); App.ApplicationRoute = Ember.Route.extend({ setupController: function(controller) { // `controller` is the instance of ApplicationController - controller.set('title', "Hello world!"); + controller.set('title', "Hello world! Switchboard #" + switchboard_id); + } +}); + +App.SwitchboardsRoute = Ember.Route.extend({ + model: function() { + return App.Switchboard.find(); } }); +App.IndexRoute = Ember.Route.extend({ + redirect: function() { + this.transitionTo('switchboard', App.Switchboard.find(switchboard_id)); + } +}); + +// Controller App.ApplicationController = Ember.Controller.extend({ appName: 'My First Example' -}); \ No newline at end of file +}); + +App.SwitchboardsController = Ember.ArrayController.extend({ + // switchboardEntrys: table.get('tab.tabItems') +}) + +// Models +App.Store = DS.Store.extend({ + revision: 11 +}); + +DS.RESTAdapter.configure("plurals", { + switchboard_entry: "switchboard_entries" +}); + +App.Switchboard = DS.Model.extend({ + switchboardEntrys: DS.hasMany('App.SwitchboardEntry'), + name: DS.attr('string'), + didLoad: function() { + console.log('Switchboard model loaded') + } +}); + + + +App.SwitchboardEntry = DS.Model.extend({ + switchboard: DS.belongsTo('App.Switchboard'), + name: DS.attr('string'), + didLoad: function() { + console.log('SwitchboardEntry model loaded') + } +}); + +// // Views +// App.SwitchboardView = Ember.View.extend({ +// templateName: 'switchboard' +// }); \ No newline at end of file -- cgit v1.2.3 From 64653a9149eca977c16233abb0a472730b94a464 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Tue, 26 Mar 2013 16:55:08 +0100 Subject: Store reload interval in the Switchboard table. --- public/js/app.js | 58 +++++++++++++++++++------------------------------------- 1 file changed, 20 insertions(+), 38 deletions(-) (limited to 'public/js/app.js') diff --git a/public/js/app.js b/public/js/app.js index 97ed43e..87a4ba6 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -1,42 +1,31 @@ App = Ember.Application.create({ LOG_TRANSITIONS: true, - rootElement: '#container' + rootElement: '#emberjs-container', + + // Reload the switchboard every x milliseconds + // if reload_interval != 0 + ready: function() { + if (reload_interval != 0) { + var switchboard = App.Switchboard.find(switchboard_id); + setInterval(function() { + switchboard.reload(); + }, reload_interval); + } + } }); // Router App.Router.map(function() { - this.resource('switchboards', function() { - this.resource('switchboard', { path: ':switchboard_id' }); - }); -}); - -App.ApplicationRoute = Ember.Route.extend({ - setupController: function(controller) { - // `controller` is the instance of ApplicationController - controller.set('title', "Hello world! Switchboard #" + switchboard_id); - } + this.resource('switchboard', { path: '/' }); }); -App.SwitchboardsRoute = Ember.Route.extend({ +App.SwitchboardRoute = Ember.Route.extend({ model: function() { - return App.Switchboard.find(); + return App.Switchboard.find(switchboard_id); } }); -App.IndexRoute = Ember.Route.extend({ - redirect: function() { - this.transitionTo('switchboard', App.Switchboard.find(switchboard_id)); - } -}); - // Controller -App.ApplicationController = Ember.Controller.extend({ - appName: 'My First Example' -}); - -App.SwitchboardsController = Ember.ArrayController.extend({ - // switchboardEntrys: table.get('tab.tabItems') -}) // Models App.Store = DS.Store.extend({ @@ -50,22 +39,15 @@ DS.RESTAdapter.configure("plurals", { App.Switchboard = DS.Model.extend({ switchboardEntrys: DS.hasMany('App.SwitchboardEntry'), name: DS.attr('string'), - didLoad: function() { - console.log('Switchboard model loaded') - } }); - - App.SwitchboardEntry = DS.Model.extend({ switchboard: DS.belongsTo('App.Switchboard'), + switchboard: DS.belongsTo('App.SipAccount'), name: DS.attr('string'), - didLoad: function() { - console.log('SwitchboardEntry model loaded') - } }); -// // Views -// App.SwitchboardView = Ember.View.extend({ -// templateName: 'switchboard' -// }); \ No newline at end of file +App.SipAccount = DS.Model.extend({ + switchboardEntrys: DS.hasMany('App.SwitchboardEntry'), + callerName: DS.attr('string'), +}); \ No newline at end of file -- cgit v1.2.3 From cea2cc3c1cc1e48fc4600c698d52dfda2bde4505 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Wed, 3 Apr 2013 22:08:19 +0200 Subject: Massive changes to the switchboard. --- public/js/app.js | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) (limited to 'public/js/app.js') diff --git a/public/js/app.js b/public/js/app.js index 87a4ba6..4bc8cc1 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -9,6 +9,11 @@ App = Ember.Application.create({ var switchboard = App.Switchboard.find(switchboard_id); setInterval(function() { switchboard.reload(); + + // var switchboard_entries = App.SwitchboardEntry.find(); + // switchboard_entries.forEach(function(switchboard_entry) { + // switchboard_entry.reload(); + // }); }, reload_interval); } } @@ -29,25 +34,57 @@ App.SwitchboardRoute = Ember.Route.extend({ // Models App.Store = DS.Store.extend({ - revision: 11 + revision: 12 }); DS.RESTAdapter.configure("plurals", { switchboard_entry: "switchboard_entries" }); +DS.RESTAdapter.reopen({ + namespace: 'api/v1' +}); + App.Switchboard = DS.Model.extend({ switchboardEntrys: DS.hasMany('App.SwitchboardEntry'), - name: DS.attr('string'), + name: DS.attr('string') }); App.SwitchboardEntry = DS.Model.extend({ switchboard: DS.belongsTo('App.Switchboard'), - switchboard: DS.belongsTo('App.SipAccount'), + sipAccount: DS.belongsTo('App.SipAccount'), name: DS.attr('string'), + path_to_user: DS.attr('string'), + avatar_src: DS.attr('string'), + callstate: DS.attr('string') }); +App.Adapter = DS.RESTAdapter.extend(); + +App.store = App.Store.create({ + adapter: App.Adapter.create() +}); + +App.store.adapter.serializer.configure(App.SwitchboardEntry, { sideloadAs: 'switchboard_entries' }); + App.SipAccount = DS.Model.extend({ switchboardEntrys: DS.hasMany('App.SwitchboardEntry'), + phoneNumbers: DS.hasMany('App.PhoneNumber'), callerName: DS.attr('string'), -}); \ No newline at end of file + authName: DS.attr('string') +}); + +App.PhoneNumber = DS.Model.extend({ + name: DS.attr('string'), + number: DS.attr('string') +}); + +App.store.adapter.serializer.configure(App.PhoneNumber, { sideloadAs: 'phone_numbers' }); + +Ember.Handlebars.registerBoundHelper('avatar_img', function(value) { + return new Handlebars.SafeString('Avatar image'); +}); + +Ember.Handlebars.registerBoundHelper('show_callstate', function(value) { + return new Handlebars.SafeString('' + value + ''); +}); -- cgit v1.2.3