Merge branch 'develop' of github.com:martini/zammad into develop

This commit is contained in:
Felix Niklas 2016-01-13 18:50:36 +01:00
commit 84a08c4a69
4 changed files with 61 additions and 27 deletions

View file

@ -18,6 +18,12 @@ class Index extends App.ControllerContent
@fetch() @fetch()
@bind('import:finished', =>
console.log('import:finished')
@Config.set('system_init_done', true)
@navigate '#'
)
fetch: -> fetch: ->
# get data # get data
@ -79,7 +85,6 @@ class Index extends App.ControllerContent
success: (data, status, xhr) => success: (data, status, xhr) =>
# validate form # validate form
console.log(data)
if data.result is 'ok' if data.result is 'ok'
@urlStatus.attr('data-state', 'success') @urlStatus.attr('data-state', 'success')
@linkErrorMessage.text('') @linkErrorMessage.text('')
@ -103,7 +108,6 @@ class Index extends App.ControllerContent
success: (data, status, xhr) => success: (data, status, xhr) =>
# validate form # validate form
console.log(data)
if data.result is 'ok' if data.result is 'ok'
@delay( @updateMigration, 3000 ) @delay( @updateMigration, 3000 )
) )

View file

@ -22,9 +22,7 @@ class ImportOtrsController < ApplicationController
'Connection refused' => 'Connection refused!', 'Connection refused' => 'Connection refused!',
} }
url_parts = params[:url].split(';') response = UserAgent.request( params[:url] )
response = UserAgent.request( url_parts[0] )
if !response.success? && response.code.to_s !~ /^40.$/ if !response.success? && response.code.to_s !~ /^40.$/
message_human = '' message_human = ''
@ -44,6 +42,11 @@ class ImportOtrsController < ApplicationController
result = {} result = {}
if response.body =~ /zammad migrator/ if response.body =~ /zammad migrator/
migrator_response = JSON.parse(response.body)
if migrator_response['Success'] == 1
url_parts = params[:url].split(';')
key_parts = url_parts[1].split('=') key_parts = url_parts[1].split('=')
Setting.set('import_backend', 'otrs') Setting.set('import_backend', 'otrs')
@ -54,6 +57,12 @@ class ImportOtrsController < ApplicationController
result: 'ok', result: 'ok',
url: params[:url], url: params[:url],
} }
else
result = {
result: 'invalid',
message_human: migrator_response['Error']
}
end
elsif response.body =~ /(otrs\sag|otrs\.com|otrs\.org)/i elsif response.body =~ /(otrs\sag|otrs\.com|otrs\.org)/i
result = { result = {
result: 'invalid', result: 'invalid',

View file

@ -412,6 +412,11 @@ module Import::OTRS
Setting.set('system_init_done', true) Setting.set('system_init_done', true)
Setting.set('import_mode', false) Setting.set('import_mode', false)
# broadcast import finish
Sessions.broadcast(
event: 'import:finished',
)
true true
end end

View file

@ -11,8 +11,6 @@ class OtrsImportBrowserTest < TestCase
fail "ERROR: Need IMPORT_BT_OTRS_ENDPOINT_KEY - hint IMPORT_BT_OTRS_ENDPOINT_KEY='01234567899876543210'" fail "ERROR: Need IMPORT_BT_OTRS_ENDPOINT_KEY - hint IMPORT_BT_OTRS_ENDPOINT_KEY='01234567899876543210'"
end end
import_url = "#{ENV['IMPORT_BT_OTRS_ENDPOINT']};Key=#{ENV['IMPORT_BT_OTRS_ENDPOINT_KEY']}"
@browser = browser_instance @browser = browser_instance
location(url: browser_url) location(url: browser_url)
@ -20,26 +18,44 @@ class OtrsImportBrowserTest < TestCase
click(css: 'a[href="#import/otrs"]') click(css: 'a[href="#import/otrs"]')
click(css: '.js-download')
click(css: '.js-otrs-link')
invalid_key_url = "#{ENV['IMPORT_BT_OTRS_ENDPOINT']};Key=31337"
set(
css: '#otrs-link',
value: invalid_key_url
)
sleep 5
watch_for(
css: '.otrs-link-error',
value: 'Invalid API key.',
)
import_url = "#{ENV['IMPORT_BT_OTRS_ENDPOINT']};Key=#{ENV['IMPORT_BT_OTRS_ENDPOINT_KEY']}"
set( set(
css: '#otrs-link', css: '#otrs-link',
value: import_url value: import_url
) )
watch_for( sleep 5
css: 'body',
value: 'xxxx', watch_for_disappear(
timeout: 10, css: '.otrs-link-error',
value: 'Invalid API key.',
) )
# click import click(css: '.js-migration-start')
# click otrs watch_for(
css: 'body',
# enter otrs url + key value: 'login',
timeout: 300,
# watch for import start )
# watch for import end
end end