Used possible channels from backend.

This commit is contained in:
Martin Edenhofer 2015-09-01 01:12:51 +02:00
parent bcc72a9793
commit e530383cf2
7 changed files with 101 additions and 68 deletions

View file

@ -243,6 +243,8 @@ class App.ChannelEmailAccountOverview extends App.Controller
render: (data = {}) =>
@channelDriver = data.channel_driver
# get channels
account_channels = []
for channel_id in data.account_channel_ids
@ -272,8 +274,9 @@ class App.ChannelEmailAccountOverview extends App.Controller
wizard: (e) =>
e.preventDefault()
new App.ChannelEmailAccountWizard(
container: @el.closest('.content')
callback: @load
container: @el.closest('.content')
callback: @load
channelDriver: @channelDriver
)
edit_inbound: (e) =>
@ -282,10 +285,11 @@ class App.ChannelEmailAccountOverview extends App.Controller
channel = App.Channel.find(id)
slide = 'js-inbound'
new App.ChannelEmailAccountWizard(
container: @el.closest('.content')
slide: slide
channel: channel
callback: @load
container: @el.closest('.content')
slide: slide
channel: channel
callback: @load
channelDriver: @channelDriver
)
edit_outbound: (e) =>
@ -294,10 +298,11 @@ class App.ChannelEmailAccountOverview extends App.Controller
channel = App.Channel.find(id)
slide = 'js-outbound'
new App.ChannelEmailAccountWizard(
container: @el.closest('.content')
slide: slide
channel: channel
callback: @load
container: @el.closest('.content')
slide: slide
channel: channel
callback: @load
channelDriver: @channelDriver
)
delete: (e) =>
@ -341,9 +346,10 @@ class App.ChannelEmailAccountOverview extends App.Controller
channel = App.Channel.find(id)
slide = 'js-outbound'
new App.ChannelEmailNotificationWizard(
container: @el.closest('.content')
channel: channel
callback: @load
container: @el.closest('.content')
channel: channel
callback: @load
channelDriver: @channelDriver
)
class App.ChannelEmailAccountWizard extends App.Wizard
@ -403,11 +409,8 @@ class App.ChannelEmailAccountWizard extends App.Wizard
@showSlide('js-intro')
# outbound
adapters =
sendmail: 'Local MTA (Sendmail/Postfix/Exim/...) - use server setup'
smtp: 'SMTP - configure your own outgoing SMTP settings'
configureAttributesOutbound = [
{ name: 'adapter', display: 'Send Mails via', tag: 'select', multiple: false, null: false, options: adapters },
{ name: 'adapter', display: 'Send Mails via', tag: 'select', multiple: false, null: false, options: @channelDriver.email.outbound },
]
new App.ControllerForm(
el: @$('.base-outbound-type')
@ -421,7 +424,7 @@ class App.ChannelEmailAccountWizard extends App.Wizard
# inbound
configureAttributesInbound = [
{ name: 'adapter', display: 'Type', tag: 'select', multiple: false, null: false, options: { imap: 'imap', pop3: 'pop3' } },
{ name: 'adapter', display: 'Type', tag: 'select', multiple: false, null: false, options: @channelDriver.email.inbound },
{ name: 'options::host', display: 'Host', tag: 'input', type: 'text', limit: 120, null: false, autocapitalize: false },
{ name: 'options::user', display: 'User', tag: 'input', type: 'text', limit: 120, null: false, autocapitalize: false, autocomplete: 'off', },
{ name: 'options::password', display: 'Password', tag: 'input', type: 'password', limit: 120, null: false, autocapitalize: false, autocomplete: 'new-password', single: true },
@ -700,11 +703,8 @@ class App.ChannelEmailNotificationWizard extends App.Wizard
@showSlide('js-outbound')
# outbound
adapters =
sendmail: 'Local MTA (Sendmail/Postfix/Exim/...) - use server setup'
smtp: 'SMTP - configure your own outgoing SMTP settings'
configureAttributesOutbound = [
{ name: 'adapter', display: 'Send Mails via', tag: 'select', multiple: false, null: false, options: adapters },
{ name: 'adapter', display: 'Send Mails via', tag: 'select', multiple: false, null: false, options: @channelDriver.email.outbound },
]
new App.ControllerForm(
el: @$('.base-outbound-type')

View file

@ -404,13 +404,10 @@ class EmailNotification extends App.Wizard
# set title
@title 'Email Notifications'
@adapters = [
{
name: 'Email'
class: 'email'
link: '#getting_started/channel/email'
},
]
@channelDriver =
email:
inbound: {}
outbound: {}
@fetch()
@ -432,43 +429,45 @@ class EmailNotification extends App.Wizard
@navigate '#import/' + data.import_backend
return
@channelDriver = data.channel_driver
# render page
@render()
)
render: ->
@html App.view('getting_started/email_notification')()
adapters =
sendmail: 'Local MTA (Sendmail/Postfix/Exim/...) - use server setup'
smtp: 'SMTP - configure your own outgoing SMTP settings'
adapter_used = 'sendmail'
configureAttributesOutbound = [
{ name: 'adapter', display: 'Send Mails via', tag: 'select', multiple: false, null: false, options: adapters , default: adapter_used },
{ name: 'adapter', display: 'Send Mails via', tag: 'select', multiple: false, null: false, options: @channelDriver.email.outbound },
]
new App.ControllerForm(
el: @$('.base-outbound-type'),
model: { configure_attributes: configureAttributesOutbound, className: '' },
el: @$('.base-outbound-type')
model:
configure_attributes: configureAttributesOutbound
className: ''
params:
adapter: @account.outbound.adapter || 'sendmail'
)
@toggleOutboundAdapter()
toggleOutboundAdapter: =>
# show used backend
channel_used = { options: {} }
@el.find('.base-outbound-settings').html('')
adapter = @$('.js-outbound [name=adapter]').val()
if adapter is 'smtp'
configureAttributesOutbound = [
{ name: 'options::host', display: 'Host', tag: 'input', type: 'text', limit: 120, null: false, autocapitalize: false, autofocus: true, default: (channel_used['options']&&channel_used['options']['host']) },
{ name: 'options::user', display: 'User', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false, autocomplete: 'off', default: (channel_used['options']&&channel_used['options']['user']) },
{ name: 'options::password', display: 'Password', tag: 'input', type: 'password', limit: 120, null: true, autocapitalize: false, autocomplete: 'new-password', single: true, default: (channel_used['options']&&channel_used['options']['password']) },
{ name: 'options::host', display: 'Host', tag: 'input', type: 'text', limit: 120, null: false, autocapitalize: false, autofocus: true },
{ name: 'options::user', display: 'User', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false, autocomplete: 'off' },
{ name: 'options::password', display: 'Password', tag: 'input', type: 'password', limit: 120, null: true, autocapitalize: false, autocomplete: 'new-password', single: true },
]
@form = new App.ControllerForm(
el: @$('.base-outbound-settings')
model: { configure_attributes: configureAttributesOutbound, className: '' }
model:
configure_attributes: configureAttributesOutbound
className: ''
params: @account.outbound
)
else
@el.find('.base-outbound-settings').html('')
submit: (e) =>
e.preventDefault()
@ -634,6 +633,11 @@ class ChannelEmail extends App.Wizard
outbound: {}
meta: {}
@channelDriver =
email:
inbound: {}
outbound: {}
@fetch()
release: =>
@ -654,6 +658,8 @@ class ChannelEmail extends App.Wizard
@navigate '#import/' + data.import_backend
return
@channelDriver = data.channel_driver
# render page
@render()
)
@ -664,29 +670,32 @@ class ChannelEmail extends App.Wizard
@showSlide('js-intro')
# outbound
adapters =
sendmail: 'Local MTA (Sendmail/Postfix/Exim/...) - use server setup'
smtp: 'SMTP - configure your own outgoing SMTP settings'
adapter_used = 'smtp'
configureAttributesOutbound = [
{ name: 'adapter', display: 'Send Mails via', tag: 'select', multiple: false, null: false, options: adapters , default: adapter_used },
{ name: 'adapter', display: 'Send Mails via', tag: 'select', multiple: false, null: false, options: @channelDriver.email.outbound },
]
new App.ControllerForm(
el: @$('.base-outbound-type'),
model: { configure_attributes: configureAttributesOutbound, className: '' },
el: @$('.base-outbound-type')
model:
configure_attributes: configureAttributesOutbound
className: ''
params:
adapter: @account.outbound.adapter || 'smtp'
)
@toggleOutboundAdapter()
# inbound
configureAttributesInbound = [
{ name: 'adapter', display: 'Type', tag: 'select', multiple: false, null: false, options: { imap: 'IMAP', pop3: 'POP3' } },
{ name: 'adapter', display: 'Type', tag: 'select', multiple: false, null: false, options: @channelDriver.email.inbound },
{ name: 'options::host', display: 'Host', tag: 'input', type: 'text', limit: 120, null: false, autocapitalize: false },
{ name: 'options::user', display: 'User', tag: 'input', type: 'text', limit: 120, null: false, autocapitalize: false, autocomplete: 'off', },
{ name: 'options::password', display: 'Password', tag: 'input', type: 'password', limit: 120, null: false, autocapitalize: false, autocomplete: 'new-password', single: true },
]
new App.ControllerForm(
el: @$('.base-inbound-settings'),
model: { configure_attributes: configureAttributesInbound, className: '' },
model:
configure_attributes: configureAttributesInbound
className: ''
params: @account.inbound
)
toggleOutboundAdapter: =>
@ -702,16 +711,17 @@ class ChannelEmail extends App.Wizard
adapter = @$('.js-outbound [name=adapter]').val()
if adapter is 'smtp'
configureAttributesOutbound = [
{ name: 'options::host', display: 'Host', tag: 'input', type: 'text', limit: 120, null: false, autocapitalize: false, autofocus: true, default: (channel_used['options']&&channel_used['options']['host']) },
{ name: 'options::user', display: 'User', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false, autocomplete: 'off', default: (channel_used['options']&&channel_used['options']['user']) },
{ name: 'options::password', display: 'Password', tag: 'input', type: 'password', limit: 120, null: true, autocapitalize: false, autocomplete: 'new-password', single: true, default: (channel_used['options']&&channel_used['options']['password']) },
{ name: 'options::host', display: 'Host', tag: 'input', type: 'text', limit: 120, null: false, autocapitalize: false, autofocus: true },
{ name: 'options::user', display: 'User', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false, autocomplete: 'off', },
{ name: 'options::password', display: 'Password', tag: 'input', type: 'password', limit: 120, null: true, autocapitalize: false, autocomplete: 'new-password', single: true },
]
@form = new App.ControllerForm(
el: @$('.base-outbound-settings')
model: { configure_attributes: configureAttributesOutbound, className: '' }
model:
configure_attributes: configureAttributesOutbound
className: ''
params: @account.outbound
)
else
@el.find('.base-outbound-settings').html('')
probeBasedOnIntro: (e) =>
e.preventDefault()

View file

@ -62,6 +62,9 @@ curl http://localhost/api/v1/channels.json -v -u #{login}:#{password} -H "Conten
notification_channel_ids: notification_channel_ids,
email_address_ids: email_address_ids,
not_used_email_address_ids: not_used_email_address_ids,
channel_driver: {
email: EmailHelper.available_driver,
}
}
end

View file

@ -226,6 +226,9 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
addresses: addresses,
groups: groups,
config: config_to_update,
channel_driver: {
email: EmailHelper.available_driver,
},
}
true
end

View file

@ -9,8 +9,14 @@ get available driver
returns
{
:inbound => ['imap', 'pop3'],
:outbound => ['smtp', 'sendmail'],
inbound: {
imap: 'IMAP',
pop3: 'POP3',
},
outbound: {
smtp: 'SMTP - configure your own outgoing SMTP settings',
sendmail: 'Local MTA (Sendmail/Postfix/Exim/...) - use server setup',
},
}
=end
@ -18,13 +24,24 @@ returns
def self.available_driver
if Setting.get('system_online_service')
return {
inbound: %w(imap pop3),
outbound: %w(smtp),
inbound: {
imap: 'IMAP',
pop3: 'POP3',
},
outbound: {
smtp: 'SMTP - configure your own outgoing SMTP settings',
},
}
end
{
inbound: %w(imap pop3),
outbound: %w(smtp sendmail),
inbound: {
imap: 'IMAP',
pop3: 'POP3',
},
outbound: {
smtp: 'SMTP - configure your own outgoing SMTP settings',
sendmail: 'Local MTA (Sendmail/Postfix/Exim/...) - use server setup',
},
}
end

View file

@ -189,7 +189,7 @@ returns on fail
adapter = params[:adapter].downcase
# validate adapter
if !EmailHelper.available_driver[:inbound].include?(adapter)
if !EmailHelper.available_driver[:inbound][adapter.to_sym]
return {
result: 'failed',
message: "Unknown adapter '#{adapter}'",
@ -268,7 +268,7 @@ returns on fail
adapter = params[:adapter].downcase
# validate adapter
if !EmailHelper.available_driver[:outbound].include?(adapter)
if !EmailHelper.available_driver[:outbound][adapter.to_sym]
return {
result: 'failed',
message: "Unknown adapter '#{adapter}'",

View file

@ -69,7 +69,7 @@ or
# validate adapter
adapter = params[:inbound][:adapter].downcase
if !EmailHelper.available_driver[:inbound].include?(adapter)
if !EmailHelper.available_driver[:inbound][adapter.to_sym]
return {
result: 'failed',
message: "Unknown adapter '#{adapter}'",