This commit is contained in:
Raven Scott 2024-12-02 05:58:22 -05:00
parent 3457eb0e46
commit 605e30c368
3 changed files with 61 additions and 54 deletions

35
app.js
View File

@ -266,33 +266,26 @@ function hideStatusIndicator() {
} }
} }
// Show Alert // Show Alert
// Show alert message
function showAlert(type, message) { function showAlert(type, message) {
const alertContainer = document.getElementById('alert-container'); const alertBox = document.createElement('div');
alertBox.className = `alert alert-${type}`;
alertBox.textContent = message;
// Create alert element const container = document.querySelector('#alert-container');
const alert = document.createElement('div'); if (container) {
alert.className = `alert ${type}`; container.appendChild(alertBox);
alert.innerHTML = `
<span>${message}</span>
<button class="close-btn" aria-label="Close">&times;</button>
`;
// Add close button functionality setTimeout(() => {
const closeButton = alert.querySelector('.close-btn'); container.removeChild(alertBox);
closeButton.addEventListener('click', () => { }, 5000);
alert.remove(); // Remove alert on close } else {
}); console.warn('[WARN] Alert container not found.');
}
// Append alert to container
alertContainer.appendChild(alert);
// Automatically remove alert after 5 seconds
setTimeout(() => {
alert.remove();
}, 5000);
} }
// Collapse Sidebar Functionality // Collapse Sidebar Functionality
const collapseSidebarBtn = document.getElementById('collapse-sidebar-btn'); const collapseSidebarBtn = document.getElementById('collapse-sidebar-btn');
collapseSidebarBtn.addEventListener('click', () => { collapseSidebarBtn.addEventListener('click', () => {

View File

@ -252,39 +252,52 @@
} }
#alert-container { #alert-container {
position: fixed; position: fixed;
bottom: 20px; bottom: 20px;
right: 20px; left: 50%;
z-index: 1055; transform: translateX(-50%);
/* Ensure it overlays important elements only */ z-index: 1055;
display: flex; /* Ensure it overlays important elements only */
flex-direction: column-reverse; display: flex;
/* Stack alerts upwards */ flex-direction: column-reverse;
gap: 10px; /* Stack alerts upwards */
/* Add space between alerts */ gap: 10px;
pointer-events: none; /* Add space between alerts */
/* Prevent container from blocking clicks */ pointer-events: none;
} /* Prevent container from blocking clicks */
}
.alert { #alert-container {
display: flex; position: fixed;
align-items: center; bottom: 20px;
justify-content: space-between; left: 50%;
max-width: 80%; transform: translateX(-50%);
padding: 12px 20px; z-index: 1055;
background-color: #2b2b2b; display: flex;
color: #e0e0e0; flex-direction: column-reverse;
border-radius: 6px; gap: 10px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5); pointer-events: none;
font-family: Arial, sans-serif; /* Prevent container from blocking clicks */
font-size: 14px; }
animation: fadeIn 0.3s ease-out, fadeOut 4.5s ease-in forwards;
white-space: nowrap; .alert {
overflow: hidden; display: inline-flex;
text-overflow: ellipsis; align-items: center;
pointer-events: auto; justify-content: space-between;
/* Allow alerts to be interactive */ padding: 12px 20px;
} background-color: #2b2b2b;
color: #e0e0e0;
border-radius: 6px;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
font-family: Arial, sans-serif;
font-size: 14px;
animation: fadeIn 0.3s ease-out, fadeOut 4.5s ease-in forwards;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
pointer-events: auto;
/* Allow alerts to be interactive */
}
.alert.success { .alert.success {
border-left: 6px solid #28a745; border-left: 6px solid #28a745;
@ -673,6 +686,7 @@
<div id="alert-container" class="position-fixed top-0 start-50 translate-middle-x mt-3" <div id="alert-container" class="position-fixed top-0 start-50 translate-middle-x mt-3"
style="z-index: 1051; max-width: 90%;"></div> style="z-index: 1051; max-width: 90%;"></div>
<!-- xterm.js --> <!-- xterm.js -->
<script src="https://cdn.jsdelivr.net/npm/xterm/lib/xterm.js"></script> <script src="https://cdn.jsdelivr.net/npm/xterm/lib/xterm.js"></script>

View File

@ -230,7 +230,7 @@ deployForm.addEventListener('submit', async (e) => {
// Wait for deployment to complete // Wait for deployment to complete
const successResponse = await deployDockerContainer(deployPayload); const successResponse = await deployDockerContainer(deployPayload);
hideStatusIndicator(); hideStatusIndicator();
showAlert('success', successResponse.message); // showAlert('success', successResponse.message);
} catch (error) { } catch (error) {
console.error('[ERROR] Failed to deploy container:', error.message); console.error('[ERROR] Failed to deploy container:', error.message);
hideStatusIndicator(); hideStatusIndicator();