Update versionManagement.html

Still not finished.
Fixed theme for the buttons and dropdown.
This commit is contained in:
Master3395
2023-11-11 01:14:25 +01:00
parent cccdbb8d09
commit c67eb83c2b

View File

@@ -5,15 +5,45 @@
{% load static %}
<style>
/* Add these styles for the buttons and select dropdown */
.button-style,
#branchSelect {
background-color: rgb(62, 72, 85);
color: #fff;
padding: 10px 20px;
border: none;
cursor: pointer;
transition: background-color 0.3s ease;
}
/* Apply these styles when hovering over the buttons or select dropdown */
.button-style:hover,
#branchSelect:hover {
background-color: darken(rgb(62, 72, 85), 10%);
}
/* Add these styles for the progress bar */
#upgradeProgress {
background-color: rgb(62, 72, 85);
}
/* Add these styles for the textarea */
textarea {
background-color: rgb(62, 72, 85);
color: #fff;
}
</style>
<div class="container">
<div id="page-title">
<h2>{% trans "Version Management" %}</h2>
<p>{% trans "Here you can manage versions and check for updates to CyberPanel" %}</p>
</div>
{% if Notecheck %}
<div class="alert alert-info">
<p style="color:red; font-weight: bold;">{% trans "Note: Latest commit does not match, please upgrade CyberPanel." %}</p>
</div>
<div class="alert alert-info">
<p style="color:red; font-weight: bold;">{% trans "Note: Latest commit does not match, please upgrade CyberPanel." %}</p>
</div>
{% endif %}
<div class="panel">
@@ -27,13 +57,14 @@
</div>
<div class="form-group">
<label for="branchSelect">{% trans "Select Branch:" %}</label>
<select id="branchSelect"></select>
<select id="branchSelect" class="button-style"></select>
</div>
<div class="form-group">
<button type="submit" onclick="upgradeCyberPanel()">Upgrade CyberPanel to selected branch</button>
<button type="submit" onclick="refreshPage()" class="line-over">Refresh page</button>
</div>
<form action="/" class="form-horizontal bordered-row">
<button type="submit" onclick="upgradeCyberPanel()" class="button-style">{% trans "Upgrade CyberPanel to selected branch" %}</button>
<button type="submit" onclick="refreshPage()" class="button-style line-over">{% trans "Refresh page" %}</button>
</div>
<form action="/" class="form-horizontal bordered-row">
<div class="form-group">
<label class="col-sm-3 control-label" style="margin: 0px!important; padding: 0px!important;">{% trans "Current Version:" %}&nbsp&nbsp</label>
<div class="current-pack col-sm-9" style="margin: 0px!important; padding: 0px!important;">{{ currentVersion }}</div>
@@ -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();
}
}