Added setting for system_online_service to check if it's used in hosted mode.

This commit is contained in:
Martin Edenhofer 2014-11-20 17:04:31 +01:00
parent 46b6d0de08
commit ff47b7f707
6 changed files with 128 additions and 19 deletions

View file

@ -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'

View file

@ -17,12 +17,14 @@
<div class="logo-preview-placeholder"><%- @T('Your Logo') %></div>
<div class="btn btn--success fileUpload"><%- @T('Upload') %><input type="file" class="js-upload" name="logo" accept="image/*"></div>
</div>
<% if !@C('system_online_service'): %>
<div class="form-group">
<label><%- @T('System URL') %></label>
<div class="alert alert--danger hide" role="alert"></div>
<input type="text" class="form-control" name="url" value="<%= @url %>" placeholder="http://zammad.example.com" required>
<p class="help-block">The URL to this installation of Zammad.</p>
</div>
<% end %>
</fieldset>
</div>
<div class="wizard-controls center">

View file

@ -0,0 +1,21 @@
<div class="main flex vertical centered darkBackground">
<img class="zammad full logo" src="<%= @C('image_path') + '/' + 'full logo on dark.svg' %>" alt="Zammad">
<form class="setup wizard js-channel">
<div class="wizard-slide">
<h2><%- @T('Connect Channels') %></h2>
<div class="wizard-body vertical center">
<p class="help-block help-block--center"><%- @T('Your Zammad as the following email address.') %></p>
<% if @addresses: %>
<% for address in @addresses: %>
<p><%= address.realname %> &lt;<%= address.email %>&gt;</p>
<% end %>
<% end %>
<p class="help-block help-block--center"><%- @T('If you want to use more email adresses, you can configure them later.') %></p>
</div>
<div class="wizard-controls center">
<a class="subtle-link" href="#getting_started/base"><%- @T('Go Back') %></a>
<a class="btn align-right" href="#getting_started/finish"><%- @T( 'Finish' ) %></a>
</div>
</div>
</form>
</div>

View file

@ -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

View file

@ -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

View file

@ -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',