Merge pull request #1689 from master3395/v2.5.5-dev

V2.5.5 dev
This commit is contained in:
Master3395
2026-02-15 01:17:44 +01:00
committed by GitHub
5 changed files with 84 additions and 50 deletions

View File

@@ -579,6 +579,7 @@ app.controller('versionManagment', function ($scope, $http, $timeout) {
$scope.updateFinish = true;
$scope.couldNotConnect = true;
var upgradeStatusTimer = null;
$scope.upgrade = function () {
@@ -660,7 +661,8 @@ app.controller('versionManagment', function ($scope, $http, $timeout) {
if (response.data.upgradeStatus === 1) {
if (response.data.finished === 1) {
$timeout.cancel();
if (upgradeStatusTimer) $timeout.cancel(upgradeStatusTimer);
upgradeStatusTimer = null;
$scope.upgradelogBox = false;
$scope.upgradeLog = response.data.upgradeLog;
$scope.upgradeLoading = true;
@@ -672,7 +674,7 @@ app.controller('versionManagment', function ($scope, $http, $timeout) {
} else {
$scope.upgradelogBox = false;
$scope.upgradeLog = response.data.upgradeLog;
timeout(getUpgradeStatus, 2000);
upgradeStatusTimer = $timeout(getUpgradeStatus, 2000);
}
}

View File

@@ -199,9 +199,9 @@
word-break: break-all;
}
/* Progress log */
/* Progress log - dark background for terminal-style visibility */
.log-container {
background: var(--text-primary, #1e1e1e);
background: #1e1e1e;
border-radius: 8px;
padding: 20px;
margin-top: 20px;
@@ -215,11 +215,12 @@
min-height: 300px;
background: transparent;
border: none;
color: var(--bg-secondary, #f0f0f0);
color: #e8e8e8;
font-family: 'SF Mono', Monaco, monospace;
font-size: 13px;
line-height: 1.6;
resize: vertical;
caret-color: #e8e8e8;
}
.log-textarea:focus {
@@ -337,30 +338,51 @@
</div>
<script>
// Function to populate the branch dropdown
function populateBranches(branches) {
var branchSelect = document.getElementById("branchSelect");
for (let i = branches.length - 1; i >= 0; i--) {
const branch = branches[i];
var option = document.createElement("option");
option.value = branch;
option.text = branch;
if (branch.startsWith("v") && branch.indexOf("dev") === -1 && branch.indexOf("version-counter") === -1) {
branchSelect.appendChild(option);
}
}
// Sort key for version branches: v2.5.5-dev > v2.5.5 > v2.4.4
function versionSortKey(name) {
var m = name.match(/^v(\d+)\.(\d+)(?:\.(\d+))?(?:-(.+))?$/);
if (!m) return [0, 0, 0, 0];
var major = parseInt(m[1], 10) || 0;
var minor = parseInt(m[2], 10) || 0;
var patch = parseInt(m[3], 10) || 0;
var suffix = (m[4] === 'dev') ? 1 : 0;
return [major, minor, patch, suffix];
}
function compareBranches(a, b) {
var ka = versionSortKey(a), kb = versionSortKey(b);
for (var i = 0; i < 4; i++) {
if (ka[i] !== kb[i]) return kb[i] - ka[i];
}
return 0;
}
// Function to populate the branch dropdown (latest 10 only)
function populateBranches(branches) {
var filtered = branches.filter(function(b) {
return b.startsWith("v") && b.indexOf("version-counter") === -1;
});
filtered.sort(compareBranches);
var latest = filtered.slice(0, 10);
var branchSelect = document.getElementById("branchSelect");
for (var i = 0; i < latest.length; i++) {
var option = document.createElement("option");
option.value = latest[i];
option.text = latest[i];
branchSelect.appendChild(option);
}
}
function getBranches(url, branches, page) {
if (!page) page = 1;
fetch(url + '?page=' + page)
fetch(url + '?per_page=100&page=' + page)
.then((response) => response.json())
.then((data) => {
if (data.length === 0) {
populateBranches(branches);
} else {
const branchNames = data.map(branch => branch.name);
var branchNames = data.map(function(b) { return b.name; });
branches = branches.concat(branchNames);
getBranches(url, branches, page + 1);
}

View File

@@ -298,6 +298,8 @@ def versionManagment(request):
latestVersion = '0'
latestBuild = '0'
on_dev_branch = (currentVersion == '2.5.5' and currentBuild == 'dev')
try:
getVersion = requests.get('https://cyberpanel.net/version.txt', timeout=10)
getVersion.raise_for_status()
@@ -306,10 +308,15 @@ def versionManagment(request):
latestBuild = str(latest.get('build', '0'))
except (requests.RequestException, ValueError, KeyError) as e:
logging.CyberCPLogFileWriter.writeToFile('[versionManagment] cyberpanel.net/version.txt failed: %s' % str(e))
if currentVersion == '2.5.5' and currentBuild == 'dev':
notechk = False
if on_dev_branch:
latestVersion, latestBuild = '2.5.5', 'dev'
branch_ref = 'v%s.%s' % (latestVersion, latestBuild)
# Dev branch: compare against v2.5.5-dev, show dev version info
if on_dev_branch:
branch_ref = 'v2.5.5-dev'
latestVersion, latestBuild = '2.5.5', 'dev'
else:
branch_ref = 'v%s.%s' % (latestVersion, latestBuild)
# Always fetch local HEAD for display
head_cmd = 'git -C /usr/local/CyberCP rev-parse HEAD 2>/dev/null || true'
@@ -319,39 +326,38 @@ def versionManagment(request):
remote_out = ProcessUtilities.outputExecutioner(remote_cmd)
is_usmannasir = 'usmannasir/cyberpanel' in (remote_out or '')
if notechk and (currentVersion == '2.5.5' and currentBuild == 'dev'):
notechk = False
elif notechk and _version_compare(currentVersion, latestVersion) > 0:
# Stable: newer than cyberpanel.net = up to date; dev: compare commits
if not on_dev_branch and notechk and _version_compare(currentVersion, latestVersion) > 0:
notechk = False
elif notechk:
if is_usmannasir:
u = "https://api.github.com/repos/usmannasir/cyberpanel/commits?sha=%s" % branch_ref
# Dev branch: always use usmannasir v2.5.5-dev as canonical "latest"
# Forks: use usmannasir for Latest Commit so all dev users compare to same upstream
fetch_branch = branch_ref if (is_usmannasir or on_dev_branch) else None
if fetch_branch:
u = "https://api.github.com/repos/usmannasir/cyberpanel/commits?sha=%s" % fetch_branch
logging.CyberCPLogFileWriter.writeToFile(u)
try:
r = requests.get(u, timeout=10)
r.raise_for_status()
latestcomit = r.json()[0]['sha']
if Currentcomt and latestcomit and Currentcomt == latestcomit:
notechk = False
except (requests.RequestException, IndexError, KeyError) as e:
logging.CyberCPLogFileWriter.writeToFile('[versionManagment] GitHub API failed: %s' % str(e))
if latestcomit and Currentcomt == latestcomit:
notechk = False
else:
notechk = False
# For forks: fetch latest commit from the actual remote for display
if not latestcomit and remote_out:
m = re.search(r'github\.com[:/]([^/]+)/([^/]+?)(?:\.git)?$', remote_out.strip())
if m:
owner, repo = m.group(1), m.group(2).rstrip('.git')
branch_cmd = 'git -C /usr/local/CyberCP rev-parse --abbrev-ref HEAD 2>/dev/null || true'
local_branch = ProcessUtilities.outputExecutioner(branch_cmd).rstrip('\n') or 'v2.5.5-dev'
try:
u = "https://api.github.com/repos/%s/%s/commits?sha=%s" % (owner, repo, local_branch)
r = requests.get(u, timeout=10)
r.raise_for_status()
latestcomit = r.json()[0]['sha']
except (requests.RequestException, IndexError, KeyError):
pass
elif not on_dev_branch:
# Stable fork: fetch from fork's branch
m = re.search(r'github\.com[:/]([^/]+)/([^/]+?)(?:\.git)?$', (remote_out or '').strip())
if m:
owner, repo = m.group(1), m.group(2).rstrip('.git')
try:
u = "https://api.github.com/repos/%s/%s/commits?sha=%s" % (owner, repo, branch_ref)
r = requests.get(u, timeout=10)
r.raise_for_status()
latestcomit = r.json()[0]['sha']
if Currentcomt and latestcomit and Currentcomt == latestcomit:
notechk = False
except (requests.RequestException, IndexError, KeyError):
pass
template = 'baseTemplate/versionManagment.html'
finalData = {'build': currentBuild, 'currentVersion': currentVersion, 'latestVersion': latestVersion,

View File

@@ -553,6 +553,7 @@ app.controller('versionManagment', function ($scope, $http, $timeout) {
$scope.updateFinish = true;
$scope.couldNotConnect = true;
var upgradeStatusTimer = null;
$scope.upgrade = function () {
@@ -623,7 +624,8 @@ app.controller('versionManagment', function ($scope, $http, $timeout) {
if (response.data.upgradeStatus === 1) {
if (response.data.finished === 1) {
$timeout.cancel();
if (upgradeStatusTimer) $timeout.cancel(upgradeStatusTimer);
upgradeStatusTimer = null;
$scope.upgradelogBox = false;
$scope.upgradeLog = response.data.upgradeLog;
$scope.upgradeLoading = true;
@@ -635,7 +637,7 @@ app.controller('versionManagment', function ($scope, $http, $timeout) {
} else {
$scope.upgradelogBox = false;
$scope.upgradeLog = response.data.upgradeLog;
$timeout(getUpgradeStatus, 2000);
upgradeStatusTimer = $timeout(getUpgradeStatus, 2000);
}
}

View File

@@ -579,6 +579,7 @@ app.controller('versionManagment', function ($scope, $http, $timeout) {
$scope.updateFinish = true;
$scope.couldNotConnect = true;
var upgradeStatusTimer = null;
$scope.upgrade = function () {
@@ -660,7 +661,8 @@ app.controller('versionManagment', function ($scope, $http, $timeout) {
if (response.data.upgradeStatus === 1) {
if (response.data.finished === 1) {
$timeout.cancel();
if (upgradeStatusTimer) $timeout.cancel(upgradeStatusTimer);
upgradeStatusTimer = null;
$scope.upgradelogBox = false;
$scope.upgradeLog = response.data.upgradeLog;
$scope.upgradeLoading = true;
@@ -672,7 +674,7 @@ app.controller('versionManagment', function ($scope, $http, $timeout) {
} else {
$scope.upgradelogBox = false;
$scope.upgradeLog = response.data.upgradeLog;
timeout(getUpgradeStatus, 2000);
upgradeStatusTimer = $timeout(getUpgradeStatus, 2000);
}
}