From ace935fd2793b09925ab4b8a6b352585b5bdf3d2 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Thu, 27 Jun 2013 12:29:04 +0200 Subject: Switchboard shows offline label when the SipAccount has no registration. --- app/serializers/sip_account_serializer.rb | 10 +++- app/views/switchboards/show.html.erb | 79 ++++++++++++++++++------------- public/js/app.js | 1 + 3 files changed, 57 insertions(+), 33 deletions(-) diff --git a/app/serializers/sip_account_serializer.rb b/app/serializers/sip_account_serializer.rb index aa749b0..7465a17 100644 --- a/app/serializers/sip_account_serializer.rb +++ b/app/serializers/sip_account_serializer.rb @@ -1,7 +1,15 @@ class SipAccountSerializer < ActiveModel::Serializer embed :ids, :include => true - attributes :id, :auth_name, :caller_name, :sip_accountable_id + attributes :id, :auth_name, :caller_name, :sip_accountable_id, :is_registrated has_many :phone_numbers has_many :calls + + def is_registrated + if object.registration + true + else + false + end + end end diff --git a/app/views/switchboards/show.html.erb b/app/views/switchboards/show.html.erb index b390ce5..1952a3c 100644 --- a/app/views/switchboards/show.html.erb +++ b/app/views/switchboards/show.html.erb @@ -40,44 +40,59 @@

{{/if}} - {{#if switchboardEntry.switchable}} -

- {{#each phoneNumber in switchboardEntry.sipAccount.phoneNumberShortList}} - - {{phoneNumber.number}} - - {{/each}} -

- {{else}} -

+ {{#if switchboardEntry.sipAccount.is_registrated}} + {{#if switchboardEntry.switchable}} +

+ {{#each phoneNumber in switchboardEntry.sipAccount.phoneNumberShortList}} + + {{phoneNumber.number}} + + {{/each}} +

+ {{else}} +

+ {{#each phoneNumber in switchboardEntry.sipAccount.phoneNumberShortList}} + + {{phoneNumber.number}} + + + {{#if dispatchableIncomingCalls.length}} +

+ {{#each dispatchableIncomingCall in dispatchableIncomingCalls}} + + + {{/each}} +

+ {{/if}} + {{/each}} +

+ {{/if}} + + {{#if switchboardEntry.sipAccount.calls.length}} +

+ {{#each call in switchboardEntry.sipAccount.calls}} + + {{#if call.isRinging}}{{/if}} + von {{call.b_caller_id_number}} an {{call.destination}} + + {{/each}} +

+ {{/if}} + {{else}} +

{{#each phoneNumber in switchboardEntry.sipAccount.phoneNumberShortList}} {{phoneNumber.number}} - - {{#if dispatchableIncomingCalls.length}} -

- {{#each dispatchableIncomingCall in dispatchableIncomingCalls}} - - - {{/each}} -

- {{/if}} {{/each}} -

- {{/if}} - - {{#if switchboardEntry.sipAccount.calls.length}} -

- {{#each call in switchboardEntry.sipAccount.calls}} - - {{#if call.isRinging}}{{/if}} - von {{call.b_caller_id_number}} an {{call.destination}} - - {{/each}} -

- {{/if}} +

+

+ + offline + +

+ {{/if}} diff --git a/public/js/app.js b/public/js/app.js index 531e4b8..6d4ba65 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -127,6 +127,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'); -- cgit v1.2.3