view.ui.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. window.loadDBAuthUrl = function(dom)
  2. {
  3. if($(dom).hasClass('disabled')) return false;
  4. var dbName = $(dom).data('dbname');
  5. var dbType = $(dom).data('dbtype');
  6. var instanceID = $(dom).data('id');
  7. $.ajaxSubmit
  8. (
  9. {
  10. url: $.createLink('instance', 'ajaxDBAuthUrl'),
  11. method: 'POST', data: {dbName, dbType, instanceID},
  12. onSuccess: (response) =>
  13. {
  14. if(response.result == 'success')
  15. {
  16. window.open(response.data.url, 'Adminer');
  17. }
  18. else
  19. {
  20. zui.Modal.alert(response.message);
  21. }
  22. }
  23. }
  24. );
  25. }
  26. $(function()
  27. {
  28. if(typeof timer !== 'undefined') clearInterval(timer);
  29. if(inQuickon && instanceType == 'store') timer = setInterval(refreshStatus, 5000);
  30. })
  31. window.onPageUnmount = function()
  32. {
  33. if(typeof timer !== 'undefined') clearInterval(timer);
  34. }
  35. function refreshStatus()
  36. {
  37. const postData = new FormData();
  38. postData.append('idList[]', instanceID);
  39. $.ajaxSubmit({
  40. url: $.createLink('instance', 'ajaxStatus'),
  41. method: 'POST',
  42. data: postData,
  43. onComplete: function(res)
  44. {
  45. if(res.result === 'success')
  46. {
  47. if(res.data.length == 0) return false;
  48. if(res.data[0].status == $('#statusTD').data('status')) return false;
  49. loadPage($.createLink('instance', 'view', `instanceID=${instanceID}`), '#setting,#statusTD,#dbStatusTD,#systemLoad,.float-toolbar');
  50. }
  51. }
  52. });
  53. }
  54. window.copyText = function(dom)
  55. {
  56. var copyText = $(dom).parent().find('input');
  57. copyText.show();
  58. copyText[0].select();
  59. document.execCommand("Copy");
  60. copyText.hide();
  61. zui.Messager.show({
  62. type: 'success',
  63. content: copied,
  64. time: 2000
  65. });
  66. }
  67. window.onManualBackup = function()
  68. {
  69. zui.Modal.confirm({message: confirmBackupTip, icon: 'icon-exclamation-sign', iconClass: 'warning-pale rounded-full icon-2x'}).then(res =>
  70. {
  71. if(res)
  72. {
  73. $.ajaxSubmit({
  74. url: $.createLink('instance', 'manualBackup', `modelID=${instanceID}`),
  75. onSuccess: function(res)
  76. {
  77. if(res.result === 'success') $('#backupList').load($.createLink('instance', 'backupList', `id=${instanceID}`));
  78. }
  79. });
  80. }
  81. })
  82. }