update SFTP

This commit is contained in:
MCHost
2025-09-25 21:50:07 -04:00
parent 2216af9fca
commit 0c6397037f
+18 -152
View File
@@ -586,7 +586,6 @@ document.addEventListener('DOMContentLoaded', () => {
}
function updateDockerUI(message) {
console.log('updateDockerUI called with message:', message);
if (message.error) {
console.log('Docker message error:', message.error);
if (elements.serverStatus) elements.serverStatus.textContent = 'Not Running';
@@ -596,8 +595,6 @@ document.addEventListener('DOMContentLoaded', () => {
// Reinitialize tagline element to handle dynamic DOM changes
elements.tagline = document.getElementById('tagline');
console.log('Tagline element in updateDockerUI:', elements.tagline);
const memoryPercent = parseFloat(message.data?.memory?.percent) || 0;
if (state.memoryPercent !== memoryPercent && elements.memoryPercent && memoryMeter) {
memoryMeter.data.datasets[0].data = [memoryPercent, 100 - memoryPercent];
@@ -638,8 +635,7 @@ document.addEventListener('DOMContentLoaded', () => {
}
}
}
console.log('Total RAM (MiB):', totalRam);
console.log('Tagline element before update:', elements.tagline.textContent);
// Use tolerance to account for floating-point discrepancies
const tolerance = 50; // Allow 50 MiB leeway
if (totalRam >= 11000 - tolerance) {
@@ -650,15 +646,12 @@ document.addEventListener('DOMContentLoaded', () => {
console.log('Set tagline to: Manage Your Premium Minecraft Server');
} else {
elements.tagline.textContent = 'Manage Your Minecraft Server';
console.log('Set tagline to: Manage Your Minecraft Server');
}
console.log('Tagline element after update:', elements.tagline.textContent);
state.taglineUpdated = true; // Mark tagline as updated
} else if (!elements.tagline) {
console.error('Tagline element not found in updateDockerUI');
showNotification('Failed to update tagline: Element not found', 'error', 'tagline-error');
} else {
console.log('Tagline already updated, skipping calculations');
}
}
@@ -675,14 +668,12 @@ document.addEventListener('DOMContentLoaded', () => {
const startBtn = document.getElementById('startBtn');
const stopBtn = elements.stopBtn;
const restartBtn = elements.restartBtn;
const sftpBrowserSection = elements.sftpBrowserSection;
const refreshBtn = elements.refresh || document.getElementById('refresh');
const mobileRefreshBtn = elements.mobileRefresh || document.getElementById('mobileRefresh');
const backupBtn = elements.backupBtn;
const mobileBackupBtn = elements.mobileBackupBtn;
const logoutBtn = elements.logoutBtn || document.getElementById('logoutBtn');
const mobileLogoutBtn = elements.mobileLogoutBtn || document.getElementById('mobileLogoutBtn');
if (startBtn) {
if (status.toLowerCase() === 'running') {
startBtn.disabled = true;
@@ -692,7 +683,6 @@ document.addEventListener('DOMContentLoaded', () => {
startBtn.classList.remove('disabled-btn');
}
}
if (status.toLowerCase() !== 'running') {
sections.forEach(section => {
if (section !== serverStatusSection) {
@@ -718,9 +708,6 @@ document.addEventListener('DOMContentLoaded', () => {
restartBtn.disabled = true;
restartBtn.classList.add('disabled-btn');
}
if (sftpBrowserSection) {
sftpBrowserSection.style.display = 'none';
}
if (refreshBtn) {
refreshBtn.classList.add('hidden');
refreshBtn.style.display = 'none';
@@ -769,9 +756,6 @@ document.addEventListener('DOMContentLoaded', () => {
restartBtn.disabled = false;
restartBtn.classList.remove('disabled-btn');
}
if (sftpBrowserSection) {
sftpBrowserSection.style.display = 'block';
}
if (refreshBtn) {
refreshBtn.classList.remove('hidden');
refreshBtn.style.display = '';
@@ -796,7 +780,6 @@ document.addEventListener('DOMContentLoaded', () => {
state.hasShownStartNotification = false;
}
}
function updateDockerLogsUI(message) {
if (message.error) {
return;
@@ -1312,15 +1295,12 @@ document.addEventListener('DOMContentLoaded', () => {
const mobileLogoutBtn = document.getElementById('mobileLogoutBtn');
if (logoutBtn) {
console.log('Desktop logout button found');
} else {
console.error('Desktop logout button (#logoutBtn) not found');
}
if (mobileLogoutBtn) {
console.log('Mobile logout button found');
} else {
console.error('Mobile logout button (#mobileLogoutBtn) not found');
}
document.removeEventListener('click', handleLogoutClick);
@@ -2131,19 +2111,21 @@ document.addEventListener('DOMContentLoaded', () => {
}
async function connectSftp() {
// if (!isSftpOnline) {
// showNotification('SFTP is offline. Please try again later.', 'error', 'sftp-offline');
// return;
// }
if (!sftpCredentials) {
showNotification('SFTP credentials not available.', 'error', 'sftp-credentials');
return;
}
try {
const key = `action-sftp-connect`;
const notification = showNotification('Connecting to SFTP...', 'loading', key);
let success = false;
// Hide the SFTP browser section initially
if (elements.sftpBrowserSection) {
elements.sftpBrowserSection.style.display = 'none';
}
while (!success) {
try {
const response = await fetch('https://sftp.my-mc.link/auto-connection', {
method: 'POST',
headers: {
@@ -2156,18 +2138,22 @@ document.addEventListener('DOMContentLoaded', () => {
password: sftpCredentials.password,
}),
});
const result = await response.json();
if (result.success && result.connectionUrl) {
elements.sftpIframe.src = result.connectionUrl;
elements.sftpBrowserSection.style.display = 'block';
updateNotification(notification, 'SFTP connected successfully', 'success', key);
success = true;
} else {
updateNotification(notification, 'Failed to establish SFTP connection.', 'error', key);
throw new Error('Failed to establish SFTP connection.');
}
} catch (error) {
console.error('SFTP connection error:', error);
showNotification(`Failed to connect to SFTP: ${error.message}`, 'error', 'sftp-connect-error');
// Ensure the SFTP browser section remains hidden on failure
if (elements.sftpBrowserSection) {
elements.sftpBrowserSection.style.display = 'none';
}
await new Promise(resolve => setTimeout(resolve, 10000));
}
}
}
@@ -2494,131 +2480,11 @@ document.addEventListener('DOMContentLoaded', () => {
observer.observe(section);
});
particlesJS("particles-js", {
"particles": {
"number": {
"value": 30,
"density": {
"enable": true,
"value_area": 800
}
},
"color": {
"value": ["#14b8a6", "#3b82f6"] // Mimics gradient by alternating colors
},
"shape": {
"type": "circle", // Matches border-radius: 50%
"stroke": {
"width": 0,
"color": "#000000"
}
},
"opacity": {
"value": 0.9, // Matches box-shadow opacity
"random": true,
"anim": {
"enable": true, // Mimics fadeInOut animation
"speed": 1, // Slower for smooth fade
"opacity_min": 0, // Fades to fully transparent
"sync": false
}
},
"size": {
"value": 8, // Default size (matches 8px)
"random": true, // Allows some particles to be larger (up to 12px)
"anim": {
"enable": true,
"speed": 4,
"size_min": 4, // Smaller sizes for variation
"sync": false
}
},
"line_linked": {
"enable": false // No lines needed per CSS
},
"move": {
"enable": true,
"speed": 2, // Mimics float animation
"direction": "none",
"random": true,
"straight": false,
"out_mode": "out",
"bounce": false,
"attract": {
"enable": false
}
}
},
"interactivity": {
"detect_on": "canvas",
"events": {
"onhover": {
"enable": true,
"mode": "repulse"
},
"onclick": {
"enable": true,
"mode": "push"
},
"resize": true
},
"modes": {
"repulse": {
"distance": 100,
"duration": 0.4
},
"push": {
"particles_nb": 4
}
}
},
"retina_detect": true
});
// Custom logic for glow effect
document.addEventListener('DOMContentLoaded', () => {
const pJS = window.pJSDom[0].pJS;
const targetElements = document.querySelectorAll('.feature-card, .nav-btn, .btn-minecraft');
// Function to check if a particle is behind or near an element
function checkParticleProximity() {
targetElements.forEach(element => {
const rect = element.getBoundingClientRect();
let hasGlow = false;
pJS.particles.array.forEach(particle => {
const particleX = particle.x + pJS.canvas.el.offsetLeft;
const particleY = particle.y + pJS.canvas.el.offsetTop;
const buffer = 20; // Buffer zone around element for glow trigger
// Check if particle is within or near the element's bounding box
if (
particleX >= rect.left - buffer &&
particleX <= rect.right + buffer &&
particleY >= rect.top - buffer &&
particleY <= rect.bottom + buffer
) {
hasGlow = true;
}
});
// Apply or remove glow effect
if (hasGlow) {
element.classList.add('glow-effect');
element.classList.remove('no-glow');
} else {
element.classList.remove('glow-effect');
element.classList.add('no-glow');
}
});
}
// Run proximity check in a separate animation loop
function animateGlowEffect() {
checkParticleProximity();
requestAnimationFrame(animateGlowEffect);
}
// Start the animation loop
animateGlowEffect();
});