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 # set title
@title 'Get Started' @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 not import backend exists, go ahead
if !App.Config.get('ImportPlugins') if !@Config.get('ImportPlugins')
@navigate 'getting_started/admin' @navigate 'getting_started/admin'
return return
@ -25,15 +30,10 @@ class Index extends App.WizardFullScreen
@ajax( @ajax(
id: 'getting_started' id: 'getting_started'
type: 'GET' type: 'GET'
url: @apiPath + '/getting_started' url: "#{@apiPath}/getting_started"
processData: true processData: true
success: (data, status, xhr) => 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 # check if auto wizard is executed
if data.auto_wizard == true if data.auto_wizard == true
@ -43,7 +43,7 @@ class Index extends App.WizardFullScreen
# check if import is active # check if import is active
if data.import_mode == true if data.import_mode == true
@navigate '#import/' + data.import_backend @navigate "#import/#{data.import_backend}"
return return
# render page # render page
@ -67,6 +67,11 @@ class AutoWizard extends App.WizardFullScreen
@navigate '#' @navigate '#'
return return
# redirect to login if master user already exists
if @Config.get('system_init_done')
@navigate '#login'
return
# set title # set title
@title 'Auto Wizard' @title 'Auto Wizard'
@renderSplash() @renderSplash()
@ -89,16 +94,21 @@ class AutoWizard extends App.WizardFullScreen
processData: true processData: true
success: (data, status, xhr) => 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 # check if auto wizard enabled
if data.auto_wizard is false if data.auto_wizard is false
@navigate '#' @navigate '#'
return 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.auto_wizard_success is false
if data.message if data.message
@renderFailed(data) @renderFailed(data)
@ -106,12 +116,8 @@ class AutoWizard extends App.WizardFullScreen
@renderToken() @renderToken()
return return
# login check / get session user # redirect to login if master user already exists
delay = => @navigate '#login'
App.Auth.loginCheck()
@navigate '#'
@delay(delay, 1200)
return
) )
renderFailed: (data) -> renderFailed: (data) ->
@ -140,6 +146,11 @@ class Admin extends App.WizardFullScreen
# set title # set title
@title 'Create Admin' @title 'Create Admin'
# redirect to login if master user already exists
if @Config.get('system_init_done')
@navigate '#login'
return
@fetch() @fetch()
release: => release: =>
@ -151,7 +162,7 @@ class Admin extends App.WizardFullScreen
@ajax( @ajax(
id: 'getting_started' id: 'getting_started'
type: 'GET' type: 'GET'
url: @apiPath + '/getting_started' url: "#{@apiPath}/getting_started"
processData: true processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
@ -160,14 +171,9 @@ class Admin extends App.WizardFullScreen
# @navigate '#getting_started/base' # @navigate '#getting_started/base'
# return # return
# redirect to login if master user already exists
if @Config.get('system_init_done')
@navigate '#login'
return
# check if import is active # check if import is active
if data.import_mode == true if data.import_mode == true
@navigate '#import/' + data.import_backend @navigate "#import/#{data.import_backend}"
return return
# load group collection # load group collection
@ -234,9 +240,7 @@ class Admin extends App.WizardFullScreen
relogin: (data, status, xhr) => relogin: (data, status, xhr) =>
@log 'notice', 'relogin:success', data @log 'notice', 'relogin:success', data
App.Event.trigger 'notify:removeall' App.Event.trigger 'notify:removeall'
@navigate 'getting_started/base' @navigate 'getting_started/base'
App.Config.set('getting_started/admin', Admin, 'Routes') App.Config.set('getting_started/admin', Admin, 'Routes')
@ -271,13 +275,13 @@ class Base extends App.WizardFullScreen
@ajax( @ajax(
id: 'getting_started', id: 'getting_started',
type: 'GET', type: 'GET',
url: @apiPath + '/getting_started', url: "#{@apiPath}/getting_started",
processData: true, processData: true,
success: (data, status, xhr) => success: (data, status, xhr) =>
# check if import is active # check if import is active
if data.import_mode == true if data.import_mode == true
@navigate '#import/' + data.import_backend @navigate "#import/#{data.import_backend}"
return return
# import config options # import config options
@ -344,7 +348,7 @@ class Base extends App.WizardFullScreen
@ajax( @ajax(
id: 'getting_started_base' id: 'getting_started_base'
type: 'POST' type: 'POST'
url: @apiPath + '/getting_started/base' url: "#{@apiPath}/getting_started/base"
data: JSON.stringify(@params) data: JSON.stringify(@params)
processData: true processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
@ -406,15 +410,15 @@ class EmailNotification extends App.WizardFullScreen
# get data # get data
@ajax( @ajax(
id: 'getting_started', id: 'getting_started'
type: 'GET', type: 'GET'
url: @apiPath + '/getting_started', url: "#{@apiPath}/getting_started"
processData: true, processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
# check if import is active # check if import is active
if data.import_mode == true if data.import_mode == true
@navigate '#import/' + data.import_backend @navigate "#import/#{data.import_backend}"
return return
@channelDriver = data.channel_driver @channelDriver = data.channel_driver
@ -469,7 +473,7 @@ class EmailNotification extends App.WizardFullScreen
@ajax( @ajax(
id: 'email_notification' id: 'email_notification'
type: 'POST' type: 'POST'
url: @apiPath + '/channels/email_notification' url: "#{@apiPath}/channels/email_notification"
data: JSON.stringify(params) data: JSON.stringify(params)
processData: true processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
@ -524,15 +528,15 @@ class Channel extends App.WizardFullScreen
# get data # get data
@ajax( @ajax(
id: 'getting_started', id: 'getting_started'
type: 'GET', type: 'GET'
url: @apiPath + '/getting_started', url: "#{@apiPath}/getting_started"
processData: true, processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
# check if import is active # check if import is active
if data.import_mode == true if data.import_mode == true
@navigate '#import/' + data.import_backend @navigate "#import/#{data.import_backend}"
return return
# render page # render page
@ -567,15 +571,15 @@ class ChannelEmailPreConfigured extends App.WizardFullScreen
# get data # get data
@ajax( @ajax(
id: 'getting_started', id: 'getting_started'
type: 'GET', type: 'GET'
url: @apiPath + '/getting_started', url: "#{@apiPath}/getting_started"
processData: true, processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
# check if import is active # check if import is active
if data.import_mode == true if data.import_mode == true
@navigate '#import/' + data.import_backend @navigate "#import/#{data.import_backend}"
return return
# render page # render page
@ -628,15 +632,15 @@ class ChannelEmail extends App.WizardFullScreen
# get data # get data
@ajax( @ajax(
id: 'getting_started', id: 'getting_started'
type: 'GET', type: 'GET'
url: @apiPath + '/getting_started', url: "#{@apiPath}/getting_started"
processData: true, processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
# check if import is active # check if import is active
if data.import_mode == true if data.import_mode == true
@navigate '#import/' + data.import_backend @navigate "#import/#{data.import_backend}"
return return
@channelDriver = data.channel_driver @channelDriver = data.channel_driver
@ -718,7 +722,7 @@ class ChannelEmail extends App.WizardFullScreen
@ajax( @ajax(
id: 'email_probe' id: 'email_probe'
type: 'POST' type: 'POST'
url: @apiPath + '/channels/email_probe' url: "#{@apiPath}/channels/email_probe"
data: JSON.stringify(params) data: JSON.stringify(params)
processData: true processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
@ -767,7 +771,7 @@ class ChannelEmail extends App.WizardFullScreen
@ajax( @ajax(
id: 'email_inbound' id: 'email_inbound'
type: 'POST' type: 'POST'
url: @apiPath + '/channels/email_inbound' url: "#{@apiPath}/channels/email_inbound"
data: JSON.stringify(params) data: JSON.stringify(params)
processData: true processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
@ -820,7 +824,7 @@ class ChannelEmail extends App.WizardFullScreen
@ajax( @ajax(
id: 'email_outbound' id: 'email_outbound'
type: 'POST' type: 'POST'
url: @apiPath + '/channels/email_outbound' url: "#{@apiPath}/channels/email_outbound"
data: JSON.stringify(params) data: JSON.stringify(params)
processData: true processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
@ -848,7 +852,7 @@ class ChannelEmail extends App.WizardFullScreen
@ajax( @ajax(
id: 'email_verify' id: 'email_verify'
type: 'POST' type: 'POST'
url: @apiPath + '/channels/email_verify' url: "#{@apiPath}/channels/email_verify"
data: JSON.stringify(account) data: JSON.stringify(account)
processData: true processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
@ -901,15 +905,15 @@ class Agent extends App.WizardFullScreen
# get data # get data
@ajax( @ajax(
id: 'getting_started', id: 'getting_started'
type: 'GET', type: 'GET'
url: @apiPath + '/getting_started', url: "#{@apiPath}/getting_started"
processData: true, processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
# check if import is active # check if import is active
if data.import_mode == true if data.import_mode == true
@navigate '#import/' + data.import_backend @navigate "#import/#{data.import_backend}"
return return
# load group collection # load group collection

View file

@ -16,26 +16,26 @@ class Index extends App.ControllerContent
# set title # set title
@title 'Import' @title 'Import'
# redirect to login if master user already exists
if @Config.get('system_init_done')
@navigate '#login'
return
@fetch() @fetch()
fetch: -> fetch: ->
# get data # get data
@ajax( @ajax(
id: 'getting_started', id: 'getting_started'
type: 'GET', type: 'GET'
url: @apiPath + '/getting_started', url: "#{@apiPath}/getting_started"
processData: true, processData: true
success: (data, status, xhr) => 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 # check if import is active
if data.import_mode == true && data.import_backend != 'otrs' if data.import_mode == true && data.import_backend != 'otrs'
@navigate '#import/' + data.import_backend @navigate "#import/#{data.import_backend}"
return return
# render page # render page
@ -71,11 +71,11 @@ class Index extends App.ControllerContent
# get data # get data
callback = => callback = =>
@ajax( @ajax(
id: 'import_otrs_url', id: 'import_otrs_url'
type: 'POST', type: 'POST'
url: @apiPath + '/import/otrs/url_check', url: "#{@apiPath}/import/otrs/url_check"
data: JSON.stringify(url: url) data: JSON.stringify(url: url)
processData: true, processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
# validate form # validate form
@ -95,23 +95,22 @@ class Index extends App.ControllerContent
e.preventDefault() e.preventDefault()
@showImportState() @showImportState()
@ajax( @ajax(
id: 'import_start', id: 'import_start'
type: 'POST', type: 'POST'
url: @apiPath + '/import/otrs/import_start', url: "#{@apiPath}/import/otrs/import_start"
processData: true, processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
if data.result is 'ok' if data.result is 'ok'
@delay(@updateMigration, 3000) @delay(@updateMigration, 3000)
) )
updateMigration: => updateMigration: =>
@showImportState() @showImportState()
@ajax( @ajax(
id: 'import_status', id: 'import_status'
type: 'GET', type: 'GET'
url: @apiPath + '/import/otrs/import_status', url: "#{@apiPath}/import/otrs/import_status"
processData: true, processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
if data.result is 'import_done' if data.result is 'import_done'

View file

@ -23,26 +23,26 @@ class Index extends App.ControllerContent
# set title # set title
@title 'Import' @title 'Import'
# redirect to login if master user already exists
if @Config.get('system_init_done')
@navigate '#login'
return
@fetch() @fetch()
fetch: -> fetch: ->
# get data # get data
@ajax( @ajax(
id: 'getting_started', id: 'getting_started'
type: 'GET', type: 'GET'
url: @apiPath + '/getting_started', url: "#{@apiPath}/getting_started"
processData: true, processData: true
success: (data, status, xhr) => 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 # check if import is active
if data.import_mode == true && data.import_backend != 'zendesk' if data.import_mode == true && data.import_backend != 'zendesk'
@navigate '#import/' + data.import_backend @navigate "#import/#{data.import_backend}"
return return
# render page # render page
@ -63,11 +63,11 @@ class Index extends App.ControllerContent
# get data # get data
callback = => callback = =>
@ajax( @ajax(
id: 'import_zendesk_url', id: 'import_zendesk_url'
type: 'POST', type: 'POST'
url: @apiPath + '/import/zendesk/url_check', url: "#{@apiPath}/import/zendesk/url_check"
data: JSON.stringify(url: @zendeskUrl.val()) data: JSON.stringify(url: @zendeskUrl.val())
processData: true, processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
# validate form # validate form
@ -91,11 +91,11 @@ class Index extends App.ControllerContent
# get data # get data
callback = => callback = =>
@ajax( @ajax(
id: 'import_zendesk_api_token', id: 'import_zendesk_api_token'
type: 'POST', type: 'POST'
url: @apiPath + '/import/zendesk/credentials_check', url: "#{@apiPath}/import/zendesk/credentials_check"
data: JSON.stringify(username: @zendeskEmail.val(), token: @zendeskApiToken.val()) data: JSON.stringify(username: @zendeskEmail.val(), token: @zendeskApiToken.val())
processData: true, processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
# validate form # validate form
@ -129,10 +129,10 @@ class Index extends App.ControllerContent
e.preventDefault() e.preventDefault()
@showImportState() @showImportState()
@ajax( @ajax(
id: 'import_start', id: 'import_start'
type: 'POST', type: 'POST'
url: @apiPath + '/import/zendesk/import_start', url: "#{@apiPath}/import/zendesk/import_start"
processData: true, processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
# validate form # validate form
@ -144,10 +144,10 @@ class Index extends App.ControllerContent
updateMigration: => updateMigration: =>
@showImportState() @showImportState()
@ajax( @ajax(
id: 'import_status', id: 'import_status'
type: 'GET', type: 'GET'
url: @apiPath + '/import/zendesk/import_status', url: "#{@apiPath}/import/zendesk/import_status"
processData: true, processData: true
success: (data, status, xhr) => success: (data, status, xhr) =>
if data.result is 'import_done' if data.result is 'import_done'