ldapview.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. $(function()
  2. {
  3. $('.btn-visit').on('click', function(event)
  4. {
  5. $.get(createLink('system', 'ajaxLdapInfo'), function(response)
  6. {
  7. let res = JSON.parse(response);
  8. if(res.result == 'success')
  9. {
  10. $('#ldapAccount').text(res.data.account);
  11. $('#ldapPassword').val(res.data.pass);
  12. $('#ldapVisitUrl').attr('href', '//' + res.data.domain);
  13. $('#ldapAccountModal').modal('show');
  14. }
  15. });
  16. });
  17. $('#ldapPassBtn').on('click', function(event){
  18. var inputTyep = $('#ldap_password').attr('type');
  19. if(inputTyep == 'text'){
  20. $('#ldap_password').attr('type', 'password');
  21. $('#ldapPassBtn').find('.icon').removeClass('icon-eye').addClass('icon-eye-off');
  22. }
  23. else
  24. {
  25. $('#ldap_password').attr('type', 'text');
  26. $('#ldapPassBtn').find('.icon').addClass('icon-eye').removeClass('icon-eye-off');
  27. }
  28. });
  29. $('#copyPassBtn').on('click', function(event)
  30. {
  31. $('#ldapPassword').select();
  32. document.execCommand('copy');
  33. bootbox.alert(copySuccess);
  34. });
  35. $('.btn-start').on('click', function(event)
  36. {
  37. bootbox.confirm(instanceNotices.confirmStart, function(result)
  38. {
  39. if(!result) return;
  40. var loadingDialog = bootbox.dialog(
  41. {
  42. message: '<div class="text-center"><i class="icon icon-spinner-indicator icon-spin"></i>&nbsp;&nbsp;' + instanceNotices.starting + '</div>',
  43. });
  44. let id = $(event.target).closest('button').attr('instance-id');
  45. let url = createLink('instance', 'ajaxStart', 'id=' + id, 'json');
  46. $.post(url).done(function(response)
  47. {
  48. loadingDialog.modal('hide');
  49. let res = JSON.parse(response);
  50. if(res.result == 'success')
  51. {
  52. window.location.reload();
  53. }
  54. else
  55. {
  56. bootbox.alert(
  57. {
  58. title: instanceNotices.fail,
  59. message: res.message,
  60. });
  61. }
  62. });
  63. });
  64. });
  65. $('.btn-stop').on('click', function(event)
  66. {
  67. bootbox.confirm(instanceNotices.confirmStop, function(result)
  68. {
  69. if(!result) return;
  70. var loadingDialog = bootbox.dialog(
  71. {
  72. message: '<div class="text-center"><i class="icon icon-spinner-indicator icon-spin"></i>&nbsp;&nbsp;' + instanceNotices.stopping + '</div>',
  73. });
  74. let id = $(event.target).closest('button').attr('instance-id');
  75. let url = createLink('instance', 'ajaxStop', 'id=' + id, 'json');
  76. $.post(url).done(function(response)
  77. {
  78. loadingDialog.modal('hide');
  79. let res = JSON.parse(response);
  80. if(res.result == 'success')
  81. {
  82. window.location.reload();
  83. }
  84. else
  85. {
  86. bootbox.alert(
  87. {
  88. title: instanceNotices.fail,
  89. message: res.message,
  90. });
  91. }
  92. });
  93. });
  94. });
  95. setInterval(function()
  96. {
  97. var mainMenu = parent.window.$.apps.getLastApp();
  98. if(mainMenu.code != 'system') return;
  99. var statusURL = createLink('instance', 'ajaxStatus');
  100. $.post(statusURL, {idList: instanceIdList}).done(function(response)
  101. {
  102. let res = JSON.parse(response);
  103. if(res.result == 'success' && res.data instanceof Array)
  104. {
  105. res.data.forEach(function(instance)
  106. {
  107. if($(".instance-status[instance-id=" + instance.id + "]").data('status') != instance.status) window.location.reload();
  108. });
  109. }
  110. if(res.locate) window.parent.location.href = res.locate;
  111. });
  112. }, 1000 * 5);
  113. $('[data-toggle="tooltip"]').tooltip();
  114. });