diff --git a/baseTemplate/templates/baseTemplate/versionManagment.html b/baseTemplate/templates/baseTemplate/versionManagment.html index e3022b7f0..3b13a3278 100755 --- a/baseTemplate/templates/baseTemplate/versionManagment.html +++ b/baseTemplate/templates/baseTemplate/versionManagment.html @@ -5,15 +5,45 @@ {% load static %} + +

{% trans "Version Management" %}

{% trans "Here you can manage versions and check for updates to CyberPanel" %}

{% if Notecheck %} -
-

{% trans "Note: Latest commit does not match, please upgrade CyberPanel." %}

-
+
+

{% trans "Note: Latest commit does not match, please upgrade CyberPanel." %}

+
{% endif %}
@@ -27,13 +57,14 @@
- +
- - -
-
+ + +
+ +
{{ currentVersion }}
@@ -100,35 +131,47 @@ getBranches('https://api.github.com/repos/usmannasir/cyberpanel/branches', [], 1 function upgradeCyberPanel() { var selectedBranch = document.getElementById("branchSelect").value; - var upgradeURL = 'https://raw.githubusercontent.com/usmannasir/cyberpanel/' + selectedBranch + '/preUpgrade.sh'; + var upgradeURL = 'https://raw.githubusercontent.com/usmannasir/cyberpanel/' + selectedBranch + '/cyberpanel_upgrade.sh'; if (confirm("Are you sure you want to upgrade to the selected branch from GitHub?")) { var xhr = new XMLHttpRequest(); xhr.open('GET', upgradeURL, true); xhr.responseType = 'text'; - xhr.onprogress = function (e) { + xhr.addEventListener('progress', function (e) { if (e.lengthComputable) { var percent = (e.loaded / e.total) * 100; document.getElementById("upgradeProgress").value = percent; + console.log('Upgrade progress: ' + percent + '%'); } - }; + }); - xhr.onreadystatechange = function () { - if (xhr.readyState === 4) { - if (xhr.status === 200) { - alert('Upgrade started. Please be patient, the upgrade process may take some time.'); - } else if (xhr.status === 0) { - alert('Upgrade failed. Server is not responding.'); - } else if (xhr.status >= 400 && xhr.status < 500) { - alert('Upgrade failed. Client error. Please check your request.'); - } else if (xhr.status >= 500) { - alert('Upgrade failed. Server error. Please check the server logs.'); - } else { - alert('Upgrade failed. Please check the logs for details.'); + xhr.addEventListener('load', function () { + if (xhr.status === 200) { + console.log('Upgrade started. Please be patient, the upgrade process may take some time.'); + console.log('Upgrade response received.'); + + // Save the response content as a Bash script + var bashScriptContent = xhr.responseText; + + try { + // Execute the Bash script using eval (handle with caution) + eval(bashScriptContent); + console.log('Upgrade script executed.'); + } catch (error) { + console.error('Error executing the upgrade script:', error); } + } else if (xhr.status === 0) { + console.error('Upgrade failed. Server is not responding.'); + } else if (xhr.status >= 400 && xhr.status < 500) { + console.error('Upgrade failed. Client error. Please check your request.'); + } else if (xhr.status >= 500) { + console.error('Upgrade failed. Server error. Please check the server logs.'); + } else { + console.error('Upgrade failed. Please check the logs for details.'); } - }; + }); + xhr.send(); } }