Moved system_init_done check to construction. Whiling import or getting started it will change automatically which leads to errors.

This commit is contained in:
Martin Edenhofer 2016-06-16 15:22:08 +02:00
parent 1e1f32a5a1
commit dda7bbdeae
3 changed files with 141 additions and 138 deletions

View file

@ -9,8 +9,13 @@ class Index extends App.WizardFullScreen
# set title
@title 'Get Started'
# redirect to login if master user already exists
if @Config.get('system_init_done')
@navigate '#login'
return
# if not import backend exists, go ahead
if !App.Config.get('ImportPlugins')
if !@Config.get('ImportPlugins')
@navigate 'getting_started/admin'
return
@ -25,15 +30,10 @@ class Index extends App.WizardFullScreen
@ajax(
id: 'getting_started'
type: 'GET'
url: @apiPath + '/getting_started'
url: "#{@apiPath}/getting_started"
processData: true
success: (data, status, xhr) =>
# redirect to login if master user already exists
if @Config.get('system_init_done')
@navigate '#login'
return
# check if auto wizard is executed
if data.auto_wizard == true
@ -43,7 +43,7 @@ class Index extends App.WizardFullScreen
# check if import is active
if data.import_mode == true
@navigate '#import/' + data.import_backend
@navigate "#import/#{data.import_backend}"
return
# render page
@ -56,7 +56,7 @@ class Index extends App.WizardFullScreen
renderAutoWizard: ->
@html App.view('getting_started/auto_wizard_enabled')()
App.Config.set( 'getting_started', Index, 'Routes' )
App.Config.set('getting_started', Index, 'Routes')
class AutoWizard extends App.WizardFullScreen
constructor: ->
@ -67,6 +67,11 @@ class AutoWizard extends App.WizardFullScreen
@navigate '#'
return
# redirect to login if master user already exists
if @Config.get('system_init_done')
@navigate '#login'
return
# set title
@title 'Auto Wizard'
@renderSplash()
@ -89,16 +94,21 @@ class AutoWizard extends App.WizardFullScreen
processData: true
success: (data, status, xhr) =>
# redirect to login if master user already exists
if @Config.get('system_init_done')
@navigate '#login'
return
# check if auto wizard enabled
if data.auto_wizard is false
@navigate '#'
return
# auto wizard setup was successful
if data.auto_wizard_success is true
# login check / get session user
delay = =>
App.Auth.loginCheck()
@navigate '#'
@delay(delay, 800)
return
if data.auto_wizard_success is false
if data.message
@renderFailed(data)
@ -106,12 +116,8 @@ class AutoWizard extends App.WizardFullScreen
@renderToken()
return
# login check / get session user
delay = =>
App.Auth.loginCheck()
@navigate '#'
@delay(delay, 1200)
return
# redirect to login if master user already exists
@navigate '#login'
)
renderFailed: (data) ->
@ -140,6 +146,11 @@ class Admin extends App.WizardFullScreen
# set title
@title 'Create Admin'
# redirect to login if master user already exists
if @Config.get('system_init_done')
@navigate '#login'
return
@fetch()
release: =>
@ -151,7 +162,7 @@ class Admin extends App.WizardFullScreen
@ajax(
id: 'getting_started'
type: 'GET'
url: @apiPath + '/getting_started'
url: "#{@apiPath}/getting_started"
processData: true
success: (data, status, xhr) =>
@ -160,14 +171,9 @@ class Admin extends App.WizardFullScreen
# @navigate '#getting_started/base'
# return
# redirect to login if master user already exists
if @Config.get('system_init_done')
@navigate '#login'
return
# check if import is active
if data.import_mode == true
@navigate '#import/' + data.import_backend
@navigate "#import/#{data.import_backend}"
return
# load group collection
@ -217,7 +223,7 @@ class Admin extends App.WizardFullScreen
error: ->
App.Event.trigger 'notify', {
type: 'error'
msg: App.i18n.translateContent( 'Signin failed! Please contact the support team!' )
msg: App.i18n.translateContent('Signin failed! Please contact the support team!')
timeout: 2500
}
)
@ -227,16 +233,14 @@ class Admin extends App.WizardFullScreen
@formEnable(e)
App.Event.trigger 'notify', {
type: 'error'
msg: App.i18n.translateContent( details.error_human || 'Can\'t create user!' )
msg: App.i18n.translateContent(details.error_human || 'Can\'t create user!')
timeout: 2500
}
)
relogin: (data, status, xhr) =>
@log 'notice', 'relogin:success', data
App.Event.trigger 'notify:removeall'
@navigate 'getting_started/base'
App.Config.set('getting_started/admin', Admin, 'Routes')
@ -271,13 +275,13 @@ class Base extends App.WizardFullScreen
@ajax(
id: 'getting_started',
type: 'GET',
url: @apiPath + '/getting_started',
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
@navigate "#import/#{data.import_backend}"
return
# import config options
@ -344,7 +348,7 @@ class Base extends App.WizardFullScreen
@ajax(
id: 'getting_started_base'
type: 'POST'
url: @apiPath + '/getting_started/base'
url: "#{@apiPath}/getting_started/base"
data: JSON.stringify(@params)
processData: true
success: (data, status, xhr) =>
@ -406,15 +410,15 @@ class EmailNotification extends App.WizardFullScreen
# get data
@ajax(
id: 'getting_started',
type: 'GET',
url: @apiPath + '/getting_started',
processData: true,
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
@navigate "#import/#{data.import_backend}"
return
@channelDriver = data.channel_driver
@ -469,8 +473,8 @@ class EmailNotification extends App.WizardFullScreen
@ajax(
id: 'email_notification'
type: 'POST'
url: @apiPath + '/channels/email_notification'
data: JSON.stringify( params )
url: "#{@apiPath}/channels/email_notification"
data: JSON.stringify(params)
processData: true
success: (data, status, xhr) =>
if data.result is 'ok'
@ -524,15 +528,15 @@ class Channel extends App.WizardFullScreen
# get data
@ajax(
id: 'getting_started',
type: 'GET',
url: @apiPath + '/getting_started',
processData: true,
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
@navigate "#import/#{data.import_backend}"
return
# render page
@ -567,15 +571,15 @@ class ChannelEmailPreConfigured extends App.WizardFullScreen
# get data
@ajax(
id: 'getting_started',
type: 'GET',
url: @apiPath + '/getting_started',
processData: true,
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
@navigate "#import/#{data.import_backend}"
return
# render page
@ -628,15 +632,15 @@ class ChannelEmail extends App.WizardFullScreen
# get data
@ajax(
id: 'getting_started',
type: 'GET',
url: @apiPath + '/getting_started',
processData: true,
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
@navigate "#import/#{data.import_backend}"
return
@channelDriver = data.channel_driver
@ -718,8 +722,8 @@ class ChannelEmail extends App.WizardFullScreen
@ajax(
id: 'email_probe'
type: 'POST'
url: @apiPath + '/channels/email_probe'
data: JSON.stringify( params )
url: "#{@apiPath}/channels/email_probe"
data: JSON.stringify(params)
processData: true
success: (data, status, xhr) =>
if data.result is 'ok'
@ -767,8 +771,8 @@ class ChannelEmail extends App.WizardFullScreen
@ajax(
id: 'email_inbound'
type: 'POST'
url: @apiPath + '/channels/email_inbound'
data: JSON.stringify( params )
url: "#{@apiPath}/channels/email_inbound"
data: JSON.stringify(params)
processData: true
success: (data, status, xhr) =>
if data.result is 'ok'
@ -820,8 +824,8 @@ class ChannelEmail extends App.WizardFullScreen
@ajax(
id: 'email_outbound'
type: 'POST'
url: @apiPath + '/channels/email_outbound'
data: JSON.stringify( params )
url: "#{@apiPath}/channels/email_outbound"
data: JSON.stringify(params)
processData: true
success: (data, status, xhr) =>
if data.result is 'ok'
@ -832,12 +836,12 @@ class ChannelEmail extends App.WizardFullScreen
@verify(@account)
else
@showSlide('js-outbound')
@showAlert('js-outbound', data.message_human || data.message )
@showAlert('js-outbound', data.message_human || data.message)
@showInvalidField('js-outbound', data.invalid_field)
@enable(e)
fail: =>
@showSlide('js-outbound')
@showAlert('js-outbound', data.message_human || data.message )
@showAlert('js-outbound', data.message_human || data.message)
@showInvalidField('js-outbound', data.invalid_field)
@enable(e)
)
@ -848,8 +852,8 @@ class ChannelEmail extends App.WizardFullScreen
@ajax(
id: 'email_verify'
type: 'POST'
url: @apiPath + '/channels/email_verify'
data: JSON.stringify( account )
url: "#{@apiPath}/channels/email_verify"
data: JSON.stringify(account)
processData: true
success: (data, status, xhr) =>
if data.result is 'ok'
@ -857,11 +861,11 @@ class ChannelEmail extends App.WizardFullScreen
else
if data.source is 'inbound' || data.source is 'outbound'
@showSlide("js-#{data.source}")
@showAlert("js-#{data.source}", data.message_human || data.message )
@showAlert("js-#{data.source}", data.message_human || data.message)
@showInvalidField("js-#{data.source}", data.invalid_field)
else
if count is 2
@showAlert('js-verify', data.message_human || data.message )
@showAlert('js-verify', data.message_human || data.message)
@delay(
=>
@showSlide('js-intro')
@ -875,7 +879,7 @@ class ChannelEmail extends App.WizardFullScreen
@verify( @account, count + 1 )
fail: =>
@showSlide('js-intro')
@showAlert('js-intro', 'Unable to verify sending and receiving. Please check your settings.' )
@showAlert('js-intro', 'Unable to verify sending and receiving. Please check your settings.')
)
App.Config.set('getting_started/channel/email', ChannelEmail, 'Routes')
@ -901,15 +905,15 @@ class Agent extends App.WizardFullScreen
# get data
@ajax(
id: 'getting_started',
type: 'GET',
url: @apiPath + '/getting_started',
processData: true,
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
@navigate "#import/#{data.import_backend}"
return
# load group collection

View file

@ -16,26 +16,26 @@ class Index extends App.ControllerContent
# set title
@title 'Import'
# redirect to login if master user already exists
if @Config.get('system_init_done')
@navigate '#login'
return
@fetch()
fetch: ->
# get data
@ajax(
id: 'getting_started',
type: 'GET',
url: @apiPath + '/getting_started',
processData: true,
id: 'getting_started'
type: 'GET'
url: "#{@apiPath}/getting_started"
processData: true
success: (data, status, xhr) =>
# redirect to login if master user already exists
if @Config.get('system_init_done')
@navigate '#login'
return
# check if import is active
if data.import_mode == true && data.import_backend != 'otrs'
@navigate '#import/' + data.import_backend
@navigate "#import/#{data.import_backend}"
return
# render page
@ -71,11 +71,11 @@ class Index extends App.ControllerContent
# get data
callback = =>
@ajax(
id: 'import_otrs_url',
type: 'POST',
url: @apiPath + '/import/otrs/url_check',
id: 'import_otrs_url'
type: 'POST'
url: "#{@apiPath}/import/otrs/url_check"
data: JSON.stringify(url: url)
processData: true,
processData: true
success: (data, status, xhr) =>
# validate form
@ -85,7 +85,7 @@ class Index extends App.ControllerContent
@nextStartMigration.removeClass('hide')
else
@urlStatus.attr('data-state', 'error')
@linkErrorMessage.text( data.message_human || data.message )
@linkErrorMessage.text(data.message_human || data.message)
@nextStartMigration.addClass('hide')
)
@ -95,23 +95,22 @@ class Index extends App.ControllerContent
e.preventDefault()
@showImportState()
@ajax(
id: 'import_start',
type: 'POST',
url: @apiPath + '/import/otrs/import_start',
processData: true,
id: 'import_start'
type: 'POST'
url: "#{@apiPath}/import/otrs/import_start"
processData: true
success: (data, status, xhr) =>
if data.result is 'ok'
@delay(@updateMigration, 3000)
)
updateMigration: =>
@showImportState()
@ajax(
id: 'import_status',
type: 'GET',
url: @apiPath + '/import/otrs/import_status',
processData: true,
id: 'import_status'
type: 'GET'
url: "#{@apiPath}/import/otrs/import_status"
processData: true
success: (data, status, xhr) =>
if data.result is 'import_done'
@ -128,11 +127,11 @@ class Index extends App.ControllerContent
for key, item of data.data
if item.done > item.total
item.done = item.total
element = @$('.js-' + key.toLowerCase() )
element = @$('.js-' + key.toLowerCase())
element.find('.js-done').text(item.done)
element.find('.js-total').text(item.total)
element.find('progress').attr('max', item.total )
element.find('progress').attr('value', item.done )
element.find('progress').attr('max', item.total)
element.find('progress').attr('value', item.done)
if item.total <= item.done
element.addClass('is-done')
else
@ -140,11 +139,11 @@ class Index extends App.ControllerContent
@delay(@updateMigration, 6500)
)
App.Config.set( 'import/otrs', Index, 'Routes' )
App.Config.set( 'otrs', {
App.Config.set('import/otrs', Index, 'Routes')
App.Config.set('otrs', {
image: 'otrs-logo.png'
title: 'OTRS'
name: 'OTRS'
class: 'js-otrs'
url: '#import/otrs'
}, 'ImportPlugins' )
}, 'ImportPlugins')

View file

@ -23,26 +23,26 @@ class Index extends App.ControllerContent
# set title
@title 'Import'
# redirect to login if master user already exists
if @Config.get('system_init_done')
@navigate '#login'
return
@fetch()
fetch: ->
# get data
@ajax(
id: 'getting_started',
type: 'GET',
url: @apiPath + '/getting_started',
processData: true,
id: 'getting_started'
type: 'GET'
url: "#{@apiPath}/getting_started"
processData: true
success: (data, status, xhr) =>
# redirect to login if master user already exists
if @Config.get('system_init_done')
@navigate '#login'
return
# check if import is active
if data.import_mode == true && data.import_backend != 'zendesk'
@navigate '#import/' + data.import_backend
@navigate "#import/#{data.import_backend}"
return
# render page
@ -63,11 +63,11 @@ class Index extends App.ControllerContent
# get data
callback = =>
@ajax(
id: 'import_zendesk_url',
type: 'POST',
url: @apiPath + '/import/zendesk/url_check',
id: 'import_zendesk_url'
type: 'POST'
url: "#{@apiPath}/import/zendesk/url_check"
data: JSON.stringify(url: @zendeskUrl.val())
processData: true,
processData: true
success: (data, status, xhr) =>
# validate form
@ -78,7 +78,7 @@ class Index extends App.ControllerContent
@nextEnterCredentials.removeClass('hide')
else
@urlStatus.attr('data-state', 'error')
@linkErrorMessage.text( data.message_human || data.message )
@linkErrorMessage.text( data.message_human || data.message)
@nextEnterCredentials.addClass('hide')
)
@ -91,11 +91,11 @@ class Index extends App.ControllerContent
# get data
callback = =>
@ajax(
id: 'import_zendesk_api_token',
type: 'POST',
url: @apiPath + '/import/zendesk/credentials_check',
id: 'import_zendesk_api_token'
type: 'POST'
url: "#{@apiPath}/import/zendesk/credentials_check"
data: JSON.stringify(username: @zendeskEmail.val(), token: @zendeskApiToken.val())
processData: true,
processData: true
success: (data, status, xhr) =>
# validate form
@ -106,11 +106,11 @@ class Index extends App.ControllerContent
@nextStartMigration.removeClass('hide')
else
@urlStatus.attr('data-state', 'error')
@apiTokenErrorMessage.text( data.message_human || data.message )
@apiTokenErrorMessage.text(data.message_human || data.message)
@nextStartMigration.addClass('hide')
)
@delay( callback, 700, 'import_zendesk_api_token' )
@delay(callback, 700, 'import_zendesk_api_token')
showCredentials: (e) =>
e.preventDefault()
@ -129,25 +129,25 @@ class Index extends App.ControllerContent
e.preventDefault()
@showImportState()
@ajax(
id: 'import_start',
type: 'POST',
url: @apiPath + '/import/zendesk/import_start',
processData: true,
id: 'import_start'
type: 'POST'
url: "#{@apiPath}/import/zendesk/import_start"
processData: true
success: (data, status, xhr) =>
# validate form
console.log(data)
if data.result is 'ok'
@delay( @updateMigration, 3000 )
@delay(@updateMigration, 3000)
)
updateMigration: =>
@showImportState()
@ajax(
id: 'import_status',
type: 'GET',
url: @apiPath + '/import/zendesk/import_status',
processData: true,
id: 'import_status'
type: 'GET'
url: "#{@apiPath}/import/zendesk/import_status"
processData: true
success: (data, status, xhr) =>
if data.result is 'import_done'
@ -173,13 +173,13 @@ class Index extends App.ControllerContent
element.addClass('is-done')
else
element.removeClass('is-done')
@delay( @updateMigration, 5000 )
@delay(@updateMigration, 5000)
)
App.Config.set( 'import/zendesk', Index, 'Routes' )
App.Config.set( 'zendesk', {
App.Config.set('import/zendesk', Index, 'Routes')
App.Config.set('zendesk', {
title: 'Zendesk'
name: 'Zendesk'
class: 'js-zendesk'
url: '#import/zendesk'
}, 'ImportPlugins' )
}, 'ImportPlugins')