backupplatform.ui.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. var backupInterval;
  2. var backupName;
  3. /**
  4. * Start backup.
  5. *
  6. * @access public
  7. * @return viod
  8. */
  9. function startBackup()
  10. {
  11. const form = new FormData($("#backupForm")[0]);
  12. $.ajaxSubmit({
  13. url: $.createLink('system', 'backupPlatform'),
  14. data: form,
  15. onComplete: function(response)
  16. {
  17. if(response.result == 'success')
  18. {
  19. $('.modal-content .panel-body').html(waiting);
  20. backupName = response.name;
  21. backupInterval = setInterval(checkBackup, 2000);
  22. }
  23. else
  24. {
  25. zui.Modal.alert(response.message);
  26. }
  27. },
  28. });
  29. }
  30. /**
  31. * Check backup progress.
  32. *
  33. * @access public
  34. * @return viod
  35. */
  36. function checkBackup()
  37. {
  38. $.ajaxSubmit({
  39. url: $.createLink('system', 'ajaxGetBackupProgress'),
  40. data: {'name': backupName},
  41. onComplete: function(response)
  42. {
  43. if(response.result == 'progress')
  44. {
  45. $('.modal-content .panel-body').html(response.text);
  46. }
  47. else
  48. {
  49. clearInterval(backupInterval);
  50. if(response.result == 'failed') zui.Modal.alert(response.message);
  51. }
  52. },
  53. });
  54. }