From 8c8788b0cc21809300a7a821c15f8d2b7cdf1f55 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 30 Aug 2015 09:15:51 +0200 Subject: [PATCH] Fixed some small email channel config bugs. Improved wording. --- .../app/controllers/_channel/email.js.coffee | 31 ++++++++-------- .../app/models/_application_model.js.coffee | 3 +- .../app/models/email_address.js.coffee | 2 +- .../javascripts/app/models/group.js.coffee | 4 +-- .../channel/email_account_overview.jst.eco | 35 ++++++++++--------- app/controllers/channels_controller.rb | 20 ++++++++++- ...50828000001_add_setting_online_service2.rb | 7 ++-- db/seeds.rb | 2 ++ 8 files changed, 65 insertions(+), 39 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_channel/email.js.coffee b/app/assets/javascripts/app/controllers/_channel/email.js.coffee index 7764bdb1b..9cc92f9b6 100644 --- a/app/assets/javascripts/app/controllers/_channel/email.js.coffee +++ b/app/assets/javascripts/app/controllers/_channel/email.js.coffee @@ -238,32 +238,35 @@ class App.ChannelEmailAccountOverview extends App.Controller # load assets App.Collection.loadAssets(data.assets) - @render(accounts_fixed: data.accounts_fixed) + @render(data) ) - render: (params = {}) => + render: (data = {}) => # get channels - channels = App.Channel.search( filter: { area: 'Email::Account' } ) - for channel in channels + account_channels = [] + for channel_id in data.account_channel_ids + account_channels.push App.Channel.fullLocal(channel_id) + + for channel in account_channels email_addresses = App.EmailAddress.search( filter: { channel_id: channel.id } ) channel.email_addresses = email_addresses # get all unlinked email addresses - email_addresses_all = App.EmailAddress.all() - email_addresses_not_used = [] - for email_address in email_addresses_all - if !email_address.channel_id || email_address.channel_id is '' - email_addresses_not_used.push email_address + not_used_email_addresses = [] + for email_address_id in data.not_used_email_address_ids + not_used_email_addresses.push App.EmailAddress.find(email_address_id) # get channels - channel = App.Channel.search( filter: { area: 'Email::Notification', active: true } )[0] + notification_channels = [] + for channel_id in data.notification_channel_ids + notification_channels.push App.Channel.find(channel_id) @html App.view('channel/email_account_overview')( - channels: channels - email_addresses_not_used: email_addresses_not_used - channel: channel - accounts_fixed: params.accounts_fixed + account_channels: account_channels + not_used_email_addresses: not_used_email_addresses + notification_channels: notification_channels + accounts_fixed: data.accounts_fixed ) wizard: (e) => diff --git a/app/assets/javascripts/app/models/_application_model.js.coffee b/app/assets/javascripts/app/models/_application_model.js.coffee index a67dd87f4..784ac3e1e 100644 --- a/app/assets/javascripts/app/models/_application_model.js.coffee +++ b/app/assets/javascripts/app/models/_application_model.js.coffee @@ -556,7 +556,8 @@ class App.Model extends Spine.Model item = App[ attribute.relation ]._fillUp(item, classNames.concat(@className)) data[ withoutId ] = item else - console.log("ERROR, cant find #{ attribute.name } App.#{ attribute.relation }.find(#{ data[attribute.name] }) for '#{ data.constructor.className }' #{ data.displayName() }") + if !attribute.do_not_log + console.log("ERROR, cant find #{ attribute.name } App.#{ attribute.relation }.find(#{ data[attribute.name] }) for '#{ data.constructor.className }' #{ data.displayName() }") data ### diff --git a/app/assets/javascripts/app/models/email_address.js.coffee b/app/assets/javascripts/app/models/email_address.js.coffee index 11b114dde..c1d435ed7 100644 --- a/app/assets/javascripts/app/models/email_address.js.coffee +++ b/app/assets/javascripts/app/models/email_address.js.coffee @@ -14,7 +14,7 @@ class App.EmailAddress extends App.Model @configure_attributes = [ { name: 'realname', display: 'Realname', tag: 'input', type: 'text', limit: 250, null: false }, { name: 'email', display: 'Email', tag: 'input', type: 'email', limit: 250, null: false }, - { name: 'channel_id', display: 'Channel', tag: 'select', multiple: false, null: true, relation: 'Channel', nulloption: true, filter: @filterChannel }, + { name: 'channel_id', display: 'Channel', tag: 'select', multiple: false, null: true, relation: 'Channel', nulloption: true, filter: @filterChannel, do_not_log: true }, { name: 'note', display: 'Note', tag: 'textarea', note: 'Notes are visible to agents only, never to customers.', limit: 250, null: true }, { name: 'updated_at', display: 'Updated', tag: 'datetime', readonly: 1 }, { name: 'active', display: 'Active', tag: 'active', readonly: 1 }, diff --git a/app/assets/javascripts/app/models/group.js.coffee b/app/assets/javascripts/app/models/group.js.coffee index b7dee1d74..b8690e110 100644 --- a/app/assets/javascripts/app/models/group.js.coffee +++ b/app/assets/javascripts/app/models/group.js.coffee @@ -8,8 +8,8 @@ class App.Group extends App.Model { name: 'assignment_timeout', display: 'Assignment Timeout', tag: 'input', note: 'Assignment timeout in minutes if assigned agent is not working on it. Ticket will be shown as unassigend.', type: 'text', limit: 100, null: true }, { name: 'follow_up_possible', display: 'Follow up possible',tag: 'select', default: 'yes', options: { yes: 'yes', reject: 'reject follow up/do not reopen Ticket', 'new_ticket': 'do not reopen Ticket but create new Ticket' }, null: false, note: 'Follow up for closed ticket possible or not.' }, { name: 'follow_up_assignment', display: 'Assign Follow Ups', tag: 'select', default: 'yes', options: { true: 'yes', false: 'no' }, 'null': false, note: 'Assign follow up to latest agent again.' }, - { name: 'email_address_id', display: 'Email', tag: 'select', multiple: false, null: true, relation: 'EmailAddress', nulloption: true }, - { name: 'signature_id', display: 'Signature', tag: 'select', multiple: false, null: true, relation: 'Signature', nulloption: true }, + { name: 'email_address_id', display: 'Email', tag: 'select', multiple: false, null: true, relation: 'EmailAddress', nulloption: true, do_not_log: true }, + { name: 'signature_id', display: 'Signature', tag: 'select', multiple: false, null: true, relation: 'Signature', nulloption: true, do_not_log: true }, { name: 'note', display: 'Note', tag: 'textarea', note: 'Notes are visible to agents only, never to customers.', limit: 250, null: true }, { name: 'updated_at', display: 'Updated', tag: 'datetime', readonly: 1 }, { name: 'active', display: 'Active', tag: 'active', default: true }, diff --git a/app/assets/javascripts/app/views/channel/email_account_overview.jst.eco b/app/assets/javascripts/app/views/channel/email_account_overview.jst.eco index ddd0ff59a..6d80700dd 100644 --- a/app/assets/javascripts/app/views/channel/email_account_overview.jst.eco +++ b/app/assets/javascripts/app/views/channel/email_account_overview.jst.eco @@ -1,6 +1,6 @@

<%- @T('Email Accounts') %>

-<% if @accounts_fixed: %> +<% if !_.isEmpty(@accounts_fixed): %>

<%- @T('Fixed email addresses') %>

<% end %> -<% if !_.isEmpty(@email_addresses_not_used): %> +<% if !_.isEmpty(@not_used_email_addresses): %>

<%- @T('Not linked email addresses') %>

<% end %> -<% if _.isEmpty(@channels): %> +<% if _.isEmpty(@account_channels): %>

<%- @T('You have no configured account right now.') %>

<% else: %> @@ -31,7 +31,7 @@ - <% for channel in @channels: %> + <% for channel in @account_channels: %>
<%- @T('State') %>: <%- @T(channel.status_in || 'unknown') %>
@@ -82,7 +82,7 @@ <%- @T('New') %> -<% if @channel && !App.Config.get('system_online_service'): %> +<% if !_.isEmpty(@notification_channels) && !App.Config.get('system_online_service'): %>

<%- @T('Notification Account') %>

@@ -92,25 +92,26 @@ - - + - <% if @channel.status_in is 'error': %> + <% if channel.status_in is 'error': %> - + <% end %> - <% if @channel.status_out is 'error': %> + <% if channel.status_out is 'error': %> - + <% end %> diff --git a/app/controllers/channels_controller.rb b/app/controllers/channels_controller.rb index a9bec86ee..f35a30a10 100644 --- a/app/controllers/channels_controller.rb +++ b/app/controllers/channels_controller.rb @@ -217,6 +217,10 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten def email_index return if deny_if_not_role(Z_ROLENAME_ADMIN) system_online_service = Setting.get('system_online_service') + account_channel_ids = [] + notification_channel_ids = [] + email_address_ids = [] + not_used_email_address_ids = [] accounts_fixed = [] assets = {} Channel.all.each {|channel| @@ -227,15 +231,29 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten } next end - assets = channel.assets(assets) + if channel.area == 'Email::Account' + account_channel_ids.push channel.id + assets = channel.assets(assets) + elsif channel.area == 'Email::Notification' && channel.active + notification_channel_ids.push channel.id + assets = channel.assets(assets) + end } EmailAddress.all.each {|email_address| next if system_online_service && email_address.preferences && email_address.preferences['online_service_disable'] + email_address_ids.push email_address.id assets = email_address.assets(assets) + if !email_address.channel_id || !email_address.active || !Channel.find_by(id: email_address.channel_id) + not_used_email_address_ids.push email_address.id + end } render json: { accounts_fixed: accounts_fixed, assets: assets, + account_channel_ids: account_channel_ids, + notification_channel_ids: notification_channel_ids, + email_address_ids: email_address_ids, + not_used_email_address_ids: not_used_email_address_ids, } end diff --git a/db/migrate/20150828000001_add_setting_online_service2.rb b/db/migrate/20150828000001_add_setting_online_service2.rb index 063c85910..0d8502042 100644 --- a/db/migrate/20150828000001_add_setting_online_service2.rb +++ b/db/migrate/20150828000001_add_setting_online_service2.rb @@ -11,9 +11,10 @@ class AddSettingOnlineService2 < ActiveRecord::Migration } Channel.where(area: 'Email::Account').each {|channel| next if !channel.options - next if !channel.options[:options] - next if !channel.options[:options][:host] - next if channel.options[:options][:host] !~ /zammad/i + next if !channel.options[:inbound][:options] + next if !channel.options[:inbound][:options][:host] + next if channel.options[:inbound][:options][:host] !~ /zammad/i + channel.preferences = {} channel.preferences[:online_service_disable] = true channel.save } diff --git a/db/seeds.rb b/db/seeds.rb index 32c49fa14..223ce7baa 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1757,6 +1757,7 @@ Channel.create_if_not_exists( }, }, group_id: 1, + preferences: { online_service_disable: true }, active: false, ) Channel.create_if_not_exists( @@ -1766,6 +1767,7 @@ Channel.create_if_not_exists( adapter: 'sendmail', }, }, + preferences: { online_service_disable: true }, active: true, )
- <%- @T('State') %>: <%- @T(@channel.status_out || 'unknown') %>
+ <% for channel in @notification_channels: %> +
+ <%- @T('State') %>: <%- @T(channel.status_out || 'unknown') %>
- <% if @channel.options.outbound && @channel.options.outbound.options: %> - <%= @channel.options.outbound.options.user %>
- <%= @channel.options.outbound.options.host %> + <% if channel.options.outbound && channel.options.outbound.options: %> + <%= channel.options.outbound.options.user %>
+ <%= channel.options.outbound.options.host %> <% end %> - (<%= @channel.options.outbound.adapter %>)
+ (<%= channel.options.outbound.adapter %>)
<%= @channel.last_log_in %><%= channel.last_log_in %>
<%= @channel.last_log_out %><%= channel.last_log_out %>