diff --git a/app/assets/javascripts/app/controllers/_integration/ldap.coffee b/app/assets/javascripts/app/controllers/_integration/ldap.coffee index c6ca0e2b1..cda274205 100644 --- a/app/assets/javascripts/app/controllers/_integration/ldap.coffee +++ b/app/assets/javascripts/app/controllers/_integration/ldap.coffee @@ -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( diff --git a/app/assets/javascripts/app/views/integration/ldap_last_import.jst.eco b/app/assets/javascripts/app/views/integration/ldap_last_import.jst.eco index 163f59277..2fb84f854 100644 --- a/app/assets/javascripts/app/views/integration/ldap_last_import.jst.eco +++ b/app/assets/javascripts/app/views/integration/ldap_last_import.jst.eco @@ -45,5 +45,8 @@ <% end %> <% end %> + <% if @job.finished_at: %> + + <% end %> <% end %> diff --git a/app/controllers/integration/ldap_controller.rb b/app/controllers/integration/ldap_controller.rb index 0fff21396..ff91b292f 100644 --- a/app/controllers/integration/ldap_controller.rb +++ b/app/controllers/integration/ldap_controller.rb @@ -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', }