Improved import workflow.
This commit is contained in:
parent
eec2801c2f
commit
388fcc6527
3 changed files with 18 additions and 25 deletions
|
@ -114,9 +114,8 @@ class Index extends App.ControllerContent
|
|||
processData: true,
|
||||
success: (data, status, xhr) =>
|
||||
|
||||
if data.setup_done
|
||||
@Config.set('system_init_done', true)
|
||||
@navigate '#'
|
||||
if data.result is 'import_done'
|
||||
window.location.reload()
|
||||
return
|
||||
|
||||
if data.result is 'error'
|
||||
|
|
|
@ -91,10 +91,7 @@ class ImportOtrsController < ApplicationController
|
|||
end
|
||||
|
||||
# start migration
|
||||
Import::OTRS.delay.start_bg(
|
||||
import_otrs_endpoint: Setting.get('import_otrs_endpoint'),
|
||||
import_otrs_endpoint_key: Setting.get('import_otrs_endpoint_key'),
|
||||
)
|
||||
Import::OTRS.delay.start_bg
|
||||
|
||||
render json: {
|
||||
result: 'ok',
|
||||
|
@ -103,7 +100,7 @@ class ImportOtrsController < ApplicationController
|
|||
|
||||
def import_status
|
||||
result = Import::OTRS.status_bg
|
||||
if result[:setup_done] == true
|
||||
if result[:result] == 'import_done'
|
||||
Setting.reload
|
||||
end
|
||||
render json: result
|
||||
|
|
|
@ -415,19 +415,15 @@ module Import::OTRS
|
|||
=begin
|
||||
start import in background
|
||||
|
||||
Import::OTRS.start_bg(
|
||||
import_otrs_endpoint: 'http://vz599.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator
|
||||
',
|
||||
import_otrs_endpoint_key: '01234567899876543210',
|
||||
)
|
||||
Import::OTRS.start_bg
|
||||
=end
|
||||
|
||||
def self.start_bg(params)
|
||||
Setting.set('import_mode', 'true')
|
||||
Setting.set('import_backend', 'otrs')
|
||||
Setting.set('import_otrs_endpoint', params[:import_otrs_endpoint])
|
||||
Setting.set('import_otrs_endpoint_key', params[:import_otrs_endpoint_key])
|
||||
def self.start_bg
|
||||
Setting.reload
|
||||
|
||||
Import::OTRS.connection_test
|
||||
|
||||
# start thread to observe current state
|
||||
status_update_thread = Thread.new {
|
||||
loop do
|
||||
result = {
|
||||
|
@ -438,9 +434,9 @@ module Import::OTRS
|
|||
sleep 8
|
||||
end
|
||||
}
|
||||
sleep 2
|
||||
|
||||
sleep 5
|
||||
|
||||
# start thread to import data
|
||||
begin
|
||||
import_thread = Thread.new {
|
||||
Import::OTRS.start
|
||||
|
@ -455,11 +451,17 @@ module Import::OTRS
|
|||
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('import_mode', false)
|
||||
end
|
||||
|
@ -473,11 +475,6 @@ module Import::OTRS
|
|||
=end
|
||||
|
||||
def self.status_bg
|
||||
if !Setting.get('import_mode')
|
||||
return {
|
||||
setup_done: true,
|
||||
}
|
||||
end
|
||||
state = Cache.get('import:state')
|
||||
return state if state
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue