diff --git a/app/assets/javascripts/app/controllers/getting_started.js.coffee b/app/assets/javascripts/app/controllers/getting_started.js.coffee index 5b74e861a..dd1f50296 100644 --- a/app/assets/javascripts/app/controllers/getting_started.js.coffee +++ b/app/assets/javascripts/app/controllers/getting_started.js.coffee @@ -276,7 +276,10 @@ class Base extends App.ControllerContent if data.result is 'ok' for key, value of data.settings App.Config.set( key, value ) - @navigate 'getting_started/channel' + if App.Config.get('system_online_service') + @navigate 'getting_started/channel/email_pre_configured' + else + @navigate 'getting_started/channel' else for key, value of data.messages @showAlert( key, value ) @@ -356,6 +359,50 @@ class Channel extends App.ControllerContent App.Config.set( 'getting_started/channel', Channel, 'Routes' ) +class ChannelEmailPreConfigured extends App.ControllerContent + className: 'getstarted fit' + + constructor: -> + super + + # redirect if we are not admin + if !@authenticate(true) + @navigate '#' + return + + # set title + @title 'Connect Channels' + + @fetch() + + release: => + @el.removeClass('fit getstarted') + + fetch: -> + + # get data + @ajax( + id: 'getting_started', + type: 'GET', + url: @apiPath + '/getting_started', + processData: true, + success: (data, status, xhr) => + + # check if import is active + if data.import_mode == true + @navigate '#import/' + data.import_backend + return + + # render page + @render(data) + ) + + render: (data) -> + @html App.view('getting_started/email_pre_configured')( + data + ) + +App.Config.set( 'getting_started/channel/email_pre_configured', ChannelEmailPreConfigured, 'Routes' ) class ChannelEmail extends App.ControllerContent className: 'getstarted fit' 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 24cf64be7..b0bd7c134 100644 --- a/app/assets/javascripts/app/views/getting_started/base.jst.eco +++ b/app/assets/javascripts/app/views/getting_started/base.jst.eco @@ -17,12 +17,14 @@
<%- @T('Your Logo') %>
<%- @T('Upload') %>
+ <% if !@C('system_online_service'): %>

The URL to this installation of Zammad.

+ <% end %>
diff --git a/app/assets/javascripts/app/views/getting_started/email_pre_configured.jst.eco b/app/assets/javascripts/app/views/getting_started/email_pre_configured.jst.eco new file mode 100644 index 000000000..419e8c695 --- /dev/null +++ b/app/assets/javascripts/app/views/getting_started/email_pre_configured.jst.eco @@ -0,0 +1,21 @@ +
+ +
+
+

<%- @T('Connect Channels') %>

+
+

<%- @T('Your Zammad as the following email address.') %>

+ <% if @addresses: %> + <% for address in @addresses: %> +

<%= address.realname %> <<%= address.email %>>

+ <% end %> + <% end %> +

<%- @T('If you want to use more email adresses, you can configure them later.') %>

+
+ +
+
+
\ No newline at end of file diff --git a/app/controllers/getting_started_controller.rb b/app/controllers/getting_started_controller.rb index d066c72f2..26281dc60 100644 --- a/app/controllers/getting_started_controller.rb +++ b/app/controllers/getting_started_controller.rb @@ -39,15 +39,12 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password} return if !authentication_check end - # get all groups - groups = Group.where( :active => true ) - # return result render :json => { - :setup_done => setup_done, - :import_mode => Setting.get('import_mode'), - :import_backend => Setting.get('import_backend'), - :groups => groups, + :setup_done => setup_done, + :import_mode => Setting.get('import_mode'), + :import_backend => Setting.get('import_backend'), + :system_online_service => Setting.get('system_online_service'), } end @@ -58,8 +55,10 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password} # validate url messages = {} - if !params[:url] ||params[:url] !~ /^(http|https):\/\/.+?$/ - messages[:url] = 'A URL looks like http://zammad.example.com' + if !Setting.get('system_online_service') + if !params[:url] ||params[:url] !~ /^(http|https):\/\/.+?$/ + messages[:url] = 'A URL looks like http://zammad.example.com' + end end # validate organization @@ -87,11 +86,13 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password} # split url in http_type and fqdn settings = {} - if params[:url] =~ /^(http|https):\/\/(.+?)$/ - Setting.set('http_type', $1) - settings[:http_type] = $1 - Setting.set('fqdn', $2) - settings[:fqdn] = $2 + if !Setting.get('system_online_service') + if params[:url] =~ /^(http|https):\/\/(.+?)$/ + Setting.set('http_type', $1) + settings[:http_type] = $1 + Setting.set('fqdn', $2) + settings[:fqdn] = $2 + end end # save organization @@ -595,7 +596,10 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password} if found && found == 'verify ok' # remember address - address = EmailAddress.all.first + address = EmailAddress.where( :email => params[:meta][:email] ).first + if !address + address = EmailAddress.first + end if address address.update_attributes( :realname => params[:meta][:realname], @@ -863,10 +867,20 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password} if !setup_done return false end + + # get all groups + groups = Group.where( :active => true ) + + # get email addresses + addresses = EmailAddress.where( :active => true ) + render :json => { - :setup_done => true, - :import_mode => Setting.get('import_mode'), - :import_backend => Setting.get('import_backend'), + :setup_done => true, + :import_mode => Setting.get('import_mode'), + :import_backend => Setting.get('import_backend'), + :system_online_service => Setting.get('system_online_service'), + :addresses => addresses, + :groups => groups, } true end diff --git a/db/migrate/20141120000001_update_setting3.rb b/db/migrate/20141120000001_update_setting3.rb new file mode 100644 index 000000000..4c0a2414f --- /dev/null +++ b/db/migrate/20141120000001_update_setting3.rb @@ -0,0 +1,16 @@ +class UpdateSetting3 < ActiveRecord::Migration + def up + Setting.create_if_not_exists( + :title => 'Online Service', + :name => 'system_online_service', + :area => 'Core', + :description => 'Defines if application is used as online service.', + :options => {}, + :state => false, + :frontend => true + ) + end + + def down + end +end \ No newline at end of file diff --git a/db/seeds.rb b/db/seeds.rb index 0314b8533..33c7369b3 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -15,6 +15,15 @@ Setting.create_if_not_exists( :state => false, :frontend => true ) +Setting.create_if_not_exists( + :title => 'Online Service', + :name => 'system_online_service', + :area => 'Core', + :description => 'Defines if application is used as online service.', + :options => {}, + :state => false, + :frontend => true +) Setting.create_if_not_exists( :title => 'Product Name', :name => 'product_name',