Add SFTP Client Connection on Load
This commit is contained in:
148
public/js/app.js
148
public/js/app.js
@ -15,6 +15,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
let allProperties = {};
|
||||
let sftpCredentials = null;
|
||||
let isSftpOnline = false;
|
||||
let hasAttemptedSftpConnect = false;
|
||||
const filteredSettings = [
|
||||
'bug-report-link',
|
||||
'query.port',
|
||||
@ -493,78 +494,85 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const editPropertiesBtn = elements.editPropertiesBtn;
|
||||
const updateModsBtn = elements.updateModsBtn;
|
||||
const backupBtn = elements.backupBtn;
|
||||
const sftpBtn = elements.sftpBtn;
|
||||
// const sftpBtn = elements.sftpBtn; // Commented out as it appears to be disabled in the provided code
|
||||
const startBtn = document.getElementById('startBtn');
|
||||
const stopBtn = elements.stopBtn;
|
||||
const restartBtn = elements.restartBtn;
|
||||
const sftpBrowserSection = elements.sftpBrowserSection;
|
||||
|
||||
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') {
|
||||
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');
|
||||
sections.forEach(section => {
|
||||
if (section !== serverStatusSection) {
|
||||
section.classList.add('hidden');
|
||||
}
|
||||
});
|
||||
if (editPropertiesBtn) {
|
||||
editPropertiesBtn.classList.add('hidden');
|
||||
}
|
||||
if (updateModsBtn) {
|
||||
updateModsBtn.classList.add('hidden');
|
||||
}
|
||||
if (backupBtn) {
|
||||
backupBtn.classList.add('hidden');
|
||||
}
|
||||
// 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 (!state.hasShownStartNotification) {
|
||||
showNotification('Server is stopped. Click "Start" to enable all features.', 'error', 'server-stopped');
|
||||
state.hasShownStartNotification = true;
|
||||
}
|
||||
});
|
||||
if (editPropertiesBtn) {
|
||||
editPropertiesBtn.classList.add('hidden');
|
||||
}
|
||||
if (updateModsBtn) {
|
||||
updateModsBtn.classList.add('hidden');
|
||||
}
|
||||
if (backupBtn) {
|
||||
backupBtn.classList.add('hidden');
|
||||
}
|
||||
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 (!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');
|
||||
}
|
||||
if (updateModsBtn) {
|
||||
updateModsBtn.classList.remove('hidden');
|
||||
}
|
||||
if (backupBtn) {
|
||||
backupBtn.classList.remove('hidden');
|
||||
}
|
||||
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');
|
||||
}
|
||||
state.hasShownStartNotification = false;
|
||||
sections.forEach(section => {
|
||||
section.classList.remove('hidden');
|
||||
});
|
||||
if (editPropertiesBtn) {
|
||||
editPropertiesBtn.classList.remove('hidden');
|
||||
}
|
||||
if (updateModsBtn) {
|
||||
updateModsBtn.classList.remove('hidden');
|
||||
}
|
||||
if (backupBtn) {
|
||||
backupBtn.classList.remove('hidden');
|
||||
}
|
||||
// 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';
|
||||
}
|
||||
state.hasShownStartNotification = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateDockerLogsUI(message) {
|
||||
if (message.error) {
|
||||
@ -621,13 +629,14 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function updateSftpCacheUI(message) {
|
||||
// For testing, this is currently configured to be internally networked to port 22 for the given container.
|
||||
// The IP Address is sent from server side on page load, in theory, this should allow us to always allow
|
||||
// SFTP Client to WORK! Even if SFTP Holesail ports are down!
|
||||
// To Revert, move hostname to message.data.hostname and port to message.data.port
|
||||
// Doing so will configure the connection to the Jump node.
|
||||
if (message.data?.hostname && message.data?.port && message.data?.user && message.data?.password) {
|
||||
// For testing, this is currently configured to be internally networked to port 22 for the given container.
|
||||
// The IP Address is sent from server side on page load, in theory, this should allow us to always allow
|
||||
// SFTP Client to WORK! Even if SFTP Holesail ports are down!
|
||||
// To Revert, move hostname to message.data.hostname and port to message.data.port
|
||||
// Doing so will configure the connection to the Jump node.
|
||||
sftpCredentials = {
|
||||
hostname: message.data.ipAddress,
|
||||
port: 22,
|
||||
@ -639,6 +648,11 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
elements.sftpLink.textContent = sftpLinkText;
|
||||
state.sftpLink = sftpLinkText;
|
||||
}
|
||||
// Call connectSftp only if it hasn't been attempted yet
|
||||
if (!hasAttemptedSftpConnect) {
|
||||
hasAttemptedSftpConnect = true;
|
||||
connectSftp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1655,7 +1669,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
});
|
||||
|
||||
elements.sftpBtn.addEventListener('click', connectSftp);
|
||||
// elements.sftpBtn.addEventListener('click', connectSftp);
|
||||
|
||||
document.getElementById('refresh').addEventListener('click', async () => {
|
||||
if (ws && ws.readyState === WebSocket.OPEN) {
|
||||
|
Reference in New Issue
Block a user