main.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. //CHARGEMENT DE LA PAGE
  2. function init_setting_activedirectory(){
  3. $('#adservers').sortable_table({
  4. onSort : activedirectory_adserver_search
  5. });
  6. $('#ad-firm-ranks').sortable_table({
  7. onSort : activedirectory_ad_firm_rank_search
  8. });
  9. }
  10. function init_setting_sheet_adserver(){
  11. activedirectory_fields_search();
  12. }
  13. //Enregistrement des configurations
  14. function activedirectory_setting_save(){
  15. $.action({
  16. action: 'activedirectory_setting_save',
  17. fields: $('#activedirectory-setting-form').toJson()
  18. },function(){
  19. $.message('success','Enregistré');
  20. });
  21. }
  22. /** SERVEUR ACTIVE DIRECTORY **/
  23. //Récuperation d'une liste serveur active directory dans le tableau #adservers
  24. function activedirectory_adserver_search(callback,exportMode){
  25. var box = new FilterBox('#activedirectory_adserver-filters');
  26. if(exportMode) $('.btn-export').addClass('btn-preloader');
  27. $('#adservers').fill({
  28. action:'activedirectory_adserver_search',
  29. filters: box.filters(),
  30. sort: $('#adservers').sortable_table('get'),
  31. export: !exportMode ? false : exportMode
  32. },function(response){
  33. if(!exportMode) $('.results-count > span').text(response.pagination.total);
  34. if(callback!=null) callback();
  35. });
  36. }
  37. //Ajout ou modification serveur active directory
  38. function activedirectory_adserver_save(){
  39. var data = $('#adserver-form').toJson();
  40. $.action(data,function(r){
  41. $('#adserver-form').attr('data-id',r.id);
  42. $.urlParam('id',r.id);
  43. activedirectory_fields_search();
  44. $.message('success','Enregistré');
  45. });
  46. }
  47. //Suppression serveur active directory
  48. function activedirectory_adserver_delete(element){
  49. if(!confirm('Êtes vous sûr de vouloir supprimer cet item ?')) return;
  50. var line = $(element).closest('.item-line');
  51. $.action({
  52. action: 'activedirectory_adserver_delete',
  53. id: line.attr('data-id')
  54. },function(r){
  55. line.remove();
  56. $.message('info','Item supprimé');
  57. });
  58. }
  59. function activedirectory_adserver_test(){
  60. var id = $.urlParam('id');
  61. if(!id) return $.message('warning','Merci d\'enregistrer le serveur avant de le tester');
  62. $('.btn-test').addClass('btn-preloader');
  63. $('#activedirectory-test :not(template)').remove();
  64. $.action({
  65. action: 'activedirectory_adserver_test',
  66. id: id
  67. },function(r){
  68. var tpl = $('#activedirectory-test template').html();
  69. var block = Mustache.render(tpl,r);
  70. $('#activedirectory-test').append(block);
  71. });
  72. }
  73. function activedirectory_fields_search(){
  74. var id = $.urlParam('id');
  75. if(!id) return;
  76. var data = {action : 'activedirectory_fields_search', id:id};
  77. $.action(data,function(r){
  78. var options = '';
  79. for (var k in r.groups) {
  80. var group = r.groups[k];
  81. options+="<option>"+group+"</option>";
  82. }
  83. $('#group').html(options);
  84. });
  85. }
  86. /** LIAISON GROUPE RANG **/
  87. //Récuperation d'une liste liaison groupe rang dans le tableau #AdFirmRanks
  88. function activedirectory_ad_firm_rank_search(callback,exportMode){
  89. var box = new FilterBox('#activedirectory_ad_firm_rank-filters');
  90. if(exportMode) $('.btn-export').addClass('btn-preloader');
  91. $('#ad-firm-ranks').fill({
  92. action:'activedirectory_ad_firm_rank_search',
  93. filters: box.filters(),
  94. sort: $('#ad-firm-ranks').sortable_table('get'),
  95. export: !exportMode ? false : exportMode
  96. },function(response){
  97. if(!exportMode) $('.results-count > span').text(response.pagination.total);
  98. if(callback!=null) callback();
  99. });
  100. }
  101. //Ajout ou modification liaison groupe rang
  102. function activedirectory_ad_firm_rank_save(){
  103. var data = $('#ad-firm-rank-form').toJson();
  104. data.server = $.urlParam('id');
  105. $.action(data,function(r){
  106. $('#ad-firm-rank-form').attr('data-id','');
  107. activedirectory_ad_firm_rank_search();
  108. });
  109. }
  110. //Récuperation ou edition liaison groupe rang
  111. function activedirectory_ad_firm_rank_edit(element){
  112. var line = $(element).closest('.item-line');
  113. $.action({
  114. action: 'activedirectory_ad_firm_rank_edit',
  115. id: line.attr('data-id')
  116. },function(r){
  117. $('#ad-firm-rank-form').fromJson(r);
  118. init_components('#ad-firm-rank-form');
  119. $('#ad-firm-rank-form').attr('data-id',r.id);
  120. });
  121. }
  122. //Suppression liaison groupe rang
  123. function activedirectory_ad_firm_rank_delete(element){
  124. if(!confirm('Êtes vous sûr de vouloir supprimer cet item ?')) return;
  125. var line = $(element).closest('.item-line');
  126. $.action({
  127. action: 'activedirectory_ad_firm_rank_delete',
  128. id: line.attr('data-id')
  129. },function(r){
  130. line.remove();
  131. $.message('info','Item supprimé');
  132. });
  133. }