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,
|
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'
|
if data.result is 'error'
|
||||||
|
|
|
@ -91,10 +91,7 @@ class ImportOtrsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# start migration
|
# start migration
|
||||||
Import::OTRS.delay.start_bg(
|
Import::OTRS.delay.start_bg
|
||||||
import_otrs_endpoint: Setting.get('import_otrs_endpoint'),
|
|
||||||
import_otrs_endpoint_key: Setting.get('import_otrs_endpoint_key'),
|
|
||||||
)
|
|
||||||
|
|
||||||
render json: {
|
render json: {
|
||||||
result: 'ok',
|
result: 'ok',
|
||||||
|
@ -103,7 +100,7 @@ class ImportOtrsController < ApplicationController
|
||||||
|
|
||||||
def import_status
|
def import_status
|
||||||
result = Import::OTRS.status_bg
|
result = Import::OTRS.status_bg
|
||||||
if result[:setup_done] == true
|
if result[:result] == 'import_done'
|
||||||
Setting.reload
|
Setting.reload
|
||||||
end
|
end
|
||||||
render json: result
|
render json: result
|
||||||
|
|
|
@ -415,19 +415,15 @@ module Import::OTRS
|
||||||
=begin
|
=begin
|
||||||
start import in background
|
start import in background
|
||||||
|
|
||||||
Import::OTRS.start_bg(
|
Import::OTRS.start_bg
|
||||||
import_otrs_endpoint: 'http://vz599.demo.znuny.com/otrs/public.pl?Action=ZammadMigrator
|
|
||||||
',
|
|
||||||
import_otrs_endpoint_key: '01234567899876543210',
|
|
||||||
)
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.start_bg(params)
|
def self.start_bg
|
||||||
Setting.set('import_mode', 'true')
|
Setting.reload
|
||||||
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])
|
|
||||||
|
|
||||||
|
Import::OTRS.connection_test
|
||||||
|
|
||||||
|
# start thread to observe current state
|
||||||
status_update_thread = Thread.new {
|
status_update_thread = Thread.new {
|
||||||
loop do
|
loop do
|
||||||
result = {
|
result = {
|
||||||
|
@ -438,9 +434,9 @@ module Import::OTRS
|
||||||
sleep 8
|
sleep 8
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
sleep 2
|
||||||
|
|
||||||
sleep 5
|
# start thread to import data
|
||||||
|
|
||||||
begin
|
begin
|
||||||
import_thread = Thread.new {
|
import_thread = Thread.new {
|
||||||
Import::OTRS.start
|
Import::OTRS.start
|
||||||
|
@ -455,11 +451,17 @@ module Import::OTRS
|
||||||
result: 'error',
|
result: 'error',
|
||||||
}
|
}
|
||||||
Cache.write('import:state', result, expires_in: 10.hours)
|
Cache.write('import:state', result, expires_in: 10.hours)
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
import_thread.join
|
import_thread.join
|
||||||
status_update_thread.exit
|
status_update_thread.exit
|
||||||
status_update_thread.join
|
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
|
end
|
||||||
|
@ -473,11 +475,6 @@ module Import::OTRS
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.status_bg
|
def self.status_bg
|
||||||
if !Setting.get('import_mode')
|
|
||||||
return {
|
|
||||||
setup_done: true,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
state = Cache.get('import:state')
|
state = Cache.get('import:state')
|
||||||
return state if state
|
return state if state
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue