Working on issue #981 - Added possibility to manually start LDAP import.

This commit is contained in:
Thorsten Eckel 2017-05-10 16:47:31 +02:00
parent ea926d1095
commit ec6a4a199c
3 changed files with 33 additions and 10 deletions

View file

@ -24,12 +24,26 @@ class Index extends App.ControllerIntegrationBase
facility: 'ldap'
)
switch: =>
super
active = @$('.js-switch input').prop('checked')
if active
@ajax(
id: 'jobs_config'
type: 'POST'
url: "#{@apiPath}/integration/ldap/job_start"
processData: true
success: (data, status, xhr) =>
@render(true)
)
class Form extends App.Controller
elements:
'.js-lastImport': 'lastImport'
'.js-wizard': 'wizardButton'
events:
'click .js-wizard': 'startWizard'
'click .js-start-sync': 'startSync'
constructor: ->
super
@ -42,14 +56,7 @@ class Form extends App.Controller
setConfig: (value) =>
App.Setting.set('ldap_config', value, {notify: true})
@ajax(
id: 'jobs_config'
type: 'POST'
url: "#{@apiPath}/integration/ldap/job_start"
processData: true
success: (data, status, xhr) =>
@render(true)
)
@startSync()
render: (top = false) =>
@config = @currentConfig()
@ -69,6 +76,16 @@ class Form extends App.Controller
@scrollToIfNeeded($('.content.active .page-header'))
@delay(a, 500)
startSync: =>
@ajax(
id: 'jobs_config'
type: 'POST'
url: "#{@apiPath}/integration/ldap/job_start"
processData: true
success: (data, status, xhr) =>
@render(true)
)
startWizard: (e) =>
e.preventDefault()
new ConnectionWizard(

View file

@ -45,5 +45,8 @@
<% end %>
</ul>
<% end %>
<% if @job.finished_at: %>
<button type="submit" class="btn btn--primary js-start-sync"><%- @T('Start new') %></button>
<% end %>
<% end %>
</div>

View file

@ -71,8 +71,11 @@ class Integration::LdapController < ApplicationController
end
def job_start_create
job = ImportJob.create(name: 'Import::Ldap', payload: Setting.get('ldap_config'))
job.delay.start
backend = 'Import::Ldap'
if !ImportJob.exists?(name: backend, finished_at: nil)
job = ImportJob.create(name: backend, payload: Setting.get('ldap_config'))
job.delay.start
end
render json: {
result: 'ok',
}