mirror of
https://github.com/usmannasir/cyberpanel.git
synced 2025-11-08 14:26:16 +01:00
Update versionManagement.html
Still not finished. Fixed theme for the buttons and dropdown.
This commit is contained in:
@@ -5,6 +5,36 @@
|
||||
|
||||
{% 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>
|
||||
@@ -27,12 +57,13 @@
|
||||
</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>
|
||||
<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:" %}  </label>
|
||||
@@ -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) {
|
||||
xhr.addEventListener('load', function () {
|
||||
if (xhr.status === 200) {
|
||||
alert('Upgrade started. Please be patient, the upgrade process may take some time.');
|
||||
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) {
|
||||
alert('Upgrade failed. Server is not responding.');
|
||||
console.error('Upgrade failed. Server is not responding.');
|
||||
} else if (xhr.status >= 400 && xhr.status < 500) {
|
||||
alert('Upgrade failed. Client error. Please check your request.');
|
||||
console.error('Upgrade failed. Client error. Please check your request.');
|
||||
} else if (xhr.status >= 500) {
|
||||
alert('Upgrade failed. Server error. Please check the server logs.');
|
||||
console.error('Upgrade failed. Server error. Please check the server logs.');
|
||||
} else {
|
||||
alert('Upgrade failed. Please check the logs for details.');
|
||||
console.error('Upgrade failed. Please check the logs for details.');
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
xhr.send();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user