Some small improvements to email channel management.

This commit is contained in:
Martin Edenhofer 2015-08-30 01:31:11 +02:00
parent ad732e298c
commit a009cb0935
3 changed files with 85 additions and 63 deletions

View file

@ -236,12 +236,12 @@ class App.ChannelEmailAccountOverview extends App.Controller
success: (data, status, xhr) =>
# load assets
App.Collection.loadAssets( data.assets )
App.Collection.loadAssets(data.assets)
@render()
@render(accounts_fixed: data.accounts_fixed)
)
render: =>
render: (params = {}) =>
# get channels
channels = App.Channel.search( filter: { area: 'Email::Account' } )
@ -260,9 +260,10 @@ class App.ChannelEmailAccountOverview extends App.Controller
channel = App.Channel.search( filter: { area: 'Email::Notification', active: true } )[0]
@html App.view('channel/email_account_overview')(
channels: channels
channels: channels
email_addresses_not_used: email_addresses_not_used
channel: channel
channel: channel
accounts_fixed: params.accounts_fixed
)
wizard: (e) =>

View file

@ -1,5 +1,14 @@
<h1><%- @T('Email Accounts') %></h1>
<% if @accounts_fixed: %>
<h2><%- @T('Fixed email addresses') %></h2>
<ul>
<% for email_address in @accounts_fixed: %>
<li><%= email_address.realname %>&lt;<%= email_address.email %>&gt;
<% end %>
</ul>
<% end %>
<% if !_.isEmpty(@email_addresses_not_used): %>
<h2><%- @T('Not linked email addresses') %></h2>
<ul>
@ -9,63 +18,67 @@
</ul>
<% end %>
<table class="table table-hover user-list">
<thead>
<tr>
<th><%- @T('Inbound') %></th>
<th><%- @T('Outbound') %></th>
<th><%- @T('Email Adresses') %></th>
<th><%- @T('Action') %></th>
</tr>
</thead>
<tbody>
<% for channel in @channels: %>
<tr data-id="<%- channel.id %>">
<td class="<% if channel.status_in is 'ok': %>success<% else if channel.status_in is 'error': %>danger<% else: %>warning<% end %>">
<%- @T('State') %>: <%- @T(channel.status_in || 'unknown') %><br>
<a href="#" data-type="edit-inbound">
<%= channel.options.inbound.options.user %><br>
<%= channel.options.inbound.options.host %> (<%= channel.options.inbound.adapter %>)
</a>
</td>
<td class="<% if channel.status_out is 'ok': %>success<% else if channel.status_out is 'error': %>danger<% else: %>warning<% end %>">
<%- @T('State') %>: <%- @T(channel.status_out || 'unknown') %><br>
<a href="#" data-type="edit-outbound">
<% if channel.options.outbound && channel.options.outbound.options: %>
<%= channel.options.outbound.options.user %><br>
<%= channel.options.outbound.options.host %>
<% end %>
(<%= channel.options.outbound.adapter %>)</a>
</td>
<td>
<ul>
<% if !_.isEmpty(channel.email_addresses): %>
<% for email_address in channel.email_addresses: %>
<li data-id="<%= email_address.id %>"><a href="" data-type="email-address-edit"><%= email_address.email %></a>
<% if _.isEmpty(@channels): %>
<p><%- @T('You have no configured account right now.') %></p>
<% else: %>
<table class="table table-hover user-list">
<thead>
<tr>
<th><%- @T('Inbound') %></th>
<th><%- @T('Outbound') %></th>
<th><%- @T('Email Adresses') %></th>
<th><%- @T('Action') %></th>
</tr>
</thead>
<tbody>
<% for channel in @channels: %>
<tr data-id="<%- channel.id %>">
<td class="<% if channel.status_in is 'ok': %>success<% else if channel.status_in is 'error': %>danger<% else: %>warning<% end %>">
<%- @T('State') %>: <%- @T(channel.status_in || 'unknown') %><br>
<a href="#" data-type="edit-inbound">
<%= channel.options.inbound.options.user %><br>
<%= channel.options.inbound.options.host %> (<%= channel.options.inbound.adapter %>)
</a>
</td>
<td class="<% if channel.status_out is 'ok': %>success<% else if channel.status_out is 'error': %>danger<% else: %>warning<% end %>">
<%- @T('State') %>: <%- @T(channel.status_out || 'unknown') %><br>
<a href="#" data-type="edit-outbound">
<% if channel.options.outbound && channel.options.outbound.options: %>
<%= channel.options.outbound.options.user %><br>
<%= channel.options.outbound.options.host %>
<% end %>
<% else: %>
<li><%- @T('none') %></li>
<% end %>
</ul>
<a href="#" data-type="email-address-new" title="<%- @Ti('New Email Address') %>"><svg class="icon-trash"><use xlink:href="#icon-plus"></use></svg></a>
</td>
<td>
<a href="#" data-type="delete" title="<%- @Ti('Delete') %>"><svg class="icon-trash"><use xlink:href="#icon-trash"></use></svg></a>
</td>
</tr>
<% if channel.status_in is 'error': %>
<tr>
<td colspan="4"><%= channel.last_log_in %></td>
</tr>
<% end %>
<% if channel.status_out is 'error': %>
<tr>
<td colspan="4"><%= channel.last_log_out %></td>
</tr>
<% end %>
(<%= channel.options.outbound.adapter %>)</a>
</td>
<td>
<ul>
<% if !_.isEmpty(channel.email_addresses): %>
<% for email_address in channel.email_addresses: %>
<li data-id="<%= email_address.id %>"><a href="" data-type="email-address-edit"><%= email_address.email %></a>
<% end %>
<% else: %>
<li><%- @T('none') %></li>
<% end %>
</ul>
<a href="#" data-type="email-address-new" title="<%- @Ti('New Email Address') %>"><svg class="icon-trash"><use xlink:href="#icon-plus"></use></svg></a>
</td>
<td>
<a href="#" data-type="delete" title="<%- @Ti('Delete') %>"><svg class="icon-trash"><use xlink:href="#icon-trash"></use></svg></a>
</td>
</tr>
<% if channel.status_in is 'error': %>
<tr>
<td colspan="4"><%= channel.last_log_in %></td>
</tr>
<% end %>
<% if channel.status_out is 'error': %>
<tr>
<td colspan="4"><%= channel.last_log_out %></td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
<% end %>
</tbody>
</table>
<a data-type="new" class="btn btn--success"><%- @T('New') %></a>

View file

@ -217,17 +217,25 @@ 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')
accounts_fixed = []
assets = {}
Channel.all.each {|channel|
next if system_online_service && channel.preferences && channel.preferences[:online_service_disable]
if system_online_service && channel.preferences && channel.preferences['online_service_disable']
email_addresses = EmailAddress.where(channel_id: channel.id)
email_addresses.each {|email_address|
accounts_fixed.push email_address
}
next
end
assets = channel.assets(assets)
}
EmailAddress.all.each {|email_address|
next if system_online_service && email_address.preferences && email_address.preferences[:online_service_disable]
next if system_online_service && email_address.preferences && email_address.preferences['online_service_disable']
assets = email_address.assets(assets)
}
render json: {
assets: assets
accounts_fixed: accounts_fixed,
assets: assets,
}
end