Merge branch 'develop' of github.com:martini/zammad into develop
This commit is contained in:
commit
ed5e0ff4d4
9 changed files with 179 additions and 65 deletions
|
@ -601,6 +601,9 @@ class ChatWindow extends App.Controller
|
||||||
@el.addClass('is-offline')
|
@el.addClass('is-offline')
|
||||||
@input.attr('disabled', true)
|
@input.attr('disabled', true)
|
||||||
|
|
||||||
|
# add footer with create ticket button
|
||||||
|
@body.append App.view('customer_chat/chat_footer')()
|
||||||
|
|
||||||
maybeAddTimestamp: ->
|
maybeAddTimestamp: ->
|
||||||
timestamp = Date.now()
|
timestamp = Date.now()
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,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('')
|
||||||
|
@ -101,9 +100,6 @@ class Index extends App.ControllerContent
|
||||||
url: @apiPath + '/import/otrs/import_start',
|
url: @apiPath + '/import/otrs/import_start',
|
||||||
processData: true,
|
processData: true,
|
||||||
success: (data, status, xhr) =>
|
success: (data, status, xhr) =>
|
||||||
|
|
||||||
# validate form
|
|
||||||
console.log(data)
|
|
||||||
if data.result is 'ok'
|
if data.result is 'ok'
|
||||||
@delay(@updateMigration, 3000)
|
@delay(@updateMigration, 3000)
|
||||||
)
|
)
|
||||||
|
@ -118,11 +114,17 @@ class Index extends App.ControllerContent
|
||||||
processData: true,
|
processData: true,
|
||||||
success: (data, status, xhr) =>
|
success: (data, status, xhr) =>
|
||||||
|
|
||||||
if data.setup_done
|
if data.result is 'import_done'
|
||||||
@Config.set('system_init_done', true)
|
window.location.reload()
|
||||||
@navigate '#'
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if data.result is 'error'
|
||||||
|
@$('.js-error').removeClass('hide')
|
||||||
|
@$('.js-error').html(App.i18n.translateContent(data.message))
|
||||||
|
else
|
||||||
|
@$('.js-error').addClass('hide')
|
||||||
|
|
||||||
|
if data.result is 'in_progress'
|
||||||
for key, item of data.data
|
for key, item of data.data
|
||||||
element = @$('.js-' + key.toLowerCase() )
|
element = @$('.js-' + key.toLowerCase() )
|
||||||
element.find('.js-done').text(item.done)
|
element.find('.js-done').text(item.done)
|
||||||
|
@ -133,7 +135,7 @@ class Index extends App.ControllerContent
|
||||||
element.addClass('is-done')
|
element.addClass('is-done')
|
||||||
else
|
else
|
||||||
element.removeClass('is-done')
|
element.removeClass('is-done')
|
||||||
@delay( @updateMigration, 5000 )
|
@delay(@updateMigration, 6500)
|
||||||
)
|
)
|
||||||
|
|
||||||
App.Config.set( 'import/otrs', Index, 'Routes' )
|
App.Config.set( 'import/otrs', Index, 'Routes' )
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
<div class="chat-footer">
|
||||||
|
<div class="btn btn--primary js-createTicket">Turn chat into ticket</div>
|
||||||
|
</div>
|
|
@ -41,6 +41,8 @@
|
||||||
|
|
||||||
<div class="wizard-slide vertical hide" data-slide="otrs-import">
|
<div class="wizard-slide vertical hide" data-slide="otrs-import">
|
||||||
<h2><%- @T('OTRS Migration') %></h2>
|
<h2><%- @T('OTRS Migration') %></h2>
|
||||||
|
<div class="alert alert--danger hide js-error" role="alert"></div>
|
||||||
|
|
||||||
<div class="wizard-body flex vertical justified">
|
<div class="wizard-body flex vertical justified">
|
||||||
<table class="progressTable">
|
<table class="progressTable">
|
||||||
<tr class="js-config">
|
<tr class="js-config">
|
||||||
|
|
|
@ -7275,7 +7275,6 @@ output {
|
||||||
}
|
}
|
||||||
|
|
||||||
&.is-offline {
|
&.is-offline {
|
||||||
.chat-body-holder,
|
|
||||||
.chat-controls {
|
.chat-controls {
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
@ -7286,7 +7285,7 @@ output {
|
||||||
background: hsl(210,8%,95%);
|
background: hsl(210,8%,95%);
|
||||||
border: 1px solid hsl(0,0%,91%);
|
border: 1px solid hsl(0,0%,91%);
|
||||||
border-radius: 3px 3px 0 0;
|
border-radius: 3px 3px 0 0;
|
||||||
height: 37px;
|
height: 43px;
|
||||||
line-height: 13px;
|
line-height: 13px;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@ -7336,7 +7335,7 @@ output {
|
||||||
.chat-disconnect,
|
.chat-disconnect,
|
||||||
.chat-close {
|
.chat-close {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
padding: 0 4px;
|
padding: 10px;
|
||||||
|
|
||||||
.btn {
|
.btn {
|
||||||
min-width: 80px;
|
min-width: 80px;
|
||||||
|
@ -7437,6 +7436,15 @@ output {
|
||||||
67% { opacity: 1; transform: scale(1); }
|
67% { opacity: 1; transform: scale(1); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.chat-footer {
|
||||||
|
border-top: 1px solid hsl(0,0%,93%);
|
||||||
|
padding: 10px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-self: stretch;
|
||||||
|
margin: 0 -10px;
|
||||||
|
}
|
||||||
|
|
||||||
.chat-controls {
|
.chat-controls {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
|
|
|
@ -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',
|
||||||
|
@ -71,7 +80,6 @@ class ImportOtrsController < ApplicationController
|
||||||
|
|
||||||
def import_start
|
def import_start
|
||||||
return if setup_done_response
|
return if setup_done_response
|
||||||
|
|
||||||
Setting.set('import_mode', true)
|
Setting.set('import_mode', true)
|
||||||
welcome = Import::OTRS.connection_test
|
welcome = Import::OTRS.connection_test
|
||||||
if !welcome
|
if !welcome
|
||||||
|
@ -83,7 +91,7 @@ class ImportOtrsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# start migration
|
# start migration
|
||||||
Import::OTRS.delay.start
|
Import::OTRS.delay.start_bg
|
||||||
|
|
||||||
render json: {
|
render json: {
|
||||||
result: 'ok',
|
result: 'ok',
|
||||||
|
@ -91,18 +99,11 @@ class ImportOtrsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_status
|
def import_status
|
||||||
if !Setting.get('import_mode')
|
result = Import::OTRS.status_bg
|
||||||
render json: {
|
if result[:result] == 'import_done'
|
||||||
setup_done: true,
|
Setting.reload
|
||||||
}
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
render json: result
|
||||||
state = Import::OTRS.current_state
|
|
||||||
render json: {
|
|
||||||
data: state,
|
|
||||||
result: 'in_progress',
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -77,13 +77,25 @@ reset config setting to default
|
||||||
@@current[:settings_config][name]
|
@@current[:settings_config][name]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
=begin
|
||||||
|
|
||||||
|
reload config settings
|
||||||
|
|
||||||
|
Setting.reload
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
|
def self.reload
|
||||||
|
load(true)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# load values and cache them
|
# load values and cache them
|
||||||
def self.load
|
def self.load(force = false)
|
||||||
|
|
||||||
# check if config is already generated
|
# check if config is already generated
|
||||||
if @@current[:settings_config]
|
if !force && @@current[:settings_config]
|
||||||
return false if cache_valid?
|
return false if cache_valid?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -214,7 +214,7 @@ module Import::OTRS
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
get object statistic from server ans save it in cache
|
get object statistic from remote server ans save it in cache
|
||||||
|
|
||||||
result = statistic('Subaction=List')
|
result = statistic('Subaction=List')
|
||||||
|
|
||||||
|
@ -409,10 +409,77 @@ module Import::OTRS
|
||||||
threads[thread].join
|
threads[thread].join
|
||||||
}
|
}
|
||||||
|
|
||||||
|
true
|
||||||
|
end
|
||||||
|
|
||||||
|
=begin
|
||||||
|
start import in background
|
||||||
|
|
||||||
|
Import::OTRS.start_bg
|
||||||
|
=end
|
||||||
|
|
||||||
|
def self.start_bg
|
||||||
|
Setting.reload
|
||||||
|
|
||||||
|
Import::OTRS.connection_test
|
||||||
|
|
||||||
|
# start thread to observe current state
|
||||||
|
status_update_thread = Thread.new {
|
||||||
|
loop do
|
||||||
|
result = {
|
||||||
|
data: current_state,
|
||||||
|
result: 'in_progress',
|
||||||
|
}
|
||||||
|
Cache.write('import:state', result, expires_in: 10.minutes)
|
||||||
|
sleep 8
|
||||||
|
end
|
||||||
|
}
|
||||||
|
sleep 2
|
||||||
|
|
||||||
|
# start thread to import data
|
||||||
|
begin
|
||||||
|
import_thread = Thread.new {
|
||||||
|
Import::OTRS.start
|
||||||
|
}
|
||||||
|
rescue => e
|
||||||
|
status_update_thread.exit
|
||||||
|
status_update_thread.join
|
||||||
|
Rails.logger.error e.message
|
||||||
|
Rails.logger.error e.backtrace.inspect
|
||||||
|
result = {
|
||||||
|
message: e.message,
|
||||||
|
result: 'error',
|
||||||
|
}
|
||||||
|
Cache.write('import:state', result, expires_in: 10.hours)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
import_thread.join
|
||||||
|
status_update_thread.exit
|
||||||
|
status_update_thread.join
|
||||||
|
|
||||||
|
result = {
|
||||||
|
result: 'import_done',
|
||||||
|
}
|
||||||
|
Cache.write('import:state', result, expires_in: 10.hours)
|
||||||
|
|
||||||
Setting.set('system_init_done', true)
|
Setting.set('system_init_done', true)
|
||||||
Setting.set('import_mode', false)
|
Setting.set('import_mode', false)
|
||||||
|
end
|
||||||
|
|
||||||
true
|
=begin
|
||||||
|
|
||||||
|
get import state from background process
|
||||||
|
|
||||||
|
result = Import::OTRS.status_bg
|
||||||
|
|
||||||
|
=end
|
||||||
|
|
||||||
|
def self.status_bg
|
||||||
|
state = Cache.get('import:state')
|
||||||
|
return state if state
|
||||||
|
{
|
||||||
|
message: 'not running',
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.diff_worker
|
def self.diff_worker
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue