summaryrefslogtreecommitdiff
path: root/public/js/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/js/app.js')
-rw-r--r--public/js/app.js126
1 files changed, 103 insertions, 23 deletions
diff --git a/public/js/app.js b/public/js/app.js
index 51b3b71..e389b9a 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -1,5 +1,4 @@
App = Ember.Application.create({
- LOG_TRANSITIONS: true,
rootElement: '#emberjs-container',
// Reload the switchboard every x milliseconds
@@ -9,11 +8,6 @@ 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);
}
}
@@ -32,16 +26,31 @@ App.SwitchboardRoute = Ember.Route.extend({
// Controller
App.SwitchboardController = Ember.ObjectController.extend({
- blind_transfer: function() {
- console.log('transfer')
- }
+ transfer_blind: function(call_id, destination) {
+ request_url = '/api/v1/calls/' + call_id + '.json';
+ jQuery.get(request_url, { transfer_blind: destination });
+ },
+
+ transfer_attended: function(call_id, destination) {
+ request_url = '/api/v1/calls/' + call_id + '.json';
+ jQuery.get(request_url, { transfer_attended: destination });
+ },
+
+ searchText: null,
+
+ searchResults: function() {
+ var searchText = this.get('searchText');
+ if (!searchText) { return; }
+ return App.PhoneBookEntry.find({ query: searchText, switchboard_id: switchboard_id });
+ }.property('searchText')
});
// Models
App.Store = DS.Store.extend();
DS.RESTAdapter.configure("plurals", {
- switchboard_entry: "switchboard_entries"
+ switchboard_entry: "switchboard_entries",
+ phone_book_entry: "phone_book_entries"
});
DS.RESTAdapter.reopen({
@@ -51,9 +60,12 @@ DS.RESTAdapter.reopen({
App.Switchboard = DS.Model.extend({
switchboardEntrys: DS.hasMany('App.SwitchboardEntry'),
activeCalls: DS.hasMany('App.ActiveCall'),
- name: DS.attr('string')
-
-
+ dispatchableIncomingCalls: DS.hasMany('App.DispatchableIncomingCall'),
+ name: DS.attr('string'),
+ show_avatars: DS.attr('boolean'),
+ blind_transfer_activated: DS.attr('boolean'),
+ search_activated: DS.attr('boolean'),
+ attended_transfer_activated: DS.attr('boolean')
});
App.SwitchboardEntry = DS.Model.extend({
@@ -62,7 +74,8 @@ App.SwitchboardEntry = DS.Model.extend({
name: DS.attr('string'),
path_to_user: DS.attr('string'),
avatar_src: DS.attr('string'),
- callstate: DS.attr('string')
+ callstate: DS.attr('string'),
+ switchable: DS.attr('boolean')
});
App.ActiveCall = DS.Model.extend({
@@ -70,7 +83,47 @@ App.ActiveCall = DS.Model.extend({
callstate: DS.attr('string'),
b_callstate: DS.attr('string'),
destination: DS.attr('string'),
- b_caller_id_number: DS.attr('string')
+ b_caller_id_number: DS.attr('string'),
+
+ isActive: function() {
+ if (this.get('b_callstate') == 'ACTIVE') {
+ return true
+ } else {
+ return false
+ }
+ }.property('b_callstate'),
+
+ isRinging: function() {
+ if (this.get('b_callstate') == 'RINGING') {
+ return true
+ } else {
+ return false
+ }
+ }.property('b_callstate')
+});
+
+App.DispatchableIncomingCall = DS.Model.extend({
+ start_stamp: DS.attr('number'),
+ callstate: DS.attr('string'),
+ b_callstate: DS.attr('string'),
+ destination: DS.attr('string'),
+ b_caller_id_number: DS.attr('string'),
+
+ isActive: function() {
+ if (this.get('b_callstate') == 'ACTIVE') {
+ return true
+ } else {
+ return false
+ }
+ }.property('b_callstate'),
+
+ isRinging: function() {
+ if (this.get('b_callstate') == 'RINGING') {
+ return true
+ } else {
+ return false
+ }
+ }.property('b_callstate')
});
App.Adapter = DS.RESTAdapter.extend();
@@ -87,6 +140,7 @@ App.SipAccount = DS.Model.extend({
phoneNumbers: DS.hasMany('App.PhoneNumber'),
callerName: DS.attr('string'),
authName: DS.attr('string'),
+ is_registrated: DS.attr('boolean'),
phoneNumberShortList: Ember.computed(function() {
var phoneNumbers = this.get('phoneNumbers');
@@ -95,12 +149,6 @@ App.SipAccount = DS.Model.extend({
});
-App.PhoneNumber = DS.Model.extend({
- name: DS.attr('string'),
- number: DS.attr('string'),
- destination: DS.attr('string')
-});
-
App.Call = DS.Model.extend({
start_stamp: DS.attr('number'),
callstate: DS.attr('string'),
@@ -114,16 +162,48 @@ App.Call = DS.Model.extend({
} else {
return false
}
- }.property('b_callstate')
+ }.property('b_callstate'),
+ isRinging: function() {
+ if (this.get('b_callstate') == 'RINGING') {
+ return true
+ } else {
+ return false
+ }
+ }.property('b_callstate')
+});
+
+App.PhoneBookEntry = DS.Model.extend({
+ first_name: DS.attr('string'),
+ last_name: DS.attr('string'),
+ organization: DS.attr('string'),
+ search_result_display: DS.attr('string'),
+ phoneNumbers: DS.hasMany('App.PhoneNumber')
+});
+
+App.PhoneNumber = DS.Model.extend({
+ name: DS.attr('string'),
+ number: DS.attr('string'),
+ destination: DS.attr('string')
});
App.store.adapter.serializer.configure(App.PhoneNumber, { sideloadAs: 'phone_numbers' });
+// Handlebar Helpers
+//
Ember.Handlebars.registerBoundHelper('avatar_img', function(value) {
return new Handlebars.SafeString('<img alt="Avatar image" class="img-rounded" src="' + value + '" style="width: 100px;">');
});
Ember.Handlebars.registerBoundHelper('show_callstate', function(value) {
- return new Handlebars.SafeString('<span class="label">' + value + '</span>');
+ if (value) {
+ return new Handlebars.SafeString('<span class="label">' + value + '</span>');
+ }
});
+
+Ember.Handlebars.registerBoundHelper('from_now', function(start_stamp) {
+ moment().lang('de');
+ var day = moment.unix(start_stamp).fromNow();
+ return day;
+});
+