update SFTP
This commit is contained in:
+156
-290
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -666,137 +659,127 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
// Reinitialize tagline element to handle dynamic DOM changes
|
||||
elements.tagline = document.getElementById('tagline');
|
||||
|
||||
function toggleSections(status) {
|
||||
const sections = document.querySelectorAll('.section-bg');
|
||||
const serverStatusSection = document.querySelector('.section-bg[data-section="server-status"]');
|
||||
const editPropertiesBtn = elements.editPropertiesBtn;
|
||||
const updateModsBtn = elements.updateModsBtn;
|
||||
const sftpBtn = elements.sftpBtn;
|
||||
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;
|
||||
startBtn.classList.add('disabled-btn');
|
||||
} else {
|
||||
startBtn.disabled = false;
|
||||
startBtn.classList.remove('disabled-btn');
|
||||
}
|
||||
}
|
||||
|
||||
if (status.toLowerCase() !== 'running') {
|
||||
sections.forEach(section => {
|
||||
if (section !== serverStatusSection) {
|
||||
section.classList.add('hidden');
|
||||
function toggleSections(status) {
|
||||
const sections = document.querySelectorAll('.section-bg');
|
||||
const serverStatusSection = document.querySelector('.section-bg[data-section="server-status"]');
|
||||
const editPropertiesBtn = elements.editPropertiesBtn;
|
||||
const updateModsBtn = elements.updateModsBtn;
|
||||
const sftpBtn = elements.sftpBtn;
|
||||
const startBtn = document.getElementById('startBtn');
|
||||
const stopBtn = elements.stopBtn;
|
||||
const restartBtn = elements.restartBtn;
|
||||
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;
|
||||
startBtn.classList.add('disabled-btn');
|
||||
} else {
|
||||
startBtn.disabled = false;
|
||||
startBtn.classList.remove('disabled-btn');
|
||||
}
|
||||
});
|
||||
if (editPropertiesBtn) {
|
||||
editPropertiesBtn.classList.add('hidden');
|
||||
editPropertiesBtn.style.display = 'none';
|
||||
}
|
||||
if (updateModsBtn) {
|
||||
updateModsBtn.classList.add('hidden');
|
||||
updateModsBtn.style.display = 'none';
|
||||
if (status.toLowerCase() !== 'running') {
|
||||
sections.forEach(section => {
|
||||
if (section !== serverStatusSection) {
|
||||
section.classList.add('hidden');
|
||||
}
|
||||
});
|
||||
if (editPropertiesBtn) {
|
||||
editPropertiesBtn.classList.add('hidden');
|
||||
editPropertiesBtn.style.display = 'none';
|
||||
}
|
||||
if (updateModsBtn) {
|
||||
updateModsBtn.classList.add('hidden');
|
||||
updateModsBtn.style.display = 'none';
|
||||
}
|
||||
if (sftpBtn) {
|
||||
sftpBtn.classList.add('hidden');
|
||||
}
|
||||
if (stopBtn) {
|
||||
stopBtn.disabled = true;
|
||||
stopBtn.classList.add('disabled-btn');
|
||||
}
|
||||
if (restartBtn) {
|
||||
restartBtn.disabled = true;
|
||||
restartBtn.classList.add('disabled-btn');
|
||||
}
|
||||
if (refreshBtn) {
|
||||
refreshBtn.classList.add('hidden');
|
||||
refreshBtn.style.display = 'none';
|
||||
}
|
||||
if (backupBtn) {
|
||||
backupBtn.classList.add('hidden');
|
||||
backupBtn.style.display = 'none';
|
||||
}
|
||||
if (logoutBtn) {
|
||||
logoutBtn.classList.add('hidden');
|
||||
logoutBtn.style.display = 'none';
|
||||
}
|
||||
if (mobileRefreshBtn && mobileRefreshBtn.parentElement) {
|
||||
mobileRefreshBtn.parentElement.classList.add('hidden');
|
||||
}
|
||||
if (mobileBackupBtn && mobileBackupBtn.parentElement) {
|
||||
mobileBackupBtn.parentElement.classList.add('hidden');
|
||||
}
|
||||
if (mobileLogoutBtn && mobileLogoutBtn.parentElement) {
|
||||
mobileLogoutBtn.parentElement.classList.add('hidden');
|
||||
}
|
||||
if (!state.hasShownStartNotification) {
|
||||
showNotification('Server is stopped. Click "Start" to enable all features.', 'error', 'server-stopped');
|
||||
state.hasShownStartNotification = true;
|
||||
}
|
||||
} else {
|
||||
sections.forEach(section => {
|
||||
section.classList.remove('hidden');
|
||||
});
|
||||
if (editPropertiesBtn) {
|
||||
editPropertiesBtn.classList.remove('hidden');
|
||||
editPropertiesBtn.style.display = '';
|
||||
}
|
||||
if (updateModsBtn) {
|
||||
updateModsBtn.classList.remove('hidden');
|
||||
updateModsBtn.style.display = '';
|
||||
}
|
||||
if (sftpBtn) {
|
||||
sftpBtn.classList.remove('hidden');
|
||||
}
|
||||
if (stopBtn) {
|
||||
stopBtn.disabled = false;
|
||||
stopBtn.classList.remove('disabled-btn');
|
||||
}
|
||||
if (restartBtn) {
|
||||
restartBtn.disabled = false;
|
||||
restartBtn.classList.remove('disabled-btn');
|
||||
}
|
||||
if (refreshBtn) {
|
||||
refreshBtn.classList.remove('hidden');
|
||||
refreshBtn.style.display = '';
|
||||
}
|
||||
if (backupBtn) {
|
||||
backupBtn.classList.remove('hidden');
|
||||
refreshBtn.style.display = '';
|
||||
}
|
||||
if (logoutBtn) {
|
||||
logoutBtn.classList.remove('hidden');
|
||||
logoutBtn.style.display = '';
|
||||
}
|
||||
if (mobileRefreshBtn && mobileRefreshBtn.parentElement) {
|
||||
mobileRefreshBtn.parentElement.classList.remove('hidden');
|
||||
}
|
||||
if (mobileBackupBtn && mobileBackupBtn.parentElement) {
|
||||
mobileBackupBtn.parentElement.classList.remove('hidden');
|
||||
}
|
||||
if (mobileLogoutBtn && mobileLogoutBtn.parentElement) {
|
||||
mobileLogoutBtn.parentElement.classList.remove('hidden');
|
||||
}
|
||||
state.hasShownStartNotification = false;
|
||||
}
|
||||
if (sftpBtn) {
|
||||
sftpBtn.classList.add('hidden');
|
||||
}
|
||||
if (stopBtn) {
|
||||
stopBtn.disabled = true;
|
||||
stopBtn.classList.add('disabled-btn');
|
||||
}
|
||||
if (restartBtn) {
|
||||
restartBtn.disabled = true;
|
||||
restartBtn.classList.add('disabled-btn');
|
||||
}
|
||||
if (sftpBrowserSection) {
|
||||
sftpBrowserSection.style.display = 'none';
|
||||
}
|
||||
if (refreshBtn) {
|
||||
refreshBtn.classList.add('hidden');
|
||||
refreshBtn.style.display = 'none';
|
||||
}
|
||||
if (backupBtn) {
|
||||
backupBtn.classList.add('hidden');
|
||||
backupBtn.style.display = 'none';
|
||||
}
|
||||
if (logoutBtn) {
|
||||
logoutBtn.classList.add('hidden');
|
||||
logoutBtn.style.display = 'none';
|
||||
}
|
||||
if (mobileRefreshBtn && mobileRefreshBtn.parentElement) {
|
||||
mobileRefreshBtn.parentElement.classList.add('hidden');
|
||||
}
|
||||
if (mobileBackupBtn && mobileBackupBtn.parentElement) {
|
||||
mobileBackupBtn.parentElement.classList.add('hidden');
|
||||
}
|
||||
if (mobileLogoutBtn && mobileLogoutBtn.parentElement) {
|
||||
mobileLogoutBtn.parentElement.classList.add('hidden');
|
||||
}
|
||||
if (!state.hasShownStartNotification) {
|
||||
showNotification('Server is stopped. Click "Start" to enable all features.', 'error', 'server-stopped');
|
||||
state.hasShownStartNotification = true;
|
||||
}
|
||||
} else {
|
||||
sections.forEach(section => {
|
||||
section.classList.remove('hidden');
|
||||
});
|
||||
if (editPropertiesBtn) {
|
||||
editPropertiesBtn.classList.remove('hidden');
|
||||
editPropertiesBtn.style.display = '';
|
||||
}
|
||||
if (updateModsBtn) {
|
||||
updateModsBtn.classList.remove('hidden');
|
||||
updateModsBtn.style.display = '';
|
||||
}
|
||||
if (sftpBtn) {
|
||||
sftpBtn.classList.remove('hidden');
|
||||
}
|
||||
if (stopBtn) {
|
||||
stopBtn.disabled = false;
|
||||
stopBtn.classList.remove('disabled-btn');
|
||||
}
|
||||
if (restartBtn) {
|
||||
restartBtn.disabled = false;
|
||||
restartBtn.classList.remove('disabled-btn');
|
||||
}
|
||||
if (sftpBrowserSection) {
|
||||
sftpBrowserSection.style.display = 'block';
|
||||
}
|
||||
if (refreshBtn) {
|
||||
refreshBtn.classList.remove('hidden');
|
||||
refreshBtn.style.display = '';
|
||||
}
|
||||
if (backupBtn) {
|
||||
backupBtn.classList.remove('hidden');
|
||||
refreshBtn.style.display = '';
|
||||
}
|
||||
if (logoutBtn) {
|
||||
logoutBtn.classList.remove('hidden');
|
||||
logoutBtn.style.display = '';
|
||||
}
|
||||
if (mobileRefreshBtn && mobileRefreshBtn.parentElement) {
|
||||
mobileRefreshBtn.parentElement.classList.remove('hidden');
|
||||
}
|
||||
if (mobileBackupBtn && mobileBackupBtn.parentElement) {
|
||||
mobileBackupBtn.parentElement.classList.remove('hidden');
|
||||
}
|
||||
if (mobileLogoutBtn && mobileLogoutBtn.parentElement) {
|
||||
mobileLogoutBtn.parentElement.classList.remove('hidden');
|
||||
}
|
||||
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,45 +2111,51 @@ 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);
|
||||
const response = await fetch('https://sftp.my-mc.link/auto-connection', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
host: sftpCredentials.hostname.replace('sftp://', ''),
|
||||
port: sftpCredentials.port,
|
||||
username: sftpCredentials.user,
|
||||
password: sftpCredentials.password,
|
||||
}),
|
||||
});
|
||||
const key = `action-sftp-connect`;
|
||||
let success = false;
|
||||
|
||||
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);
|
||||
} else {
|
||||
updateNotification(notification, 'Failed to establish SFTP connection.', 'error', key);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('SFTP connection error:', error);
|
||||
showNotification(`Failed to connect to SFTP: ${error.message}`, 'error', 'sftp-connect-error');
|
||||
// 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: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
host: sftpCredentials.hostname.replace('sftp://', ''),
|
||||
port: sftpCredentials.port,
|
||||
username: sftpCredentials.user,
|
||||
password: sftpCredentials.password,
|
||||
}),
|
||||
});
|
||||
const result = await response.json();
|
||||
if (result.success && result.connectionUrl) {
|
||||
elements.sftpIframe.src = result.connectionUrl;
|
||||
elements.sftpBrowserSection.style.display = 'block';
|
||||
success = true;
|
||||
} else {
|
||||
throw new Error('Failed to establish SFTP connection.');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('SFTP connection error:', 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
elements.loginBtn.addEventListener('click', () => {
|
||||
apiKey = elements.loginApiKey.value.trim();
|
||||
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user