From 15602d52b598caecbb1daabe621e1d2e02df6be7 Mon Sep 17 00:00:00 2001 From: Julian Pawlowski Date: Mon, 25 Mar 2013 17:09:59 +0100 Subject: add ionice for backup jobs --- app/models/backup_job.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/backup_job.rb b/app/models/backup_job.rb index 9cb4f53..e2f2e6c 100644 --- a/app/models/backup_job.rb +++ b/app/models/backup_job.rb @@ -37,7 +37,7 @@ class BackupJob < ActiveRecord::Base if tmp_backup_directory.blank? self.state = 'failed' else - system "cd #{backup_directory} && nice -n 19 sudo /bin/tar czf #{backup_name_prefix}#{File.basename(tmp_backup_directory)}.tar.gz #{File.basename(tmp_backup_directory)}" + system "cd #{backup_directory} && nice -n 19 ionice -c2 -n7 sudo /bin/tar czf #{backup_name_prefix}#{File.basename(tmp_backup_directory)}.tar.gz #{File.basename(tmp_backup_directory)}" require 'fileutils' FileUtils.rm_rf tmp_backup_directory file = File::Stat.new("#{backup_directory}/#{backup_name_prefix}#{File.basename(tmp_backup_directory)}.tar.gz") -- cgit v1.2.3 From 3833ac1506fb336cd617ec41d25e35c34e74064e Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 26 Mar 2013 15:51:35 +0100 Subject: voicemail refactored --- app/controllers/sip_accounts_controller.rb | 7 ++ app/controllers/voicemail_accounts_controller.rb | 68 +++++++++++++++++ app/controllers/voicemail_settings_controller.rb | 85 ++++++---------------- app/helpers/voicemail_accounts_helper.rb | 2 + app/models/sip_account.rb | 24 ++---- app/models/user.rb | 2 + app/models/voicemail_account.rb | 20 +++++ app/models/voicemail_setting.rb | 52 +++++++++++-- app/views/sip_accounts/_form_core.html.haml | 1 + app/views/sip_accounts/show.html.haml | 5 ++ app/views/voicemail_accounts/_form.html.haml | 7 ++ app/views/voicemail_accounts/_form_core.html.haml | 3 + app/views/voicemail_accounts/_index_core.html.haml | 15 ++++ app/views/voicemail_accounts/edit.html.haml | 3 + app/views/voicemail_accounts/index.html.haml | 6 ++ app/views/voicemail_accounts/new.html.haml | 3 + app/views/voicemail_accounts/show.html.haml | 19 +++++ app/views/voicemail_settings/_form.html.haml | 3 +- app/views/voicemail_settings/_form_core.html.haml | 17 ++--- app/views/voicemail_settings/_index_core.html.haml | 14 ++++ app/views/voicemail_settings/edit.html.haml | 2 +- app/views/voicemail_settings/index.html.haml | 6 ++ app/views/voicemail_settings/new.html.haml | 3 + app/views/voicemail_settings/show.html.haml | 33 ++++----- 24 files changed, 280 insertions(+), 120 deletions(-) create mode 100644 app/controllers/voicemail_accounts_controller.rb create mode 100644 app/helpers/voicemail_accounts_helper.rb create mode 100644 app/models/voicemail_account.rb create mode 100644 app/views/voicemail_accounts/_form.html.haml create mode 100644 app/views/voicemail_accounts/_form_core.html.haml create mode 100644 app/views/voicemail_accounts/_index_core.html.haml create mode 100644 app/views/voicemail_accounts/edit.html.haml create mode 100644 app/views/voicemail_accounts/index.html.haml create mode 100644 app/views/voicemail_accounts/new.html.haml create mode 100644 app/views/voicemail_accounts/show.html.haml create mode 100644 app/views/voicemail_settings/_index_core.html.haml create mode 100644 app/views/voicemail_settings/index.html.haml create mode 100644 app/views/voicemail_settings/new.html.haml (limited to 'app') diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb index 0d34109..8208a29 100644 --- a/app/controllers/sip_accounts_controller.rb +++ b/app/controllers/sip_accounts_controller.rb @@ -36,6 +36,7 @@ class SipAccountsController < ApplicationController break unless SipAccount.exists?(:auth_name => @sip_account.auth_name) end @sip_account.password = SecureRandom.hex(GsParameter.get('DEFAULT_LENGTH_SIP_PASSWORD')) + possible_voicemail_accounts end def create @@ -61,6 +62,7 @@ class SipAccountsController < ApplicationController end def edit + possible_voicemail_accounts end def update @@ -101,4 +103,9 @@ class SipAccountsController < ApplicationController end end + def possible_voicemail_accounts + @possible_voicemail_accounts = @sip_account.voicemail_accounts + @possible_voicemail_accounts = @possible_voicemail_accounts + @sip_account.sip_accountable.voicemail_accounts + end + end diff --git a/app/controllers/voicemail_accounts_controller.rb b/app/controllers/voicemail_accounts_controller.rb new file mode 100644 index 0000000..7e00131 --- /dev/null +++ b/app/controllers/voicemail_accounts_controller.rb @@ -0,0 +1,68 @@ +class VoicemailAccountsController < ApplicationController + load_resource :sip_account + load_resource :conference + load_resource :hunt_group + load_resource :automatic_call_distributor + load_resource :user + load_resource :tenant + load_resource :voicemail_account + + load_and_authorize_resource :phone_number, :through => [:sip_account, :conference, :hunt_group, :automatic_call_distributor, :user, :tenant] + + before_filter :set_and_authorize_parent + + def index + @voicemail_accounts = @parent.voicemail_accounts + end + + def show + + end + + def new + @voicemail_account = @parent.voicemail_accounts.build(:active => true) + if @parent.class == SipAccount && VoicemailAccount.where(:name => @parent.auth_name).count == 0 + @voicemail_account.name = @parent.auth_name + else + @voicemail_account.name = SecureRandom.hex(GsParameter.get('DEFAULT_LENGTH_SIP_AUTH_NAME')) + end + end + + def create + @voicemail_account = @parent.voicemail_accounts.new(params[:voicemail_account]) + if @voicemail_account.save + m = method( :"#{@parent.class.name.underscore}_voicemail_accounts_url" ) + redirect_to m.( @parent ), :notice => t('voicemail_accounts.controller.successfuly_created') + else + render :new + end + end + + def edit + @voicemail_account = VoicemailAccount.find(params[:id]) + end + + def update + @voicemail_account = VoicemailAccount.find(params[:id]) + if @voicemail_account.update_attributes(params[:voicemail_account]) + m = method( :"#{@parent.class.name.underscore}_voicemail_accounts_url" ) + redirect_to m.( @parent ), :notice => t('voicemail_accounts.controller.successfuly_updated') + else + render :edit + end + end + + def destroy + @voicemail_account = VoicemailAccount.find(params[:id]) + @voicemail_account.destroy + m = method( :"#{@parent.class.name.underscore}_voicemail_accounts_url" ) + redirect_to m.( @parent ), :notice => t('voicemail_accounts.controller.successfuly_destroyed') + end + + private + def set_and_authorize_parent + @parent = @sip_account || @conference || @hunt_group || @automatic_call_distributor || @user || @tenant + + authorize! :read, @parent + end +end diff --git a/app/controllers/voicemail_settings_controller.rb b/app/controllers/voicemail_settings_controller.rb index 5de0c35..ee8e36b 100644 --- a/app/controllers/voicemail_settings_controller.rb +++ b/app/controllers/voicemail_settings_controller.rb @@ -1,92 +1,53 @@ class VoicemailSettingsController < ApplicationController - load_resource :sip_account - load_and_authorize_resource :voicemail_setting, :through => :sip_account, :singleton => true - - before_filter :set_and_authorize_parent - before_filter :spread_breadcrumbs - before_filter :voicemail_defaults, :only => [:index, :show, :new, :create, :edit] + load_and_authorize_resource :voicemail_account + load_and_authorize_resource :voicemail_setting, :through => [:voicemail_account] def index - render :edit + @voicemail_settings = @voicemail_account.voicemail_settings end def show - render :edit end def new - render :edit end def create - @sip_account = SipAccount.where(:id => params[:sip_account_id]).first - params[:voicemail_setting][:username] = @sip_account.auth_name - params[:voicemail_setting][:domain] = @sip_account.sip_domain.try(:host) - @voicemail_setting = VoicemailSetting.new(params[:voicemail_setting]) + @voicemail_setting = @voicemail_account.voicemail_settings.build(params[:voicemail_setting]) + @voicemail_setting.class_type = VoicemailSetting::VOICEMAIL_SETTINGS[@voicemail_setting.name] if @voicemail_setting.save - redirect_to sip_account_voicemail_settings_path(@sip_account), :notice => t('voicemail_settings.controller.successfuly_created') + m = method( :"#{@voicemail_account.voicemail_accountable.class.name.underscore}_voicemail_account_path" ) + redirect_to m.( @voicemail_account.voicemail_accountable, @voicemail_account ), :notice => t('voicemail_settings.controller.successfuly_created') else - render :action => 'edit' + render :new end end def edit - + @voicemail_setting = @voicemail_account.voicemail_settings.find(params[:id]) + @no_edit = { + :name => { + :input => VoicemailSetting::VOICEMAIL_SETTINGS[@voicemail_setting.name][:input], + :name => @voicemail_setting.name + }, + :description => true + } end def update + @voicemail_setting = @voicemail_account.voicemail_settings.find(params[:id]) if @voicemail_setting.update_attributes(params[:voicemail_setting]) - redirect_to sip_account_voicemail_settings_path(@sip_account), :notice => t('voicemail_settings.controller.successfuly_updated') + m = method( :"#{@voicemail_account.voicemail_accountable.class.name.underscore}_voicemail_account_path" ) + redirect_to m.( @voicemail_account.voicemail_accountable, @voicemail_account ), :notice => t('voicemail_settings.controller.successfuly_updated') else render :edit end end def destroy - - end - - private - def set_and_authorize_parent - @parent = @sip_account - - authorize! :read, @parent - - @show_path_method = method( :"#{@parent.class.name.underscore}_voicemail_setting_path" ) - @index_path_method = method( :"#{@parent.class.name.underscore}_voicemail_settings_path" ) - @new_path_method = method( :"new_#{@parent.class.name.underscore}_voicemail_setting_path" ) - @edit_path_method = method( :"edit_#{@parent.class.name.underscore}_voicemail_setting_path" ) - end - - def spread_breadcrumbs - if @parent.class == SipAccount - if @sip_account.sip_accountable.class == User - add_breadcrumb t("#{@sip_account.sip_accountable.class.name.underscore.pluralize}.index.page_title"), method( :"tenant_#{@sip_account.sip_accountable.class.name.underscore.pluralize}_path" ).(@sip_account.tenant) - add_breadcrumb @sip_account.sip_accountable, method( :"tenant_#{@sip_account.sip_accountable.class.name.underscore}_path" ).(@sip_account.tenant, @sip_account.sip_accountable) - end - add_breadcrumb t("sip_accounts.index.page_title"), method( :"#{@sip_account.sip_accountable.class.name.underscore}_sip_accounts_path" ).(@sip_account.sip_accountable) - add_breadcrumb @sip_account, method( :"#{@sip_account.sip_accountable.class.name.underscore}_sip_account_path" ).(@sip_account.sip_accountable, @sip_account) - add_breadcrumb t("voicemail_settings.index.page_title"), sip_account_voicemail_settings_path(@sip_account) - end - end - - def voicemail_defaults - storage_dir = GsParameter.where(:entity => 'voicemail', :section => 'parameters', :name => 'storage-dir').first.try(:value) - path = "#{storage_dir}/#{@sip_account.sip_domain.host}/#{@sip_account.auth_name}/" - @greeting_files = Dir.glob("#{path}*greeting*.wav").collect {|r| [ File.basename(r), File.expand_path(r) ] } - @name_files = Dir.glob("#{path}*name*.wav").collect {|r| [ File.basename(r), File.expand_path(r) ] } - - if @voicemail_setting.blank? then - @voicemail_setting = @sip_account.voicemail_setting - end - - if @voicemail_setting.blank? - @voicemail_setting = VoicemailSetting.new - @voicemail_setting.notify = true - @voicemail_setting.attachment = true - @voicemail_setting.mark_read = true - @voicemail_setting.purge = false - end + @voicemail_setting = @voicemail_account.voicemail_settings.find(params[:id]) + @voicemail_setting.destroy + m = method( :"#{@voicemail_account.voicemail_accountable.class.name.underscore}_voicemail_account_path" ) + redirect_to m.( @voicemail_account.voicemail_accountable, @voicemail_account ), :notice => t('voicemail_settings.controller.successfuly_destroyed') end - end diff --git a/app/helpers/voicemail_accounts_helper.rb b/app/helpers/voicemail_accounts_helper.rb new file mode 100644 index 0000000..5a75e18 --- /dev/null +++ b/app/helpers/voicemail_accounts_helper.rb @@ -0,0 +1,2 @@ +module VoicemailAccountsHelper +end diff --git a/app/models/sip_account.rb b/app/models/sip_account.rb index 0c923be..77fe87a 100644 --- a/app/models/sip_account.rb +++ b/app/models/sip_account.rb @@ -6,7 +6,8 @@ class SipAccount < ActiveRecord::Base attr_accessible :auth_name, :caller_name, :password, :voicemail_pin, :tenant_id, :call_waiting, :clir, :clip_no_screening, :clip, :description, :callforward_rules_act_per_sip_account, - :hotdeskable, :gs_node_id, :language_code + :hotdeskable, :gs_node_id, :language_code, :voicemail_account_id + # Associations: # @@ -27,8 +28,6 @@ class SipAccount < ActiveRecord::Base has_many :call_histories, :as => :call_historyable, :dependent => :destroy - has_one :voicemail_setting, :class_name => "VoicemailSetting", :primary_key => 'auth_name', :foreign_key => 'username', :dependent => :destroy - belongs_to :gs_node belongs_to :language, :foreign_key => 'language_code', :primary_key => 'code' @@ -44,6 +43,9 @@ class SipAccount < ActiveRecord::Base has_many :acd_agents, :as => :destination, :dependent => :destroy has_many :switchboard_entries, :dependent => :destroy + has_many :voicemail_accounts, :as => :voicemail_accountable, :dependent => :destroy + belongs_to :voicemail_account + # Delegations: # delegate :host, :to => :sip_domain, :allow_nil => true @@ -58,15 +60,11 @@ class SipAccount < ActiveRecord::Base validate_sip_password :password - validates_format_of :voicemail_pin, :with => /[0-9]+/, - :allow_nil => true, :allow_blank => true - validates_uniqueness_of :auth_name, :scope => :sip_domain_id # Before and after hooks: # before_save :save_value_of_to_s - after_save :create_voicemail_setting, :if => :'voicemail_setting == nil' before_validation :find_and_set_tenant_id before_validation :set_sip_domain_id before_validation :convert_umlauts_in_caller_name @@ -279,18 +277,6 @@ class SipAccount < ActiveRecord::Base end end - def create_voicemail_setting - voicemail_setting = VoicemailSetting.new() - voicemail_setting.username = self.auth_name - voicemail_setting.domain = self.sip_domain.try(:host) - voicemail_setting.password = self.voicemail_pin - voicemail_setting.notify = true - voicemail_setting.attachment = true - voicemail_setting.mark_read = true - voicemail_setting.purge = false - voicemail_setting.save - end - def create_default_group_memberships default_groups = Hash.new() templates = GsParameter.get('SipAccount', 'group', 'default') diff --git a/app/models/user.rb b/app/models/user.rb index b74fc06..81d1622 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -94,6 +94,8 @@ class User < ActiveRecord::Base has_many :switchboards, :dependent => :destroy + has_many :voicemail_accounts, :as => :voicemail_accountable, :dependent => :destroy + # Avatar like photo mount_uploader :image, ImageUploader diff --git a/app/models/voicemail_account.rb b/app/models/voicemail_account.rb new file mode 100644 index 0000000..02dc283 --- /dev/null +++ b/app/models/voicemail_account.rb @@ -0,0 +1,20 @@ +class VoicemailAccount < ActiveRecord::Base + attr_accessible :uuid, :name, :active, :gs_node_id, :voicemail_accountable_type, :voicemail_accountable_id + + belongs_to :voicemail_accountable, :polymorphic => true + has_many :voicemail_settings + + validates :name, + :presence => true, + :uniqueness => true + + validates :voicemail_accountable_id, + :presence => true + + validates :voicemail_accountable_type, + :presence => true + + def to_s + "#{voicemail_accountable.to_s}: #{name}" + end +end diff --git a/app/models/voicemail_setting.rb b/app/models/voicemail_setting.rb index a8bb304..4a9fbc9 100644 --- a/app/models/voicemail_setting.rb +++ b/app/models/voicemail_setting.rb @@ -1,12 +1,48 @@ -class VoicemailSetting < ActiveRecord::Base - self.table_name = 'voicemail_prefs' - self.primary_key = 'username' +class VoicemailSetting < ActiveRecord::Base + CLASS_TYPES = ['String', 'Integer', 'Boolean'] + VOICEMAIL_SETTINGS = { + 'password' => { :type => 'String', :characters => /[^0-9]/, :input => :password }, + 'notify' => { :type => 'Boolean', :input => :boolean }, + 'attachment' => { :type => 'Boolean', :input => :boolean }, + 'mark_read' => { :type => 'Boolean', :input => :boolean }, + 'purge' => { :type => 'Boolean', :input => :boolean }, + 'record_length_max' => { :type => 'Integer', :input => :integer }, + 'record_length_min' => { :type => 'Integer', :input => :integer }, + 'records_max' => { :type => 'Integer', :input => :integer }, + } - attr_accessible :username, :domain, :name_path, :greeting_path, :password, :notify, :attachment, :mark_read, :purge, :sip_account + attr_accessible :voicemail_account_id, :name, :value, :class_type, :description - has_one :sip_account, :foreign_key => 'auth_name' + belongs_to :voicemail_account - validates_presence_of :username - validates_presence_of :domain - validates :username, :uniqueness => {:scope => :domain} + validates :name, + :presence => true, + :uniqueness => {:scope => :voicemail_account_id} + + validates :class_type, + :presence => true, + :inclusion => { :in => CLASS_TYPES } + + before_validation :set_class_type_and_value + + def to_s + name + end + + def set_class_type_and_value + seting_pref = VOICEMAIL_SETTINGS[self.name] + if seting_pref + self.class_type = seting_pref[:type] + case self.class_type + when 'String' + if seting_pref[:characters] && self.class_type == 'String' + self.value = self.value.to_s.gsub(seting_pref[:characters], '') + end + when 'Integer' + self.value = self.value.to_i + when 'Boolean' + self.value = ActiveRecord::ConnectionAdapters::Column.value_to_boolean(self.value) + end + end + end end diff --git a/app/views/sip_accounts/_form_core.html.haml b/app/views/sip_accounts/_form_core.html.haml index d7c65d0..2e4882e 100644 --- a/app/views/sip_accounts/_form_core.html.haml +++ b/app/views/sip_accounts/_form_core.html.haml @@ -14,3 +14,4 @@ = f.input :hotdeskable, :label => t('sip_accounts.form.hotdeskable.label'), :hint => conditional_hint('sip_accounts.form.hotdeskable.hint') = f.input :clip_no_screening, :label => t('sip_accounts.form.clip_no_screening.label'), :hint => conditional_hint('sip_accounts.form.clip_no_screening.hint') = f.input :language_code, :collection => Language.all.collect{|l| [l.to_s, l.code]}, :label => t('sip_accounts.form.language_code.label'), :hint => conditional_hint('sip_accounts.form.language_id.hint'), :include_blank => false + = f.input :voicemail_account_id, :collection => @possible_voicemail_accounts.collect{|l| [l.to_s, l.id]}, :label => t('sip_accounts.form.voicemail_account_id.label'), :hint => conditional_hint('voicemail_accounts.form.sip_account_id.hint'), :include_blank => true diff --git a/app/views/sip_accounts/show.html.haml b/app/views/sip_accounts/show.html.haml index e79907f..a7cd3ce 100644 --- a/app/views/sip_accounts/show.html.haml +++ b/app/views/sip_accounts/show.html.haml @@ -37,6 +37,11 @@ %strong= t('sip_accounts.show.hotdeskable') + ":" %td = @sip_account.hotdeskable == true ? t('simple_form.yes') : t('simple_form.no') + %tr + %td + %strong= t('sip_accounts.show.voicemail_account') + ":" + %td + = @sip_account.voicemail_account - if @sip_account.registration.try(:network_ip) && @sip_account.registration.try(:network_port) %tr diff --git a/app/views/voicemail_accounts/_form.html.haml b/app/views/voicemail_accounts/_form.html.haml new file mode 100644 index 0000000..1e5ffc0 --- /dev/null +++ b/app/views/voicemail_accounts/_form.html.haml @@ -0,0 +1,7 @@ += simple_form_for([@parent, @voicemail_account]) do |f| + = f.error_notification + + = render "form_core", :f => f + + .form-actions + = f.button :submit, conditional_t('voicemail_accounts.form.submit') diff --git a/app/views/voicemail_accounts/_form_core.html.haml b/app/views/voicemail_accounts/_form_core.html.haml new file mode 100644 index 0000000..a13ae51 --- /dev/null +++ b/app/views/voicemail_accounts/_form_core.html.haml @@ -0,0 +1,3 @@ +.inputs + = f.input :name, :label => t('voicemail_accounts.form.name.label'), :hint => conditional_hint('voicemail_accounts.form.name.hint') + = f.input :active, :label => t('voicemail_accounts.form.active.label'), :hint => conditional_hint('voicemail_accounts.form.active.hint') diff --git a/app/views/voicemail_accounts/_index_core.html.haml b/app/views/voicemail_accounts/_index_core.html.haml new file mode 100644 index 0000000..908c2b4 --- /dev/null +++ b/app/views/voicemail_accounts/_index_core.html.haml @@ -0,0 +1,15 @@ +%table.table.table-striped + %tr + %th + %th= t('voicemail_accounts.index.name') + + + - for voicemail_account in voicemail_accounts + %tr + %td + - if voicemail_account.active + %i.icon-ok + - else + %i.icon-ban-circle + %td= voicemail_account.name + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => voicemail_account.voicemail_accountable, :child => voicemail_account} \ No newline at end of file diff --git a/app/views/voicemail_accounts/edit.html.haml b/app/views/voicemail_accounts/edit.html.haml new file mode 100644 index 0000000..8d1518e --- /dev/null +++ b/app/views/voicemail_accounts/edit.html.haml @@ -0,0 +1,3 @@ +- content_for :title, t("voicemail_accounts.edit.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/voicemail_accounts/index.html.haml b/app/views/voicemail_accounts/index.html.haml new file mode 100644 index 0000000..2bc8ae4 --- /dev/null +++ b/app/views/voicemail_accounts/index.html.haml @@ -0,0 +1,6 @@ +- content_for :title, t("voicemail_accounts.index.page_title") + +- if @voicemail_accounts && @voicemail_accounts.count > 0 + = render "index_core", :voicemail_accounts => @voicemail_accounts + += render :partial => 'shared/create_link', :locals => {:parent => @parent, :child_class => VoicemailAccount} \ No newline at end of file diff --git a/app/views/voicemail_accounts/new.html.haml b/app/views/voicemail_accounts/new.html.haml new file mode 100644 index 0000000..193779d --- /dev/null +++ b/app/views/voicemail_accounts/new.html.haml @@ -0,0 +1,3 @@ +- content_for :title, t("voicemail_accounts.new.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/voicemail_accounts/show.html.haml b/app/views/voicemail_accounts/show.html.haml new file mode 100644 index 0000000..06b4d1a --- /dev/null +++ b/app/views/voicemail_accounts/show.html.haml @@ -0,0 +1,19 @@ +- content_for :title, t("voicemail_accounts.show.page_title") + +%p + %strong= t('voicemail_accounts.show.uuid') + ":" + = @voicemail_account.uuid +%p + %strong= t('voicemail_accounts.show.name') + ":" + = @voicemail_account.name +%p + %strong= t('voicemail_accounts.show.active') + ":" + = @voicemail_account.active + += render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @parent, :child => @voicemail_account } + +%h3= t('voicemail_settings.index.page_title') +- if @voicemail_account.voicemail_settings.any? + = render "voicemail_settings/index_core", :voicemail_settings => @voicemail_account.voicemail_settings + %br += render :partial => 'shared/create_link', :locals => { :parent => @voicemail_account, :child_class => VoicemailSetting } \ No newline at end of file diff --git a/app/views/voicemail_settings/_form.html.haml b/app/views/voicemail_settings/_form.html.haml index cd43b2d..08fc37b 100644 --- a/app/views/voicemail_settings/_form.html.haml +++ b/app/views/voicemail_settings/_form.html.haml @@ -1,4 +1,5 @@ -= simple_form_for([@sip_account,@voicemail_setting]) do |f| + += simple_form_for([@voicemail_account, @voicemail_setting]) do |f| = f.error_notification = render "form_core", :f => f diff --git a/app/views/voicemail_settings/_form_core.html.haml b/app/views/voicemail_settings/_form_core.html.haml index 08bdfc2..bf47e46 100644 --- a/app/views/voicemail_settings/_form_core.html.haml +++ b/app/views/voicemail_settings/_form_core.html.haml @@ -1,11 +1,10 @@ .inputs + - if !@no_edit or !@no_edit[:name] + = f.input :name, :collection => VoicemailSetting::VOICEMAIL_SETTINGS.keys.collect{|i, k| [t("voicemail_settings.settings.#{i}"), i]}, :label => t('voicemail_settings.form.name.label'), :hint => conditional_hint('voicemail_settings.form.name.hint'), :autofocus => true, :include_blank => false + = f.input :value, :label => t('voicemail_settings.form.value.label'), :hint => conditional_hint('voicemail_settings.form.value.hint') + - else + = f.input :value, :label => t("voicemail_settings.settings.#{@no_edit[:name][:name]}"), :hint => conditional_hint('voicemail_settings.form.value.hint'), :as => @no_edit[:name][:input] - = f.input :greeting_path, :as => :select, :label => t('voicemail_settings.form.greeting.label'), :hint => conditional_hint('voicemail_settings.form.greeting.hint'), :collection => @greeting_files - = f.input :name_path, :as => :select, :label => t('voicemail_settings.form.name.label'), :hint => conditional_hint('voicemail_settings.form.name.hint'), :collection => @name_files - - = f.input :password, :label => t('voicemail_settings.form.pin.label'), :hint => conditional_hint('voicemail_settings.form.pin.hint') - - = f.input :notify, :as => :boolean, :label => t('voicemail_settings.form.notify.label'), :hint => conditional_hint('voicemail_settings.form.notify.hint') - = f.input :attachment, :as => :boolean, :label => t('voicemail_settings.form.attachment.label'), :hint => conditional_hint('voicemail_settings.form.attachment.hint') - = f.input :mark_read, :as => :boolean, :label => t('voicemail_settings.form.mark_read.label'), :hint => conditional_hint('voicemail_settings.form.mark_read.hint') - = f.input :purge, :as => :boolean, :label => t('voicemail_settings.form.purge.label'), :hint => conditional_hint('voicemail_settings.form.purge.hint') + - if !@no_edit or !@no_edit[:description] + = f.input :description, :label => t('voicemail_settings.form.description.label'), :hint => conditional_hint('voicemail_settings.form.description.hint') + diff --git a/app/views/voicemail_settings/_index_core.html.haml b/app/views/voicemail_settings/_index_core.html.haml new file mode 100644 index 0000000..94ebfb1 --- /dev/null +++ b/app/views/voicemail_settings/_index_core.html.haml @@ -0,0 +1,14 @@ +%table.table.table-striped + %thead + %tr + %th= t('voicemail_settings.index.name') + %th= t('voicemail_settings.index.value') + %th= t('voicemail_settings.index.description') + + %tbody + - for voicemail_setting in voicemail_settings + %tr + %td= voicemail_setting.name + %td= voicemail_setting.value + %td= voicemail_setting.description + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => voicemail_setting.voicemail_account, :child => voicemail_setting} diff --git a/app/views/voicemail_settings/edit.html.haml b/app/views/voicemail_settings/edit.html.haml index 56e5765..cb9924b 100644 --- a/app/views/voicemail_settings/edit.html.haml +++ b/app/views/voicemail_settings/edit.html.haml @@ -1,3 +1,3 @@ - content_for :title, t("voicemail_settings.edit.page_title") -= render "form" += render "form" \ No newline at end of file diff --git a/app/views/voicemail_settings/index.html.haml b/app/views/voicemail_settings/index.html.haml new file mode 100644 index 0000000..5eb9940 --- /dev/null +++ b/app/views/voicemail_settings/index.html.haml @@ -0,0 +1,6 @@ +- content_for :title, t("voicemail_settings.index.page_title") + +- if @voicemail_settings && @voicemail_settings.count > 0 + = render "index_core", :voicemail_settings => @voicemail_settings + += render :partial => 'shared/create_link', :locals => {:parent => @voicemail_account, :child_class => VoicemailSetting} diff --git a/app/views/voicemail_settings/new.html.haml b/app/views/voicemail_settings/new.html.haml new file mode 100644 index 0000000..6eddc39 --- /dev/null +++ b/app/views/voicemail_settings/new.html.haml @@ -0,0 +1,3 @@ +- content_for :title, t("voicemail_settings.new.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/voicemail_settings/show.html.haml b/app/views/voicemail_settings/show.html.haml index e156d7b..f1a3e61 100644 --- a/app/views/voicemail_settings/show.html.haml +++ b/app/views/voicemail_settings/show.html.haml @@ -1,26 +1,19 @@ - content_for :title, t("voicemail_settings.show.page_title") %p - %strong= t('voicemail_settings.show.greeting_path') + ":" - = File.basename(@voicemail_setting.greeting_path.to_s) - + %strong= t('voicemail_settings.show.voicemail_id') + ":" + = @voicemail_setting.voicemail %p - %strong= t('voicemail_settings.show.name_path') + ":" - = File.basename(@voicemail_setting.name_path.to_s) - + %strong= t('voicemail_settings.show.name') + ":" + = @voicemail_setting.name +%p + %strong= t('voicemail_settings.show.value') + ":" + = @voicemail_setting.value +%p + %strong= t('voicemail_settings.show.class_type') + ":" + = @voicemail_setting.class_type %p - %strong= t('voicemail_settings.show.flags') + ":" - - if @voicemail_setting.notify - %br - = "- " + t('voicemail_settings.show.notify') - - if @voicemail_setting.attachment - %br - = "- " + t('voicemail_settings.show.attachment') - - if @voicemail_setting.mark_read - %br - = "- " + t('voicemail_settings.show.mark_read') - - if @voicemail_setting.purge - %br - = "- " + t('voicemail_settings.show.purge') + %strong= t('voicemail_settings.show.description') + ":" + = @voicemail_setting.description -= link_to t('voicemail_settings.actions.edit'), edit_sip_account_voicemail_setting_path(@sip_account, @voicemail_setting) += render :partial => 'shared/show_edit_destroy_part', :locals => {:parent => @voicemail_setting.voicemail_account, :child => @voicemail_setting} \ No newline at end of file -- cgit v1.2.3 From 41b306402d020aff3615308cdd555b0a05221343 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 27 Mar 2013 08:13:21 +0100 Subject: voicemail settings --- app/controllers/voicemail_settings_controller.rb | 5 ++-- app/models/voicemail_setting.rb | 34 +++++++++++++++++----- app/views/voicemail_settings/_form_core.html.haml | 3 +- app/views/voicemail_settings/_index_core.html.haml | 2 +- 4 files changed, 32 insertions(+), 12 deletions(-) (limited to 'app') diff --git a/app/controllers/voicemail_settings_controller.rb b/app/controllers/voicemail_settings_controller.rb index ee8e36b..1b2e371 100644 --- a/app/controllers/voicemail_settings_controller.rb +++ b/app/controllers/voicemail_settings_controller.rb @@ -27,8 +27,9 @@ class VoicemailSettingsController < ApplicationController @voicemail_setting = @voicemail_account.voicemail_settings.find(params[:id]) @no_edit = { :name => { - :input => VoicemailSetting::VOICEMAIL_SETTINGS[@voicemail_setting.name][:input], - :name => @voicemail_setting.name + :input => VoicemailSetting::VOICEMAIL_SETTINGS.fetch(@voicemail_setting.name,{}).fetch(:input, {}), + :name => @voicemail_setting.name.to_s, + :html => VoicemailSetting::VOICEMAIL_SETTINGS.fetch(@voicemail_setting.name,{}).fetch(:html, {}), }, :description => true } diff --git a/app/models/voicemail_setting.rb b/app/models/voicemail_setting.rb index 4a9fbc9..0f34402 100644 --- a/app/models/voicemail_setting.rb +++ b/app/models/voicemail_setting.rb @@ -1,14 +1,32 @@ class VoicemailSetting < ActiveRecord::Base CLASS_TYPES = ['String', 'Integer', 'Boolean'] VOICEMAIL_SETTINGS = { - 'password' => { :type => 'String', :characters => /[^0-9]/, :input => :password }, - 'notify' => { :type => 'Boolean', :input => :boolean }, - 'attachment' => { :type => 'Boolean', :input => :boolean }, - 'mark_read' => { :type => 'Boolean', :input => :boolean }, - 'purge' => { :type => 'Boolean', :input => :boolean }, - 'record_length_max' => { :type => 'Integer', :input => :integer }, - 'record_length_min' => { :type => 'Integer', :input => :integer }, - 'records_max' => { :type => 'Integer', :input => :integer }, + 'pin' => { :type => 'String', :characters => /[^0-9]/, :html => { maxlength: 8 } }, + 'notify' => { :type => 'Boolean', :input => :boolean }, + 'attachment' => { :type => 'Boolean', :input => :boolean }, + 'mark_read' => { :type => 'Boolean', :input => :boolean }, + 'purge' => { :type => 'Boolean', :input => :boolean }, + 'record_length_max' => { :type => 'Integer', :input => :integer, :html => { min: 0, max: 100 } }, + 'record_length_min' => { :type => 'Integer', :input => :integer, :html => { min: 0, max: 100 } }, + 'records_max' => { :type => 'Integer', :input => :integer, :html => { min: 0, max: 100 } }, + 'pin_length_max' => { :type => 'Integer', :input => :integer, :html => { min: 1, max: 10 } }, + 'pin_length_min' => { :type => 'Integer', :input => :integer, :html => { min: 1, max: 8 } }, + 'pin_timeout' => { :type => 'Integer', :input => :integer, :html => { min: 1, max: 10 } }, + 'key_new_messages' => { :type => 'String', :characters => /[^0-9]\#\*/, :html => { maxlength: 1 } }, + 'key_saved_messages' => { :type => 'String', :characters => /[^0-9]\#\*/, :html => { maxlength: 1 } }, + 'key_config_menu' => { :type => 'String', :characters => /[^0-9]\#\*/, :html => { maxlength: 1 } }, + 'key_terminator' => { :type => 'String', :characters => /[^0-9]\#\*/, :html => { maxlength: 1 } }, + 'key_previous' => { :type => 'String', :characters => /[^0-9]\#\*/, :html => { maxlength: 1 } }, + 'key_next' => { :type => 'String', :characters => /[^0-9]\#\*/, :html => { maxlength: 1 } }, + 'key_delete' => { :type => 'String', :characters => /[^0-9]\#\*/, :html => { maxlength: 1 } }, + 'key_save' => { :type => 'String', :characters => /[^0-9]\#\*/, :html => { maxlength: 1 } }, + 'key_main_menu' => { :type => 'String', :characters => /[^0-9]\#\*/, :html => { maxlength: 1 } }, + 'silence_lenght_abort' => { :type => 'Integer', :input => :integer, :html => { min: 0, max: 100 } }, + 'silence_level' => { :type => 'Integer', :input => :integer, :html => { min: 0, max: 1000 } }, + 'record_file_prefix' => { :type => 'String' }, + 'record_file_suffix' => { :type => 'String' }, + 'record_file_path' => { :type => 'String' }, + 'record_repeat' => { :type => 'Integer', :input => :integer, :html => { min: 0, max: 10 } }, } attr_accessible :voicemail_account_id, :name, :value, :class_type, :description diff --git a/app/views/voicemail_settings/_form_core.html.haml b/app/views/voicemail_settings/_form_core.html.haml index bf47e46..31c6bbf 100644 --- a/app/views/voicemail_settings/_form_core.html.haml +++ b/app/views/voicemail_settings/_form_core.html.haml @@ -1,9 +1,10 @@ + .inputs - if !@no_edit or !@no_edit[:name] = f.input :name, :collection => VoicemailSetting::VOICEMAIL_SETTINGS.keys.collect{|i, k| [t("voicemail_settings.settings.#{i}"), i]}, :label => t('voicemail_settings.form.name.label'), :hint => conditional_hint('voicemail_settings.form.name.hint'), :autofocus => true, :include_blank => false = f.input :value, :label => t('voicemail_settings.form.value.label'), :hint => conditional_hint('voicemail_settings.form.value.hint') - else - = f.input :value, :label => t("voicemail_settings.settings.#{@no_edit[:name][:name]}"), :hint => conditional_hint('voicemail_settings.form.value.hint'), :as => @no_edit[:name][:input] + = f.input :value, :label => t("voicemail_settings.settings.#{@no_edit[:name][:name]}"), :hint => conditional_hint('voicemail_settings.form.value.hint'), :as => @no_edit[:name][:input], input_html: @no_edit[:name][:html] - if !@no_edit or !@no_edit[:description] = f.input :description, :label => t('voicemail_settings.form.description.label'), :hint => conditional_hint('voicemail_settings.form.description.hint') diff --git a/app/views/voicemail_settings/_index_core.html.haml b/app/views/voicemail_settings/_index_core.html.haml index 94ebfb1..9173fe6 100644 --- a/app/views/voicemail_settings/_index_core.html.haml +++ b/app/views/voicemail_settings/_index_core.html.haml @@ -8,7 +8,7 @@ %tbody - for voicemail_setting in voicemail_settings %tr - %td= voicemail_setting.name + %td= t("voicemail_settings.settings.#{voicemail_setting.name}") %td= voicemail_setting.value %td= voicemail_setting.description =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => voicemail_setting.voicemail_account, :child => voicemail_setting} -- cgit v1.2.3 From ec565b14adfdb21c74e6c3558dc8a56082ec1c7a Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 27 Mar 2013 10:29:01 +0100 Subject: voicemail_pin removed --- app/views/sip_accounts/_form_core.html.haml | 1 - 1 file changed, 1 deletion(-) (limited to 'app') diff --git a/app/views/sip_accounts/_form_core.html.haml b/app/views/sip_accounts/_form_core.html.haml index 2e4882e..f84f38a 100644 --- a/app/views/sip_accounts/_form_core.html.haml +++ b/app/views/sip_accounts/_form_core.html.haml @@ -6,7 +6,6 @@ - else = f.input :auth_name, :as => :string, :label => t('sip_accounts.form.auth_name.label'), :hint => conditional_hint('sip_accounts.form.auth_name.hint') = f.input :password, :as => :string, :label => t('sip_accounts.form.password.label'), :hint => conditional_hint('sip_accounts.form.password.hint') - = f.input :voicemail_pin, :as => :string, :label => t('sip_accounts.form.voicemail_pin.label'), :hint => conditional_hint('sip_accounts.form.voicemail_pin.hint') = f.input :call_waiting, :label => t('sip_accounts.form.call_waiting.label'), :hint => conditional_hint('sip_accounts.form.call_waiting.hint') = f.input :clir, :label => t('sip_accounts.form.clir.label'), :hint => conditional_hint('sip_accounts.form.clir.hint') = f.input :clip, :label => t('sip_accounts.form.clip.label'), :hint => conditional_hint('sip_accounts.form.clip.hint') -- cgit v1.2.3 From d5ac8f72af16fa5487ab1e16bf784e8125a7b450 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 27 Mar 2013 10:30:12 +0100 Subject: destinationable_type can be a non model string --- app/models/call_forward.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/models/call_forward.rb b/app/models/call_forward.rb index 195ac36..fcac294 100644 --- a/app/models/call_forward.rb +++ b/app/models/call_forward.rb @@ -2,7 +2,7 @@ class CallForward < ActiveRecord::Base attr_accessor :to_voicemail, :hunt_group_id - attr_accessible :phone_number_id, :call_forward_case_id, :timeout, + attr_accessible :call_forward_case_id, :timeout, :destination, :source, :depth, :active, :to_voicemail, :hunt_group_id, :call_forwardable_type, :call_forwardable_id, @@ -71,7 +71,7 @@ class CallForward < ActiveRecord::Base else destinationable_type = " #{self.destinationable_type}" end - if self.destinationable + if Module.constants.include?(destinationable_type.to_sym) && self.destinationable destination = "#{self.destinationable}#{destinationable_type}" else destination = "#{self.destination}#{destinationable_type}" -- cgit v1.2.3 From a634e8b158dac11250181d7cae35a08afbea96d4 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 27 Mar 2013 10:31:08 +0100 Subject: create voicemail account for newly crested users --- app/controllers/users_controller.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app') diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 584d08c..ea8ed69 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -22,6 +22,12 @@ class UsersController < ApplicationController def create @user = @parent.users.build(params[:user]) if @user.save + if VoicemailAccount.where(:name => "user_#{@user.user_name}").count == 0 + @user.voicemail_accounts.create(:name => "user_#{@user.user_name}", :active => true ) + else + @user.voicemail_accounts.create(:active => true) + end + if @parent.class == Tenant @parent.tenant_memberships.create(:user => @user) if @parent.user_groups.exists?(:name => 'Users') -- cgit v1.2.3 From b9e37bcb2ba1d54ab32dc1185266d7ffa0a0c3b9 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 27 Mar 2013 10:32:34 +0100 Subject: inherit voicemail_account and language_code --- app/controllers/sip_accounts_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb index 8208a29..7bb2689 100644 --- a/app/controllers/sip_accounts_controller.rb +++ b/app/controllers/sip_accounts_controller.rb @@ -22,7 +22,6 @@ class SipAccountsController < ApplicationController @sip_account.call_waiting = GsParameter.get('CALL_WAITING') @sip_account.clir = GsParameter.get('DEFAULT_CLIR_SETTING') @sip_account.clip = GsParameter.get('DEFAULT_CLIP_SETTING') - @sip_account.voicemail_pin = random_pin @sip_account.callforward_rules_act_per_sip_account = GsParameter.get('CALLFORWARD_RULES_ACT_PER_SIP_ACCOUNT_DEFAULT') if @parent.class == User @sip_account.hotdeskable = true @@ -36,6 +35,9 @@ class SipAccountsController < ApplicationController break unless SipAccount.exists?(:auth_name => @sip_account.auth_name) end @sip_account.password = SecureRandom.hex(GsParameter.get('DEFAULT_LENGTH_SIP_PASSWORD')) + + @sip_account.voicemail_account = VoicemailAccount.where(:voicemail_accountable_type => @parent.class.name, :voicemail_accountable_id => @parent.id).first + @sip_account.language_code = @parent.language.try(:code) possible_voicemail_accounts end -- cgit v1.2.3 From 3a20974d9403877ffa9a720efd999df49a1733bf Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 27 Mar 2013 10:33:28 +0100 Subject: list possible voicemail accounts --- app/controllers/call_forwards_controller.rb | 41 +++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/controllers/call_forwards_controller.rb b/app/controllers/call_forwards_controller.rb index b30ee9e..858ed12 100644 --- a/app/controllers/call_forwards_controller.rb +++ b/app/controllers/call_forwards_controller.rb @@ -131,15 +131,46 @@ class CallForwardsController < ApplicationController phone_number_destination = CallForwardingDestination.new() phone_number_destination.id = ':PhoneNumber' phone_number_destination.label = 'Phone Number' - voice_mail_destination = CallForwardingDestination.new() - voice_mail_destination.id = ':Voicemail' - voice_mail_destination.label = 'Voice Mail' call_forwarding_destinations = [ phone_number_destination, - voice_mail_destination, ] + if @parent.try(:voicemail_accounts) + @parent.voicemail_accounts.each do |voicemail_account| + call_forwards_destination = CallForwardingDestination.new() + call_forwards_destination.id = "#{voicemail_account.id}:VoicemailAccount" + call_forwards_destination.label = "VoicemailAccount: #{voicemail_account.to_s}" + call_forwarding_destinations << call_forwards_destination + end + end + + if @parent.class == SipAccount + sip_account = @parent + if sip_account.sip_accountable.class == User || sip_account.sip_accountable.class == Tenant + sip_account.sip_accountable.voicemail_accounts.each do |voicemail_account| + call_forwards_destination = CallForwardingDestination.new() + call_forwards_destination.id = "#{voicemail_account.id}:VoicemailAccount" + call_forwards_destination.label = "VoicemailAccount: #{voicemail_account.to_s}" + call_forwarding_destinations << call_forwards_destination + end + end + end + + if @parent.class == PhoneNumber + if @parent.phone_numberable.class == SipAccount + sip_account = @parent.phone_numberable + if sip_account.sip_accountable.class == User || sip_account.sip_accountable.class == Tenant + sip_account.sip_accountable.voicemail_accounts.each do |voicemail_account| + call_forwards_destination = CallForwardingDestination.new() + call_forwards_destination.id = "#{voicemail_account.id}:VoicemailAccount" + call_forwards_destination.label = "VoicemailAccount: #{voicemail_account.to_s}" + call_forwarding_destinations << call_forwards_destination + end + end + end + end + if GuiFunction.display?('huntgroup_in_destination_field_in_call_forward_form', current_user) HuntGroup.all.each do |hunt_group| hunt_group_destination = CallForwardingDestination.new() @@ -149,7 +180,7 @@ class CallForwardsController < ApplicationController end end - return call_forwarding_destinations + return call_forwarding_destinations.uniq end end -- cgit v1.2.3 From 09f6490dc92d9685afa5f77563ea8c230c450211 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 27 Mar 2013 10:34:21 +0100 Subject: subscribe to default voicemail account --- app/controllers/config_snom_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb index 8db1d57..b692693 100644 --- a/app/controllers/config_snom_controller.rb +++ b/app/controllers/config_snom_controller.rb @@ -260,9 +260,13 @@ class ConfigSnomController < ApplicationController :name => sip_account.auth_name, :realname => 'Call', :idle_text => sip_account.caller_name, - :mailbox => "", :expiry => expiry_seconds, } + + if sip_account.voicemail_account + snom_sip_account[:mailbox] = "" + end + @sip_accounts.push(snom_sip_account) sip_account_index = @sip_accounts.length sip_account.softkeys.order(:position).each do |softkey| -- cgit v1.2.3 From 73a629589e6d4e20b2fb8dbddaa842908f5588d7 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 27 Mar 2013 10:34:53 +0100 Subject: voicemail_accounts added to tenants --- app/models/tenant.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app') diff --git a/app/models/tenant.rb b/app/models/tenant.rb index ffa68a7..b47faee 100644 --- a/app/models/tenant.rb +++ b/app/models/tenant.rb @@ -63,6 +63,8 @@ class Tenant < ActiveRecord::Base has_many :group_memberships, :as => :item, :dependent => :destroy, :uniq => true has_many :groups, :through => :group_memberships + has_many :voicemail_accounts, :as => :voicemail_accountable, :dependent => :destroy + # Validations: # validates_presence_of :name, :state, :country, :language -- cgit v1.2.3 From a51e98d9487ade1079c962739ac8fe2b3aa11312 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 27 Mar 2013 10:36:18 +0100 Subject: destinationable_type can be a non model string --- app/views/call_forwards/_index_core.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/views/call_forwards/_index_core.html.haml b/app/views/call_forwards/_index_core.html.haml index 3c57405..ab8873b 100644 --- a/app/views/call_forwards/_index_core.html.haml +++ b/app/views/call_forwards/_index_core.html.haml @@ -22,7 +22,7 @@ - if call_forward.destinationable_type %br = call_forward.destinationable_type - - if call_forward.destinationable_id + - if Module.constants.include?(call_forward.destinationable_type.to_sym) = ": #{call_forward.destinationable}" %td= call_forward.source =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => call_forward.call_forwardable, :child => call_forward} -- cgit v1.2.3 From 045eea165f469bb053c28e629848af35a93787de Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 27 Mar 2013 12:14:02 +0100 Subject: notification methods added --- app/models/voicemail_account.rb | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'app') diff --git a/app/models/voicemail_account.rb b/app/models/voicemail_account.rb index 02dc283..8ec181f 100644 --- a/app/models/voicemail_account.rb +++ b/app/models/voicemail_account.rb @@ -3,6 +3,7 @@ class VoicemailAccount < ActiveRecord::Base belongs_to :voicemail_accountable, :polymorphic => true has_many :voicemail_settings + has_many :voicemail_messages, :foreign_key => 'username', :primary_key => 'name' validates :name, :presence => true, @@ -17,4 +18,47 @@ class VoicemailAccount < ActiveRecord::Base def to_s "#{voicemail_accountable.to_s}: #{name}" end + + def notify_to + send_notification = nil + if self.voicemail_settings.where(:name => 'notify', :value => true).first + send_notification = true + elsif self.voicemail_settings.where(:name => 'notify', :value => false).first + send_notification = false + end + + if send_notification == nil + send_notification = GsParameter.get('notify', 'voicemail', 'settings') + end + + if !send_notification + return send_notification + end + + email = self.voicemail_settings.where(:name => 'email').first.try(:value) + + if email.blank? + if self.voicemail_accountable.class == User + email = self.voicemail_accountable.email + end + end + + return email + end + + + def notification_setting(name) + setting = nil + if self.voicemail_settings.where(:name => name, :value => true).first + setting = true + elsif self.voicemail_settings.where(:name => name, :value => false).first + setting = false + end + + if setting == nil + setting = GsParameter.get(name, 'voicemail', 'settings') + end + + return setting + end end -- cgit v1.2.3 From c27a8d084d84240aee90f460104fdab9be41fbff Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 27 Mar 2013 12:14:32 +0100 Subject: email setting added --- app/models/voicemail_setting.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'app') diff --git a/app/models/voicemail_setting.rb b/app/models/voicemail_setting.rb index 0f34402..0e9e3fa 100644 --- a/app/models/voicemail_setting.rb +++ b/app/models/voicemail_setting.rb @@ -6,6 +6,7 @@ class VoicemailSetting < ActiveRecord::Base 'attachment' => { :type => 'Boolean', :input => :boolean }, 'mark_read' => { :type => 'Boolean', :input => :boolean }, 'purge' => { :type => 'Boolean', :input => :boolean }, + 'email' => { :type => 'String', }, 'record_length_max' => { :type => 'Integer', :input => :integer, :html => { min: 0, max: 100 } }, 'record_length_min' => { :type => 'Integer', :input => :integer, :html => { min: 0, max: 100 } }, 'records_max' => { :type => 'Integer', :input => :integer, :html => { min: 0, max: 100 } }, -- cgit v1.2.3 From 15d961291513ec240f683552f5b547df443beed9 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 27 Mar 2013 12:15:12 +0100 Subject: email notifications mailer --- app/mailers/notifications.rb | 15 +++------------ app/views/notifications/new_voicemail.text.erb | 2 +- 2 files changed, 4 insertions(+), 13 deletions(-) (limited to 'app') diff --git a/app/mailers/notifications.rb b/app/mailers/notifications.rb index 5b46f23..44a6a7a 100644 --- a/app/mailers/notifications.rb +++ b/app/mailers/notifications.rb @@ -42,20 +42,11 @@ class Notifications < ActionMailer::Base mail(from: Tenant.find(GsParameter.get('DEFAULT_API_TENANT_ID')).from_field_pin_change_email, to: "#{user.email}", :subject => "Password recovery") end - def new_voicemail(freeswitch_voicemail_msg, attach_file = false) - sip_account = SipAccount.find_by_auth_name(freeswitch_voicemail_msg.username) - user = sip_account.sip_accountable - + def new_voicemail(freeswitch_voicemail_msg, account, email, attach_file = false) @voicemail = Hash.new() - if ! user.first_name.blank? - @voicemail[:greeting] = user.first_name - else - @voicemail[:greeting] = user.user_name - end - @voicemail[:destination] = freeswitch_voicemail_msg.in_folder @voicemail[:from] = "#{freeswitch_voicemail_msg.cid_number} #{freeswitch_voicemail_msg.cid_name}" - @voicemail[:to] = sip_account.to_s + @voicemail[:to] = account.to_s @voicemail[:date] = Time.at(freeswitch_voicemail_msg.created_epoch).getlocal.to_s @voicemail[:duration] = Time.at(freeswitch_voicemail_msg.message_len).utc.strftime('%T') @@ -67,7 +58,7 @@ class Notifications < ActionMailer::Base attachments["#{Time.at(freeswitch_voicemail_msg.created_epoch).getlocal.strftime('%Y%m%d-%H%M%S')}-#{caller_number}.wav"] = File.read(freeswitch_voicemail_msg.file_path) end - mail(from: Tenant.find(GsParameter.get('DEFAULT_API_TENANT_ID')).from_field_voicemail_email, to: "#{user.email}", :subject => "New Voicemail from #{@voicemail[:from]}, received #{Time.at(freeswitch_voicemail_msg.created_epoch).getlocal.to_s}") + mail(from: Tenant.find(GsParameter.get('DEFAULT_API_TENANT_ID')).from_field_voicemail_email, to: email, :subject => "New Voicemail from #{@voicemail[:from]}, received #{Time.at(freeswitch_voicemail_msg.created_epoch).getlocal.to_s}") end def new_fax(fax_document) diff --git a/app/views/notifications/new_voicemail.text.erb b/app/views/notifications/new_voicemail.text.erb index adeabda..926610b 100644 --- a/app/views/notifications/new_voicemail.text.erb +++ b/app/views/notifications/new_voicemail.text.erb @@ -1,4 +1,4 @@ -Hello <%= @voicemail[:greeting] %>, +Hello, You've just received a voicemail on your Gemeinschaft account <%= @voicemail[:destination] %>. -- cgit v1.2.3 From bb6e8f24515c056347c6444668c0cb636b799815 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 27 Mar 2013 12:15:40 +0100 Subject: trigger controller fixed --- app/controllers/trigger_controller.rb | 55 ++++++++++++++++------------------- 1 file changed, 25 insertions(+), 30 deletions(-) (limited to 'app') diff --git a/app/controllers/trigger_controller.rb b/app/controllers/trigger_controller.rb index 6b58d6a..3dbb2a5 100644 --- a/app/controllers/trigger_controller.rb +++ b/app/controllers/trigger_controller.rb @@ -1,49 +1,44 @@ class TriggerController < ApplicationController def voicemail - if !params[:sip_account_id].blank? - sip_account = SipAccount.where(:id => params[:sip_account_id].to_i).first - if sip_account - sip_account.voicemail_messages.where(:notification => nil).each do |message| - message.notification = false - message.save - if !File.exists?( message.file_path ) - next + if !params[:voicemail_account_id].blank? + voicemail_account = VoicemailAccount.where(:id => params[:voicemail_account_id].to_i).first + if voicemail_account + voicemail_messages = voicemail_account.voicemail_messages.where(:notification => nil) + if voicemail_messages.count > 0 + if voicemail_account.voicemail_accountable.class == User + user = voicemail_account.voicemail_accountable + elsif voicemail_account.voicemail_accountable.class == SipAccount && voicemail_account.voicemail_accountable.sip_accountable.class == User + user = voicemail_account.voicemail_accountable = voicemail_account.voicemail_accountable.sip_accountable end - user = sip_account.sip_accountable - if user.class != User - next + if user + PrivatePub.publish_to("/users/#{user.id}/messages/new", "$('#new_voicemail_or_fax_indicator').hide('fast').show('slow');") + PrivatePub.publish_to("/users/#{user.id}/messages/new", "document.title = '* ' + document.title.replace( '* ' , '');") end + end - # Indicate a new voicemail in the navigation bar. - # - PrivatePub.publish_to("/users/#{user.id}/messages/new", "$('#new_voicemail_or_fax_indicator').hide('fast').show('slow');") - PrivatePub.publish_to("/users/#{user.id}/messages/new", "document.title = '* ' + document.title.replace( '* ' , '');") + email = voicemail_account.notify_to - if user.email.blank? - next - end - - voicemail_settings = sip_account.voicemail_setting - if !voicemail_settings - voicemail_settings = VoicemailSetting.new(:notify => user.send_voicemail_as_email_attachment, :attachment => user.send_voicemail_as_email_attachment, :mark_read => user.send_voicemail_as_email_attachment) - end + if !email.blank? + voicemail_messages.each do |message| + message.notification = false + message.save + if !File.exists?( message.file_path ) + next + end + message.notification = true - message.notification = voicemail_settings.notify - if voicemail_settings.notify - if Notifications.new_voicemail(message, voicemail_settings.attachment).deliver - if voicemail_settings.purge + if Notifications.new_voicemail(message, voicemail_account, email, voicemail_account.notification_setting('attachment')).deliver + if voicemail_account.notification_setting('purge') message.delete next end message.save - if voicemail_settings.mark_read + if voicemail_account.notification_setting('mark_read') message.mark_read end end - else - message.save end end -- cgit v1.2.3 From b67144bf911dd6e41775bda99646b3010195c8b3 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 28 Mar 2013 09:11:19 +0100 Subject: split method removed --- app/models/call_forward.rb | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'app') diff --git a/app/models/call_forward.rb b/app/models/call_forward.rb index fcac294..de3afc4 100644 --- a/app/models/call_forward.rb +++ b/app/models/call_forward.rb @@ -56,7 +56,6 @@ class CallForward < ActiveRecord::Base end } - before_save :split_and_format_destination_numbers after_save :set_presence after_save :deactivate_concurring_entries, :if => Proc.new { |cf| cf.active == true } before_destroy :deactivate_connected_softkeys @@ -102,19 +101,6 @@ class CallForward < ActiveRecord::Base end private - def split_and_format_destination_numbers - if !self.destination.blank? - destinations = self.destination.gsub(/[^+0-9\,]/,'').gsub(/[\,]+/,',').split(/\,/).delete_if{|x| x.blank?} - self.destination = nil - if destinations.count > 0 - destinations.each do |single_destination| - self.destination = self.destination.to_s + ", #{PhoneNumber.parse_and_format(single_destination)}" - end - end - self.destination = self.destination.to_s.gsub(/[^+0-9\,]/,'').gsub(/[\,]+/,',').split(/\,/).sort.delete_if{|x| x.blank?}.join(', ') - end - end - def set_presence state = 'terminated' -- cgit v1.2.3 From e2b4088b25551316d373eae6a4e4cc2293801058 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 28 Mar 2013 09:12:05 +0100 Subject: parent accounts fixed --- app/controllers/call_forwards_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/controllers/call_forwards_controller.rb b/app/controllers/call_forwards_controller.rb index 858ed12..cdf6c06 100644 --- a/app/controllers/call_forwards_controller.rb +++ b/app/controllers/call_forwards_controller.rb @@ -136,7 +136,7 @@ class CallForwardsController < ApplicationController phone_number_destination, ] - if @parent.try(:voicemail_accounts) + if @parent.class == SipAccount || @parent.class == User || @parent.class == Tenant @parent.voicemail_accounts.each do |voicemail_account| call_forwards_destination = CallForwardingDestination.new() call_forwards_destination.id = "#{voicemail_account.id}:VoicemailAccount" -- cgit v1.2.3 From 735518861ed7a0a400298be0b951d2b4086a5e22 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 28 Mar 2013 14:25:45 +0100 Subject: forward_to permission added --- app/models/group_permission.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/group_permission.rb b/app/models/group_permission.rb index c859f52..d9c8011 100644 --- a/app/models/group_permission.rb +++ b/app/models/group_permission.rb @@ -1,7 +1,7 @@ class GroupPermission < ActiveRecord::Base attr_accessible :group_id, :permission, :target_group_id - PERMISSION_TYPES = ['pickup', 'presence'] + PERMISSION_TYPES = ['pickup', 'presence', 'forward_to',] belongs_to :group belongs_to :target_group, :class_name => "Group" -- cgit v1.2.3 From d8a6f81af4d1752c9c28c6560fb9bc1c52e7ab9c Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 28 Mar 2013 14:26:17 +0100 Subject: target_group_ids_by_permission method added --- app/models/group.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app') diff --git a/app/models/group.rb b/app/models/group.rb index 6c65f70..849fa71 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -29,4 +29,12 @@ class Group < ActiveRecord::Base return group_ids.uniq end + + def self.target_group_ids_by_permission(permission, *group_sets) + target_groups = [] + group_sets.each do |groups| + target_groups = target_groups + Group.union(groups.collect{|g| g.permission_targets(permission)}) + end + return target_groups.uniq + end end -- cgit v1.2.3 From 68ee69efeca95e6fa5fb063ca77274cffb053692 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 28 Mar 2013 14:27:22 +0100 Subject: call_forwarding_destinations method --- app/controllers/call_forwards_controller.rb | 43 +++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 9 deletions(-) (limited to 'app') diff --git a/app/controllers/call_forwards_controller.rb b/app/controllers/call_forwards_controller.rb index cdf6c06..917bee3 100644 --- a/app/controllers/call_forwards_controller.rb +++ b/app/controllers/call_forwards_controller.rb @@ -127,7 +127,7 @@ class CallForwardsController < ApplicationController end def call_forwarding_destination_types - + destinations_hash = {} phone_number_destination = CallForwardingDestination.new() phone_number_destination.id = ':PhoneNumber' phone_number_destination.label = 'Phone Number' @@ -140,18 +140,37 @@ class CallForwardsController < ApplicationController @parent.voicemail_accounts.each do |voicemail_account| call_forwards_destination = CallForwardingDestination.new() call_forwards_destination.id = "#{voicemail_account.id}:VoicemailAccount" - call_forwards_destination.label = "VoicemailAccount: #{voicemail_account.to_s}" - call_forwarding_destinations << call_forwards_destination + call_forwards_destination.label = "VoicemailAccount: #{voicemail_account.to_s}" + if !destinations_hash[call_forwards_destination.id] + destinations_hash[call_forwards_destination.id] = true + call_forwarding_destinations << call_forwards_destination + end end end if @parent.class == SipAccount sip_account = @parent + group_ids = Group.target_group_ids_by_permission(:forward_to, sip_account.groups) + if sip_account.sip_accountable.class == User || sip_account.sip_accountable.class == Tenant + group_ids = group_ids + Group.target_group_ids_by_permission(:forward_to, sip_account.sip_accountable.groups) sip_account.sip_accountable.voicemail_accounts.each do |voicemail_account| call_forwards_destination = CallForwardingDestination.new() call_forwards_destination.id = "#{voicemail_account.id}:VoicemailAccount" call_forwards_destination.label = "VoicemailAccount: #{voicemail_account.to_s}" + if !destinations_hash[call_forwards_destination.id] + destinations_hash[call_forwards_destination.id] = true + call_forwarding_destinations << call_forwards_destination + end + end + end + + GroupMembership.where(:group_id => group_ids, :item_type => 'VoicemailAccount').each do |group_member| + call_forwards_destination = CallForwardingDestination.new() + call_forwards_destination.id = "#{group_member.item.id}:VoicemailAccount" + call_forwards_destination.label = "VoicemailAccount: #{group_member.item.to_s}" + if !destinations_hash[call_forwards_destination.id] + destinations_hash[call_forwards_destination.id] = true call_forwarding_destinations << call_forwards_destination end end @@ -165,7 +184,10 @@ class CallForwardsController < ApplicationController call_forwards_destination = CallForwardingDestination.new() call_forwards_destination.id = "#{voicemail_account.id}:VoicemailAccount" call_forwards_destination.label = "VoicemailAccount: #{voicemail_account.to_s}" - call_forwarding_destinations << call_forwards_destination + if !destinations_hash[call_forwards_destination.id] + destinations_hash[call_forwards_destination.id] = true + call_forwarding_destinations << call_forwards_destination + end end end end @@ -173,14 +195,17 @@ class CallForwardsController < ApplicationController if GuiFunction.display?('huntgroup_in_destination_field_in_call_forward_form', current_user) HuntGroup.all.each do |hunt_group| - hunt_group_destination = CallForwardingDestination.new() - hunt_group_destination.id = "#{hunt_group.id}:HuntGroup" - hunt_group_destination.label = "HuntGroup: #{hunt_group.to_s}" - call_forwarding_destinations.push(hunt_group_destination) + call_forwards_destination = CallForwardingDestination.new() + call_forwards_destination.id = "#{hunt_group.id}:HuntGroup" + call_forwards_destination.label = "HuntGroup: #{hunt_group.to_s}" + if !destinations_hash[call_forwards_destination.id] + destinations_hash[call_forwards_destination.id] = true + call_forwarding_destinations << call_forwards_destination + end end end - return call_forwarding_destinations.uniq + return call_forwarding_destinations end end -- cgit v1.2.3 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 --- app/controllers/switchboards_controller.rb | 3 +++ app/views/switchboards/app.js | 8 ++++++++ app/views/switchboards/show-old.html.haml | 21 +++++++++++++++++++++ app/views/switchboards/show.html.erb | 23 +++++++++++++++++++++++ app/views/switchboards/show.html.haml | 21 --------------------- 5 files changed, 55 insertions(+), 21 deletions(-) create mode 100644 app/views/switchboards/app.js create mode 100644 app/views/switchboards/show-old.html.haml create mode 100644 app/views/switchboards/show.html.erb delete mode 100644 app/views/switchboards/show.html.haml (limited to 'app') diff --git a/app/controllers/switchboards_controller.rb b/app/controllers/switchboards_controller.rb index 98008c1..c499c69 100644 --- a/app/controllers/switchboards_controller.rb +++ b/app/controllers/switchboards_controller.rb @@ -8,6 +8,9 @@ class SwitchboardsController < ApplicationController end def show + if @user.nil? + @user = current_user + end @switchboard = @user.switchboards.find(params[:id]) @switchboard_entries = @switchboard.switchboard_entries spread_breadcrumbs diff --git a/app/views/switchboards/app.js b/app/views/switchboards/app.js new file mode 100644 index 0000000..a4aa100 --- /dev/null +++ b/app/views/switchboards/app.js @@ -0,0 +1,8 @@ +window.App = Ember.Application.create({ + rootElement: '#xxxyyy', + + ready: function() { + App.view.appendTo('#xxxyyy'); + } +}); + diff --git a/app/views/switchboards/show-old.html.haml b/app/views/switchboards/show-old.html.haml new file mode 100644 index 0000000..a825806 --- /dev/null +++ b/app/views/switchboards/show-old.html.haml @@ -0,0 +1,21 @@ +- content_for :title, "Switchboard #{@switchboard.name}" + +.row + .span12 + = render :partial => "current_user_dashboard", :current_user => current_user + + %ul.thumbnails + = render :partial => "switchboard_entries/switchboard_entry", :collection => @switchboard_entries + + - if can? :edit, @switchboard + .row + .span12 + %a.btn.btn-small.btn-warning{:href => switchboard_switchboard_entries_path(@switchboard) } + %i.icon-edit.icon-white + %span.hidden-phone + =t("switchboard_entries.index.page_title") + + .span6 + + += subscribe_to "/switchboards/#{@switchboard.id}" \ No newline at end of file diff --git a/app/views/switchboards/show.html.erb b/app/views/switchboards/show.html.erb new file mode 100644 index 0000000..337d00c --- /dev/null +++ b/app/views/switchboards/show.html.erb @@ -0,0 +1,23 @@ +<% content_for :title, "Switchboard #{@switchboard.name}" %> + +
+
+
+ +
+ + + + + +
+
+ + + + + diff --git a/app/views/switchboards/show.html.haml b/app/views/switchboards/show.html.haml deleted file mode 100644 index a825806..0000000 --- a/app/views/switchboards/show.html.haml +++ /dev/null @@ -1,21 +0,0 @@ -- content_for :title, "Switchboard #{@switchboard.name}" - -.row - .span12 - = render :partial => "current_user_dashboard", :current_user => current_user - - %ul.thumbnails - = render :partial => "switchboard_entries/switchboard_entry", :collection => @switchboard_entries - - - if can? :edit, @switchboard - .row - .span12 - %a.btn.btn-small.btn-warning{:href => switchboard_switchboard_entries_path(@switchboard) } - %i.icon-edit.icon-white - %span.hidden-phone - =t("switchboard_entries.index.page_title") - - .span6 - - -= subscribe_to "/switchboards/#{@switchboard.id}" \ 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 --- app/controllers/switchboard_entries_controller.rb | 13 +++++++++++-- app/controllers/switchboards_controller.rb | 13 +++++++++++++ app/serializers/switchboard_entry_serializer.rb | 3 +++ app/serializers/switchboard_serializer.rb | 6 ++++++ app/views/switchboards/show.html.erb | 19 +++++++++++++------ 5 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 app/serializers/switchboard_entry_serializer.rb create mode 100644 app/serializers/switchboard_serializer.rb (limited to 'app') diff --git a/app/controllers/switchboard_entries_controller.rb b/app/controllers/switchboard_entries_controller.rb index ef6c72e..32ca9bb 100644 --- a/app/controllers/switchboard_entries_controller.rb +++ b/app/controllers/switchboard_entries_controller.rb @@ -8,8 +8,17 @@ class SwitchboardEntriesController < ApplicationController end def show - @switchboard_entry = @switchboard.switchboard_entries.find(params[:id]) - spread_breadcrumbs + if @switchboard + @switchboard_entry = @switchboard.switchboard_entries.find(params[:id]) + spread_breadcrumbs + else + @switchboard_entry = SwitchboardEntry.find(params[:id]) + end + + respond_to do |format| + format.html + format.json { render json: @switchboard_entry } + end end def new diff --git a/app/controllers/switchboards_controller.rb b/app/controllers/switchboards_controller.rb index c499c69..8ceb96d 100644 --- a/app/controllers/switchboards_controller.rb +++ b/app/controllers/switchboards_controller.rb @@ -3,8 +3,16 @@ class SwitchboardsController < ApplicationController authorize_resource :switchboard, :through => :user def index + if @user.nil? + @user = current_user + end @switchboards = @user.switchboards spread_breadcrumbs + + respond_to do |format| + format.html + format.json { render json: @switchboards } + end end def show @@ -14,6 +22,11 @@ class SwitchboardsController < ApplicationController @switchboard = @user.switchboards.find(params[:id]) @switchboard_entries = @switchboard.switchboard_entries spread_breadcrumbs + + respond_to do |format| + format.html + format.json { render json: @switchboard } + end end def new 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 diff --git a/app/views/switchboards/show.html.erb b/app/views/switchboards/show.html.erb index 337d00c..a4bdae0 100644 --- a/app/views/switchboards/show.html.erb +++ b/app/views/switchboards/show.html.erb @@ -1,19 +1,26 @@ <% content_for :title, "Switchboard #{@switchboard.name}" %> + +
-
- -
+
+ -
-- 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/controllers/switchboard_entries_controller.rb | 13 ++++++-- app/controllers/switchboards_controller.rb | 5 ++- app/models/switchboard.rb | 21 ++++++++++++ app/models/switchboard_entry.rb | 2 ++ app/serializers/switchboard_entry_serializer.rb | 2 ++ app/serializers/switchboard_serializer.rb | 7 ++-- app/views/switchboards/_form_core.html.haml | 3 ++ app/views/switchboards/app.js | 8 ----- app/views/switchboards/show.html.erb | 40 ++++++++++++++++++----- 9 files changed, 79 insertions(+), 22 deletions(-) delete mode 100644 app/views/switchboards/app.js (limited to 'app') diff --git a/app/controllers/switchboard_entries_controller.rb b/app/controllers/switchboard_entries_controller.rb index 32ca9bb..3f82976 100644 --- a/app/controllers/switchboard_entries_controller.rb +++ b/app/controllers/switchboard_entries_controller.rb @@ -3,8 +3,17 @@ class SwitchboardEntriesController < ApplicationController authorize_resource :switchboard_entry, :through => :switchboard, :except => [:sort] def index - @switchboard_entries = @switchboard.switchboard_entries - spread_breadcrumbs + if @switchboard + @switchboard_entries = @switchboard.switchboard_entries + spread_breadcrumbs + else + @switchboard_entries = SwitchboardEntry.where(:id => params[:ids]) + end + + respond_to do |format| + format.html + format.json { render json: @switchboard_entries } + end end def show diff --git a/app/controllers/switchboards_controller.rb b/app/controllers/switchboards_controller.rb index 8ceb96d..d3424ad 100644 --- a/app/controllers/switchboards_controller.rb +++ b/app/controllers/switchboards_controller.rb @@ -31,6 +31,9 @@ class SwitchboardsController < ApplicationController def new @switchboard = @user.switchboards.build + @switchboard.show_avatars = true + @switchboard.entry_width = 2 + @switchboard.reload_interval = 2000 spread_breadcrumbs end @@ -68,7 +71,7 @@ class SwitchboardsController < ApplicationController private def switchboard_params - params.require(:switchboard).permit(:name) + params.require(:switchboard).permit(:name, :reload_interval, :show_avatars, :entry_width) end def spread_breadcrumbs diff --git a/app/models/switchboard.rb b/app/models/switchboard.rb index 74e2767..360de70 100644 --- a/app/models/switchboard.rb +++ b/app/models/switchboard.rb @@ -6,11 +6,32 @@ class Switchboard < ActiveRecord::Base :presence => true, :uniqueness => {:scope => :user_id} + validates :reload_interval, + :numericality => { :only_integer => true, + :greater_than => 250, + :allow_nil => true + } + + validates :entry_width, + :numericality => { :only_integer => true, + :greater_than => 0, + :less_than => 5 + } + belongs_to :user, :touch => true has_many :switchboard_entries, :dependent => :destroy has_many :sip_accounts, :through => :switchboard_entries + before_validation :convert_0_to_nil + def to_s self.name.to_s end + + private + def convert_0_to_nil + if self.reload_interval == 0 + self.reload_interval = nil + end + end end diff --git a/app/models/switchboard_entry.rb b/app/models/switchboard_entry.rb index 76d002f..faeba8c 100644 --- a/app/models/switchboard_entry.rb +++ b/app/models/switchboard_entry.rb @@ -5,6 +5,8 @@ class SwitchboardEntry < ActiveRecord::Base belongs_to :switchboard, :touch => true belongs_to :sip_account, :touch => true + has_many :phone_numbers, :through => :sip_account + validates :switchboard, :presence => true 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 diff --git a/app/views/switchboards/_form_core.html.haml b/app/views/switchboards/_form_core.html.haml index 61b5934..59a2442 100644 --- a/app/views/switchboards/_form_core.html.haml +++ b/app/views/switchboards/_form_core.html.haml @@ -1,2 +1,5 @@ .inputs = f.input :name, :label => t('switchboards.form.name.label'), :hint => conditional_hint('switchboards.form.name.hint'), :autofocus => true + = f.input :reload_interval, :label => t('switchboards.form.reload_interval.label'), :hint => conditional_hint('switchboards.form.reload_interval.hint') + = f.input :show_avatars, :label => t('switchboards.form.show_avatars.label'), :hint => conditional_hint('switchboards.form.show_avatars.hint') + = f.input :entry_width, :label => t('switchboards.form.entry_width.label'), :hint => conditional_hint('switchboards.form.entry_width.hint') diff --git a/app/views/switchboards/app.js b/app/views/switchboards/app.js deleted file mode 100644 index a4aa100..0000000 --- a/app/views/switchboards/app.js +++ /dev/null @@ -1,8 +0,0 @@ -window.App = Ember.Application.create({ - rootElement: '#xxxyyy', - - ready: function() { - App.view.appendTo('#xxxyyy'); - } -}); - diff --git a/app/views/switchboards/show.html.erb b/app/views/switchboards/show.html.erb index a4bdae0..87bb551 100644 --- a/app/views/switchboards/show.html.erb +++ b/app/views/switchboards/show.html.erb @@ -2,23 +2,47 @@
-
- -
-- 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/controllers/api/v1/phone_numbers_controller.rb | 23 +++++++++++++++ app/controllers/api/v1/sip_accounts_controller.rb | 23 +++++++++++++++ .../api/v1/switchboard_entries_controller.rb | 23 +++++++++++++++ app/controllers/api/v1/switchboards_controller.rb | 21 ++++++++++++++ app/controllers/switchboard_entries_controller.rb | 26 +++-------------- app/controllers/switchboards_controller.rb | 16 ----------- app/models/switchboard.rb | 3 +- app/models/switchboard_entry.rb | 33 ++++++++++++++++++++++ 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 +++--- app/views/switchboards/show.html.erb | 20 ++++++------- 13 files changed, 163 insertions(+), 56 deletions(-) create mode 100644 app/controllers/api/v1/phone_numbers_controller.rb create mode 100644 app/controllers/api/v1/sip_accounts_controller.rb create mode 100644 app/controllers/api/v1/switchboard_entries_controller.rb create mode 100644 app/controllers/api/v1/switchboards_controller.rb create mode 100644 app/serializers/phone_number_serializer.rb create mode 100644 app/serializers/sip_account_serializer.rb (limited to 'app') diff --git a/app/controllers/api/v1/phone_numbers_controller.rb b/app/controllers/api/v1/phone_numbers_controller.rb new file mode 100644 index 0000000..ff58fd3 --- /dev/null +++ b/app/controllers/api/v1/phone_numbers_controller.rb @@ -0,0 +1,23 @@ +module Api + module V1 + class PhoneNumbersController < ApplicationController + respond_to :json + + def index + if params[:ids] + @phone_numbers = PhoneNumber.where(:id => params[:ids]) + else + @phone_numbers = PhoneNumber.all + end + + respond_with @phone_numbers + end + + def show + @phone_number = PhoneNumber.find(params[:id]) + + respond_with @phone_number + end + end + end +end diff --git a/app/controllers/api/v1/sip_accounts_controller.rb b/app/controllers/api/v1/sip_accounts_controller.rb new file mode 100644 index 0000000..6f305a4 --- /dev/null +++ b/app/controllers/api/v1/sip_accounts_controller.rb @@ -0,0 +1,23 @@ +module Api + module V1 + class SipAccountsController < ApplicationController + respond_to :json + + def index + if params[:ids] + @sip_accounts = SipAccount.where(:id => params[:ids]) + else + @sip_accounts = SipAccount.all + end + + respond_with @sip_accounts + end + + def show + @sip_account = SipAccount.find(params[:id]) + + respond_with @sip_account + end + end + end +end diff --git a/app/controllers/api/v1/switchboard_entries_controller.rb b/app/controllers/api/v1/switchboard_entries_controller.rb new file mode 100644 index 0000000..688f108 --- /dev/null +++ b/app/controllers/api/v1/switchboard_entries_controller.rb @@ -0,0 +1,23 @@ +module Api + module V1 + class SwitchboardEntriesController < ApplicationController + respond_to :json + + def index + if params[:ids] + @switchboard_entries = SwitchboardEntry.where(:id => params[:ids]) + else + @switchboard_entries = SwitchboardEntry.all + end + + respond_with @switchboard_entries + end + + def show + @switchboard_entry = SwitchboardEntry.find(params[:id]) + + respond_with @switchboard_entry + end + end + end +end \ No newline at end of file diff --git a/app/controllers/api/v1/switchboards_controller.rb b/app/controllers/api/v1/switchboards_controller.rb new file mode 100644 index 0000000..e6996ca --- /dev/null +++ b/app/controllers/api/v1/switchboards_controller.rb @@ -0,0 +1,21 @@ +module Api + module V1 + class SwitchboardsController < ApplicationController + respond_to :json + + def index + @user = current_user + @switchboards = @user.switchboards + + respond_with @switchboards + end + + def show + @user = current_user + @switchboard = @user.switchboards.find(params[:id]) + + respond_with @switchboard + end + end + end +end diff --git a/app/controllers/switchboard_entries_controller.rb b/app/controllers/switchboard_entries_controller.rb index 3f82976..ef6c72e 100644 --- a/app/controllers/switchboard_entries_controller.rb +++ b/app/controllers/switchboard_entries_controller.rb @@ -3,31 +3,13 @@ class SwitchboardEntriesController < ApplicationController authorize_resource :switchboard_entry, :through => :switchboard, :except => [:sort] def index - if @switchboard - @switchboard_entries = @switchboard.switchboard_entries - spread_breadcrumbs - else - @switchboard_entries = SwitchboardEntry.where(:id => params[:ids]) - end - - respond_to do |format| - format.html - format.json { render json: @switchboard_entries } - end + @switchboard_entries = @switchboard.switchboard_entries + spread_breadcrumbs end def show - if @switchboard - @switchboard_entry = @switchboard.switchboard_entries.find(params[:id]) - spread_breadcrumbs - else - @switchboard_entry = SwitchboardEntry.find(params[:id]) - end - - respond_to do |format| - format.html - format.json { render json: @switchboard_entry } - end + @switchboard_entry = @switchboard.switchboard_entries.find(params[:id]) + spread_breadcrumbs end def new diff --git a/app/controllers/switchboards_controller.rb b/app/controllers/switchboards_controller.rb index d3424ad..f48e7fb 100644 --- a/app/controllers/switchboards_controller.rb +++ b/app/controllers/switchboards_controller.rb @@ -3,30 +3,14 @@ class SwitchboardsController < ApplicationController authorize_resource :switchboard, :through => :user def index - if @user.nil? - @user = current_user - end @switchboards = @user.switchboards spread_breadcrumbs - - respond_to do |format| - format.html - format.json { render json: @switchboards } - end end def show - if @user.nil? - @user = current_user - end @switchboard = @user.switchboards.find(params[:id]) @switchboard_entries = @switchboard.switchboard_entries spread_breadcrumbs - - respond_to do |format| - format.html - format.json { render json: @switchboard } - end end def new diff --git a/app/models/switchboard.rb b/app/models/switchboard.rb index 360de70..53f69a4 100644 --- a/app/models/switchboard.rb +++ b/app/models/switchboard.rb @@ -8,7 +8,7 @@ class Switchboard < ActiveRecord::Base validates :reload_interval, :numericality => { :only_integer => true, - :greater_than => 250, + :greater_than => 249, :allow_nil => true } @@ -21,6 +21,7 @@ class Switchboard < ActiveRecord::Base belongs_to :user, :touch => true has_many :switchboard_entries, :dependent => :destroy has_many :sip_accounts, :through => :switchboard_entries + has_many :phone_numbers, :through => :sip_accounts before_validation :convert_0_to_nil diff --git a/app/models/switchboard_entry.rb b/app/models/switchboard_entry.rb index faeba8c..44de7fd 100644 --- a/app/models/switchboard_entry.rb +++ b/app/models/switchboard_entry.rb @@ -30,4 +30,37 @@ class SwitchboardEntry < ActiveRecord::Base self.name.to_s end end + + def avatar_src + if self.sip_account.sip_accountable.class == User + if self.sip_account.sip_accountable.image? + self.sip_account.sip_accountable.image_url(:profile) + else + if self.sip_account.sip_accountable.male? + '/assets/icons/user-male-16x.png' + else + '/assets/icons/user-female-16x.png' + end + end + else + nil + end + end + + def callstate + if self.sip_account.call_legs.where(callstate: 'ACTIVE').any? || self.sip_account.b_call_legs.where(b_callstate: 'ACTIVE').any? + 'ACTIVE' + else + if self.sip_account.call_legs.where(callstate: 'EARLY').any? + 'EARLY' + else + if self.sip_account.call_legs.where(callstate: 'RINGING').any? + 'RINGING' + else + nil + end + end + end + end + end 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 diff --git a/app/views/switchboards/show.html.erb b/app/views/switchboards/show.html.erb index 87bb551..1fd9d9a 100644 --- a/app/views/switchboards/show.html.erb +++ b/app/views/switchboards/show.html.erb @@ -22,20 +22,18 @@ {{#each switchboardEntry in switchboardEntrys}}
  • - - User-male-16x - + {{avatar_img switchboardEntry.avatar_src}}

    - {{switchboardEntry.name}} -
    - - 33 - + {{switchboardEntry.name}}
    + + {{#each phoneNumber in switchboardEntry.sipAccount.phoneNumbers}} + + {{phoneNumber.number}} + + {{/each}}
    - - - + {{show_callstate switchboardEntry.callstate}}

    -- cgit v1.2.3 From d6a733440eee34dab3daf25089d40aed91018a49 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Thu, 4 Apr 2013 12:04:34 +0200 Subject: Limit the amount of displayed phone_numbers in a switchboard_entry --- app/controllers/switchboards_controller.rb | 3 ++- app/models/switchboard.rb | 6 ++++++ app/views/switchboards/_form_core.html.haml | 1 + app/views/switchboards/show.html.erb | 3 ++- 4 files changed, 11 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/controllers/switchboards_controller.rb b/app/controllers/switchboards_controller.rb index f48e7fb..3e2f8d6 100644 --- a/app/controllers/switchboards_controller.rb +++ b/app/controllers/switchboards_controller.rb @@ -18,6 +18,7 @@ class SwitchboardsController < ApplicationController @switchboard.show_avatars = true @switchboard.entry_width = 2 @switchboard.reload_interval = 2000 + @switchboard.amount_of_displayed_phone_numbers = 1 spread_breadcrumbs end @@ -55,7 +56,7 @@ class SwitchboardsController < ApplicationController private def switchboard_params - params.require(:switchboard).permit(:name, :reload_interval, :show_avatars, :entry_width) + params.require(:switchboard).permit(:name, :reload_interval, :show_avatars, :entry_width, :amount_of_displayed_phone_numbers) end def spread_breadcrumbs diff --git a/app/models/switchboard.rb b/app/models/switchboard.rb index 53f69a4..cf8c708 100644 --- a/app/models/switchboard.rb +++ b/app/models/switchboard.rb @@ -18,6 +18,12 @@ class Switchboard < ActiveRecord::Base :less_than => 5 } + validates :amount_of_displayed_phone_numbers, + :numericality => { :only_integer => true, + :greater_than_or_equal_to => 0, + :less_than => 20 + } + belongs_to :user, :touch => true has_many :switchboard_entries, :dependent => :destroy has_many :sip_accounts, :through => :switchboard_entries diff --git a/app/views/switchboards/_form_core.html.haml b/app/views/switchboards/_form_core.html.haml index 59a2442..2258640 100644 --- a/app/views/switchboards/_form_core.html.haml +++ b/app/views/switchboards/_form_core.html.haml @@ -3,3 +3,4 @@ = f.input :reload_interval, :label => t('switchboards.form.reload_interval.label'), :hint => conditional_hint('switchboards.form.reload_interval.hint') = f.input :show_avatars, :label => t('switchboards.form.show_avatars.label'), :hint => conditional_hint('switchboards.form.show_avatars.hint') = f.input :entry_width, :label => t('switchboards.form.entry_width.label'), :hint => conditional_hint('switchboards.form.entry_width.hint') + = f.input :amount_of_displayed_phone_numbers, :label => t('switchboards.form.amount_of_displayed_phone_numbers.label'), :hint => conditional_hint('switchboards.form.amount_of_displayed_phone_numbers.hint') \ No newline at end of file diff --git a/app/views/switchboards/show.html.erb b/app/views/switchboards/show.html.erb index 1fd9d9a..a240b55 100644 --- a/app/views/switchboards/show.html.erb +++ b/app/views/switchboards/show.html.erb @@ -4,6 +4,7 @@ var switchboard_id = <%= @switchboard.id %>; var show_avatars = <%= @switchboard.show_avatars.to_s %>; var reload_interval = <%= @switchboard.reload_interval.nil? ? 0 : @switchboard.reload_interval %>; + var amount_of_displayed_phone_numbers = <%= @switchboard.amount_of_displayed_phone_numbers %>;
    @@ -27,7 +28,7 @@ {{switchboardEntry.name}}
    - {{#each phoneNumber in switchboardEntry.sipAccount.phoneNumbers}} + {{#each phoneNumber in switchboardEntry.sipAccount.phoneNumberShortList}} {{phoneNumber.number}} -- cgit v1.2.3 From 512c7e16b8164c85e4d6f473cf10bd25e6fc9ad2 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 8 Apr 2013 11:28:56 +0200 Subject: display related call_forwards --- app/models/softkey.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/models/softkey.rb b/app/models/softkey.rb index 27527f9..7e9b66d 100644 --- a/app/models/softkey.rb +++ b/app/models/softkey.rb @@ -35,10 +35,9 @@ class Softkey < ActiveRecord::Base map{ |phone_number| phone_number.phone_numberable.hunt_group.id }. uniq - call_forwards = call_forwards + CallForward.where(:destinationable_type => 'HuntGroup', :destinationable_id => hunt_group_ids, :call_forwardable_type => 'PhoneNumber'). - where('call_forwardable_id NOT IN (?)', phone_numbers_ids) + call_forwards = call_forwards + CallForward.where(:destinationable_type => 'HuntGroup', :destinationable_id => hunt_group_ids, :call_forward_case_id => CallForwardCase.where(:value => 'assistant').first.try(:id)) - return call_forwards + return call_forwards.uniq end def possible_blf_sip_accounts -- cgit v1.2.3 From 78ea4bcd397a4d8f39ad3c08066fe918a8fc89ad Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 11 Apr 2013 10:51:28 +0200 Subject: file uploader --- app/controllers/generic_files_controller.rb | 64 +++++++++++++++++++++++++++ app/helpers/generic_files_helper.rb | 2 + app/models/generic_file.rb | 44 ++++++++++++++++++ app/uploaders/generic_file_uploader.rb | 18 ++++++++ app/views/generic_files/_form.html.haml | 7 +++ app/views/generic_files/_form_core.html.haml | 7 +++ app/views/generic_files/_index_core.html.haml | 14 ++++++ app/views/generic_files/edit.html.haml | 3 ++ app/views/generic_files/index.html.haml | 6 +++ app/views/generic_files/new.html.haml | 3 ++ app/views/generic_files/show.html.haml | 20 +++++++++ 11 files changed, 188 insertions(+) create mode 100644 app/controllers/generic_files_controller.rb create mode 100644 app/helpers/generic_files_helper.rb create mode 100644 app/models/generic_file.rb create mode 100644 app/uploaders/generic_file_uploader.rb create mode 100644 app/views/generic_files/_form.html.haml create mode 100644 app/views/generic_files/_form_core.html.haml create mode 100644 app/views/generic_files/_index_core.html.haml create mode 100644 app/views/generic_files/edit.html.haml create mode 100644 app/views/generic_files/index.html.haml create mode 100644 app/views/generic_files/new.html.haml create mode 100644 app/views/generic_files/show.html.haml (limited to 'app') diff --git a/app/controllers/generic_files_controller.rb b/app/controllers/generic_files_controller.rb new file mode 100644 index 0000000..b7dc453 --- /dev/null +++ b/app/controllers/generic_files_controller.rb @@ -0,0 +1,64 @@ +class GenericFilesController < ApplicationController + + load_resource :sip_account + load_resource :conference + load_resource :hunt_group + load_resource :automatic_call_distributor + load_resource :user + load_resource :tenant + load_resource :generic_file + + load_and_authorize_resource :generic_file, :through => [:sip_account, :conference, :hunt_group, :automatic_call_distributor, :user, :tenant] + + before_filter :set_and_authorize_parent + + def index + @generic_files = @parent.generic_files + end + + def show + + end + + def new + @generic_file = @parent.generic_files.build() + end + + def create + @generic_file = @parent.generic_files.new(params[:generic_file]) + if @generic_file.save + m = method( :"#{@parent.class.name.underscore}_generic_files_url" ) + redirect_to m.( @parent ), :notice => t('generic_files.controller.successfuly_created') + else + render :new + end + end + + def edit + @generic_file = GenericFile.find(params[:id]) + end + + def update + @generic_file = GenericFile.find(params[:id]) + if @generic_file.update_attributes(params[:generic_file]) + m = method( :"#{@parent.class.name.underscore}_generic_files_url" ) + redirect_to m.( @parent ), :notice => t('generic_files.controller.successfuly_updated') + else + render :edit + end + end + + def destroy + @generic_file = GenericFile.find(params[:id]) + @generic_file.destroy + m = method( :"#{@parent.class.name.underscore}_generic_files_url" ) + redirect_to m.( @parent ), :notice => t('generic_files.controller.successfuly_destroyed') + end + + private + def set_and_authorize_parent + @parent = @sip_account || @conference || @hunt_group || @automatic_call_distributor || @user || @tenant + + authorize! :read, @parent + end +end diff --git a/app/helpers/generic_files_helper.rb b/app/helpers/generic_files_helper.rb new file mode 100644 index 0000000..6e067ed --- /dev/null +++ b/app/helpers/generic_files_helper.rb @@ -0,0 +1,2 @@ +module GenericFilesHelper +end diff --git a/app/models/generic_file.rb b/app/models/generic_file.rb new file mode 100644 index 0000000..b6b3ede --- /dev/null +++ b/app/models/generic_file.rb @@ -0,0 +1,44 @@ +class GenericFile < ActiveRecord::Base + FILE_TYPES = %w(pdf ps jpg gif png tif wav mp3) + CATEGORIES = %w(file document image greeting recording) + + attr_accessible :name, :file, :file_type, :category, :owner_id, :owner_type + + mount_uploader :file, GenericFileUploader + + belongs_to :owner, :polymorphic => true + + before_save :determine_file_type + + def store_dir + "/var/opt/gemeinschaft/generic_files/#{self.id.to_i}" + end + + def mime_type + return GenericFile.mime_type(self.file.to_s) + end + + def self.mime_type(file_name) + mime_type = `file -b --mime-type "#{file_name}"`.strip + if mime_type.blank? + mime_type = MIME::Types.type_for(file_name).first.to_s + end + + return mime_type + end + + def file_size + if self.file + return File.size(self.file.to_s) + else + return 0 + end + end + + private + def determine_file_type + if self.file_changed? + self.file_type = self.mime_type + end + end +end diff --git a/app/uploaders/generic_file_uploader.rb b/app/uploaders/generic_file_uploader.rb new file mode 100644 index 0000000..4a226ed --- /dev/null +++ b/app/uploaders/generic_file_uploader.rb @@ -0,0 +1,18 @@ +# encoding: utf-8 + +class GenericFileUploader < CarrierWave::Uploader::Base + + storage :file + + def store_dir + model.store_dir + end + + def cache_dir + '/tmp/generic_file_uploader' + end + + def extension_white_list + %w(pdf ps jpg jpeg gif png tif tiff wav mp3) + end +end diff --git a/app/views/generic_files/_form.html.haml b/app/views/generic_files/_form.html.haml new file mode 100644 index 0000000..8912daa --- /dev/null +++ b/app/views/generic_files/_form.html.haml @@ -0,0 +1,7 @@ += simple_form_for([@parent, @generic_file]) do |f| + = f.error_notification + + = render "form_core", :f => f + + .form-actions + = f.button :submit, conditional_t('generic_files.form.submit') diff --git a/app/views/generic_files/_form_core.html.haml b/app/views/generic_files/_form_core.html.haml new file mode 100644 index 0000000..b0e8889 --- /dev/null +++ b/app/views/generic_files/_form_core.html.haml @@ -0,0 +1,7 @@ +.inputs + - if @generic_file.new_record? + = f.input :file, :label => t('generic_files.form.file.label'), :hint => conditional_hint('generic_files.form.file.hint') + - else + = f.input :file_type, :label => t('generic_files.form.file_type.label'), :hint => conditional_hint('generic_files.form.file_type.hint'), :disabled => true + = f.input :name, :label => t('generic_files.form.name.label'), :hint => conditional_hint('generic_files.form.name.hint') + = f.input :category, :label => t('generic_files.form.category.label'), :collection => GenericFile::CATEGORIES, :hint => conditional_hint('generic_files.form.category.hint'), :include_blank => false diff --git a/app/views/generic_files/_index_core.html.haml b/app/views/generic_files/_index_core.html.haml new file mode 100644 index 0000000..5fa66f7 --- /dev/null +++ b/app/views/generic_files/_index_core.html.haml @@ -0,0 +1,14 @@ +%table.table.table-striped + %tr + %th= t('generic_files.index.category') + %th= t('generic_files.index.name') + %th= t('generic_files.index.file_type') + + - for generic_file in generic_files + %tr + %td= generic_file.category + %td= generic_file.name + %td= generic_file.file_type + + + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => generic_file.owner, :child => generic_file} \ No newline at end of file diff --git a/app/views/generic_files/edit.html.haml b/app/views/generic_files/edit.html.haml new file mode 100644 index 0000000..b59dd2b --- /dev/null +++ b/app/views/generic_files/edit.html.haml @@ -0,0 +1,3 @@ +- content_for :title, t("generic_files.edit.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/generic_files/index.html.haml b/app/views/generic_files/index.html.haml new file mode 100644 index 0000000..b3c489e --- /dev/null +++ b/app/views/generic_files/index.html.haml @@ -0,0 +1,6 @@ +- content_for :title, t("generic_files.index.page_title") + +- if @generic_files && @generic_files.count > 0 + = render "index_core", :generic_files => @generic_files + += render :partial => 'shared/create_link', :locals => {:parent => @parent, :child_class => GenericFile} \ No newline at end of file diff --git a/app/views/generic_files/new.html.haml b/app/views/generic_files/new.html.haml new file mode 100644 index 0000000..05af0da --- /dev/null +++ b/app/views/generic_files/new.html.haml @@ -0,0 +1,3 @@ +- content_for :title, t("generic_files.new.page_title") + += render "form" \ No newline at end of file diff --git a/app/views/generic_files/show.html.haml b/app/views/generic_files/show.html.haml new file mode 100644 index 0000000..b375dfc --- /dev/null +++ b/app/views/generic_files/show.html.haml @@ -0,0 +1,20 @@ +- content_for :title, t("generic_files.show.page_title") + +%p + %strong= t('generic_files.show.category') + ":" + = @generic_file.category + +%p + %strong= t('generic_files.show.name') + ":" + = @generic_file.name + +%p + %strong= t('generic_files.show.file_type') + ":" + = @generic_file.file_type + +%p + %strong= t('generic_files.show.file_size') + ":" + = number_to_human_size(@generic_file.file_size) + + += render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @parent, :child => @generic_file } \ No newline at end of file -- cgit v1.2.3 From 4cbc64ec6a0a800d14ba37acb3b210dc6aa39269 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 11 Apr 2013 10:51:51 +0200 Subject: show destination --- app/views/call_forwards/show.html.haml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app') diff --git a/app/views/call_forwards/show.html.haml b/app/views/call_forwards/show.html.haml index ad9ab16..fdd5197 100644 --- a/app/views/call_forwards/show.html.haml +++ b/app/views/call_forwards/show.html.haml @@ -10,6 +10,8 @@ %strong= t('call_forwards.show.destination') + ":" - if @call_forward.destinationable_id && @call_forward.destinationable = "#{@call_forward.destinationable_type}: #{@call_forward.destinationable}" + - if !@call_forward.destination.blank? + = "(#{@call_forward.destination})" - elsif !@call_forward.destinationable_type.blank? = "#{@call_forward.destinationable_type}: #{@call_forward.destination}" - else -- cgit v1.2.3 From ea80c69be9749d15cad1b74253f3e5397466f4ad Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 11 Apr 2013 10:52:14 +0200 Subject: user files --- app/models/user.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app') diff --git a/app/models/user.rb b/app/models/user.rb index 81d1622..5e97459 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -96,6 +96,8 @@ class User < ActiveRecord::Base has_many :voicemail_accounts, :as => :voicemail_accountable, :dependent => :destroy + has_many :generic_files, :as => :owner, :dependent => :destroy + # Avatar like photo mount_uploader :image, ImageUploader -- cgit v1.2.3 From 4c18abe0693475c6676fb1e9ebc0ac2f92b7f39a Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 11 Apr 2013 11:46:33 +0200 Subject: validations added --- app/models/generic_file.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'app') diff --git a/app/models/generic_file.rb b/app/models/generic_file.rb index b6b3ede..04c06df 100644 --- a/app/models/generic_file.rb +++ b/app/models/generic_file.rb @@ -8,6 +8,13 @@ class GenericFile < ActiveRecord::Base belongs_to :owner, :polymorphic => true + validates :name, + :presence => true, + :uniqueness => {:scope => [:owner_id, :owner_type]} + + validates :file, + :presence => true + before_save :determine_file_type def store_dir -- cgit v1.2.3 From f0ab616d674d7c7e9d0018ba7a9fde7107b0519f Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 12 Apr 2013 11:52:13 +0200 Subject: files view added --- app/views/users/_generic_files.html.haml | 7 +++++++ app/views/users/show.html.haml | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 app/views/users/_generic_files.html.haml (limited to 'app') diff --git a/app/views/users/_generic_files.html.haml b/app/views/users/_generic_files.html.haml new file mode 100644 index 0000000..15bdb74 --- /dev/null +++ b/app/views/users/_generic_files.html.haml @@ -0,0 +1,7 @@ +-# Files +-# +- if (can?( :index, GenericFile ) && user.generic_files.count > 0 ) || can?( :create, GenericFile ) + %h2= t('generic_files.index.page_title') + - if can?( :index, GenericFile ) && user.generic_files.count > 0 + = render "generic_files/index_core", :generic_files => user.generic_files + = render :partial => 'shared/create_link', :locals => {:parent => user, :child_class => GenericFile} \ No newline at end of file diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 98f7cc6..9bf76df 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -89,4 +89,7 @@ = render :partial => 'conferences', :locals => {:user => @user} - cache(['user_switchboards_overview', I18n.locale, @user, @user.switchboards]) do - = render :partial => 'switchboards', :locals => {:user => @user} \ No newline at end of file + = render :partial => 'switchboards', :locals => {:user => @user} + + - cache(['user_show_generic_files_overview', I18n.locale, @user, @user.generic_files]) do + = render :partial => 'generic_files', :locals => {:user => @user} \ No newline at end of file -- cgit v1.2.3 From e1462c8f4159e332b729819281fca7c2937e49eb Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 16 Apr 2013 13:02:18 +0200 Subject: voicemail settigs disabled --- app/views/users/show.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 9bf76df..8421c40 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -47,8 +47,8 @@ =link_to t("voicemail_messages.index.page_title"), sip_account_voicemail_messages_path(sip_account) %br =link_to t("call_forwards.index.page_title"), sip_account_call_forwards_path(sip_account) - %br - =link_to t("voicemail_settings.index.page_title"), sip_account_voicemail_settings_path(sip_account) + /%br + /=link_to t("voicemail_settings.index.page_title"), sip_account_voicemail_settings_path(sip_account) %br =link_to t("softkeys.index.page_title"), sip_account_softkeys_path(sip_account) %br -- cgit v1.2.3 From 73172e5ce8f863951476559890fdf7528037bc07 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 17 Apr 2013 10:26:30 +0200 Subject: tenant fax_accounts --- app/controllers/fax_accounts_controller.rb | 5 +++-- app/models/fax_account.rb | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/controllers/fax_accounts_controller.rb b/app/controllers/fax_accounts_controller.rb index 031080e..804cdb9 100644 --- a/app/controllers/fax_accounts_controller.rb +++ b/app/controllers/fax_accounts_controller.rb @@ -1,7 +1,8 @@ class FaxAccountsController < ApplicationController load_resource :user + load_resource :tenant load_resource :user_group - load_and_authorize_resource :fax_account, :through => [:user, :user_group] + load_and_authorize_resource :fax_account, :through => [:user, :user_group, :tenant] before_filter :set_and_authorize_parent before_filter :spread_breadcrumbs @@ -54,7 +55,7 @@ class FaxAccountsController < ApplicationController private def set_and_authorize_parent - @parent = @user || @user_group + @parent = @user || @user_group || @tenant authorize! :read, @parent end diff --git a/app/models/fax_account.rb b/app/models/fax_account.rb index 683447a..2677c5d 100644 --- a/app/models/fax_account.rb +++ b/app/models/fax_account.rb @@ -49,6 +49,7 @@ class FaxAccount < ActiveRecord::Base tenant = case self.fax_accountable_type when 'UserGroup' ; fax_accountable.tenant when 'User' ; fax_accountable.current_tenant || fax_accountable.tenants.last + when 'Tenant' ; fax_accountable else nil end self.tenant_id = tenant.id if tenant != nil -- cgit v1.2.3 From f8e34e0e948352f18db9665b55c9848b1b71b512 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 17 Apr 2013 10:27:05 +0200 Subject: files view --- app/models/tenant.rb | 2 ++ app/views/tenants/_admin_area.de.html.haml | 2 ++ app/views/tenants/_admin_area.en.html.haml | 4 +++- app/views/tenants/_generic_files.html.haml | 5 +++++ 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 app/views/tenants/_generic_files.html.haml (limited to 'app') diff --git a/app/models/tenant.rb b/app/models/tenant.rb index b47faee..7ed14c7 100644 --- a/app/models/tenant.rb +++ b/app/models/tenant.rb @@ -65,6 +65,8 @@ class Tenant < ActiveRecord::Base has_many :voicemail_accounts, :as => :voicemail_accountable, :dependent => :destroy + has_many :generic_files, :as => :owner, :dependent => :destroy + # Validations: # validates_presence_of :name, :state, :country, :language diff --git a/app/views/tenants/_admin_area.de.html.haml b/app/views/tenants/_admin_area.de.html.haml index 8acc95d..cfcbcf3 100644 --- a/app/views/tenants/_admin_area.de.html.haml +++ b/app/views/tenants/_admin_area.de.html.haml @@ -16,6 +16,8 @@ = render :partial => 'tenants/table_of_phone_books', :locals => {:tenant => tenant} + = render :partial => 'generic_files', :locals => {:tenant => tenant} + .well %h2 Gemeinschaft Konfiguration = render :partial => 'tenants/gs_parameter_table', :locals => {:tenant => tenant} diff --git a/app/views/tenants/_admin_area.en.html.haml b/app/views/tenants/_admin_area.en.html.haml index c40e3ca..f0d1e56 100644 --- a/app/views/tenants/_admin_area.en.html.haml +++ b/app/views/tenants/_admin_area.en.html.haml @@ -16,6 +16,8 @@ = render :partial => 'tenants/table_of_phone_books', :locals => {:tenant => tenant} + = render :partial => 'generic_files', :locals => {:tenant => tenant} + .well %h2 Gemeinschaft Configuration = render :partial => 'tenants/gs_parameter_table', :locals => {:tenant => tenant} @@ -42,4 +44,4 @@ = render :partial => 'gateways', :locals => {:tenant => tenant, :gateways => gateways} - = render :partial => 'table_of_backup_jobs', :locals => {:tenant => tenant, :backup_jobs => backup_jobs} \ No newline at end of file + = render :partial => 'table_of_backup_jobs', :locals => {:tenant => tenant, :backup_jobs => backup_jobs} diff --git a/app/views/tenants/_generic_files.html.haml b/app/views/tenants/_generic_files.html.haml new file mode 100644 index 0000000..1b6fee5 --- /dev/null +++ b/app/views/tenants/_generic_files.html.haml @@ -0,0 +1,5 @@ +-# Files +-# +%h2= t('generic_files.index.page_title') += render "generic_files/index_core", :generic_files => tenant.generic_files += render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => GenericFile} \ No newline at end of file -- cgit v1.2.3 From e266a3deb58d3a4c6798b09f2a1216447091f304 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 19 Apr 2013 10:15:35 +0200 Subject: VoicemailAccount ability added --- app/models/ability.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'app') diff --git a/app/models/ability.rb b/app/models/ability.rb index 2dd96b8..185572c 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -181,6 +181,7 @@ class Ability # Voicemail # + can :read, VoicemailAccount can :manage, VoicemailMessage can :manage, VoicemailSetting -- cgit v1.2.3 From af09d2c8d9f72e681c2c6d460a0d2545504d72d3 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 19 Apr 2013 10:17:55 +0200 Subject: voicemail_accounts in voicemail_messages_controller --- app/controllers/voicemail_messages_controller.rb | 36 ++++++++++++------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'app') diff --git a/app/controllers/voicemail_messages_controller.rb b/app/controllers/voicemail_messages_controller.rb index dfe0ae4..239fed4 100644 --- a/app/controllers/voicemail_messages_controller.rb +++ b/app/controllers/voicemail_messages_controller.rb @@ -1,7 +1,7 @@ class VoicemailMessagesController < ApplicationController - load_resource :sip_account - load_and_authorize_resource :voicemail_message, :through => [:sip_account] + load_resource :voicemail_account + load_and_authorize_resource :voicemail_message, :through => [:voicemail_account] before_filter :set_and_authorize_parent before_filter :spread_breadcrumbs @@ -17,22 +17,22 @@ class VoicemailMessagesController < ApplicationController } def index - @messages_count = @sip_account.voicemail_messages.count - @messages_unread_count = @sip_account.voicemail_messages.where(:read_epoch => 0).count + @messages_count = @voicemail_account.voicemail_messages.count + @messages_unread_count = @voicemail_account.voicemail_messages.where(:read_epoch => 0).count @messages_read_count = @messages_count - @messages_unread_count if @type == 'read' - @voicemail_messages = @sip_account.voicemail_messages.where('read_epoch > 0').order('created_epoch DESC').paginate( + @voicemail_messages = @voicemail_account.voicemail_messages.where('read_epoch > 0').order('created_epoch DESC').paginate( :page => @pagination_page_number, :per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE') ) elsif @type == 'unread' - @voicemail_messages = @sip_account.voicemail_messages.where(:read_epoch => 0).order('created_epoch DESC').paginate( + @voicemail_messages = @voicemail_account.voicemail_messages.where(:read_epoch => 0).order('created_epoch DESC').paginate( :page => @pagination_page_number, :per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE') ) else - @voicemail_messages = @sip_account.voicemail_messages.order('created_epoch DESC').paginate( + @voicemail_messages = @voicemail_account.voicemail_messages.order('created_epoch DESC').paginate( :page => @pagination_page_number, :per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE') ) @@ -78,7 +78,7 @@ class VoicemailMessagesController < ApplicationController def destroy_multiple result = false if ! params[:selected_uuids].blank? then - voicemail_messages = @sip_account.voicemail_messages.where(:uuid => params[:selected_uuids]) + voicemail_messages = @voicemail_account.voicemail_messages.where(:uuid => params[:selected_uuids]) voicemail_messages.each do |voicemail_message| result = voicemail_message.destroy end @@ -94,8 +94,8 @@ class VoicemailMessagesController < ApplicationController def call phone_number = @voicemail_message.cid_number - if ! phone_number.blank? && @sip_account.registration - @sip_account.call(phone_number) + if ! phone_number.blank? && @voicemail_account.registration + @voicemail_account.call(phone_number) end redirect_to(:back) end @@ -112,7 +112,7 @@ class VoicemailMessagesController < ApplicationController private def set_and_authorize_parent - @parent = @sip_account + @parent = @voicemail_account authorize! :read, @parent @@ -124,15 +124,15 @@ class VoicemailMessagesController < ApplicationController def spread_breadcrumbs if @parent.class == SipAccount - if @sip_account.sip_accountable.class == User - add_breadcrumb t("#{@sip_account.sip_accountable.class.name.underscore.pluralize}.index.page_title"), method( :"tenant_#{@sip_account.sip_accountable.class.name.underscore.pluralize}_path" ).(@sip_account.tenant) - add_breadcrumb @sip_account.sip_accountable, method( :"tenant_#{@sip_account.sip_accountable.class.name.underscore}_path" ).(@sip_account.tenant, @sip_account.sip_accountable) + if @voicemail_account.voicemail_accountable.class == User + add_breadcrumb t("#{@voicemail_account.voicemail_accountable.class.name.underscore.pluralize}.index.page_title"), method( :"tenant_#{@voicemail_account.voicemail_accountable.class.name.underscore.pluralize}_path" ).(@voicemail_account.tenant) + add_breadcrumb @voicemail_account.voicemail_accountable, method( :"tenant_#{@voicemail_account.voicemail_accountable.class.name.underscore}_path" ).(@voicemail_account.tenant, @voicemail_account.voicemail_accountable) end - add_breadcrumb t("sip_accounts.index.page_title"), method( :"#{@sip_account.sip_accountable.class.name.underscore}_sip_accounts_path" ).(@sip_account.sip_accountable) - add_breadcrumb @sip_account, method( :"#{@sip_account.sip_accountable.class.name.underscore}_sip_account_path" ).(@sip_account.sip_accountable, @sip_account) - add_breadcrumb t("voicemail_messages.index.page_title"), sip_account_voicemail_messages_path(@sip_account) + add_breadcrumb t("voicemail_accounts.index.page_title"), method( :"#{@voicemail_account.voicemail_accountable.class.name.underscore}_voicemail_accounts_path" ).(@voicemail_account.voicemail_accountable) + add_breadcrumb @voicemail_account, method( :"#{@voicemail_account.voicemail_accountable.class.name.underscore}_voicemail_account_path" ).(@voicemail_account.voicemail_accountable, @voicemail_account) + add_breadcrumb t("voicemail_messages.index.page_title"), voicemail_account_voicemail_messages_path(@voicemail_account) if @voicemail_message && !@voicemail_message.new_record? - add_breadcrumb @voicemail_message, sip_account_voicemail_message_path(@sip_account, @voicemail_message) + add_breadcrumb @voicemail_message, voicemail_account_voicemail_message_path(@voicemail_account, @voicemail_message) end end end -- cgit v1.2.3 From fc1e3b48b69d5b358ea19256cd48523d82821326 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 19 Apr 2013 10:18:47 +0200 Subject: voicemail_accounts in voicemail_messages view --- app/views/voicemail_messages/_index_core.html.haml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'app') diff --git a/app/views/voicemail_messages/_index_core.html.haml b/app/views/voicemail_messages/_index_core.html.haml index 5e82761..ceb6fb3 100644 --- a/app/views/voicemail_messages/_index_core.html.haml +++ b/app/views/voicemail_messages/_index_core.html.haml @@ -1,4 +1,4 @@ -= form_tag(destroy_multiple_sip_account_voicemail_messages_path(@sip_account), :method => :delete, :id => 'voicemail_message_form') do += form_tag(destroy_multiple_voicemail_account_voicemail_messages_path(@voicemail_account), :method => :delete, :id => 'voicemail_message_form') do %header.entries-nav= render :partial => "voicemail_messages/navigation" .content %table.table.table-striped @@ -26,18 +26,18 @@ = t("voicemail_messages.index.flags.#{voicemail_message.flags}") %td.form-actions - if can?(:show, voicemail_message) && File.readable?(voicemail_message.file_path) - = link_to t('voicemail_messages.index.actions.download'), sip_account_voicemail_message_path(@sip_account, voicemail_message, :format => :wav), :method => :get - %td.actions - - if @sip_account.registration && can?(:call, voicemail_message) - = link_to t('voicemail_messages.index.actions.call'), call_sip_account_voicemail_message_path(@sip_account, voicemail_message), :method => :put + = link_to t('voicemail_messages.index.actions.download'), voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message, :format => :wav), :method => :get + /%td.actions + / - if @voicemail_account.registration && can?(:call, voicemail_message) + / = link_to t('voicemail_messages.index.actions.call'), call_voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message), :method => :put %td.form-actions - if can?(:edit, voicemail_message) && voicemail_message.read_epoch > 0 - = link_to t('voicemail_messages.index.actions.mark_unread'), mark_unread_sip_account_voicemail_message_path(@sip_account, voicemail_message), :method => :put + = link_to t('voicemail_messages.index.actions.mark_unread'), mark_unread_voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message), :method => :put - else - = link_to t('voicemail_messages.index.actions.mark_read'), mark_read_sip_account_voicemail_message_path(@sip_account, voicemail_message), :method => :put + = link_to t('voicemail_messages.index.actions.mark_read'), mark_read_voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message), :method => :put %td.form-actions - if can? :destroy, voicemail_message - = link_to t('voicemail_messages.index.actions.destroy'), sip_account_voicemail_message_path(@sip_account, voicemail_message), :method => :delete + = link_to t('voicemail_messages.index.actions.destroy'), voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message), :method => :delete %footer.entries-nav= render :partial => "voicemail_messages/navigation" = link_to Haml::Engine.new("%i.icon-remove").render + ' test ', root_url -- cgit v1.2.3 From 5e728545915b87683087d7814bf08034b8d44a33 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 19 Apr 2013 10:19:45 +0200 Subject: list voicemails count --- app/views/voicemail_accounts/_index_core.html.haml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/views/voicemail_accounts/_index_core.html.haml b/app/views/voicemail_accounts/_index_core.html.haml index 908c2b4..cd87c31 100644 --- a/app/views/voicemail_accounts/_index_core.html.haml +++ b/app/views/voicemail_accounts/_index_core.html.haml @@ -2,6 +2,7 @@ %tr %th %th= t('voicemail_accounts.index.name') + %th= t('voicemail_messages.index.page_title') - for voicemail_account in voicemail_accounts @@ -12,4 +13,6 @@ - else %i.icon-ban-circle %td= voicemail_account.name - =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => voicemail_account.voicemail_accountable, :child => voicemail_account} \ No newline at end of file + %td= link_to voicemail_account.voicemail_messages.count, voicemail_account_voicemail_messages_path(voicemail_account) + + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => voicemail_account.voicemail_accountable, :child => voicemail_account} -- cgit v1.2.3 From 4c4deedd65d8c459795ed83d282022a07f38757e Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 19 Apr 2013 10:20:33 +0200 Subject: link to voicemail messages of first account found --- app/views/layouts/_navbar.html.haml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/views/layouts/_navbar.html.haml b/app/views/layouts/_navbar.html.haml index 3e1da1c..f4914b2 100644 --- a/app/views/layouts/_navbar.html.haml +++ b/app/views/layouts/_navbar.html.haml @@ -20,9 +20,10 @@ %li %a{:href => sip_account_call_histories_path(current_user.sip_accounts.first)} =t("call_histories.index.page_title") - %li - %a{:href => sip_account_voicemail_messages_path(current_user.sip_accounts.first)} - =t("voicemail_messages.index.page_title") + - if current_user.voicemail_accounts.first + %li + %a{:href => voicemail_account_voicemail_messages_path(current_user.voicemail_accounts.first)} + =t("voicemail_messages.index.page_title") - if current_user %ul.nav.pull-right -- cgit v1.2.3 From 75bc8af34e4ea625725206f015b04730fad8de63 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 19 Apr 2013 10:21:29 +0200 Subject: list voicemail accounts in user view --- app/views/users/_voicemail_accounts.html.haml | 7 +++++++ app/views/users/show.html.haml | 10 ++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 app/views/users/_voicemail_accounts.html.haml (limited to 'app') diff --git a/app/views/users/_voicemail_accounts.html.haml b/app/views/users/_voicemail_accounts.html.haml new file mode 100644 index 0000000..4410b09 --- /dev/null +++ b/app/views/users/_voicemail_accounts.html.haml @@ -0,0 +1,7 @@ +-# VoicemailAccount +-# +- if (can?( :index, VoicemailAccount ) && user.voicemail_accounts.count > 0 ) || can?( :create, VoicemailAccount ) + %h2= t('voicemail_accounts.index.page_title') + - if can?( :index, VoicemailAccount ) && user.voicemail_accounts.count > 0 + = render "voicemail_accounts/index_core", {:voicemail_accounts => user.voicemail_accounts, :voicemail_accountable => user} + = render :partial => 'shared/create_link', :locals => {:parent => user, :child_class => VoicemailAccount} \ No newline at end of file diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 8421c40..697604a 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -43,12 +43,11 @@ %strong ... %p =link_to t("call_histories.index.page_title"), sip_account_call_histories_path(sip_account) - %br - =link_to t("voicemail_messages.index.page_title"), sip_account_voicemail_messages_path(sip_account) + - if ! sip_account.voicemail_account.blank? + %br + =link_to t("voicemail_messages.index.page_title"), voicemail_account_voicemail_messages_path(sip_account.voicemail_account) %br =link_to t("call_forwards.index.page_title"), sip_account_call_forwards_path(sip_account) - /%br - /=link_to t("voicemail_settings.index.page_title"), sip_account_voicemail_settings_path(sip_account) %br =link_to t("softkeys.index.page_title"), sip_account_softkeys_path(sip_account) %br @@ -85,6 +84,9 @@ - cache(['user_show_fax_accounts_overview', I18n.locale, @user, @user.fax_accounts]) do = render :partial => 'fax_accounts', :locals => {:user => @user} + - cache(['user_show_voicemail_accounts_overview', I18n.locale, @user, @user.voicemail_accounts]) do + = render :partial => 'voicemail_accounts', :locals => {:user => @user} + - cache(['user_show_conferences_overview', I18n.locale, @user, @user.conferences]) do = render :partial => 'conferences', :locals => {:user => @user} -- cgit v1.2.3 From 9a78a0b46509751f912275f8290b009d4a2221fc Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 19 Apr 2013 10:34:34 +0200 Subject: voicemai_accounts added to tenant view --- app/views/tenants/_admin_area.de.html.haml | 2 ++ app/views/tenants/_admin_area.en.html.haml | 2 ++ app/views/tenants/_table_of_voicemail_accounts.html.haml | 8 ++++++++ 3 files changed, 12 insertions(+) create mode 100644 app/views/tenants/_table_of_voicemail_accounts.html.haml (limited to 'app') diff --git a/app/views/tenants/_admin_area.de.html.haml b/app/views/tenants/_admin_area.de.html.haml index cfcbcf3..8ca1e79 100644 --- a/app/views/tenants/_admin_area.de.html.haml +++ b/app/views/tenants/_admin_area.de.html.haml @@ -16,6 +16,8 @@ = render :partial => 'tenants/table_of_phone_books', :locals => {:tenant => tenant} + = render :partial => 'tenants/table_of_voicemail_accounts', :locals => {:tenant => tenant} + = render :partial => 'generic_files', :locals => {:tenant => tenant} .well diff --git a/app/views/tenants/_admin_area.en.html.haml b/app/views/tenants/_admin_area.en.html.haml index f0d1e56..a10f75a 100644 --- a/app/views/tenants/_admin_area.en.html.haml +++ b/app/views/tenants/_admin_area.en.html.haml @@ -16,6 +16,8 @@ = render :partial => 'tenants/table_of_phone_books', :locals => {:tenant => tenant} + = render :partial => 'tenants/table_of_voicemail_accounts', :locals => {:tenant => tenant} + = render :partial => 'generic_files', :locals => {:tenant => tenant} .well diff --git a/app/views/tenants/_table_of_voicemail_accounts.html.haml b/app/views/tenants/_table_of_voicemail_accounts.html.haml new file mode 100644 index 0000000..1cf455a --- /dev/null +++ b/app/views/tenants/_table_of_voicemail_accounts.html.haml @@ -0,0 +1,8 @@ +- cache(['table_of_pbx_features_voicemail_accounts_row', I18n.locale, tenant, tenant.voicemail_accounts.count, tenant.voicemail_accounts.reorder(:updated_at).last]) do + -# VoicemailAccounts + -# + - if (can?( :index, VoicemailAccount ) && tenant.voicemail_accounts.count > 0 ) || can?( :create, VoicemailAccount ) + %h2= t('voicemail_accounts.index.page_title') + - if can?( :index, VoicemailAccount ) && tenant.voicemail_accounts.count > 0 + = render "voicemail_accounts/index_core", :voicemail_accounts => tenant.voicemail_accounts + = render :partial => 'shared/create_link', :locals => {:parent => tenant, :child_class => VoicemailAccount} -- cgit v1.2.3 From 819978b3d4abffdd49bc5adec47746486d5153a2 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 19 Apr 2013 10:44:31 +0200 Subject: groups added to tenant view --- app/views/tenants/_admin_area.de.html.haml | 2 ++ app/views/tenants/_admin_area.en.html.haml | 3 +++ app/views/tenants/_table_of_groups.html.haml | 8 ++++++++ 3 files changed, 13 insertions(+) create mode 100644 app/views/tenants/_table_of_groups.html.haml (limited to 'app') diff --git a/app/views/tenants/_admin_area.de.html.haml b/app/views/tenants/_admin_area.de.html.haml index 8ca1e79..db21c80 100644 --- a/app/views/tenants/_admin_area.de.html.haml +++ b/app/views/tenants/_admin_area.de.html.haml @@ -24,6 +24,8 @@ %h2 Gemeinschaft Konfiguration = render :partial => 'tenants/gs_parameter_table', :locals => {:tenant => tenant} + = render :partial => 'tenants/table_of_groups', :locals => {:tenant => tenant} + %p Das System kann = PhoneModel.count diff --git a/app/views/tenants/_admin_area.en.html.haml b/app/views/tenants/_admin_area.en.html.haml index a10f75a..4b687af 100644 --- a/app/views/tenants/_admin_area.en.html.haml +++ b/app/views/tenants/_admin_area.en.html.haml @@ -12,6 +12,7 @@ = render :partial => 'tenants/table_of_automatic_call_distributors', :locals => {:tenant => tenant} = render :partial => 'tenants/users_table', :locals => {:tenant => tenant} + = render :partial => 'tenants/user_groups_table', :locals => {:tenant => tenant} = render :partial => 'tenants/table_of_phone_books', :locals => {:tenant => tenant} @@ -24,6 +25,8 @@ %h2 Gemeinschaft Configuration = render :partial => 'tenants/gs_parameter_table', :locals => {:tenant => tenant} + = render :partial => 'tenants/table_of_groups', :locals => {:tenant => tenant} + %p This system can provision a total of = PhoneModel.count diff --git a/app/views/tenants/_table_of_groups.html.haml b/app/views/tenants/_table_of_groups.html.haml new file mode 100644 index 0000000..60f93cc --- /dev/null +++ b/app/views/tenants/_table_of_groups.html.haml @@ -0,0 +1,8 @@ +%h2= t("groups.index.page_title") + +- if Group.count <= GsParameter.get('NUMBER_OF_SHOWN_ITEMS') + = render "groups/index_core", :groups => Group.all + = render :partial => 'shared/create_link', :locals => {:child_class => Group} +- else + %p + = link_to t("groups.index.page_title"), groups_path -- cgit v1.2.3 From 3680e51d0a10dad80f46ecc6cbb52cb5dc0519e1 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 19 Apr 2013 23:16:54 +0200 Subject: test removed --- app/views/voicemail_messages/_index_core.html.haml | 1 - 1 file changed, 1 deletion(-) (limited to 'app') diff --git a/app/views/voicemail_messages/_index_core.html.haml b/app/views/voicemail_messages/_index_core.html.haml index ceb6fb3..7324bd3 100644 --- a/app/views/voicemail_messages/_index_core.html.haml +++ b/app/views/voicemail_messages/_index_core.html.haml @@ -40,6 +40,5 @@ = link_to t('voicemail_messages.index.actions.destroy'), voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message), :method => :delete %footer.entries-nav= render :partial => "voicemail_messages/navigation" - = link_to Haml::Engine.new("%i.icon-remove").render + ' test ', root_url = image_submit_tag('icons/cross-16x.png', :confirm => t("voicemail_messages.index.actions.confirm_selected")) = t("voicemail_messages.index.actions.destroy_multiple") -- cgit v1.2.3 From e3b373bcf144dcd0c8e36f8894954dc2b752a05b Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sat, 20 Apr 2013 12:51:50 +0200 Subject: voicemaiL_account in call_histories index --- app/views/call_histories/_index_core.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/views/call_histories/_index_core.html.haml b/app/views/call_histories/_index_core.html.haml index 8bbf761..2faa220 100644 --- a/app/views/call_histories/_index_core.html.haml +++ b/app/views/call_histories/_index_core.html.haml @@ -28,7 +28,7 @@ %td - if call_history.voicemail_message? .voicemail-message - %a{:href => sip_account_voicemail_messages_path(@sip_account, :anchor => "message_#{call_history.voicemail_message.id}")} + %a{:href => voicemail_account_voicemail_messages_path(@sip_account.voicemail_account, :anchor => "message_#{call_history.voicemail_message.id}")} = image_tag('icons/gs_envelope_16x.png') = call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format")) -- cgit v1.2.3 From 00e26f18486d953814fc0c0a4ba0d30432b56f23 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 24 Apr 2013 22:48:50 +0200 Subject: pickup indication disabled --- app/views/config_snom/show.xml.haml | 1 + 1 file changed, 1 insertion(+) (limited to 'app') diff --git a/app/views/config_snom/show.xml.haml b/app/views/config_snom/show.xml.haml index 3d0edf1..16a05d0 100644 --- a/app/views/config_snom/show.xml.haml +++ b/app/views/config_snom/show.xml.haml @@ -36,6 +36,7 @@ %ringer_animation{:perm => 'RW'}= 'on' %display_method{:perm => 'RW'}= 'display_name_number' %callpickup_dialoginfo{:perm => 'RW'}= 'on' + %pickup_indication{:perm => 'RW'}= 'off' %show_local_line{:perm => 'RW'}= 'off' %mwi_notification{:perm => 'RW'}= 'silent' %mwi_dialtone{:perm => 'RW'}= 'normal' -- cgit v1.2.3 From ae99f98a7ae52a375f1b3b5a85d34c9dd15ff81c Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Wed, 24 Apr 2013 22:49:23 +0200 Subject: generic_files user abilities --- app/models/ability.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app') diff --git a/app/models/ability.rb b/app/models/ability.rb index 185572c..2725572 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -185,6 +185,8 @@ class Ability can :manage, VoicemailMessage can :manage, VoicemailSetting + can :manage, GenericFile, :owner_type => 'User', :owner_id => user.id + # Switchboard # can :read, Switchboard, :id => user.switchboard_ids -- cgit v1.2.3 From 0a935c19be0bfdec2c46258d9390ff0b8cfe356d Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 25 Apr 2013 12:10:07 +0200 Subject: return string --- app/models/voicemail_setting.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/voicemail_setting.rb b/app/models/voicemail_setting.rb index 0e9e3fa..be3d749 100644 --- a/app/models/voicemail_setting.rb +++ b/app/models/voicemail_setting.rb @@ -60,7 +60,7 @@ class VoicemailSetting < ActiveRecord::Base when 'Integer' self.value = self.value.to_i when 'Boolean' - self.value = ActiveRecord::ConnectionAdapters::Column.value_to_boolean(self.value) + self.value = ActiveRecord::ConnectionAdapters::Column.value_to_boolean(self.value).to_s end end end -- cgit v1.2.3 From ae05a20f5b474071dfa9b6c8760636304861a7d1 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 25 Apr 2013 12:12:12 +0200 Subject: voicemail_settings controller value input_type --- app/controllers/voicemail_settings_controller.rb | 25 ++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'app') diff --git a/app/controllers/voicemail_settings_controller.rb b/app/controllers/voicemail_settings_controller.rb index 1b2e371..8a7c411 100644 --- a/app/controllers/voicemail_settings_controller.rb +++ b/app/controllers/voicemail_settings_controller.rb @@ -10,6 +10,19 @@ class VoicemailSettingsController < ApplicationController end def new + @names_possible = [] + VoicemailSetting::VOICEMAIL_SETTINGS.keys.each do |name| + if @voicemail_account.voicemail_settings.where(:name => name).first + next + end + + label = t("voicemail_settings.settings.#{name}") + if label =~ /^translation missing/ + label = name.to_s.gsub('_', ' ').capitalize; + end + + @names_possible << [label, name] + end end def create @@ -25,14 +38,8 @@ class VoicemailSettingsController < ApplicationController def edit @voicemail_setting = @voicemail_account.voicemail_settings.find(params[:id]) - @no_edit = { - :name => { - :input => VoicemailSetting::VOICEMAIL_SETTINGS.fetch(@voicemail_setting.name,{}).fetch(:input, {}), - :name => @voicemail_setting.name.to_s, - :html => VoicemailSetting::VOICEMAIL_SETTINGS.fetch(@voicemail_setting.name,{}).fetch(:html, {}), - }, - :description => true - } + @input_type = VoicemailSetting::VOICEMAIL_SETTINGS.fetch(@voicemail_setting.name,{}).fetch(:input, 'String') + @input_html = VoicemailSetting::VOICEMAIL_SETTINGS.fetch(@voicemail_setting.name,{}).fetch(:html, {}) end def update @@ -41,6 +48,8 @@ class VoicemailSettingsController < ApplicationController m = method( :"#{@voicemail_account.voicemail_accountable.class.name.underscore}_voicemail_account_path" ) redirect_to m.( @voicemail_account.voicemail_accountable, @voicemail_account ), :notice => t('voicemail_settings.controller.successfuly_updated') else + @input_type = VoicemailSetting::VOICEMAIL_SETTINGS.fetch(@voicemail_setting.name,{}).fetch(:input, 'String') + @input_html = VoicemailSetting::VOICEMAIL_SETTINGS.fetch(@voicemail_setting.name,{}).fetch(:html, {}) render :edit end end -- cgit v1.2.3 From ebd0b70051c53d207ab21d9671944201894baea3 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 25 Apr 2013 12:13:12 +0200 Subject: form_core fixed --- app/views/voicemail_settings/_form_core.html.haml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'app') diff --git a/app/views/voicemail_settings/_form_core.html.haml b/app/views/voicemail_settings/_form_core.html.haml index 31c6bbf..00d2a9e 100644 --- a/app/views/voicemail_settings/_form_core.html.haml +++ b/app/views/voicemail_settings/_form_core.html.haml @@ -1,11 +1,5 @@ .inputs - - if !@no_edit or !@no_edit[:name] - = f.input :name, :collection => VoicemailSetting::VOICEMAIL_SETTINGS.keys.collect{|i, k| [t("voicemail_settings.settings.#{i}"), i]}, :label => t('voicemail_settings.form.name.label'), :hint => conditional_hint('voicemail_settings.form.name.hint'), :autofocus => true, :include_blank => false - = f.input :value, :label => t('voicemail_settings.form.value.label'), :hint => conditional_hint('voicemail_settings.form.value.hint') - - else - = f.input :value, :label => t("voicemail_settings.settings.#{@no_edit[:name][:name]}"), :hint => conditional_hint('voicemail_settings.form.value.hint'), :as => @no_edit[:name][:input], input_html: @no_edit[:name][:html] - - - if !@no_edit or !@no_edit[:description] - = f.input :description, :label => t('voicemail_settings.form.description.label'), :hint => conditional_hint('voicemail_settings.form.description.hint') - + = f.input :name, :collection => @names_possible, :label => t('voicemail_settings.form.name.label'), :hint => conditional_hint('voicemail_settings.form.name.hint'), :autofocus => true, :include_blank => false + = f.input :value, :label => t('voicemail_settings.form.value.label'), :hint => conditional_hint('voicemail_settings.form.value.hint') + = f.input :description, :label => t('voicemail_settings.form.description.label'), :hint => conditional_hint('voicemail_settings.form.description.hint') -- cgit v1.2.3 From 7e6b6a93a2d21c0e5bd8ad4c2b7be6172cb2638b Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 25 Apr 2013 12:13:49 +0200 Subject: edit form --- app/views/voicemail_settings/_edit_form.html.haml | 8 ++++++++ app/views/voicemail_settings/_edit_form_core.html.haml | 2 ++ app/views/voicemail_settings/edit.html.haml | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 app/views/voicemail_settings/_edit_form.html.haml create mode 100644 app/views/voicemail_settings/_edit_form_core.html.haml (limited to 'app') diff --git a/app/views/voicemail_settings/_edit_form.html.haml b/app/views/voicemail_settings/_edit_form.html.haml new file mode 100644 index 0000000..374df9f --- /dev/null +++ b/app/views/voicemail_settings/_edit_form.html.haml @@ -0,0 +1,8 @@ + += simple_form_for([@voicemail_account, @voicemail_setting]) do |f| + = f.error_notification + + = render "edit_form_core", :f => f + + .form-actions + = f.button :submit, conditional_t('voicemail_settings.form.submit') diff --git a/app/views/voicemail_settings/_edit_form_core.html.haml b/app/views/voicemail_settings/_edit_form_core.html.haml new file mode 100644 index 0000000..4352f24 --- /dev/null +++ b/app/views/voicemail_settings/_edit_form_core.html.haml @@ -0,0 +1,2 @@ +.inputs + = f.input :value, :label => t("voicemail_settings.settings.#{@voicemail_setting.name.to_s}"), :hint => @voicemail_setting.description, :as => @input_type, input_html: @input_html diff --git a/app/views/voicemail_settings/edit.html.haml b/app/views/voicemail_settings/edit.html.haml index cb9924b..cfda363 100644 --- a/app/views/voicemail_settings/edit.html.haml +++ b/app/views/voicemail_settings/edit.html.haml @@ -1,3 +1,3 @@ - content_for :title, t("voicemail_settings.edit.page_title") -= render "form" \ No newline at end of file += render "edit_form" \ No newline at end of file -- cgit v1.2.3 From f9012f9ffa7eb074cf5c7db74a372437017e2ddd Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 25 Apr 2013 12:14:26 +0200 Subject: voicemail_settings view fixed --- app/views/voicemail_settings/show.html.haml | 3 --- 1 file changed, 3 deletions(-) (limited to 'app') diff --git a/app/views/voicemail_settings/show.html.haml b/app/views/voicemail_settings/show.html.haml index f1a3e61..277874e 100644 --- a/app/views/voicemail_settings/show.html.haml +++ b/app/views/voicemail_settings/show.html.haml @@ -1,8 +1,5 @@ - content_for :title, t("voicemail_settings.show.page_title") -%p - %strong= t('voicemail_settings.show.voicemail_id') + ":" - = @voicemail_setting.voicemail %p %strong= t('voicemail_settings.show.name') + ":" = @voicemail_setting.name -- cgit v1.2.3 From 15664d01ab69da8e7478dfd45cf52ef709349428 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 25 Apr 2013 14:00:41 +0200 Subject: defailt voicemail settings --- app/controllers/voicemail_accounts_controller.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app') diff --git a/app/controllers/voicemail_accounts_controller.rb b/app/controllers/voicemail_accounts_controller.rb index 7e00131..0bfa160 100644 --- a/app/controllers/voicemail_accounts_controller.rb +++ b/app/controllers/voicemail_accounts_controller.rb @@ -31,6 +31,15 @@ class VoicemailAccountsController < ApplicationController def create @voicemail_account = @parent.voicemail_accounts.new(params[:voicemail_account]) if @voicemail_account.save + if @parent.class == User + @email = @parent.email + end + @voicemail_account.voicemail_settings.create(:name => 'pin', :value => ("%06d" % SecureRandom.random_number(999999)), :class_type => 'String') + @voicemail_account.voicemail_settings.create(:name => 'notify', :value => 'true', :class_type => 'Boolean') + @voicemail_account.voicemail_settings.create(:name => 'attachment', :value => 'true', :class_type => 'Boolean') + @voicemail_account.voicemail_settings.create(:name => 'mark_read', :value => 'true', :class_type => 'Boolean') + @voicemail_account.voicemail_settings.create(:name => 'purge', :value => 'false', :class_type => 'Boolean') + @voicemail_account.voicemail_settings.create(:name => 'email', :value => @email, :class_type => 'String') m = method( :"#{@parent.class.name.underscore}_voicemail_accounts_url" ) redirect_to m.( @parent ), :notice => t('voicemail_accounts.controller.successfuly_created') else @@ -65,4 +74,5 @@ class VoicemailAccountsController < ApplicationController authorize! :read, @parent end + end -- cgit v1.2.3 From 2c594b0f62798d077d7d55b60ca9871f9b56a07a Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 26 Apr 2013 10:03:43 +0200 Subject: respond to file format --- app/controllers/generic_files_controller.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/controllers/generic_files_controller.rb b/app/controllers/generic_files_controller.rb index b7dc453..b3c0390 100644 --- a/app/controllers/generic_files_controller.rb +++ b/app/controllers/generic_files_controller.rb @@ -17,7 +17,15 @@ class GenericFilesController < ApplicationController end def show - + respond_to do |format| + format.html + format.xml {render :xml => @generic_file} + format.all { + if request.format == @generic_file.file_type + send_file @generic_file.file.path, :type => @generic_file.file_type, :filename => "#{@generic_file.name}.#{request.parameters[:format].to_s}" + end + } + end end def new -- cgit v1.2.3 From 2cab3ca685d41c14c31f80bba4484531acd1cf36 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 26 Apr 2013 10:30:20 +0200 Subject: file_extension --- app/models/generic_file.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'app') diff --git a/app/models/generic_file.rb b/app/models/generic_file.rb index 04c06df..24680af 100644 --- a/app/models/generic_file.rb +++ b/app/models/generic_file.rb @@ -42,6 +42,13 @@ class GenericFile < ActiveRecord::Base end end + def file_extension + mime_type = Mime::LOOKUP[self.file_type] + if mime_type.class == Mime::Type + return mime_type.symbol + end + end + private def determine_file_type if self.file_changed? -- cgit v1.2.3 From f80fb1082eaf083557acd1fa92da4d2ffbfe1de9 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 26 Apr 2013 10:31:08 +0200 Subject: display download link --- app/views/generic_files/_index_core.html.haml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/views/generic_files/_index_core.html.haml b/app/views/generic_files/_index_core.html.haml index 5fa66f7..3e21b30 100644 --- a/app/views/generic_files/_index_core.html.haml +++ b/app/views/generic_files/_index_core.html.haml @@ -9,6 +9,10 @@ %td= generic_file.category %td= generic_file.name %td= generic_file.file_type - + %td + %p + %a{:href => method( :"#{@parent.class.name.underscore}_generic_file_path" ).(@parent, generic_file, :format => generic_file.file_extension), :method => :get} + %i{:class => 'icon-download'} + = t("generic_files.index.actions.download") - =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => generic_file.owner, :child => generic_file} \ No newline at end of file + =render :partial => 'shared/index_view_edit_destroy_part', :locals => {:parent => generic_file.owner, :child => generic_file} -- cgit v1.2.3 From 025c5730f7bc746687730044909652950ffb9b95 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 26 Apr 2013 10:31:45 +0200 Subject: display download link --- app/views/generic_files/show.html.haml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/views/generic_files/show.html.haml b/app/views/generic_files/show.html.haml index b375dfc..9405444 100644 --- a/app/views/generic_files/show.html.haml +++ b/app/views/generic_files/show.html.haml @@ -16,5 +16,10 @@ %strong= t('generic_files.show.file_size') + ":" = number_to_human_size(@generic_file.file_size) +%p + %i{:class => 'icon-download'} + %strong= t('generic_files.index.actions.download') + ":" + %a{:href => method( :"#{@parent.class.name.underscore}_generic_file_path" ).(@parent, @generic_file, :format => @generic_file.file_extension), :method => :get} + = "#{@generic_file.name}.#{@generic_file.file_extension}" -= render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @parent, :child => @generic_file } \ No newline at end of file += render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @parent, :child => @generic_file } -- cgit v1.2.3 From fc95124eb0eb628ddf3250b4ca4ce8a07e7deeda Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 26 Apr 2013 10:44:51 +0200 Subject: to_s method added --- app/models/generic_file.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app') diff --git a/app/models/generic_file.rb b/app/models/generic_file.rb index 24680af..0e4dce5 100644 --- a/app/models/generic_file.rb +++ b/app/models/generic_file.rb @@ -17,6 +17,10 @@ class GenericFile < ActiveRecord::Base before_save :determine_file_type + def to_s + self.name + end + def store_dir "/var/opt/gemeinschaft/generic_files/#{self.id.to_i}" end -- cgit v1.2.3 From 5129d7701de57224030468ef547859f7b651a6cd Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 26 Apr 2013 10:45:18 +0200 Subject: parent fixed --- app/views/generic_files/_index_core.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/views/generic_files/_index_core.html.haml b/app/views/generic_files/_index_core.html.haml index 3e21b30..b8ed1f6 100644 --- a/app/views/generic_files/_index_core.html.haml +++ b/app/views/generic_files/_index_core.html.haml @@ -11,7 +11,7 @@ %td= generic_file.file_type %td %p - %a{:href => method( :"#{@parent.class.name.underscore}_generic_file_path" ).(@parent, generic_file, :format => generic_file.file_extension), :method => :get} + %a{:href => method( :"#{generic_file.owner.class.name.underscore}_generic_file_path" ).(generic_file.owner, generic_file, :format => generic_file.file_extension), :method => :get} %i{:class => 'icon-download'} = t("generic_files.index.actions.download") -- cgit v1.2.3 From 02818937b8f7de0ae2417337c30771827d7c1c9e Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 26 Apr 2013 10:45:45 +0200 Subject: breadcrumbs added --- app/controllers/generic_files_controller.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'app') diff --git a/app/controllers/generic_files_controller.rb b/app/controllers/generic_files_controller.rb index b3c0390..ddedbe5 100644 --- a/app/controllers/generic_files_controller.rb +++ b/app/controllers/generic_files_controller.rb @@ -11,6 +11,7 @@ class GenericFilesController < ApplicationController load_and_authorize_resource :generic_file, :through => [:sip_account, :conference, :hunt_group, :automatic_call_distributor, :user, :tenant] before_filter :set_and_authorize_parent + before_filter :spread_breadcrumbs def index @generic_files = @parent.generic_files @@ -69,4 +70,18 @@ class GenericFilesController < ApplicationController authorize! :read, @parent end + + def spread_breadcrumbs + if @parent.class == User + add_breadcrumb t("users.index.page_title"), tenant_users_path(@parent.current_tenant) + add_breadcrumb @parent, tenant_user_path(@parent.current_tenant, @parent) + end + + add_breadcrumb t("generic_files.index.page_title"), method( :"#{@parent.class.name.underscore}_generic_files_url" ).(@parent) + + if @generic_file + add_breadcrumb @generic_file + end + + end end -- cgit v1.2.3 From e1177a1d6ae27d3c23e3723fdea05c6ac2893294 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 26 Apr 2013 10:49:12 +0200 Subject: table headers --- app/views/generic_files/_index_core.html.haml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app') diff --git a/app/views/generic_files/_index_core.html.haml b/app/views/generic_files/_index_core.html.haml index b8ed1f6..2cea8a1 100644 --- a/app/views/generic_files/_index_core.html.haml +++ b/app/views/generic_files/_index_core.html.haml @@ -3,6 +3,8 @@ %th= t('generic_files.index.category') %th= t('generic_files.index.name') %th= t('generic_files.index.file_type') + %th + %th - for generic_file in generic_files %tr -- cgit v1.2.3 From 433883b08761d5d89c491e0c454812c618ba2b01 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 26 Apr 2013 12:13:22 +0200 Subject: no breadcrumbs on empty name --- app/controllers/generic_files_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/controllers/generic_files_controller.rb b/app/controllers/generic_files_controller.rb index ddedbe5..69e00e1 100644 --- a/app/controllers/generic_files_controller.rb +++ b/app/controllers/generic_files_controller.rb @@ -79,7 +79,7 @@ class GenericFilesController < ApplicationController add_breadcrumb t("generic_files.index.page_title"), method( :"#{@parent.class.name.underscore}_generic_files_url" ).(@parent) - if @generic_file + if !@generic_file.to_s.blank? add_breadcrumb @generic_file end -- cgit v1.2.3 From 9784b4e513cb23fa9d6b169270d83a673fd5c644 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 26 Apr 2013 12:13:46 +0200 Subject: VoicemailSetting abilities --- app/models/ability.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/ability.rb b/app/models/ability.rb index 2725572..8718dc4 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -183,7 +183,7 @@ class Ability # can :read, VoicemailAccount can :manage, VoicemailMessage - can :manage, VoicemailSetting + can [:read, :edit, :update], VoicemailSetting can :manage, GenericFile, :owner_type => 'User', :owner_id => user.id -- cgit v1.2.3 From 24e872cdd9be4f5f3397a93bad3ef2c21e3fd419 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 26 Apr 2013 12:14:18 +0200 Subject: uuid removed --- app/views/voicemail_accounts/show.html.haml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'app') diff --git a/app/views/voicemail_accounts/show.html.haml b/app/views/voicemail_accounts/show.html.haml index 06b4d1a..8c75c93 100644 --- a/app/views/voicemail_accounts/show.html.haml +++ b/app/views/voicemail_accounts/show.html.haml @@ -1,8 +1,5 @@ - content_for :title, t("voicemail_accounts.show.page_title") -%p - %strong= t('voicemail_accounts.show.uuid') + ":" - = @voicemail_account.uuid %p %strong= t('voicemail_accounts.show.name') + ":" = @voicemail_account.name @@ -16,4 +13,4 @@ - if @voicemail_account.voicemail_settings.any? = render "voicemail_settings/index_core", :voicemail_settings => @voicemail_account.voicemail_settings %br -= render :partial => 'shared/create_link', :locals => { :parent => @voicemail_account, :child_class => VoicemailSetting } \ No newline at end of file += render :partial => 'shared/create_link', :locals => { :parent => @voicemail_account, :child_class => VoicemailSetting } -- cgit v1.2.3 From af24d971e2cd913ad6ad3bcf58e47469090b1eda Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 26 Apr 2013 12:14:39 +0200 Subject: breadcrumbs added --- app/controllers/voicemail_accounts_controller.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'app') diff --git a/app/controllers/voicemail_accounts_controller.rb b/app/controllers/voicemail_accounts_controller.rb index 0bfa160..2e96cb7 100644 --- a/app/controllers/voicemail_accounts_controller.rb +++ b/app/controllers/voicemail_accounts_controller.rb @@ -10,6 +10,7 @@ class VoicemailAccountsController < ApplicationController load_and_authorize_resource :phone_number, :through => [:sip_account, :conference, :hunt_group, :automatic_call_distributor, :user, :tenant] before_filter :set_and_authorize_parent + before_filter :spread_breadcrumbs def index @voicemail_accounts = @parent.voicemail_accounts @@ -75,4 +76,17 @@ class VoicemailAccountsController < ApplicationController authorize! :read, @parent end + def spread_breadcrumbs + if @parent.class == User + add_breadcrumb t("users.index.page_title"), tenant_users_path(@parent.current_tenant) + add_breadcrumb @parent, tenant_user_path(@parent.current_tenant, @parent) + end + + add_breadcrumb t("voicemail_accounts.index.page_title"), method( :"#{@parent.class.name.underscore}_voicemail_accounts_url" ).(@parent) + + if !@voicemail_account.to_s.blank? + add_breadcrumb @voicemail_account.name + end + end + end -- cgit v1.2.3 From a94fafb695e19715505e05ab71034b14d7bde8c1 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 26 Apr 2013 12:14:55 +0200 Subject: breadcrumbs added --- app/controllers/voicemail_settings_controller.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'app') diff --git a/app/controllers/voicemail_settings_controller.rb b/app/controllers/voicemail_settings_controller.rb index 8a7c411..f270c3d 100644 --- a/app/controllers/voicemail_settings_controller.rb +++ b/app/controllers/voicemail_settings_controller.rb @@ -2,6 +2,8 @@ class VoicemailSettingsController < ApplicationController load_and_authorize_resource :voicemail_account load_and_authorize_resource :voicemail_setting, :through => [:voicemail_account] + before_filter :spread_breadcrumbs + def index @voicemail_settings = @voicemail_account.voicemail_settings end @@ -60,4 +62,21 @@ class VoicemailSettingsController < ApplicationController m = method( :"#{@voicemail_account.voicemail_accountable.class.name.underscore}_voicemail_account_path" ) redirect_to m.( @voicemail_account.voicemail_accountable, @voicemail_account ), :notice => t('voicemail_settings.controller.successfuly_destroyed') end + + private + def spread_breadcrumbs + voicemail_accountable = @voicemail_account.voicemail_accountable + if voicemail_accountable.class == User + add_breadcrumb t("users.index.page_title"), tenant_users_path(voicemail_accountable.current_tenant) + add_breadcrumb voicemail_accountable, tenant_user_path(voicemail_accountable.current_tenant, voicemail_accountable) + end + + add_breadcrumb t("voicemail_accounts.index.page_title"), method( :"#{voicemail_accountable.class.name.underscore}_voicemail_accounts_url" ).(voicemail_accountable) + add_breadcrumb @voicemail_account.name, method( :"#{voicemail_accountable.class.name.underscore}_voicemail_account_path" ).(voicemail_accountable, @voicemail_account) + add_breadcrumb t("voicemail_settings.index.page_title"), voicemail_account_voicemail_settings_url(@voicemail_account) + + if !@voicemail_setting.to_s.blank? + add_breadcrumb @voicemail_setting + end + end end -- cgit v1.2.3 From eea29ec6d3e9658e9f9424e4d1e4f278f438630a Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 26 Apr 2013 12:25:20 +0200 Subject: breadcrumbs --- app/controllers/gateway_settings_controller.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'app') diff --git a/app/controllers/gateway_settings_controller.rb b/app/controllers/gateway_settings_controller.rb index 0304411..0fecdaf 100644 --- a/app/controllers/gateway_settings_controller.rb +++ b/app/controllers/gateway_settings_controller.rb @@ -2,6 +2,8 @@ class GatewaySettingsController < ApplicationController load_and_authorize_resource :gateway load_and_authorize_resource :gateway_setting, :through => [:gateway] + before_filter :spread_breadcrumbs + def index @gateway_settings = @gateway.gateway_settings end @@ -41,4 +43,15 @@ class GatewaySettingsController < ApplicationController @gateway_setting.destroy redirect_to gateway_path(@gateway), :notice => t('gateway_settings.controller.successfuly_destroyed') end + + private + def spread_breadcrumbs + add_breadcrumb t("gateways.index.page_title"), gateways_path + add_breadcrumb @gateway, @gateway + add_breadcrumb t("gateway_settings.index.page_title"), gateway_gateway_settings_url(@gateway) + + if @gateway_setting && !@gateway_setting.new_record? + add_breadcrumb @gateway_setting + end + end end -- cgit v1.2.3 From 0c545798470f64923db9b37b8abac96684c739eb Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 26 Apr 2013 12:25:27 +0200 Subject: breadcrumbs --- app/controllers/gateway_parameters_controller.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'app') diff --git a/app/controllers/gateway_parameters_controller.rb b/app/controllers/gateway_parameters_controller.rb index d5ade9e..693a484 100644 --- a/app/controllers/gateway_parameters_controller.rb +++ b/app/controllers/gateway_parameters_controller.rb @@ -2,6 +2,8 @@ class GatewayParametersController < ApplicationController load_and_authorize_resource :gateway load_and_authorize_resource :gateway_parameter, :through => [:gateway] + before_filter :spread_breadcrumbs + def index @gateway_parameters = @gateway.gateway_parameters end @@ -41,4 +43,15 @@ class GatewayParametersController < ApplicationController @gateway_parameter.destroy redirect_to gateway_path(@gateway), :notice => t('gateway_parameters.controller.successfuly_destroyed') end + + private + def spread_breadcrumbs + add_breadcrumb t("gateways.index.page_title"), gateways_path + add_breadcrumb @gateway, @gateway + add_breadcrumb t("gateway_parameters.index.page_title"), gateway_gateway_parameters_url(@gateway) + + if @gateway_parameter && !@gateway_parameter.new_record? + add_breadcrumb @gateway_parameter + end + end end -- cgit v1.2.3 From 3d04f33c0281ef62f6868c58565bd8220c94de99 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 26 Apr 2013 12:46:02 +0200 Subject: _id removed --- app/views/gateway_parameters/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/views/gateway_parameters/show.html.haml b/app/views/gateway_parameters/show.html.haml index 9bdad76..8314b3c 100644 --- a/app/views/gateway_parameters/show.html.haml +++ b/app/views/gateway_parameters/show.html.haml @@ -1,7 +1,7 @@ - content_for :title, t("gateway_parameters.show.page_title") %p - %strong= t('gateway_parameters.show.gateway_id') + ":" + %strong= t('gateway_parameters.show.gateway') + ":" = @gateway_parameter.gateway %p %strong= t('gateway_parameters.show.name') + ":" -- cgit v1.2.3 From d5a9128e4d9d95691214064a6d6960b251623c9e Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 26 Apr 2013 12:46:11 +0200 Subject: _id removed --- app/views/gateway_settings/show.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/views/gateway_settings/show.html.haml b/app/views/gateway_settings/show.html.haml index 019aec4..9880d01 100644 --- a/app/views/gateway_settings/show.html.haml +++ b/app/views/gateway_settings/show.html.haml @@ -1,7 +1,7 @@ - content_for :title, t("gateway_settings.show.page_title") %p - %strong= t('gateway_settings.show.gateway_id') + ":" + %strong= t('gateway_settings.show.gateway') + ":" = @gateway_setting.gateway %p %strong= t('gateway_settings.show.name') + ":" -- cgit v1.2.3 From a5cedf9149f4444f0d53b777fc31f3db00ccc206 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 26 Apr 2013 12:46:26 +0200 Subject: _id removed --- app/views/group_permissions/show.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/views/group_permissions/show.html.haml b/app/views/group_permissions/show.html.haml index 402c5ce..8fe4c2b 100644 --- a/app/views/group_permissions/show.html.haml +++ b/app/views/group_permissions/show.html.haml @@ -4,7 +4,7 @@ %strong= t('group_permissions.show.permission') + ":" = @group_permission.permission %p - %strong= t('group_permissions.show.target_group_id') + ":" - = @group_permission.target_group_id + %strong= t('group_permissions.show.target_group') + ":" + = @group_permission.target_group = render :partial => 'shared/show_edit_destroy_part', :locals => { :parent => @group, :child => @group_permission } -- cgit v1.2.3 From 2e3f13b5519f6764bbad4bb16232d1dc22be7551 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 29 Apr 2013 13:39:40 +0200 Subject: padination added to navigation view --- app/views/call_histories/_navigation.html.haml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'app') diff --git a/app/views/call_histories/_navigation.html.haml b/app/views/call_histories/_navigation.html.haml index d72ad64..2218c50 100644 --- a/app/views/call_histories/_navigation.html.haml +++ b/app/views/call_histories/_navigation.html.haml @@ -1,14 +1,14 @@ %ul{:class => 'nav nav-pills'} - %li + %li{:class => (type.blank? ? :active : nil )} %a{ :href => "?type=" }= t("call_histories.index.navigation.all", :calls => @calls_count) - %li + %li{:class => (type == 'missed' ? :active : nil )} %a{ :href => "?type=missed" }= t("call_histories.index.navigation.missed", :calls => @calls_missed_count) - %li + %li{:class => (type == 'received' ? :active : nil )} %a{ :href => "?type=received" }= t("call_histories.index.navigation.received", :calls => @calls_received_count) - %li + %li{:class => (type == 'dialed' ? :active : nil )} %a{ :href => "?type=dialed" }= t("call_histories.index.navigation.dialed", :calls => @calls_dialed_count) - %li + %li{:class => (type == 'forwarded' ? :active : nil )} %a{ :href => "?type=forwarded" }= t("call_histories.index.navigation.forwarded", :calls => @calls_forwarded_count) -/ .pagination -/ = will_paginate @call_histories +.pagination + = will_paginate call_histories, :renderer => BootstrapPagination::Rails -- cgit v1.2.3 From 07e0df9203bbeae4b289add2c8b80de20a725637 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 29 Apr 2013 13:40:53 +0200 Subject: sortable helper method added --- app/helpers/application_helper.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de4d677..9334f7d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -19,4 +19,9 @@ module ApplicationHelper end end + def sortable(column, title) + link_class = (column.to_s == sort_column.to_s) ? "sort_descending #{sort_descending}" : nil + link_to title, {:sort => column, :desc => !!(!sort_descending && column), :type => @type}, {:class => link_class} + end + end -- cgit v1.2.3 From 0f0314eb0e38fc8a50530abab6aca67918ab240c Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 29 Apr 2013 13:41:55 +0200 Subject: pagination added --- app/controllers/call_histories_controller.rb | 33 ++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'app') diff --git a/app/controllers/call_histories_controller.rb b/app/controllers/call_histories_controller.rb index 2bfd4e3..a4d0c21 100644 --- a/app/controllers/call_histories_controller.rb +++ b/app/controllers/call_histories_controller.rb @@ -1,5 +1,8 @@ class CallHistoriesController < ApplicationController - + MAX_CALL_HISTORY_ENTRIES = 10000; + + helper_method :sort_column, :sort_descending + load_resource :sip_account before_filter :set_and_authorize_parent @@ -18,12 +21,7 @@ class CallHistoriesController < ApplicationController def index hunt_group_member_ids = PhoneNumber.where(:phone_numberable_type => 'HuntGroupMember', :number => @sip_account.phone_numbers.map {|a| a.number}).map {|a| a.phone_numberable_id} hunt_group_ids = HuntGroupMember.where(:id => hunt_group_member_ids, :active => true).map {|a| a.hunt_group_id} - calls = CallHistory.where('(call_historyable_type = "SipAccount" AND call_historyable_id = ?) OR (call_historyable_type = "HuntGroup" AND call_historyable_id IN (?))', @sip_account.id, hunt_group_ids).order('start_stamp DESC') - - @call_histories = calls.paginate( - :page => @pagination_page_number, - :per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE') - ) + calls = CallHistory.where('(call_historyable_type = "SipAccount" AND call_historyable_id = ?) OR (call_historyable_type = "HuntGroup" AND call_historyable_id IN (?))', @sip_account.id, hunt_group_ids).order(sort_column + ' ' + (sort_descending ? 'DESC' : 'ASC')) @calls_count = calls.count @calls_received_count = calls.where(:entry_type => 'received').count @@ -32,10 +30,15 @@ class CallHistoriesController < ApplicationController @calls_forwarded_count = calls.where(:entry_type => 'forwarded').count if ! @type.blank? - @call_histories = @call_histories.where(:entry_type => @type) + @call_histories = calls.where(:entry_type => @type).limit(MAX_CALL_HISTORY_ENTRIES) + else + @call_histories = calls.limit(MAX_CALL_HISTORY_ENTRIES) end - @call_histories = @call_histories.order(:created_at).reverse_order.limit(1000) + @call_histories = @call_histories.paginate( + :page => @pagination_page_number, + :per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE') + ) end @@ -102,4 +105,16 @@ class CallHistoriesController < ApplicationController end end + def sort_descending + if sort_column == 'start_stamp' && params[:desc].to_s.blank? + return true + end + + params[:desc].to_s == 'true' + end + + def sort_column + CallHistory.column_names.include?(params[:sort]) ? params[:sort] : 'start_stamp' + end + end -- cgit v1.2.3 From 4cb4a33bb831439f3a6060bcabc4590a61fae27b Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 29 Apr 2013 13:43:00 +0200 Subject: call histories index --- app/views/call_histories/_index_core.html.haml | 143 +++++++++++-------------- 1 file changed, 61 insertions(+), 82 deletions(-) (limited to 'app') diff --git a/app/views/call_histories/_index_core.html.haml b/app/views/call_histories/_index_core.html.haml index 2faa220..bc10cde 100644 --- a/app/views/call_histories/_index_core.html.haml +++ b/app/views/call_histories/_index_core.html.haml @@ -1,85 +1,64 @@ -= render :partial => "call_histories/navigation" -%table.table.table-striped - %thead - %tr - %th - Datum - %th - Uhrzeit - %th - Misc - %th - Avatar - %th - Teilnehmer - %th - Status += render :partial => "call_histories/navigation", :locals => {:call_histories => call_histories, :type => @type} - %tbody - - for call_history in call_histories - - if !call_history.display_number.blank? - - phone_book_entry = call_history.phone_book_entry_by_number(call_history.display_number) - %tr{:id => "call_history_id_#{call_history.id}_tr", :class => (call_history.duration.blank? ? 'warning' : '')} - %td - = l call_history.start_stamp, :format => :short - %td - = l call_history.start_stamp, :format => :short - %td - - if call_history.voicemail_message? - .voicemail-message - %a{:href => voicemail_account_voicemail_messages_path(@sip_account.voicemail_account, :anchor => "message_#{call_history.voicemail_message.id}")} - = image_tag('icons/gs_envelope_16x.png') - = call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format")) += form_tag(destroy_multiple_sip_account_call_histories_path(@sip_account), :method => :delete, :id => 'call_hostory_form') do + %table.table.table-striped + %thead + %tr + %th{:width => '10px'} + %th + =sortable :start_stamp, t("call_histories.index.date") + %th{:width => '10px'} + %th + =sortable :caller_id_name, t("call_histories.index.called_party") + %th + =sortable :duration, t("call_histories.index.duration") + %th + =sortable :result, t("call_histories.index.status") + %th - - else - - case call_history.entry_type - - when 'forwarded' - .call-forwarded= call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format")) - - if call_history.callee_account_type.to_s.downcase == 'voicemail' - = t("call_histories.index.voicemail") - - else - = call_history.destination_number - - when 'dialed' - .call-placed= call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format")) - - when 'received' - .call-received= call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format")) - - when 'missed' - .call-missed= call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format")) - - else - .call-unknown - = t("call_histories.index.#{call_history.entry_type}") - = call_history.display_call_date(t("call_histories.index.date_format"), t("call_histories.index.date_today_format")) - - - if call_history.forwarding_service && call_history.entry_type != 'forwarded' - = t("call_histories.index.forwarded_by") - = call_history.display_auth_account_name - %td - - image = call_history.display_image(:small, phone_book_entry) - - if image - %ul.thumbnails - %li.span1 - %div.thumbnail - %a.thumbnail{:href => call_history.display_image(:profile, phone_book_entry)} - =image_tag(image, :alt => phone_book_entry.to_s, :class => 'img-rounded') - %td - - display_name = call_history.display_name - - if display_name.blank? - - display_name = phone_book_entry.to_s - - if phone_book_entry - %a.name{:href => phone_book_phone_book_entry_path(phone_book_entry.phone_book, phone_book_entry), :itemprop => "name"}= display_name - - else - .name= display_name - .phone= call_history.display_number - %td - - if call_history.display_duration - = call_history.display_duration - - else - = t("call_histories.call_results.#{call_history.result}") - %td - - if @sip_account.registration && can?(:call, call_history) - = link_to raw(" ") + t('call_histories.index.actions.call'), call_sip_account_call_history_path(@sip_account, call_history), :method => :put, :class => 'btn btn-mini' - %td - - if can? :destroy, call_history - = link_to raw(" ") + t('call_histories.index.actions.destroy'), [@sip_account, call_history], :method => :delete, :remote => true, :class => 'btn btn-mini btn-danger' - \ No newline at end of file + %tbody + - for call_history in call_histories + - if !call_history.display_number.blank? + - phone_book_entry = call_history.phone_book_entry_by_number(call_history.display_number) + %tr{:id => "call_history_id_#{call_history.id}_tr", :class => (call_history.duration.blank? ? 'warning' : '')} + %td.select_box= check_box_tag("selected_ids[]", call_history.id, false, :uuid => "select_item_#{call_history.id}", :class => 'select_item') + %td + -if call_history.entry_type == 'dialed' + %i{:class => 'icon-arrow-left'} + -elsif call_history.entry_type == 'missed' + %i{:class => 'icon-time'} + -elsif call_history.entry_type == 'forwarded' + %i{:class => 'icon-random'} + - else + %i{:class => 'icon-arrow-right'} + = l call_history.start_stamp, :format => :short + %br= t("call_histories.index.missed.#{call_history.entry_type}") + %td + - image = call_history.display_image(:mini, phone_book_entry) + - if image + %ul.thumbnails + =image_tag(image, :alt => phone_book_entry.to_s, :class => 'img-rounded') + %td + - display_name = call_history.display_name + - if display_name.blank? + - display_name = phone_book_entry.to_s + - if phone_book_entry + %a.name{:href => phone_book_phone_book_entry_path(phone_book_entry.phone_book, phone_book_entry), :itemprop => "name"}= display_name + - else + .name= display_name + .phone= call_history.display_number + %td + - if call_history.display_duration + = call_history.display_duration + %td + - if t("call_histories.call_results.#{call_history.result}").include?('translation missing') + = call_history.result.gsub('_', ' ').titleize + - else + = t("call_histories.call_results.#{call_history.result}") + %td + - if @sip_account.registration && can?(:call, call_history) + = link_to raw(" ") + t('call_histories.index.actions.call'), call_sip_account_call_history_path(@sip_account, call_history), :method => :put, :class => 'btn btn-mini' + %td + - if can? :destroy, call_history + = link_to raw(" ") + t('call_histories.index.actions.destroy'), [@sip_account, call_history], :method => :delete, :remote => true, :class => 'btn btn-mini btn-danger' -- cgit v1.2.3 From 1cc85875f35b69c31b25b7d426439f38e6936893 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 29 Apr 2013 14:54:26 +0200 Subject: display sounrce/destination number --- app/views/call_histories/_index_core.html.haml | 33 +++++++++++++++++++------- 1 file changed, 24 insertions(+), 9 deletions(-) (limited to 'app') diff --git a/app/views/call_histories/_index_core.html.haml b/app/views/call_histories/_index_core.html.haml index bc10cde..0cbcd60 100644 --- a/app/views/call_histories/_index_core.html.haml +++ b/app/views/call_histories/_index_core.html.haml @@ -24,16 +24,30 @@ %tr{:id => "call_history_id_#{call_history.id}_tr", :class => (call_history.duration.blank? ? 'warning' : '')} %td.select_box= check_box_tag("selected_ids[]", call_history.id, false, :uuid => "select_item_#{call_history.id}", :class => 'select_item') %td - -if call_history.entry_type == 'dialed' - %i{:class => 'icon-arrow-left'} - -elsif call_history.entry_type == 'missed' - %i{:class => 'icon-time'} - -elsif call_history.entry_type == 'forwarded' - %i{:class => 'icon-random'} - - else - %i{:class => 'icon-arrow-right'} = l call_history.start_stamp, :format => :short - %br= t("call_histories.index.missed.#{call_history.entry_type}") + %br + -if call_history.entry_type == 'dialed' + %i{:class => 'icon-arrow-left'} + -elsif call_history.entry_type == 'missed' + %i{:class => 'icon-time'} + -elsif call_history.entry_type == 'forwarded' + - if call_history.callee_account_type.to_s.downcase == 'voicemailaccount' + %i{:class => 'icon-envelope'} + - else + %i{:class => 'icon-random'} + - else + %i{:class => 'icon-arrow-right'} + + - if call_history.entry_type == 'forwarded' + - if call_history.callee_account_type.to_s.downcase == 'phonenumber' + = call_history.destination_number + - if call_history.callee_account_type.to_s.downcase == 'voicemailaccount' + = VoicemailAccount.where(:id => call_history.callee_account_id).first.to_s + - elsif call_history.entry_type == 'dialed' + = call_history.caller_id_number + - else + = call_history.destination_number + %td - image = call_history.display_image(:mini, phone_book_entry) - if image @@ -56,6 +70,7 @@ = call_history.result.gsub('_', ' ').titleize - else = t("call_histories.call_results.#{call_history.result}") + /= call_history.inspect %td - if @sip_account.registration && can?(:call, call_history) = link_to raw(" ") + t('call_histories.index.actions.call'), call_sip_account_call_history_path(@sip_account, call_history), :method => :put, :class => 'btn btn-mini' -- cgit v1.2.3 From 9d9bf18ab11aa67e967b09f774af5c651f6064ce Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 29 Apr 2013 15:11:02 +0200 Subject: pagination and sorting added --- app/controllers/users_controller.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'app') diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ea8ed69..99e2fc5 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -5,8 +5,14 @@ class UsersController < ApplicationController before_filter :set_and_authorize_parent before_filter :spread_breadcrumbs + + helper_method :sort_column, :sort_descending def index + @users = User.order(sort_column + ' ' + (sort_descending ? 'DESC' : 'ASC')).paginate( + :page => @pagination_page_number, + :per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE') + ) end def show @@ -88,4 +94,12 @@ class UsersController < ApplicationController end end + def sort_descending + params[:desc].to_s == 'true' + end + + def sort_column + User.column_names.include?(params[:sort]) ? params[:sort] : 'id' + end + end -- cgit v1.2.3 From 165d746547658d63ad80ed6a7c781629c29be5ea Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 29 Apr 2013 15:11:16 +0200 Subject: pagination and sorting added --- app/views/users/_index_core.html.haml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/views/users/_index_core.html.haml b/app/views/users/_index_core.html.haml index 9d63afc..c994997 100644 --- a/app/views/users/_index_core.html.haml +++ b/app/views/users/_index_core.html.haml @@ -1,16 +1,18 @@ - cache(['user_table_row_inner_td', I18n.locale, current_user, users.reorder(:updated_at).last, users.count, GsParameter.get('NUMBER_OF_SHOWN_ITEMS')]) do + .pagination + = will_paginate users, :renderer => BootstrapPagination::Rails %table.table.table-striped %thead %tr %th - %th= t('users.index.user_name') + %th= sortable :user_name, t('users.index.user_name') %th %span.hidden-phone - = t('users.index.email') + = sortable :email, t('users.index.email') %th %span.hidden-phone - = t('users.index.first_name') - %th= t('users.index.last_name') + = sortable :first_name, t('users.index.first_name') + %th= sortable :last_name, t('users.index.last_name') %tbody - for user in users -- cgit v1.2.3 From d181daa525a730cc46c942845e5e2168858b7ef3 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 29 Apr 2013 15:11:47 +0200 Subject: sort_descending fixed --- app/helpers/application_helper.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9334f7d..b74fa27 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -21,7 +21,8 @@ module ApplicationHelper def sortable(column, title) link_class = (column.to_s == sort_column.to_s) ? "sort_descending #{sort_descending}" : nil - link_to title, {:sort => column, :desc => !!(!sort_descending && column), :type => @type}, {:class => link_class} + desc = (column.to_s == sort_column.to_s) ? !!(!sort_descending && column) : nil + link_to title, {:sort => column, :desc => desc, :type => @type}, {:class => link_class} end end -- cgit v1.2.3 From 0317faf79380e706b72290939c6a0d46644b0ffe Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 29 Apr 2013 15:24:17 +0200 Subject: return title if sort_descending is not defined --- app/helpers/application_helper.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'app') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b74fa27..7171fbb 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -20,6 +20,9 @@ module ApplicationHelper end def sortable(column, title) + if !defined?(sort_descending) + return title + end link_class = (column.to_s == sort_column.to_s) ? "sort_descending #{sort_descending}" : nil desc = (column.to_s == sort_column.to_s) ? !!(!sort_descending && column) : nil link_to title, {:sort => column, :desc => desc, :type => @type}, {:class => link_class} -- cgit v1.2.3 From 92fd1b2e6611aaf0910b9c5a80908e9160559bcc Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 29 Apr 2013 15:25:06 +0200 Subject: omit pagination for embedded views --- app/views/users/_index_core.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/views/users/_index_core.html.haml b/app/views/users/_index_core.html.haml index c994997..d741282 100644 --- a/app/views/users/_index_core.html.haml +++ b/app/views/users/_index_core.html.haml @@ -1,6 +1,7 @@ - cache(['user_table_row_inner_td', I18n.locale, current_user, users.reorder(:updated_at).last, users.count, GsParameter.get('NUMBER_OF_SHOWN_ITEMS')]) do .pagination - = will_paginate users, :renderer => BootstrapPagination::Rails + - if defined?(users.total_pages) + = will_paginate users, :renderer => BootstrapPagination::Rails %table.table.table-striped %thead %tr -- cgit v1.2.3 From f7ecf4866953cbfb0bc2a092b8547192f2943242 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 29 Apr 2013 15:40:13 +0200 Subject: list users of specified parent only --- app/controllers/users_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 99e2fc5..971ce4b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -9,7 +9,7 @@ class UsersController < ApplicationController helper_method :sort_column, :sort_descending def index - @users = User.order(sort_column + ' ' + (sort_descending ? 'DESC' : 'ASC')).paginate( + @users = @parent.users.order(sort_column + ' ' + (sort_descending ? 'DESC' : 'ASC')).paginate( :page => @pagination_page_number, :per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE') ) -- cgit v1.2.3 From 265c6e89e46be414cac6e8a33b35591282cb0ae9 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 29 Apr 2013 15:40:37 +0200 Subject: sorting and paginations --- app/controllers/sip_accounts_controller.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'app') diff --git a/app/controllers/sip_accounts_controller.rb b/app/controllers/sip_accounts_controller.rb index 7bb2689..8e88405 100644 --- a/app/controllers/sip_accounts_controller.rb +++ b/app/controllers/sip_accounts_controller.rb @@ -6,7 +6,13 @@ class SipAccountsController < ApplicationController before_filter :set_and_authorize_parent before_filter :spread_breadcrumbs + helper_method :sort_column, :sort_descending + def index + @sip_accounts = @parent.sip_accounts.order(sort_column + ' ' + (sort_descending ? 'DESC' : 'ASC')).paginate( + :page => @pagination_page_number, + :per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE') + ) end def show @@ -110,4 +116,12 @@ class SipAccountsController < ApplicationController @possible_voicemail_accounts = @possible_voicemail_accounts + @sip_account.sip_accountable.voicemail_accounts end + def sort_descending + params[:desc].to_s == 'true' + end + + def sort_column + SipAccount.column_names.include?(params[:sort]) ? params[:sort] : 'id' + end + end -- cgit v1.2.3 From 905a8d0715018188d952d99af5f4686437b4a779 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Mon, 29 Apr 2013 15:40:44 +0200 Subject: sorting and paginations --- app/views/sip_accounts/_index_core.html.haml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/views/sip_accounts/_index_core.html.haml b/app/views/sip_accounts/_index_core.html.haml index d98ea0a..7f393d7 100644 --- a/app/views/sip_accounts/_index_core.html.haml +++ b/app/views/sip_accounts/_index_core.html.haml @@ -1,10 +1,13 @@ +.pagination + - if defined?(users.total_pages) + = will_paginate users, :renderer => BootstrapPagination::Rails %table.table.table-striped %thead %tr %th %span.hidden-phone = t('sip_accounts.index.online') - %th= t('sip_accounts.index.caller_name') + %th= sortable :caller_name, t('sip_accounts.index.caller_name') %th %span.hidden-phone = t('sip_accounts.index.phone_numbers') -- cgit v1.2.3 From 91a4c93f7e89c44059283b2395d7c7419c6a4c7d Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 30 Apr 2013 08:32:08 +0200 Subject: chevrons added --- app/helpers/application_helper.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7171fbb..2c420c4 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -23,9 +23,18 @@ module ApplicationHelper if !defined?(sort_descending) return title end - link_class = (column.to_s == sort_column.to_s) ? "sort_descending #{sort_descending}" : nil - desc = (column.to_s == sort_column.to_s) ? !!(!sort_descending && column) : nil - link_to title, {:sort => column, :desc => desc, :type => @type}, {:class => link_class} + + if column.to_s == sort_column.to_s + link_class = "sort_descending #{sort_descending}" + desc = !!(!sort_descending && column) + icon = sort_descending ? ' ' : ' ' + else + link_class = nil + desc = nil + icon = '' + end + + link_to raw('') + title + raw(icon), {:sort => column, :desc => desc, :type => @type}, {:class => link_class} end end -- cgit v1.2.3 From 7f50ae3e137a2c14754f79e31e8034c4e2a40cf4 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 30 Apr 2013 10:13:09 +0200 Subject: sorting --- app/controllers/voicemail_messages_controller.rb | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/controllers/voicemail_messages_controller.rb b/app/controllers/voicemail_messages_controller.rb index 239fed4..3c75a64 100644 --- a/app/controllers/voicemail_messages_controller.rb +++ b/app/controllers/voicemail_messages_controller.rb @@ -5,6 +5,8 @@ class VoicemailMessagesController < ApplicationController before_filter :set_and_authorize_parent before_filter :spread_breadcrumbs + + helper_method :sort_column, :sort_descending before_filter { |controller| if ! params[:type].blank? then @@ -22,17 +24,17 @@ class VoicemailMessagesController < ApplicationController @messages_read_count = @messages_count - @messages_unread_count if @type == 'read' - @voicemail_messages = @voicemail_account.voicemail_messages.where('read_epoch > 0').order('created_epoch DESC').paginate( + @voicemail_messages = @voicemail_account.voicemail_messages.where('read_epoch > 0').order(sort_column + ' ' + (sort_descending ? 'DESC' : 'ASC')).paginate( :page => @pagination_page_number, :per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE') ) elsif @type == 'unread' - @voicemail_messages = @voicemail_account.voicemail_messages.where(:read_epoch => 0).order('created_epoch DESC').paginate( + @voicemail_messages = @voicemail_account.voicemail_messages.where(:read_epoch => 0).order(sort_column + ' ' + (sort_descending ? 'DESC' : 'ASC')).paginate( :page => @pagination_page_number, :per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE') ) else - @voicemail_messages = @voicemail_account.voicemail_messages.order('created_epoch DESC').paginate( + @voicemail_messages = @voicemail_account.voicemail_messages.order(sort_column + ' ' + (sort_descending ? 'DESC' : 'ASC')).paginate( :page => @pagination_page_number, :per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE') ) @@ -137,4 +139,16 @@ class VoicemailMessagesController < ApplicationController end end + def sort_descending + if sort_column == 'created_epoch' && params[:desc].to_s.blank? + return true + end + + params[:desc].to_s == 'true' + end + + def sort_column + VoicemailMessage.column_names.include?(params[:sort]) ? params[:sort] : 'created_epoch' + end + end -- cgit v1.2.3 From 2beeef5436da123dac0b3a9020c0ee352c8724c9 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 30 Apr 2013 10:13:42 +0200 Subject: delete multiple items --- app/views/call_histories/_index_core.html.haml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app') diff --git a/app/views/call_histories/_index_core.html.haml b/app/views/call_histories/_index_core.html.haml index 0cbcd60..fd335d4 100644 --- a/app/views/call_histories/_index_core.html.haml +++ b/app/views/call_histories/_index_core.html.haml @@ -6,6 +6,8 @@ %thead %tr %th{:width => '10px'} + = button_tag(:type => 'submit', :class => 'btn btn-mini btn-danger', :confirm => t("call_histories.index.actions.confirm_selected")) do + %i{:class => 'icon-trash icon-white'} %th =sortable :start_stamp, t("call_histories.index.date") %th{:width => '10px'} -- cgit v1.2.3 From 40875583e650747c6ad7f3be22ed5c365c667f36 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 30 Apr 2013 10:14:55 +0200 Subject: voicemail messages index view --- app/views/voicemail_messages/_index_core.html.haml | 87 +++++++++++++--------- app/views/voicemail_messages/_navigation.html.haml | 15 ++-- 2 files changed, 61 insertions(+), 41 deletions(-) (limited to 'app') diff --git a/app/views/voicemail_messages/_index_core.html.haml b/app/views/voicemail_messages/_index_core.html.haml index 7324bd3..fcaefb4 100644 --- a/app/views/voicemail_messages/_index_core.html.haml +++ b/app/views/voicemail_messages/_index_core.html.haml @@ -1,44 +1,63 @@ -= form_tag(destroy_multiple_voicemail_account_voicemail_messages_path(@voicemail_account), :method => :delete, :id => 'voicemail_message_form') do - %header.entries-nav= render :partial => "voicemail_messages/navigation" - .content - %table.table.table-striped - + += render :partial => "voicemail_messages/navigation", :locals => {:type => @type} + += form_tag(destroy_multiple_voicemail_account_voicemail_messages_path(@voicemail_account), :method => :delete, :id => 'Setting_form') do + %table.table.table-striped + %thead + %tr + %th{:width => '10px'} + = button_tag(:type => 'submit', :class => 'btn btn-mini btn-danger', :confirm => t("voicemail_messages.index.actions.confirm_selected")) do + %i{:class => 'icon-trash icon-white'} + %th + =sortable :created_epoch, t("voicemail_messages.index.date") + %th{:width => '10px'} + %th + =sortable :cid_name, t("voicemail_messages.index.calling_party") + %th + =sortable :message_len, t("voicemail_messages.index.duration") + %th + =sortable :flags, t("voicemail_messages.index.message_flags") + %th + %th + + %tbody - for voicemail_message in voicemail_messages - %tr.voicemail-messages-entry{:id => "message_#{voicemail_message.uuid}"} + - phone_book_entry = nil + %tr{:id => "message_#{voicemail_message.uuid}"} %td.select_box= check_box_tag("selected_uuids[]", voicemail_message.uuid, false, :uuid => "select_item_#{voicemail_message.uuid}", :class => 'select_item') - %td.time - .voicemail-received - = voicemail_message.format_date(voicemail_message.created_epoch, t("voicemail_messages.index.date_format"), t("voicemail_messages.index.date_today_format")) - - - read_date = voicemail_message.format_date(voicemail_message.read_epoch, t("voicemail_messages.index.date_format"), t("voicemail_messages.index.date_today_format")) - - if read_date - .voicemail-read - = read_date - %td.folder - = t("voicemail_messages.index.mailbox.#{voicemail_message.in_folder}") - %td.user - .name= voicemail_message.cid_name + %td + = l Time.at(voicemail_message.created_epoch).to_datetime, :format => :short + - if voicemail_message.read_epoch > 0 + %br + %i{:class => 'icon-bullhorn'} + = l Time.at(voicemail_message.read_epoch).to_datetime, :format => :short + - else + %br + %i{:class => 'icon-envelope'} + = t("voicemail_messages.index.unread") + %td + - image = nil + - if image + %ul.thumbnails + =image_tag(image, :alt => phone_book_entry.to_s, :class => 'img-rounded') + %td + - if phone_book_entry + %a.name{:href => phone_book_phone_book_entry_path(phone_book_entry.phone_book, phone_book_entry), :itemprop => "name"}= voicemail_message.cid_name + - else + .name= voicemail_message.cid_name .phone= voicemail_message.cid_number - %td.status - .duration= voicemail_message.display_duration + %td + = voicemail_message.display_duration %td - if ! voicemail_message.flags.blank? = t("voicemail_messages.index.flags.#{voicemail_message.flags}") - %td.form-actions + %td - if can?(:show, voicemail_message) && File.readable?(voicemail_message.file_path) - = link_to t('voicemail_messages.index.actions.download'), voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message, :format => :wav), :method => :get - /%td.actions - / - if @voicemail_account.registration && can?(:call, voicemail_message) - / = link_to t('voicemail_messages.index.actions.call'), call_voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message), :method => :put - %td.form-actions + = link_to raw(" ") + t('voicemail_messages.index.actions.download'), voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message, :format => :wav), :method => :get - if can?(:edit, voicemail_message) && voicemail_message.read_epoch > 0 - = link_to t('voicemail_messages.index.actions.mark_unread'), mark_unread_voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message), :method => :put + = link_to raw(" ") + t('voicemail_messages.index.actions.mark_unread'), mark_unread_voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message), :method => :put - else - = link_to t('voicemail_messages.index.actions.mark_read'), mark_read_voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message), :method => :put - %td.form-actions + = link_to raw(" ") + t('voicemail_messages.index.actions.mark_read'), mark_read_voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message), :method => :put + %td - if can? :destroy, voicemail_message - = link_to t('voicemail_messages.index.actions.destroy'), voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message), :method => :delete - - %footer.entries-nav= render :partial => "voicemail_messages/navigation" - = image_submit_tag('icons/cross-16x.png', :confirm => t("voicemail_messages.index.actions.confirm_selected")) - = t("voicemail_messages.index.actions.destroy_multiple") + = link_to raw(" ") + t('voicemail_messages.index.actions.destroy'), [@voicemail_account, voicemail_message], :method => :delete, :remote => true, :class => 'btn btn-mini btn-danger' diff --git a/app/views/voicemail_messages/_navigation.html.haml b/app/views/voicemail_messages/_navigation.html.haml index 2277bf2..d3b9c5d 100644 --- a/app/views/voicemail_messages/_navigation.html.haml +++ b/app/views/voicemail_messages/_navigation.html.haml @@ -1,9 +1,10 @@ -%nav - %ol.abc - %li - %a{ :href => "?type=" }= t('voicemail_messages.index.navigation.all', :count => @messages_count) - %a{ :href => "?type=read" }= t('voicemail_messages.index.navigation.read', :count => @messages_read_count) - %a{ :href => "?type=unread" }= t('voicemail_messages.index.navigation.unread', :count => @messages_unread_count) +%ul{:class => 'nav nav-pills'} + %li{:class => (type.blank? ? :active : nil )} + %a{ :href => "?type=" }= t('voicemail_messages.index.navigation.all', :count => @messages_count) + %li{:class => (type == 'read' ? :active : nil )} + %a{ :href => "?type=read" }= t('voicemail_messages.index.navigation.read', :count => @messages_read_count) + %li{:class => (type == 'unread' ? :active : nil )} + %a{ :href => "?type=unread" }= t('voicemail_messages.index.navigation.unread', :count => @messages_unread_count) .pagination - = will_paginate @voicemail_messages + = will_paginate @voicemail_messages, :renderer => BootstrapPagination::Rails -- cgit v1.2.3 From 4b118eb90f6b87d3346c77efd6d6c2d37ef0e6d1 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 30 Apr 2013 11:43:34 +0200 Subject: comment removed --- app/views/call_histories/_index_core.html.haml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'app') diff --git a/app/views/call_histories/_index_core.html.haml b/app/views/call_histories/_index_core.html.haml index fd335d4..8c40890 100644 --- a/app/views/call_histories/_index_core.html.haml +++ b/app/views/call_histories/_index_core.html.haml @@ -72,10 +72,9 @@ = call_history.result.gsub('_', ' ').titleize - else = t("call_histories.call_results.#{call_history.result}") - /= call_history.inspect %td - if @sip_account.registration && can?(:call, call_history) = link_to raw(" ") + t('call_histories.index.actions.call'), call_sip_account_call_history_path(@sip_account, call_history), :method => :put, :class => 'btn btn-mini' - %td + - if can? :destroy, call_history = link_to raw(" ") + t('call_histories.index.actions.destroy'), [@sip_account, call_history], :method => :delete, :remote => true, :class => 'btn btn-mini btn-danger' -- cgit v1.2.3 From f9168c5a5b132eca327833613d04fef66fb8b8bd Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 30 Apr 2013 11:44:07 +0200 Subject: call method fixed --- app/controllers/voicemail_messages_controller.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/controllers/voicemail_messages_controller.rb b/app/controllers/voicemail_messages_controller.rb index 3c75a64..5c28572 100644 --- a/app/controllers/voicemail_messages_controller.rb +++ b/app/controllers/voicemail_messages_controller.rb @@ -39,6 +39,8 @@ class VoicemailMessagesController < ApplicationController :per_page => GsParameter.get('DEFAULT_PAGINATION_ENTRIES_PER_PAGE') ) end + + @available_sip_account = available_sip_account() end def show @@ -94,10 +96,20 @@ class VoicemailMessagesController < ApplicationController end end + def available_sip_account + voicemail_accountable = @voicemail_account.voicemail_accountable + if voicemail_accountable.class == SipAccount + return voicemail_accountable + elsif voicemail_accountable.class == User + return voicemail_accountable.sip_accounts.first + end + end + def call phone_number = @voicemail_message.cid_number - if ! phone_number.blank? && @voicemail_account.registration - @voicemail_account.call(phone_number) + sip_account = self.available_sip_account + if ! phone_number.blank? && sip_account && sip_account.registration + sip_account.call(phone_number) end redirect_to(:back) end -- cgit v1.2.3 From 8bf701532cfb0009a367aa936b21b7f3fe338a5d Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 30 Apr 2013 11:44:31 +0200 Subject: call button added --- app/views/voicemail_messages/_index_core.html.haml | 3 +++ 1 file changed, 3 insertions(+) (limited to 'app') diff --git a/app/views/voicemail_messages/_index_core.html.haml b/app/views/voicemail_messages/_index_core.html.haml index fcaefb4..0616b61 100644 --- a/app/views/voicemail_messages/_index_core.html.haml +++ b/app/views/voicemail_messages/_index_core.html.haml @@ -59,5 +59,8 @@ - else = link_to raw(" ") + t('voicemail_messages.index.actions.mark_read'), mark_read_voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message), :method => :put %td + - if @available_sip_account && @available_sip_account.registration && can?(:call, voicemail_message) + = link_to raw(" ") + t('voicemail_messages.index.actions.call'), call_voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message), :method => :put, :class => 'btn btn-mini' + - if can? :destroy, voicemail_message = link_to raw(" ") + t('voicemail_messages.index.actions.destroy'), [@voicemail_account, voicemail_message], :method => :delete, :remote => true, :class => 'btn btn-mini btn-danger' -- cgit v1.2.3 From 466c90b7c7e04901142ca40b0220293de36af0c2 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 30 Apr 2013 11:58:40 +0200 Subject: table footer added --- app/views/voicemail_messages/_index_core.html.haml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/views/voicemail_messages/_index_core.html.haml b/app/views/voicemail_messages/_index_core.html.haml index 0616b61..09e3b95 100644 --- a/app/views/voicemail_messages/_index_core.html.haml +++ b/app/views/voicemail_messages/_index_core.html.haml @@ -19,7 +19,13 @@ =sortable :flags, t("voicemail_messages.index.message_flags") %th %th - + %tfoot + %tr + %td{:colspan => 2} + = button_tag(:type => 'submit', :class => 'btn btn-mini btn-danger', :confirm => t("voicemail_messages.index.actions.confirm_selected")) do + %i{:class => 'icon-trash icon-white'} + = t("voicemail_messages.index.actions.destroy_multiple") + %td{:colspan => 4} %tbody - for voicemail_message in voicemail_messages - phone_book_entry = nil -- cgit v1.2.3 From 4b904201187892676a0fd12e518513334924c534 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 30 Apr 2013 11:58:48 +0200 Subject: table footer added --- app/views/call_histories/_index_core.html.haml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/views/call_histories/_index_core.html.haml b/app/views/call_histories/_index_core.html.haml index 8c40890..f5e73ca 100644 --- a/app/views/call_histories/_index_core.html.haml +++ b/app/views/call_histories/_index_core.html.haml @@ -18,7 +18,13 @@ %th =sortable :result, t("call_histories.index.status") %th - + %tfoot + %tr + %td{:colspan => 2} + = button_tag(:type => 'submit', :class => 'btn btn-mini btn-danger', :confirm => t("call_histories.index.actions.confirm_selected")) do + %i{:class => 'icon-trash icon-white'} + = t("call_histories.index.actions.destroy_multiple") + %td{:colspan => 5} %tbody - for call_history in call_histories - if !call_history.display_number.blank? -- cgit v1.2.3 From bf29bf2261e955d702e02ea852adb8c9cf46a110 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 30 Apr 2013 12:23:35 +0200 Subject: phone book lookup method added --- app/models/voicemail_message.rb | 42 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/voicemail_message.rb b/app/models/voicemail_message.rb index 91ba457..698aa50 100644 --- a/app/models/voicemail_message.rb +++ b/app/models/voicemail_message.rb @@ -2,7 +2,8 @@ class VoicemailMessage < ActiveRecord::Base self.table_name = 'voicemail_msgs' self.primary_key = 'uuid' -# belongs_to :sip_account, :foreign_key => 'username', :primary_key => 'auth_name', :readonly => true + belongs_to :voicemail_account, :foreign_key => 'username', :primary_key => 'name', :readonly => true + # Prevent objects from being destroyed def before_destroy raise ActiveRecord::ReadOnlyRecord @@ -49,4 +50,43 @@ class VoicemailMessage < ActiveRecord::Base end end + def phone_book_entry_by_number(number) + begin + voicemail_accountable = self.voicemail_account.voicemail_accountable + rescue + return nil + end + + if ! voicemail_accountable + return nil + end + + if voicemail_accountable.class == SipAccount + owner = voicemail_accountable.sip_accountable + else + owner = voicemail_accountable + end + + if owner.class == User + phone_books = owner.phone_books.all + phone_books.concat(owner.current_tenant.phone_books.all) + elsif owner.class == Tenant + phone_books = owner.phone_books.all + end + + if ! phone_books + return nil + end + + phone_books.each do |phone_book| + phone_book_entry = phone_book.find_entry_by_number(number) + if phone_book_entry + return phone_book_entry + end + end + + return nil + + end + end -- cgit v1.2.3 From 645901c2cb3fd52df146f086e1bc3ae6f59cabaf Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 30 Apr 2013 12:24:09 +0200 Subject: phone book lookup added --- app/views/voicemail_messages/_index_core.html.haml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/views/voicemail_messages/_index_core.html.haml b/app/views/voicemail_messages/_index_core.html.haml index 09e3b95..57226aa 100644 --- a/app/views/voicemail_messages/_index_core.html.haml +++ b/app/views/voicemail_messages/_index_core.html.haml @@ -29,6 +29,10 @@ %tbody - for voicemail_message in voicemail_messages - phone_book_entry = nil + - image = nil + - if !voicemail_message.cid_number.blank? + - phone_book_entry = voicemail_message.phone_book_entry_by_number(voicemail_message.cid_number) + - image = phone_book_entry.image_url(:mini) %tr{:id => "message_#{voicemail_message.uuid}"} %td.select_box= check_box_tag("selected_uuids[]", voicemail_message.uuid, false, :uuid => "select_item_#{voicemail_message.uuid}", :class => 'select_item') %td @@ -42,7 +46,6 @@ %i{:class => 'icon-envelope'} = t("voicemail_messages.index.unread") %td - - image = nil - if image %ul.thumbnails =image_tag(image, :alt => phone_book_entry.to_s, :class => 'img-rounded') @@ -57,6 +60,7 @@ %td - if ! voicemail_message.flags.blank? = t("voicemail_messages.index.flags.#{voicemail_message.flags}") + = voicemail_message.phone_book_entry_by_number(voicemail_message.cid_number) %td - if can?(:show, voicemail_message) && File.readable?(voicemail_message.file_path) = link_to raw(" ") + t('voicemail_messages.index.actions.download'), voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message, :format => :wav), :method => :get -- cgit v1.2.3 From 55763dfa7b4072cf057b72c15e68c4d6c6bc1d14 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 30 Apr 2013 15:07:33 +0200 Subject: phone_book_entry can be nil --- app/views/voicemail_messages/_index_core.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/views/voicemail_messages/_index_core.html.haml b/app/views/voicemail_messages/_index_core.html.haml index 57226aa..e5dc853 100644 --- a/app/views/voicemail_messages/_index_core.html.haml +++ b/app/views/voicemail_messages/_index_core.html.haml @@ -32,7 +32,8 @@ - image = nil - if !voicemail_message.cid_number.blank? - phone_book_entry = voicemail_message.phone_book_entry_by_number(voicemail_message.cid_number) - - image = phone_book_entry.image_url(:mini) + - if phone_book_entry + - image = phone_book_entry.image_url(:mini) %tr{:id => "message_#{voicemail_message.uuid}"} %td.select_box= check_box_tag("selected_uuids[]", voicemail_message.uuid, false, :uuid => "select_item_#{voicemail_message.uuid}", :class => 'select_item') %td -- cgit v1.2.3 From 9a3fb878930698d5f799c92c6900060844cff6ce Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 30 Apr 2013 15:11:26 +0200 Subject: breadcrumbs --- app/controllers/voicemail_accounts_controller.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app') diff --git a/app/controllers/voicemail_accounts_controller.rb b/app/controllers/voicemail_accounts_controller.rb index 2e96cb7..6e840fb 100644 --- a/app/controllers/voicemail_accounts_controller.rb +++ b/app/controllers/voicemail_accounts_controller.rb @@ -80,6 +80,14 @@ class VoicemailAccountsController < ApplicationController if @parent.class == User add_breadcrumb t("users.index.page_title"), tenant_users_path(@parent.current_tenant) add_breadcrumb @parent, tenant_user_path(@parent.current_tenant, @parent) + elsif @parent.class == SipAccount + if @parent.sip_accountable.class == User + add_breadcrumb t("users.index.page_title"), tenant_users_path(@parent.sip_accountable.current_tenant) + add_breadcrumb @parent.sip_accountable, tenant_user_path(@parent.sip_accountable.current_tenant, @parent.sip_accountable) + end + + add_breadcrumb t("sip_accounts.index.page_title"), method( :"#{@parent.sip_accountable.class.name.underscore}_sip_accounts_url" ).(@parent.sip_accountable) + add_breadcrumb @parent, method( :"#{@parent.sip_accountable.class.name.underscore}_sip_account_path" ).(@parent.sip_accountable, @parent) end add_breadcrumb t("voicemail_accounts.index.page_title"), method( :"#{@parent.class.name.underscore}_voicemail_accounts_url" ).(@parent) -- cgit v1.2.3 From 6b02f64994d6fd79621c486ff4f29c0390aa8b15 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 30 Apr 2013 15:11:33 +0200 Subject: breadcrumbs --- app/controllers/voicemail_messages_controller.rb | 29 +++++++++++++++--------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'app') diff --git a/app/controllers/voicemail_messages_controller.rb b/app/controllers/voicemail_messages_controller.rb index 5c28572..7511385 100644 --- a/app/controllers/voicemail_messages_controller.rb +++ b/app/controllers/voicemail_messages_controller.rb @@ -137,18 +137,25 @@ class VoicemailMessagesController < ApplicationController end def spread_breadcrumbs - if @parent.class == SipAccount - if @voicemail_account.voicemail_accountable.class == User - add_breadcrumb t("#{@voicemail_account.voicemail_accountable.class.name.underscore.pluralize}.index.page_title"), method( :"tenant_#{@voicemail_account.voicemail_accountable.class.name.underscore.pluralize}_path" ).(@voicemail_account.tenant) - add_breadcrumb @voicemail_account.voicemail_accountable, method( :"tenant_#{@voicemail_account.voicemail_accountable.class.name.underscore}_path" ).(@voicemail_account.tenant, @voicemail_account.voicemail_accountable) - end - add_breadcrumb t("voicemail_accounts.index.page_title"), method( :"#{@voicemail_account.voicemail_accountable.class.name.underscore}_voicemail_accounts_path" ).(@voicemail_account.voicemail_accountable) - add_breadcrumb @voicemail_account, method( :"#{@voicemail_account.voicemail_accountable.class.name.underscore}_voicemail_account_path" ).(@voicemail_account.voicemail_accountable, @voicemail_account) - add_breadcrumb t("voicemail_messages.index.page_title"), voicemail_account_voicemail_messages_path(@voicemail_account) - if @voicemail_message && !@voicemail_message.new_record? - add_breadcrumb @voicemail_message, voicemail_account_voicemail_message_path(@voicemail_account, @voicemail_message) - end + parent = @voicemail_account.voicemail_accountable + + if parent.class == User + add_breadcrumb t("users.index.page_title"), tenant_users_path(parent.current_tenant) + add_breadcrumb parent, tenant_user_path(parent.current_tenant, parent) + elsif parent.class == SipAccount + if parent.sip_accountable.class == User + add_breadcrumb t("users.index.page_title"), tenant_users_path(parent.sip_accountable.current_tenant) + add_breadcrumb parent.sip_accountable, tenant_user_path(parent.sip_accountable.current_tenant, parent.sip_accountable) + end + + add_breadcrumb t("sip_accounts.index.page_title"), method( :"#{parent.sip_accountable.class.name.underscore}_sip_accounts_url" ).(parent.sip_accountable) + add_breadcrumb parent, method( :"#{parent.sip_accountable.class.name.underscore}_sip_account_path" ).(parent.sip_accountable, parent) end + + add_breadcrumb t("voicemail_accounts.index.page_title"), method( :"#{parent.class.name.underscore}_voicemail_accounts_url" ).(parent) + add_breadcrumb @voicemail_account.name, method( :"#{parent.class.name.underscore}_voicemail_account_path" ).(parent, @voicemail_account) + + add_breadcrumb t("voicemail_messages.index.page_title") end def sort_descending -- cgit v1.2.3 From fc40cc2b38a3b83115881a557c4c1fbf417fa95f Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 2 May 2013 10:50:24 +0200 Subject: pagination --- app/views/call_histories/_navigation.html.haml | 27 +++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'app') diff --git a/app/views/call_histories/_navigation.html.haml b/app/views/call_histories/_navigation.html.haml index 2218c50..d293471 100644 --- a/app/views/call_histories/_navigation.html.haml +++ b/app/views/call_histories/_navigation.html.haml @@ -1,14 +1,15 @@ -%ul{:class => 'nav nav-pills'} - %li{:class => (type.blank? ? :active : nil )} - %a{ :href => "?type=" }= t("call_histories.index.navigation.all", :calls => @calls_count) - %li{:class => (type == 'missed' ? :active : nil )} - %a{ :href => "?type=missed" }= t("call_histories.index.navigation.missed", :calls => @calls_missed_count) - %li{:class => (type == 'received' ? :active : nil )} - %a{ :href => "?type=received" }= t("call_histories.index.navigation.received", :calls => @calls_received_count) - %li{:class => (type == 'dialed' ? :active : nil )} - %a{ :href => "?type=dialed" }= t("call_histories.index.navigation.dialed", :calls => @calls_dialed_count) - %li{:class => (type == 'forwarded' ? :active : nil )} - %a{ :href => "?type=forwarded" }= t("call_histories.index.navigation.forwarded", :calls => @calls_forwarded_count) +%div{:class => 'pagination'} + %ul + %li{:class => (type.blank? ? :active : nil )} + %a{ :href => "?type=" }= t("call_histories.index.navigation.all", :calls => @calls_count) + %li{:class => (type == 'missed' ? :active : nil )} + %a{ :href => "?type=missed" }= t("call_histories.index.navigation.missed", :calls => @calls_missed_count) + %li{:class => (type == 'received' ? :active : nil )} + %a{ :href => "?type=received" }= t("call_histories.index.navigation.received", :calls => @calls_received_count) + %li{:class => (type == 'dialed' ? :active : nil )} + %a{ :href => "?type=dialed" }= t("call_histories.index.navigation.dialed", :calls => @calls_dialed_count) + %li{:class => (type == 'forwarded' ? :active : nil )} + %a{ :href => "?type=forwarded" }= t("call_histories.index.navigation.forwarded", :calls => @calls_forwarded_count) -.pagination - = will_paginate call_histories, :renderer => BootstrapPagination::Rails + + = will_paginate call_histories, :renderer => BootstrapPagination::Rails, :previous_label => raw(''), :next_label => raw(''), :class => nil -- cgit v1.2.3 From 59a4200095e983f8dbb94a76603944dab9f06a41 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 2 May 2013 10:50:34 +0200 Subject: pagination --- app/views/voicemail_messages/_navigation.html.haml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'app') diff --git a/app/views/voicemail_messages/_navigation.html.haml b/app/views/voicemail_messages/_navigation.html.haml index d3b9c5d..225801c 100644 --- a/app/views/voicemail_messages/_navigation.html.haml +++ b/app/views/voicemail_messages/_navigation.html.haml @@ -1,10 +1,10 @@ -%ul{:class => 'nav nav-pills'} - %li{:class => (type.blank? ? :active : nil )} - %a{ :href => "?type=" }= t('voicemail_messages.index.navigation.all', :count => @messages_count) - %li{:class => (type == 'read' ? :active : nil )} - %a{ :href => "?type=read" }= t('voicemail_messages.index.navigation.read', :count => @messages_read_count) - %li{:class => (type == 'unread' ? :active : nil )} - %a{ :href => "?type=unread" }= t('voicemail_messages.index.navigation.unread', :count => @messages_unread_count) +%div{:class => 'pagination'} + %ul + %li{:class => (type.blank? ? :active : nil )} + %a{ :href => "?type=" }= t('voicemail_messages.index.navigation.all', :count => @messages_count) + %li{:class => (type == 'read' ? :active : nil )} + %a{ :href => "?type=read" }= t('voicemail_messages.index.navigation.read', :count => @messages_read_count) + %li{:class => (type == 'unread' ? :active : nil )} + %a{ :href => "?type=unread" }= t('voicemail_messages.index.navigation.unread', :count => @messages_unread_count) -.pagination - = will_paginate @voicemail_messages, :renderer => BootstrapPagination::Rails + = will_paginate @voicemail_messages, :renderer => BootstrapPagination::Rails, :previous_label => raw(''), :next_label => raw(''), :class => nil -- cgit v1.2.3 From 20570c967e0d63fd6d1644cd64e4c0c7859bc57f Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 2 May 2013 10:50:47 +0200 Subject: pagination --- app/views/sip_accounts/_index_core.html.haml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/views/sip_accounts/_index_core.html.haml b/app/views/sip_accounts/_index_core.html.haml index 7f393d7..d91a3ef 100644 --- a/app/views/sip_accounts/_index_core.html.haml +++ b/app/views/sip_accounts/_index_core.html.haml @@ -1,6 +1,7 @@ -.pagination - - if defined?(users.total_pages) - = will_paginate users, :renderer => BootstrapPagination::Rails + +- if defined?(users.total_pages) + = will_paginate users, :renderer => BootstrapPagination::Rails, :previous_label => raw(''), :next_label => raw('') + %table.table.table-striped %thead %tr -- cgit v1.2.3 From 5525a9af9229f0ac65d44472519aac4ab8751018 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Thu, 2 May 2013 10:50:53 +0200 Subject: pagination --- app/views/users/_index_core.html.haml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/views/users/_index_core.html.haml b/app/views/users/_index_core.html.haml index d741282..78510a2 100644 --- a/app/views/users/_index_core.html.haml +++ b/app/views/users/_index_core.html.haml @@ -1,7 +1,8 @@ - cache(['user_table_row_inner_td', I18n.locale, current_user, users.reorder(:updated_at).last, users.count, GsParameter.get('NUMBER_OF_SHOWN_ITEMS')]) do - .pagination - - if defined?(users.total_pages) - = will_paginate users, :renderer => BootstrapPagination::Rails + + - if defined?(users.total_pages) + = will_paginate users, :renderer => BootstrapPagination::Rails, :previous_label => raw(''), :next_label => raw('') + %table.table.table-striped %thead %tr -- cgit v1.2.3 From 8b592b0a04c2ebc51794537275ec8ac7500ccda3 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 3 May 2013 09:36:10 +0200 Subject: display table only if some items are present --- app/views/call_histories/_index_core.html.haml | 157 +++++++++++++------------ 1 file changed, 79 insertions(+), 78 deletions(-) (limited to 'app') diff --git a/app/views/call_histories/_index_core.html.haml b/app/views/call_histories/_index_core.html.haml index f5e73ca..ef5654a 100644 --- a/app/views/call_histories/_index_core.html.haml +++ b/app/views/call_histories/_index_core.html.haml @@ -1,86 +1,87 @@ = render :partial => "call_histories/navigation", :locals => {:call_histories => call_histories, :type => @type} -= form_tag(destroy_multiple_sip_account_call_histories_path(@sip_account), :method => :delete, :id => 'call_hostory_form') do - %table.table.table-striped - %thead - %tr - %th{:width => '10px'} - = button_tag(:type => 'submit', :class => 'btn btn-mini btn-danger', :confirm => t("call_histories.index.actions.confirm_selected")) do - %i{:class => 'icon-trash icon-white'} - %th - =sortable :start_stamp, t("call_histories.index.date") - %th{:width => '10px'} - %th - =sortable :caller_id_name, t("call_histories.index.called_party") - %th - =sortable :duration, t("call_histories.index.duration") - %th - =sortable :result, t("call_histories.index.status") - %th - %tfoot - %tr - %td{:colspan => 2} - = button_tag(:type => 'submit', :class => 'btn btn-mini btn-danger', :confirm => t("call_histories.index.actions.confirm_selected")) do - %i{:class => 'icon-trash icon-white'} - = t("call_histories.index.actions.destroy_multiple") - %td{:colspan => 5} - %tbody - - for call_history in call_histories - - if !call_history.display_number.blank? - - phone_book_entry = call_history.phone_book_entry_by_number(call_history.display_number) - %tr{:id => "call_history_id_#{call_history.id}_tr", :class => (call_history.duration.blank? ? 'warning' : '')} - %td.select_box= check_box_tag("selected_ids[]", call_history.id, false, :uuid => "select_item_#{call_history.id}", :class => 'select_item') - %td - = l call_history.start_stamp, :format => :short - %br - -if call_history.entry_type == 'dialed' - %i{:class => 'icon-arrow-left'} - -elsif call_history.entry_type == 'missed' - %i{:class => 'icon-time'} - -elsif call_history.entry_type == 'forwarded' - - if call_history.callee_account_type.to_s.downcase == 'voicemailaccount' - %i{:class => 'icon-envelope'} +- if call_histories.any? + = form_tag(destroy_multiple_sip_account_call_histories_path(@sip_account), :method => :delete, :id => 'call_hostory_form') do + %table.table.table-striped + %thead + %tr + %th{:width => '10px'} + = button_tag(:type => 'submit', :class => 'btn btn-mini btn-danger', :confirm => t("call_histories.index.actions.confirm_selected")) do + %i{:class => 'icon-trash icon-white'} + %th + =sortable :start_stamp, t("call_histories.index.date") + %th{:width => '10px'} + %th + =sortable :caller_id_name, t("call_histories.index.called_party") + %th + =sortable :duration, t("call_histories.index.duration") + %th + =sortable :result, t("call_histories.index.status") + %th + %tfoot + %tr + %td{:colspan => 2} + = button_tag(:type => 'submit', :class => 'btn btn-mini btn-danger', :confirm => t("call_histories.index.actions.confirm_selected")) do + %i{:class => 'icon-trash icon-white'} + = t("call_histories.index.actions.destroy_multiple") + %td{:colspan => 5} + %tbody + - for call_history in call_histories + - if !call_history.display_number.blank? + - phone_book_entry = call_history.phone_book_entry_by_number(call_history.display_number) + %tr{:id => "call_history_id_#{call_history.id}_tr", :class => (call_history.duration.blank? ? 'warning' : '')} + %td.select_box= check_box_tag("selected_ids[]", call_history.id, false, :uuid => "select_item_#{call_history.id}", :class => 'select_item') + %td + = l call_history.start_stamp, :format => :short + %br + -if call_history.entry_type == 'dialed' + %i{:class => 'icon-arrow-left'} + -elsif call_history.entry_type == 'missed' + %i{:class => 'icon-time'} + -elsif call_history.entry_type == 'forwarded' + - if call_history.callee_account_type.to_s.downcase == 'voicemailaccount' + %i{:class => 'icon-envelope'} + - else + %i{:class => 'icon-random'} - else - %i{:class => 'icon-random'} - - else - %i{:class => 'icon-arrow-right'} + %i{:class => 'icon-arrow-right'} - - if call_history.entry_type == 'forwarded' - - if call_history.callee_account_type.to_s.downcase == 'phonenumber' + - if call_history.entry_type == 'forwarded' + - if call_history.callee_account_type.to_s.downcase == 'phonenumber' + = call_history.destination_number + - if call_history.callee_account_type.to_s.downcase == 'voicemailaccount' + = VoicemailAccount.where(:id => call_history.callee_account_id).first.to_s + - elsif call_history.entry_type == 'dialed' + = call_history.caller_id_number + - else = call_history.destination_number - - if call_history.callee_account_type.to_s.downcase == 'voicemailaccount' - = VoicemailAccount.where(:id => call_history.callee_account_id).first.to_s - - elsif call_history.entry_type == 'dialed' - = call_history.caller_id_number + + %td + - image = call_history.display_image(:mini, phone_book_entry) + - if image + %ul.thumbnails + =image_tag(image, :alt => phone_book_entry.to_s, :class => 'img-rounded') + %td + - display_name = call_history.display_name + - if display_name.blank? + - display_name = phone_book_entry.to_s + - if phone_book_entry + %a.name{:href => phone_book_phone_book_entry_path(phone_book_entry.phone_book, phone_book_entry), :itemprop => "name"}= display_name + - else + .name= display_name + .phone= call_history.display_number + %td + - if call_history.display_duration + = call_history.display_duration + %td + - if t("call_histories.call_results.#{call_history.result}").include?('translation missing') + = call_history.result.gsub('_', ' ').titleize - else - = call_history.destination_number - - %td - - image = call_history.display_image(:mini, phone_book_entry) - - if image - %ul.thumbnails - =image_tag(image, :alt => phone_book_entry.to_s, :class => 'img-rounded') - %td - - display_name = call_history.display_name - - if display_name.blank? - - display_name = phone_book_entry.to_s - - if phone_book_entry - %a.name{:href => phone_book_phone_book_entry_path(phone_book_entry.phone_book, phone_book_entry), :itemprop => "name"}= display_name - - else - .name= display_name - .phone= call_history.display_number - %td - - if call_history.display_duration - = call_history.display_duration - %td - - if t("call_histories.call_results.#{call_history.result}").include?('translation missing') - = call_history.result.gsub('_', ' ').titleize - - else - = t("call_histories.call_results.#{call_history.result}") - %td - - if @sip_account.registration && can?(:call, call_history) - = link_to raw(" ") + t('call_histories.index.actions.call'), call_sip_account_call_history_path(@sip_account, call_history), :method => :put, :class => 'btn btn-mini' + = t("call_histories.call_results.#{call_history.result}") + %td + - if @sip_account.registration && can?(:call, call_history) + = link_to raw(" ") + t('call_histories.index.actions.call'), call_sip_account_call_history_path(@sip_account, call_history), :method => :put, :class => 'btn btn-mini' - - if can? :destroy, call_history - = link_to raw(" ") + t('call_histories.index.actions.destroy'), [@sip_account, call_history], :method => :delete, :remote => true, :class => 'btn btn-mini btn-danger' + - if can? :destroy, call_history + = link_to raw(" ") + t('call_histories.index.actions.destroy'), [@sip_account, call_history], :method => :delete, :remote => true, :class => 'btn btn-mini btn-danger' -- cgit v1.2.3 From 6d8466c44d31007dc3ec469b83855286ca553c5d Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Fri, 3 May 2013 09:36:19 +0200 Subject: display table only if some items are present --- app/views/voicemail_messages/_index_core.html.haml | 144 ++++++++++----------- 1 file changed, 72 insertions(+), 72 deletions(-) (limited to 'app') diff --git a/app/views/voicemail_messages/_index_core.html.haml b/app/views/voicemail_messages/_index_core.html.haml index e5dc853..f93365c 100644 --- a/app/views/voicemail_messages/_index_core.html.haml +++ b/app/views/voicemail_messages/_index_core.html.haml @@ -1,77 +1,77 @@ = render :partial => "voicemail_messages/navigation", :locals => {:type => @type} -= form_tag(destroy_multiple_voicemail_account_voicemail_messages_path(@voicemail_account), :method => :delete, :id => 'Setting_form') do - %table.table.table-striped - %thead - %tr - %th{:width => '10px'} - = button_tag(:type => 'submit', :class => 'btn btn-mini btn-danger', :confirm => t("voicemail_messages.index.actions.confirm_selected")) do - %i{:class => 'icon-trash icon-white'} - %th - =sortable :created_epoch, t("voicemail_messages.index.date") - %th{:width => '10px'} - %th - =sortable :cid_name, t("voicemail_messages.index.calling_party") - %th - =sortable :message_len, t("voicemail_messages.index.duration") - %th - =sortable :flags, t("voicemail_messages.index.message_flags") - %th - %th - %tfoot - %tr - %td{:colspan => 2} - = button_tag(:type => 'submit', :class => 'btn btn-mini btn-danger', :confirm => t("voicemail_messages.index.actions.confirm_selected")) do - %i{:class => 'icon-trash icon-white'} - = t("voicemail_messages.index.actions.destroy_multiple") - %td{:colspan => 4} - %tbody - - for voicemail_message in voicemail_messages - - phone_book_entry = nil - - image = nil - - if !voicemail_message.cid_number.blank? - - phone_book_entry = voicemail_message.phone_book_entry_by_number(voicemail_message.cid_number) - - if phone_book_entry - - image = phone_book_entry.image_url(:mini) - %tr{:id => "message_#{voicemail_message.uuid}"} - %td.select_box= check_box_tag("selected_uuids[]", voicemail_message.uuid, false, :uuid => "select_item_#{voicemail_message.uuid}", :class => 'select_item') - %td - = l Time.at(voicemail_message.created_epoch).to_datetime, :format => :short - - if voicemail_message.read_epoch > 0 - %br - %i{:class => 'icon-bullhorn'} - = l Time.at(voicemail_message.read_epoch).to_datetime, :format => :short - - else - %br - %i{:class => 'icon-envelope'} - = t("voicemail_messages.index.unread") - %td - - if image - %ul.thumbnails - =image_tag(image, :alt => phone_book_entry.to_s, :class => 'img-rounded') - %td +- if voicemail_messages.any? + = form_tag(destroy_multiple_voicemail_account_voicemail_messages_path(@voicemail_account), :method => :delete, :id => 'Setting_form') do + %table.table.table-striped + %thead + %tr + %th{:width => '10px'} + = button_tag(:type => 'submit', :class => 'btn btn-mini btn-danger', :confirm => t("voicemail_messages.index.actions.confirm_selected")) do + %i{:class => 'icon-trash icon-white'} + %th + =sortable :created_epoch, t("voicemail_messages.index.date") + %th{:width => '10px'} + %th + =sortable :cid_name, t("voicemail_messages.index.calling_party") + %th + =sortable :message_len, t("voicemail_messages.index.duration") + %th + =sortable :flags, t("voicemail_messages.index.message_flags") + %th + %th + %tfoot + %tr + %td{:colspan => 2} + = button_tag(:type => 'submit', :class => 'btn btn-mini btn-danger', :confirm => t("voicemail_messages.index.actions.confirm_selected")) do + %i{:class => 'icon-trash icon-white'} + = t("voicemail_messages.index.actions.destroy_multiple") + %td{:colspan => 4} + %tbody + - for voicemail_message in voicemail_messages + - phone_book_entry = nil + - image = nil + - if !voicemail_message.cid_number.blank? + - phone_book_entry = voicemail_message.phone_book_entry_by_number(voicemail_message.cid_number) - if phone_book_entry - %a.name{:href => phone_book_phone_book_entry_path(phone_book_entry.phone_book, phone_book_entry), :itemprop => "name"}= voicemail_message.cid_name - - else - .name= voicemail_message.cid_name - .phone= voicemail_message.cid_number - %td - = voicemail_message.display_duration - %td - - if ! voicemail_message.flags.blank? - = t("voicemail_messages.index.flags.#{voicemail_message.flags}") - = voicemail_message.phone_book_entry_by_number(voicemail_message.cid_number) - %td - - if can?(:show, voicemail_message) && File.readable?(voicemail_message.file_path) - = link_to raw(" ") + t('voicemail_messages.index.actions.download'), voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message, :format => :wav), :method => :get - - if can?(:edit, voicemail_message) && voicemail_message.read_epoch > 0 - = link_to raw(" ") + t('voicemail_messages.index.actions.mark_unread'), mark_unread_voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message), :method => :put - - else - = link_to raw(" ") + t('voicemail_messages.index.actions.mark_read'), mark_read_voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message), :method => :put - %td - - if @available_sip_account && @available_sip_account.registration && can?(:call, voicemail_message) - = link_to raw(" ") + t('voicemail_messages.index.actions.call'), call_voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message), :method => :put, :class => 'btn btn-mini' + - image = phone_book_entry.image_url(:mini) + %tr{:id => "message_#{voicemail_message.uuid}"} + %td.select_box= check_box_tag("selected_uuids[]", voicemail_message.uuid, false, :uuid => "select_item_#{voicemail_message.uuid}", :class => 'select_item') + %td + = l Time.at(voicemail_message.created_epoch).to_datetime, :format => :short + - if voicemail_message.read_epoch > 0 + %br + %i{:class => 'icon-bullhorn'} + = l Time.at(voicemail_message.read_epoch).to_datetime, :format => :short + - else + %br + %i{:class => 'icon-envelope'} + = t("voicemail_messages.index.unread") + %td + - if image + %ul.thumbnails + =image_tag(image, :alt => phone_book_entry.to_s, :class => 'img-rounded') + %td + - if phone_book_entry + %a.name{:href => phone_book_phone_book_entry_path(phone_book_entry.phone_book, phone_book_entry), :itemprop => "name"}= voicemail_message.cid_name + - else + .name= voicemail_message.cid_name + .phone= voicemail_message.cid_number + %td + = voicemail_message.display_duration + %td + - if ! voicemail_message.flags.blank? + = t("voicemail_messages.index.flags.#{voicemail_message.flags}") + %td + - if can?(:show, voicemail_message) && File.readable?(voicemail_message.file_path) + = link_to raw(" ") + t('voicemail_messages.index.actions.download'), voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message, :format => :wav), :method => :get + - if can?(:edit, voicemail_message) && voicemail_message.read_epoch > 0 + = link_to raw(" ") + t('voicemail_messages.index.actions.mark_unread'), mark_unread_voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message), :method => :put + - else + = link_to raw(" ") + t('voicemail_messages.index.actions.mark_read'), mark_read_voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message), :method => :put + %td + - if @available_sip_account && @available_sip_account.registration && can?(:call, voicemail_message) + = link_to raw(" ") + t('voicemail_messages.index.actions.call'), call_voicemail_account_voicemail_message_path(@voicemail_account, voicemail_message), :method => :put, :class => 'btn btn-mini' - - if can? :destroy, voicemail_message - = link_to raw(" ") + t('voicemail_messages.index.actions.destroy'), [@voicemail_account, voicemail_message], :method => :delete, :remote => true, :class => 'btn btn-mini btn-danger' + - if can? :destroy, voicemail_message + = link_to raw(" ") + t('voicemail_messages.index.actions.destroy'), [@voicemail_account, voicemail_message], :method => :delete, :remote => true, :class => 'btn btn-mini btn-danger' -- cgit v1.2.3 From 4cd6ef5dc7b98e389ef526db448deaaa611f926e Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 5 May 2013 09:37:36 +0200 Subject: resolve_prerouting method added --- app/models/phone_number.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'app') diff --git a/app/models/phone_number.rb b/app/models/phone_number.rb index f6453ce..919b703 100644 --- a/app/models/phone_number.rb +++ b/app/models/phone_number.rb @@ -223,6 +223,25 @@ class PhoneNumber < ActiveRecord::Base end end end + + def resolve_prerouting + return PhoneNumber.resolve_prerouting(self.number, self.phone_numberable) + end + + def self.resolve_prerouting(number, account = SipAccount.first) + + routes = CallRoute.test_route(:prerouting, { + 'caller.destination_number' => number, + 'caller.auth_account_type' => account.class.name, + 'caller.auth_account_id' => account.id, + 'caller.auth_account_uuid' => account.try(:uuid), + 'caller.account_type' => account.class.name, + 'caller.account_id' => account.id, + 'caller.account_uuid' => account.try(:uuid), + }) + + return routes['routes']['1'] + end # Find the (grand-)parent tenant of this phone number: # -- cgit v1.2.3 From 11dc1567646feed73d908d293cd0fcba4c6224bb Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 5 May 2013 09:40:51 +0200 Subject: routes can be nil --- app/models/phone_number.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/phone_number.rb b/app/models/phone_number.rb index 919b703..4b22f40 100644 --- a/app/models/phone_number.rb +++ b/app/models/phone_number.rb @@ -240,7 +240,9 @@ class PhoneNumber < ActiveRecord::Base 'caller.account_uuid' => account.try(:uuid), }) - return routes['routes']['1'] + if routes + return routes['routes']['1'] + end end # Find the (grand-)parent tenant of this phone number: -- cgit v1.2.3 From 8610dace5d1caa31827d560af4bea1621d871010 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 5 May 2013 09:53:17 +0200 Subject: resolve prerouting --- app/models/phone_number.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/models/phone_number.rb b/app/models/phone_number.rb index 4b22f40..193e4a8 100644 --- a/app/models/phone_number.rb +++ b/app/models/phone_number.rb @@ -210,6 +210,10 @@ class PhoneNumber < ActiveRecord::Base self.central_office_code = nil self.extension = self.number.to_s.strip else + prerouting = resolve_prerouting + if prerouting && !prerouting['destination_number'].blank? && prerouting['type'] == 'phonenumber' + self.number = prerouting['destination_number'] + end parsed_number = PhoneNumber.parse( self.number ) if parsed_number self.country_code = parsed_number[:country_code] @@ -225,10 +229,11 @@ class PhoneNumber < ActiveRecord::Base end def resolve_prerouting - return PhoneNumber.resolve_prerouting(self.number, self.phone_numberable) + return PhoneNumber.resolve_prerouting(self.number.strip, self.phone_numberable) end - def self.resolve_prerouting(number, account = SipAccount.first) + def self.resolve_prerouting(number, account = nil) + account = account || SipAccount.first routes = CallRoute.test_route(:prerouting, { 'caller.destination_number' => number, -- cgit v1.2.3 From 8968171f9cee1e3c4e5a9267484585a8c99c4c43 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Sun, 5 May 2013 09:53:48 +0200 Subject: resolve_prerouting method added --- app/models/call_forward.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'app') diff --git a/app/models/call_forward.rb b/app/models/call_forward.rb index de3afc4..a4bfbb5 100644 --- a/app/models/call_forward.rb +++ b/app/models/call_forward.rb @@ -56,6 +56,8 @@ class CallForward < ActiveRecord::Base end } + before_validation :resolve_prerouting + after_save :set_presence after_save :deactivate_concurring_entries, :if => Proc.new { |cf| cf.active == true } before_destroy :deactivate_connected_softkeys @@ -135,6 +137,18 @@ class CallForward < ActiveRecord::Base end end + def resolve_prerouting + if self.destinationable_type == 'PhoneNumber' && GsParameter.get('CALLFORWARD_DESTINATION_RESOLVE') != false + if self.call_forwardable.class == PhoneNumber + prerouting = PhoneNumber.resolve_prerouting(self.destination, self.call_forwardable.phone_numberable) + else + prerouting = PhoneNumber.resolve_prerouting(self.destination, self.call_forwardable) + end + if prerouting && !prerouting['destination_number'].blank? && prerouting['type'] == 'phonenumber' + self.destination = prerouting['destination_number'] + end + end + end def send_presence_event(state, call_forwarding_service = nil) dialplan_function = "cftg-#{self.id}" -- cgit v1.2.3 From 289d88ee79ea5dc4228cf93a64faddf5c0815c54 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 7 May 2013 12:57:06 +0200 Subject: get_list method added --- app/models/gs_parameter.rb | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'app') diff --git a/app/models/gs_parameter.rb b/app/models/gs_parameter.rb index cd4f47b..f301e95 100644 --- a/app/models/gs_parameter.rb +++ b/app/models/gs_parameter.rb @@ -17,22 +17,37 @@ class GsParameter < ActiveRecord::Base else item = GsParameter.where(:name => wanted_variable).first end - if item.nil? || item.class_type == 'Nil' - return nil - else - return item.value.to_i if item.class_type == 'Integer' - return item.value.to_s if item.class_type == 'String' - if item.class_type == 'Boolean' - return true if item.value == 'true' - return false if item.value == 'false' - end - return YAML.load(item.value) if item.class_type == 'YAML' - end + return GsParameter.cast_variable(item) else nil end end + def self.get_list(entity, section) + items = {} + if GsParameter.table_exists? + GsParameter.where(:entity => entity, :section => section).each do |item| + items[item.name] = GsParameter.cast_variable(item) + end + end + + return items + end + + def self.cast_variable(item) + if item.nil? || item.class_type == 'Nil' + return nil + else + return item.value.to_i if item.class_type == 'Integer' + return item.value.to_s if item.class_type == 'String' + if item.class_type == 'Boolean' + return true if item.value == 'true' + return false if item.value == 'false' + end + return YAML.load(item.value) if item.class_type == 'YAML' + end + end + def to_s name end -- cgit v1.2.3 From c5bfe11c01f2b3575ec96b6bd6f567976d93ff63 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 7 May 2013 12:58:01 +0200 Subject: support for additional provisioning parameters --- app/controllers/config_snom_controller.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb index b692693..805f682 100644 --- a/app/controllers/config_snom_controller.rb +++ b/app/controllers/config_snom_controller.rb @@ -242,6 +242,7 @@ class ConfigSnomController < ApplicationController phone_sip_accounts = Array.new() if send_sensitve + phone_parameters = GsParameter.get_list('phones', 'snom') if @phone.sip_accounts && @phone.sip_accounts.count > 0 phone_sip_accounts = @phone.sip_accounts elsif @phone.fallback_sip_account @@ -250,6 +251,7 @@ class ConfigSnomController < ApplicationController expiry_seconds = GsParameter.get('SIP_EXPIRY_SECONDS') phone_sip_accounts.each do |sip_account| if (sip_account.sip_accountable_type == @phone.phoneable_type) and (sip_account.sip_accountable_id == @phone.phoneable_id) + snom_sip_account = { :id => sip_account.id, :active => 'on', @@ -259,7 +261,7 @@ class ConfigSnomController < ApplicationController :outbound => sip_account.host, :name => sip_account.auth_name, :realname => 'Call', - :idle_text => sip_account.caller_name, + :user_idle_text => sip_account.caller_name, :expiry => expiry_seconds, } @@ -267,6 +269,16 @@ class ConfigSnomController < ApplicationController snom_sip_account[:mailbox] = "" end + phone_parameters.each do |name, value| + snom_sip_account[name.to_sym] = value.gsub!(/\{([a-z0-9_\.]+)\}/) { |v| + source = sip_account + $1.split('.').each do |method| + source = source.send(method) if source.respond_to?(method) + end + source.to_s + } + end + @sip_accounts.push(snom_sip_account) sip_account_index = @sip_accounts.length sip_account.softkeys.order(:position).each do |softkey| -- cgit v1.2.3 From f96ae5aa5b18b1a8b5359853e38ee3ae2b2e6028 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 7 May 2013 12:58:07 +0200 Subject: support for additional provisioning parameters --- app/controllers/config_siemens_controller.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/controllers/config_siemens_controller.rb b/app/controllers/config_siemens_controller.rb index 7d5eb3f..3fe3aaa 100644 --- a/app/controllers/config_siemens_controller.rb +++ b/app/controllers/config_siemens_controller.rb @@ -194,6 +194,18 @@ class ConfigSiemensController < ApplicationController #logger.debug(@phone_items) @my_nonce = params[:WorkpointMessage][:Message][:nonce] @new_settings = Array.new + + phone_parameters = GsParameter.get_list('phones', 'siemens') + phone_parameters.each do |name, value| + value = value.gsub!(/\{([a-z0-9_\.]+)\}/) { |v| + source = @sip_account + $1.split('.').each do |method| + source = source.send(method) if source.respond_to?(method) + end + source.to_s + } + @new_settings << [name, nil, value] + end @new_settings << ['dhcp', nil, 'true'] @new_settings << ['hostname', nil, mac_address.gsub(':', '') ] @@ -479,7 +491,6 @@ class ConfigSiemensController < ApplicationController @new_settings << ['feature-availability', 33, 'true'] # line overview @new_settings << ['feature-availability', 33, 'false'] # phone lock - @soft_keys = Array.new # Fill softkeys with keys dependent on limit of phone @sip_account.softkeys.order(:position).each do |sk| -- cgit v1.2.3 From ea2a4bbe0fc05e175bb05b0b8cbf3a02f008c7f9 Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 7 May 2013 14:42:14 +0200 Subject: voicemail menu added --- app/controllers/config_snom_controller.rb | 85 ++++++++++++++++++++++++++++--- 1 file changed, 77 insertions(+), 8 deletions(-) (limited to 'app') diff --git a/app/controllers/config_snom_controller.rb b/app/controllers/config_snom_controller.rb index 805f682..4b9489b 100644 --- a/app/controllers/config_snom_controller.rb +++ b/app/controllers/config_snom_controller.rb @@ -802,7 +802,7 @@ AAAA' @phone_xml_object = { :name => 'snom_phone_directory', - :title => "$(lang:menu100_phone_book) #{@dialpad_keys}".strip, + :title => "#{t('config_snom.phone_book.title')} #{@dialpad_keys}".strip, :entries => [], :softkeys => [], } @@ -865,7 +865,6 @@ AAAA' end def call_history - if ! @sip_account render( :status => 404, @@ -876,10 +875,10 @@ AAAA' return end - if ['dialed', 'missed', 'received'].include? @type + if ['dialed', 'missed', 'received', 'forwarded'].include? @type @phone_xml_object = { :name => "snom_phone_directory", - :title => "$(lang:menu100_call_lists) - #{@type.to_s.camelize}", + :title => "#{t('config_snom.call_history.title')} - #{@type.to_s.camelize}", :entries => [] } @@ -909,11 +908,81 @@ AAAA' base_url = "#{request.protocol}#{request.host_with_port}#{request.fullpath.split("?")[0]}" @phone_xml_object = { :name => 'snom_phone_menu', - :title => '$(lang:menu100_call_lists)', + :title => t('config_snom.call_history.title'), + :entries => [ + {:text => t('config_snom.call_history.missed'), :url => "#{base_url}?&type=missed", :selected => false}, + {:text => t('config_snom.call_history.received'), :url => "#{base_url}?&type=received", :selected => false}, + {:text => t('config_snom.call_history.dialed'), :url => "#{base_url}?&type=dialed", :selected => false}, + ] + } + end + + respond_to { |format| + format.any { + self.formats = [ :xml ] + render :action => "_#{@phone_xml_object[:name]}" + } + } + + end + + def voicemail + if ! @sip_account + render( + :status => 404, + :layout => false, + :content_type => 'text/plain', + :text => "", + ) + return + end + + if !@sip_account.voicemail_account + render( + :status => 404, + :layout => false, + :content_type => 'text/plain', + :text => "", + ) + return + end + + account = @sip_account.voicemail_account + + if ['read', 'unread'].include? @type + if @type == 'unread' + messages = account.voicemail_messages.where('read_epoch IS NULL OR read_epoch = 0') + elsif @type == 'read' + messages = account.voicemail_messages.where('read_epoch > 0') + end + @phone_xml_object = { + :name => "snom_phone_directory", + :title => t("config_snom.voicemail.#{@type}_count", :count => messages.count), + :entries => [] + } + messages.each do |message| + @phone_xml_object[:entries].push({ + :selected => false, + :number => "f-vmplay-#{message.uuid}", + :text => "#{call_date_compact(Time.at(message.created_epoch).to_datetime)} #{message.cid_name} #{message.cid_number}", + }) + end + elsif @type == 'settings' + base_url = "#{request.protocol}#{request.host_with_port}#{request.fullpath.split("?")[0]}" + @phone_xml_object = { + :name => 'snom_phone_menu', + :title => t('config_snom.voicemail_settings.title'), + :entries => [] + } + else + base_url = "#{request.protocol}#{request.host_with_port}#{request.fullpath.split("?")[0]}" + @phone_xml_object = { + :name => 'snom_phone_menu', + :title => account, :entries => [ - {:text => '$(lang:list_missed)', :url => "#{base_url}?&type=missed", :selected => false}, - {:text => '$(lang:list_taken)', :url => "#{base_url}?&type=received", :selected => false}, - {:text => '$(lang:list_dialed)', :url => "#{base_url}?&type=dialed", :selected => false}, + {:text => t('config_snom.voicemail.unread_count', :count => account.voicemail_messages.where('read_epoch IS NULL OR read_epoch = 0').count), :url => "#{base_url}?&type=unread", :selected => false}, + {:text => t('config_snom.voicemail.read_count', :count => account.voicemail_messages.where('read_epoch > 0').count), :url => "#{base_url}?&type=read", :selected => false}, + {:text => t('config_snom.voicemail.settings'), :url => "#{base_url}?&type=settings", :selected => false}, ] } end -- cgit v1.2.3 From c910e18564a401284296ea7e1f5f86650f5ddc7b Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 7 May 2013 14:43:04 +0200 Subject: translations --- app/views/config_snom/state_settings.xml.haml | 47 +++++++++++++++------------ 1 file changed, 27 insertions(+), 20 deletions(-) (limited to 'app') diff --git a/app/views/config_snom/state_settings.xml.haml b/app/views/config_snom/state_settings.xml.haml index 6be1efc..8bb5239 100644 --- a/app/views/config_snom/state_settings.xml.haml +++ b/app/views/config_snom/state_settings.xml.haml @@ -1,49 +1,56 @@ !!! XML %SnomIPPhoneMenu{:state => 'relevant', :title => "Gemeinschaft #{GsParameter.get('GEMEINSCHAFT_VERSION')}"} - %MenuItem{:name => '$(lang:menu100_phone_book)'} + %MenuItem{:name => t('config_snom.main_menu.phone_book')} %URL= "#{@base_url}/#{@sip_account_ids.first}/phone_book.xml" - %Menu{:name => '$(lang:menu100_call_lists)'} - %MenuItem{:name => '$(lang:list_missed)'} + %Menu{:name => t('config_snom.main_menu.call_history')} + %MenuItem{:name => t('config_snom.call_history.missed')} - @sip_account_ids.each_with_index do |id, index| %If{:condition => "$(current_line)==#{index+1}"} %URL= "#{@base_url}/#{id}/call_history_missed.xml" - %MenuItem{:name => '$(lang:list_taken)'} + %MenuItem{:name => t('config_snom.call_history.received')} - @sip_account_ids.each_with_index do |id, index| %If{:condition => "$(current_line)==#{index+1}"} %URL= "#{@base_url}/#{id}/call_history_received.xml" - %MenuItem{:name => '$(lang:list_dialed)'} + %MenuItem{:name => t('config_snom.call_history.dialed')} - @sip_account_ids.each_with_index do |id, index| %If{:condition => "$(current_line)==#{index+1}"} %URL= "#{@base_url}/#{id}/call_history_dialed.xml" - %MenuItem{:name => '$(lang:sel100_activeline)'} + %MenuItem{:name => t('config_snom.call_history.forwarded')} + - @sip_account_ids.each_with_index do |id, index| + %If{:condition => "$(current_line)==#{index+1}"} + %URL= "#{@base_url}/#{id}/call_history_forwarded.xml" + + %MenuItem{:name => t('config_snom.main_menu.voicemail')} + %URL= "#{@base_url}/#{@sip_account_ids.first}/voicemail.xml" + %MenuItem{:name => t('config_snom.main_menu.sip_account')} %Action= 'active_line' - if @enable_login - %MenuItem{:name => 'Log in'} + %MenuItem{:name => t('config_snom.main_menu.log_in')} %URL= "#{@base_url}/log_in.xml" - if @enable_logout - %MenuItem{:name => 'Log out'} + %MenuItem{:name => t('config_snom.main_menu.log_out')} %URL= "#{@base_url}/log_out.xml" - %Menu{:name => '$(lang:preferences_settings)'} - %MenuItem{:name => '$(lang:menu_gen_contrast)'} + %Menu{:name => t('config_snom.main_menu.preferences')} + %MenuItem{:name => t('config_snom.preferences.contrast')} %Action= 'contrast' - %MenuItem{:name => '$(lang:use_backlight)'} + %MenuItem{:name => t('config_snom.preferences.use_backlight')} %Action= 'use_backlight' - %MenuItem{:name => '$(lang:use_backlight) $(lang:backlight_when_active)'} + %MenuItem{:name => t('config_snom.preferences.backlight_active')} %Action= 'backlight_active' - %MenuItem{:name => '$(lang:use_backlight) $(lang:backlight_when_idle)'} + %MenuItem{:name => t('config_snom.preferences.backlight_idle')} %Action= 'backlight_idle' - %MenuItem{:name => '$(lang:menu_equalizer)'} + %MenuItem{:name => t('config_snom.preferences.equalizer')} %Action= 'equalizer' - %Menu{:name => '$(lang:maintenance_settings)'} - %MenuItem{:name => '$(lang:system_information_menu)'} + %Menu{:name => t('config_snom.main_menu.maintenance')} + %MenuItem{:name => t('config_snom.maintenance.system_info')} %Action= 'sysinfo' - %MenuItem{:name => '$(lang:sel100_reboot)'} + %MenuItem{:name => t('config_snom.maintenance.reboot')} %Action= 'reboot' %If{:condition => '$(set:admin_mode)'} - %MenuItem{:name => '$(lang:reset_settings)'} + %MenuItem{:name => t('config_snom.maintenance.reset_settings')} %Action= 'reset_settings' %If{:condition => '$(update_available)'} - %MenuItem{:name => '$(lang:update_header)'} - %Action= 'software_update' \ No newline at end of file + %MenuItem{:name => t('config_snom.maintenance.software_update')} + %Action= 'software_update' -- cgit v1.2.3 From 91b9da216d001c749b6d3429d88b35d0c1d3537b Mon Sep 17 00:00:00 2001 From: Peter Kozak Date: Tue, 7 May 2013 14:44:01 +0200 Subject: set user_idle_text --- app/views/config_snom/show.xml.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/views/config_snom/show.xml.haml b/app/views/config_snom/show.xml.haml index 16a05d0..22df8bc 100644 --- a/app/views/config_snom/show.xml.haml +++ b/app/views/config_snom/show.xml.haml @@ -129,7 +129,7 @@ != "\