123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- //Init des settings
- function init_setting_activedirectory(parameter){
- switch(parameter.section){
- case 'activedirectory':
- $(document).ready(function(){
- var form = $('#activedirectory-setting-form');
- //usersRoot
- var usersInput = $('input[data-root="users"]', form);
- if(usersInput.length>0){
- $.each(usersInput.val().split(';'), function(i, value){
- var usersClone = i==0 ? usersInput : usersInput.clone();
- usersClone.val(value);
- if(i!=0) usersInput.after(usersClone);
- });
- }
- //groupsRoot
- var groupsInput = $('input[data-root="groups"]', form);
- if(groupsInput.length>0){
- $.each(groupsInput.val().split(';'), function(i, value){
- var groupsClone = i==0 ? groupsInput : groupsInput.clone();
- groupsClone.val(value);
- if(i!=0) groupsInput.after(groupsClone);
- });
- }
- });
- activedirectory_group_search();
- break;
- }
- }
- /* ACTIVEDIRECTORY GROUP */
- //SEARCH
- function activedirectory_group_search(callback){
- $('#group-rank-firm').fill({
- action:'activedirectory_group_search',
- }, function(){
- if(callback!=null) callback();
- });
- }
- //SAVE
- function activedirectory_group_save(){
- var form = $('#ad-correspondance');
- var data = $.getForm(form);
- data.id = form.attr('data-id');
- $.action(data,function(r){
- $.message('success','Enregistré');
- activedirectory_group_search();
- $('input, select', form).val('');
- form.attr('data-id','');
- });
- }
- //EDIT
- function activedirectory_group_edit(element){
- var line = $(element).closest('tr');
- $.action({
- action:'activedirectory_group_edit',
- id:line.attr('data-id')
- },function(r){
- $.setForm('#ad-correspondance',r);
- $('#ad-correspondance').attr('data-id',r.id);
- });
- }
- //DELETE
- function activedirectory_group_delete(element){
- if(!confirm('Êtes-vous sûr de vouloir supprimer cette correspondance ?')) return;
- var line = $(element).closest('tr');
- $.action({
- action: 'activedirectory_group_delete',
- id: line.attr('data-id')
- },function(r){
- line.remove();
- $.message('info','Correspondance Groupe/Rang/Établissement supprimée');
- });
- }
- /* ACTIVEDIRECTORY SETTING */
- // ADD USER/GROUP ROOTS
- function activedirectory_activedirectory_add_roots(element){
- var btn = $(element);
- var input = btn.parent().next('td').find('input:eq(0)');
- var clone = input.clone();
- clone.val('');
- input.parent().append(clone);
- }
- //SAVE
- function activedirectory_setting_save(callback){
- //On est obligé de passer par là pour utiliser
- //le tableau de configuration auto-généré avec
- //les champs un peu customs
- var fields = $('#activedirectory-setting-form').toJson();
- fields['activedirectory_users_root'] = [];
- $.each($('input[data-root="users"]'), function(i, input){
- // if(!$(input).val().length) return;
- fields['activedirectory_users_root'].push($(input).val());
- });
- fields['activedirectory_groups_root'] = [];
- $.each($('input[data-root="groups"]'), function(i, input){
- // if(!$(input).val().length) return;
- fields['activedirectory_groups_root'].push($(input).val());
- });
- $.action({
- action: 'activedirectory_setting_save',
- fields: fields
- }, function(r){
- $.message('success', 'Enregistré');
- if(callback!=null) callback();
- });
- }
- //CHECK CONNECTION
- function activedirectory_connection_check(){
- activedirectory_setting_save(function(){
- $('.activedirectory-test-connection').load(document.URL + ' .activedirectory-test-connection>*', function(){
- $('.activedirectory-test-connection .card-icon > i').attr('class', 'fas fa-spinner fa-pulse ');
- $.action({
- action: 'activedirectory_connection_check'
- }, function(r){
- $.each(r.tests, function(id, result){
- var card = $('#'+id);
- card.addClass(result?'border-success':'border-danger');
- $('.card-icon > i', card).attr('class', (result?'text-success fas fa-check-circle':'text-danger fas fa-times-circle'));
- $('.label', card).addClass(result?'text-success':'text-danger');
- });
- });
- });
- });
- }
|