From bf1f53d60f951acaeb0210dedd0d5da54f4050b5 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 22 Oct 2014 23:26:00 +0200 Subject: [PATCH] Fixed naming and added split of url to fqdn and http_type. --- .../app/controllers/getting_started.js.coffee | 16 +++++++------- .../app/views/getting_started/base.jst.eco | 3 +-- app/controllers/getting_started_controller.rb | 21 +++++++++++++------ 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/app/assets/javascripts/app/controllers/getting_started.js.coffee b/app/assets/javascripts/app/controllers/getting_started.js.coffee index fd3882b82..f2ae337e9 100644 --- a/app/assets/javascripts/app/controllers/getting_started.js.coffee +++ b/app/assets/javascripts/app/controllers/getting_started.js.coffee @@ -45,7 +45,7 @@ class Base extends App.ControllerContent className: 'getstarted fit' events: 'change [name=adapter]': 'toggleAdapter' - 'submit .base': 'storeFqdn' + 'submit .base': 'storeUrl' 'submit .base-outbound': 'storeOutbound' 'submit .base-inbound': 'storeInbound' 'click .js-next': 'submit' @@ -87,12 +87,12 @@ class Base extends App.ControllerContent @html App.view('getting_started/base')() - # fqdn + # url 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( - el: @$('.base-fqdn'), + el: @$('.base-url'), 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') @enable( @$('.btn') ) - storeFqdn: (e) => + storeUrl: (e) => e.preventDefault() # get params @@ -172,10 +172,10 @@ class Base extends App.ControllerContent @disable(e) @ajax( - id: 'base_fqdn' + id: 'base_url' type: 'POST' - url: @apiPath + '/getting_started/base_fqdn' - data: JSON.stringify( {fqdn:params.fqdn} ) + url: @apiPath + '/getting_started/base_url' + data: JSON.stringify( {url:params.url} ) processData: true success: (data, status, xhr) => if data.result is 'ok' diff --git a/app/assets/javascripts/app/views/getting_started/base.jst.eco b/app/assets/javascripts/app/views/getting_started/base.jst.eco index aed068680..aa2806866 100644 --- a/app/assets/javascripts/app/views/getting_started/base.jst.eco +++ b/app/assets/javascripts/app/views/getting_started/base.jst.eco @@ -7,7 +7,7 @@
-
+
@@ -20,7 +20,6 @@
<%- @T('E-Mail Inbound') %>
-
diff --git a/app/controllers/getting_started_controller.rb b/app/controllers/getting_started_controller.rb index d98fe7911..6a6d10ba1 100644 --- a/app/controllers/getting_started_controller.rb +++ b/app/controllers/getting_started_controller.rb @@ -47,23 +47,32 @@ curl http://localhost/api/v1/getting_started.json -v -u #{login}:#{password} } end - def base_fqdn + def base_url return if setup_done_response # validate - if !params[:fqdn] ||params[:fqdn] !~ /^(http|https):\/\/.+?$/ + if !params[:url] ||params[:url] !~ /^(http|https):\/\/.+?$/ render :json => { :result => 'invalid', :message => 'Invalid!', } - return true + return 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 => { - :result => 'ok', + :result => 'invalid', + :message => 'Unable to parse url!', } end