smtpview.js 3.6 KB

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