Added import setting options.
This commit is contained in:
parent
5ef4c19007
commit
4f10d35bad
|
@ -38,6 +38,19 @@ class Index extends App.ControllerLevel2
|
||||||
nav: '#settings/security',
|
nav: '#settings/security',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# import
|
||||||
|
if @type is 'import'
|
||||||
|
@menu = [
|
||||||
|
{ name: 'Base', 'target': 'base', controller: App.SettingsArea, params: { area: 'Import::Base' } },
|
||||||
|
{ name: 'OTRS', 'target': 'otrs', controller: App.SettingsArea, params: { area: 'Import::OTRS' } },
|
||||||
|
]
|
||||||
|
@page = {
|
||||||
|
title: 'Import',
|
||||||
|
head: 'Import',
|
||||||
|
sub_title: 'System'
|
||||||
|
nav: '#settings/import',
|
||||||
|
}
|
||||||
|
|
||||||
# ticket
|
# ticket
|
||||||
if @type is 'ticket'
|
if @type is 'ticket'
|
||||||
@menu = [
|
@menu = [
|
||||||
|
@ -60,5 +73,6 @@ App.Config.set( 'settings/:type', Index, 'Routes' )
|
||||||
|
|
||||||
App.Config.set( 'System', { prio: 1400, parent: '#settings', name: 'System', target: '#settings/system', role: ['Admin'] }, 'NavBar' )
|
App.Config.set( 'System', { prio: 1400, parent: '#settings', name: 'System', target: '#settings/system', role: ['Admin'] }, 'NavBar' )
|
||||||
App.Config.set( 'Security', { prio: 1500, parent: '#settings', name: 'Security', target: '#settings/security', role: ['Admin'] }, 'NavBar' )
|
App.Config.set( 'Security', { prio: 1500, parent: '#settings', name: 'Security', target: '#settings/security', role: ['Admin'] }, 'NavBar' )
|
||||||
|
App.Config.set( 'Import', { prio: 1550, parent: '#settings', name: 'Import', target: '#settings/import', role: ['Admin'] }, 'NavBar' )
|
||||||
App.Config.set( 'Ticket', { prio: 1600, parent: '#settings', name: 'Ticket', target: '#settings/ticket', role: ['Admin'] }, 'NavBar' )
|
App.Config.set( 'Ticket', { prio: 1600, parent: '#settings', name: 'Ticket', target: '#settings/ticket', role: ['Admin'] }, 'NavBar' )
|
||||||
App.Config.set( 'Object', { prio: 1700, parent: '#settings', name: 'Objects', target: '#settings/objects', role: ['Admin'] }, 'NavBar' )
|
App.Config.set( 'Object', { prio: 1700, parent: '#settings', name: 'Objects', target: '#settings/objects', role: ['Admin'] }, 'NavBar' )
|
||||||
|
|
44
db/seeds.rb
44
db/seeds.rb
|
@ -1021,7 +1021,7 @@ Setting.create_if_not_exists(
|
||||||
Setting.create_if_not_exists(
|
Setting.create_if_not_exists(
|
||||||
:title => 'Import Mode',
|
:title => 'Import Mode',
|
||||||
:name => 'import_mode',
|
:name => 'import_mode',
|
||||||
:area => 'System::Import',
|
:area => 'Import::Base',
|
||||||
:description => 'Set system in import mode (disable some triggers).',
|
:description => 'Set system in import mode (disable some triggers).',
|
||||||
:options => {
|
:options => {
|
||||||
:form => [
|
:form => [
|
||||||
|
@ -1043,6 +1043,48 @@ Setting.create_if_not_exists(
|
||||||
:frontend => true
|
:frontend => true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Setting.create_if_not_exists(
|
||||||
|
:title => 'Import Endpoint',
|
||||||
|
:name => 'import_otrs_endpoint',
|
||||||
|
:area => 'Import::OTRS',
|
||||||
|
:description => 'Defines OTRS endpoint to import users, ticket, ticket_states and articles.',
|
||||||
|
:options => {
|
||||||
|
:form => [
|
||||||
|
{
|
||||||
|
:display => '',
|
||||||
|
:null => false,
|
||||||
|
:name => 'import_otrs_endpoint',
|
||||||
|
:tag => 'input',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
:state => {
|
||||||
|
:value => 'http://otrs_host/otrs',
|
||||||
|
},
|
||||||
|
:frontend => true
|
||||||
|
)
|
||||||
|
Setting.create_if_not_exists(
|
||||||
|
:title => 'Import Key',
|
||||||
|
:name => 'import_otrs_endpoint_key',
|
||||||
|
:area => 'Import::OTRS',
|
||||||
|
:description => 'Defines OTRS endpoint auth key.',
|
||||||
|
:options => {
|
||||||
|
:form => [
|
||||||
|
{
|
||||||
|
:display => '',
|
||||||
|
:null => false,
|
||||||
|
:name => 'import_otrs_endpoint_key',
|
||||||
|
:tag => 'input',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
:state => {
|
||||||
|
:value => '',
|
||||||
|
},
|
||||||
|
:frontend => true
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
email_address = EmailAddress.create_if_not_exists(
|
email_address = EmailAddress.create_if_not_exists(
|
||||||
:id => 1,
|
:id => 1,
|
||||||
:realname => 'Zammad',
|
:realname => 'Zammad',
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
module Import::OTRS
|
module Import::OTRS
|
||||||
@@url = 'http://vz109.demo.znuny.com/'
|
|
||||||
@@key = 'KFWUKfasdjuiU3424k212mALGJU3591KFE'
|
|
||||||
|
|
||||||
def self.request(part)
|
def self.request(part)
|
||||||
url = @@url + part
|
url = Setting.get('import_otrs_endpoint') + '/' + part + ';Key=' + Setting.get('import_otrs_endpoint_key')
|
||||||
puts 'GET:' + url
|
puts 'GET:' + url
|
||||||
# response = Net::HTTP.get_response( URI.parse(url), { :use_ssl => true, :verify_mode => OpenSSL::SSL::VERIFY_NONE } )
|
# response = Net::HTTP.get_response( URI.parse(url), { :use_ssl => true, :verify_mode => OpenSSL::SSL::VERIFY_NONE } )
|
||||||
uri = URI.parse(url)
|
uri = URI.parse(url)
|
||||||
|
@ -26,15 +23,15 @@ module Import::OTRS
|
||||||
def self.start
|
def self.start
|
||||||
puts 'Start import...'
|
puts 'Start import...'
|
||||||
|
|
||||||
# set system in import mode
|
# # set system in import mode
|
||||||
Setting.set('import_mode', true)
|
# Setting.set('import_mode', true)
|
||||||
|
|
||||||
# check if system is in import mode
|
# check if system is in import mode
|
||||||
if !Setting.get('import_mode')
|
if !Setting.get('import_mode')
|
||||||
raise "System is not in import mode!"
|
raise "System is not in import mode!"
|
||||||
end
|
end
|
||||||
|
|
||||||
response = request("/otrs/public.pl?Key=#{@@key};Action=Export")
|
response = request("public.pl?Action=Export")
|
||||||
return if response.code.to_s != '200'
|
return if response.code.to_s != '200'
|
||||||
|
|
||||||
#self.ticket('156115')
|
#self.ticket('156115')
|
||||||
|
@ -69,7 +66,7 @@ module Import::OTRS
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.ticket(ticket_ids)
|
def self.ticket(ticket_ids)
|
||||||
url = "/otrs/public.pl?Key=#{@@key};Action=Export;Type=Ticket;"
|
url = "public.pl?Action=Export;Type=Ticket;"
|
||||||
ticket_ids.each {|ticket_id|
|
ticket_ids.each {|ticket_id|
|
||||||
url = url + "TicketID=#{CGI::escape ticket_id};"
|
url = url + "TicketID=#{CGI::escape ticket_id};"
|
||||||
}
|
}
|
||||||
|
@ -396,7 +393,7 @@ module Import::OTRS
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.ticket_state
|
def self.ticket_state
|
||||||
response = request( "/otrs/public.pl?Key=#{@@key};Action=Export;Type=State" )
|
response = request( "public.pl?Action=Export;Type=State" )
|
||||||
return if response.code.to_s != '200'
|
return if response.code.to_s != '200'
|
||||||
|
|
||||||
result = json(response)
|
result = json(response)
|
||||||
|
@ -451,7 +448,7 @@ module Import::OTRS
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
def self.ticket_priority
|
def self.ticket_priority
|
||||||
response = request( "/otrs/public.pl?Key=#{@@key};Action=Export;Type=Priority" )
|
response = request( "public.pl?Action=Export;Type=Priority" )
|
||||||
return if response.code.to_s != '200'
|
return if response.code.to_s != '200'
|
||||||
|
|
||||||
result = json(response)
|
result = json(response)
|
||||||
|
@ -494,7 +491,7 @@ module Import::OTRS
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
def self.ticket_group
|
def self.ticket_group
|
||||||
response = request( "/otrs/public.pl?Key=#{@@key};Action=Export;Type=Queue" )
|
response = request( "public.pl?Action=Export;Type=Queue" )
|
||||||
return if response.code.to_s != '200'
|
return if response.code.to_s != '200'
|
||||||
|
|
||||||
result = json(response)
|
result = json(response)
|
||||||
|
@ -537,7 +534,7 @@ module Import::OTRS
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
def self.user
|
def self.user
|
||||||
response = request( "/otrs/public.pl?Key=#{@@key};Action=Export;Type=User" )
|
response = request( "public.pl?Action=Export;Type=User" )
|
||||||
return if response.code.to_s != '200'
|
return if response.code.to_s != '200'
|
||||||
result = json(response)
|
result = json(response)
|
||||||
map = {
|
map = {
|
||||||
|
@ -601,7 +598,7 @@ module Import::OTRS
|
||||||
while done == false
|
while done == false
|
||||||
sleep 2
|
sleep 2
|
||||||
puts "Count=#{count};Offset=#{count}"
|
puts "Count=#{count};Offset=#{count}"
|
||||||
response = request( "/otrs/public.pl?Key=#{@@key};Action=Export;Type=Customer;Count=100;Offset=#{count}" )
|
response = request( "public.pl?Action=Export;Type=Customer;Count=100;Offset=#{count}" )
|
||||||
count = count + 3000
|
count = count + 3000
|
||||||
return if response.code.to_s != '200'
|
return if response.code.to_s != '200'
|
||||||
result = json(response)
|
result = json(response)
|
||||||
|
|
Loading…
Reference in a new issue