Fixed naming and added split of url to fqdn and http_type.

This commit is contained in:
Martin Edenhofer 2014-10-22 23:26:00 +02:00
parent 29115451cd
commit bf1f53d60f
3 changed files with 24 additions and 16 deletions

View file

@ -45,7 +45,7 @@ class Base extends App.ControllerContent
className: 'getstarted fit' className: 'getstarted fit'
events: events:
'change [name=adapter]': 'toggleAdapter' 'change [name=adapter]': 'toggleAdapter'
'submit .base': 'storeFqdn' 'submit .base': 'storeUrl'
'submit .base-outbound': 'storeOutbound' 'submit .base-outbound': 'storeOutbound'
'submit .base-inbound': 'storeInbound' 'submit .base-inbound': 'storeInbound'
'click .js-next': 'submit' 'click .js-next': 'submit'
@ -87,12 +87,12 @@ class Base extends App.ControllerContent
@html App.view('getting_started/base')() @html App.view('getting_started/base')()
# fqdn # url
configureAttributesBase = [ configureAttributesBase = [
{ name: 'fqdn', display: 'System URL (where the system can be reached)', tag: 'input', null: false, placeholder: 'http://yourhost' }, { name: 'url', display: 'System URL (where the system can be reached)', tag: 'input', null: false, placeholder: 'http://yourhost' },
] ]
new App.ControllerForm( new App.ControllerForm(
el: @$('.base-fqdn'), el: @$('.base-url'),
model: { configure_attributes: configureAttributesBase, className: '' }, model: { configure_attributes: configureAttributesBase, className: '' },
) )
@ -163,7 +163,7 @@ class Base extends App.ControllerContent
@$('.wizard-controls .btn').text('Check').attr('data-form', 'base-inbound').addClass('btn--primary').removeClass('btn--danger').removeClass('btn--success') @$('.wizard-controls .btn').text('Check').attr('data-form', 'base-inbound').addClass('btn--primary').removeClass('btn--danger').removeClass('btn--success')
@enable( @$('.btn') ) @enable( @$('.btn') )
storeFqdn: (e) => storeUrl: (e) =>
e.preventDefault() e.preventDefault()
# get params # get params
@ -172,10 +172,10 @@ class Base extends App.ControllerContent
@disable(e) @disable(e)
@ajax( @ajax(
id: 'base_fqdn' id: 'base_url'
type: 'POST' type: 'POST'
url: @apiPath + '/getting_started/base_fqdn' url: @apiPath + '/getting_started/base_url'
data: JSON.stringify( {fqdn:params.fqdn} ) data: JSON.stringify( {url:params.url} )
processData: true processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
if data.result is 'ok' if data.result is 'ok'

View file

@ -7,7 +7,7 @@
</ol> </ol>
<form class="base"> <form class="base">
<div class="base-fqdn"></div> <div class="base-url"></div>
</form> </form>
@ -20,7 +20,6 @@
<form class="base-inbound hide"> <form class="base-inbound hide">
<%- @T('E-Mail Inbound') %> <%- @T('E-Mail Inbound') %>
<div class="base-inbound-settings"></div> <div class="base-inbound-settings"></div>
<div class="base-inbound-state"></div>
</form> </form>
<div class="wizard-controls horizontal center"> <div class="wizard-controls horizontal center">

View file

@ -47,23 +47,32 @@ curl http://localhost/api/v1/getting_started.json -v -u #{login}:#{password}
} }
end end
def base_fqdn def base_url
return if setup_done_response return if setup_done_response
# validate # validate
if !params[:fqdn] ||params[:fqdn] !~ /^(http|https):\/\/.+?$/ if !params[:url] ||params[:url] !~ /^(http|https):\/\/.+?$/
render :json => { render :json => {
:result => 'invalid', :result => 'invalid',
:message => 'Invalid!', :message => 'Invalid!',
} }
return true return
end end
Setting.set('fqdn', params[:fqdn]) # split url in http_type and fqdn
if params[:url] =~ /^(http|https):\/\/(.+?)$/
Setting.set('http_type', $1)
Setting.set('fqdn', $2)
render :json => {
:result => 'ok',
}
return
end
# return result
render :json => { render :json => {
:result => 'ok', :result => 'invalid',
:message => 'Unable to parse url!',
} }
end end