From 877364c24ef9c7954f0e193456bb3f2d39169977 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Mon, 25 Mar 2013 10:26:49 +0100 Subject: First try --- app/serializers/switchboard_entry_serializer.rb | 3 +++ app/serializers/switchboard_serializer.rb | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 app/serializers/switchboard_entry_serializer.rb create mode 100644 app/serializers/switchboard_serializer.rb (limited to 'app/serializers') diff --git a/app/serializers/switchboard_entry_serializer.rb b/app/serializers/switchboard_entry_serializer.rb new file mode 100644 index 0000000..dace1c5 --- /dev/null +++ b/app/serializers/switchboard_entry_serializer.rb @@ -0,0 +1,3 @@ +class SwitchboardEntrySerializer < ActiveModel::Serializer + attributes :id, :name +end diff --git a/app/serializers/switchboard_serializer.rb b/app/serializers/switchboard_serializer.rb new file mode 100644 index 0000000..c460add --- /dev/null +++ b/app/serializers/switchboard_serializer.rb @@ -0,0 +1,6 @@ +class SwitchboardSerializer < ActiveModel::Serializer + embed :ids, :include => true + + attributes :id, :name + has_many :switchboard_entries, :key => :switchboard_entry_ids, :root => :switchboardEntrys +end -- 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. --- app/serializers/switchboard_entry_serializer.rb | 2 ++ app/serializers/switchboard_serializer.rb | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'app/serializers') diff --git a/app/serializers/switchboard_entry_serializer.rb b/app/serializers/switchboard_entry_serializer.rb index dace1c5..0b5f4c1 100644 --- a/app/serializers/switchboard_entry_serializer.rb +++ b/app/serializers/switchboard_entry_serializer.rb @@ -1,3 +1,5 @@ class SwitchboardEntrySerializer < ActiveModel::Serializer attributes :id, :name + + has_many :phone_numbers, embed: :ids end diff --git a/app/serializers/switchboard_serializer.rb b/app/serializers/switchboard_serializer.rb index c460add..2912a56 100644 --- a/app/serializers/switchboard_serializer.rb +++ b/app/serializers/switchboard_serializer.rb @@ -1,6 +1,7 @@ class SwitchboardSerializer < ActiveModel::Serializer - embed :ids, :include => true - attributes :id, :name - has_many :switchboard_entries, :key => :switchboard_entry_ids, :root => :switchboardEntrys + + embed :ids + + has_many :switchboard_entries, :key => :switchboard_entrys end -- 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. --- app/serializers/phone_number_serializer.rb | 3 +++ app/serializers/sip_account_serializer.rb | 6 ++++++ app/serializers/switchboard_entry_serializer.rb | 13 +++++++++++-- app/serializers/switchboard_serializer.rb | 9 +++++---- 4 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 app/serializers/phone_number_serializer.rb create mode 100644 app/serializers/sip_account_serializer.rb (limited to 'app/serializers') diff --git a/app/serializers/phone_number_serializer.rb b/app/serializers/phone_number_serializer.rb new file mode 100644 index 0000000..865534b --- /dev/null +++ b/app/serializers/phone_number_serializer.rb @@ -0,0 +1,3 @@ +class PhoneNumberSerializer < ActiveModel::Serializer + attributes :id, :name, :number +end diff --git a/app/serializers/sip_account_serializer.rb b/app/serializers/sip_account_serializer.rb new file mode 100644 index 0000000..c85c8a0 --- /dev/null +++ b/app/serializers/sip_account_serializer.rb @@ -0,0 +1,6 @@ +class SipAccountSerializer < ActiveModel::Serializer + embed :ids, :include => true + + attributes :id, :auth_name, :caller_name, :sip_accountable_id + has_many :phone_numbers +end diff --git a/app/serializers/switchboard_entry_serializer.rb b/app/serializers/switchboard_entry_serializer.rb index 0b5f4c1..1b6c761 100644 --- a/app/serializers/switchboard_entry_serializer.rb +++ b/app/serializers/switchboard_entry_serializer.rb @@ -1,5 +1,14 @@ class SwitchboardEntrySerializer < ActiveModel::Serializer - attributes :id, :name + attributes :id, :name, :path_to_user, :avatar_src, :callstate - has_many :phone_numbers, embed: :ids + has_one :sip_account, embed: :ids + has_one :switchboard, embed: :ids + + def path_to_user + if object.sip_account && object.sip_account.sip_accountable_type == 'User' + "/tenants/#{object.sip_account.sip_accountable.current_tenant.id}/users/#{object.sip_account.sip_accountable.id}" + else + nil + end + end end diff --git a/app/serializers/switchboard_serializer.rb b/app/serializers/switchboard_serializer.rb index 2912a56..600c79a 100644 --- a/app/serializers/switchboard_serializer.rb +++ b/app/serializers/switchboard_serializer.rb @@ -1,7 +1,8 @@ class SwitchboardSerializer < ActiveModel::Serializer - attributes :id, :name - - embed :ids + embed :ids, :include => true - has_many :switchboard_entries, :key => :switchboard_entrys + attributes :id, :name + has_many :switchboard_entries + has_many :sip_accounts, :through => :switchboard_entries + has_many :phone_numbers end -- cgit v1.2.3