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

31
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
const closeButton = alert.querySelector('.close-btn');
closeButton.addEventListener('click', () => {
alert.remove(); // Remove alert on close
});
// Append alert to container
alertContainer.appendChild(alert);
// Automatically remove alert after 5 seconds
setTimeout(() => { setTimeout(() => {
alert.remove(); container.removeChild(alertBox);
}, 5000); }, 5000);
} else {
console.warn('[WARN] Alert container not found.');
}
} }
// 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

@ -254,7 +254,8 @@
#alert-container { #alert-container {
position: fixed; position: fixed;
bottom: 20px; bottom: 20px;
right: 20px; left: 50%;
transform: translateX(-50%);
z-index: 1055; z-index: 1055;
/* Ensure it overlays important elements only */ /* Ensure it overlays important elements only */
display: flex; display: flex;
@ -264,13 +265,25 @@
/* Add space between alerts */ /* Add space between alerts */
pointer-events: none; pointer-events: none;
/* Prevent container from blocking clicks */ /* Prevent container from blocking clicks */
} }
.alert { #alert-container {
position: fixed;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
z-index: 1055;
display: flex; display: flex;
flex-direction: column-reverse;
gap: 10px;
pointer-events: none;
/* Prevent container from blocking clicks */
}
.alert {
display: inline-flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
max-width: 80%;
padding: 12px 20px; padding: 12px 20px;
background-color: #2b2b2b; background-color: #2b2b2b;
color: #e0e0e0; color: #e0e0e0;
@ -284,7 +297,7 @@
text-overflow: ellipsis; text-overflow: ellipsis;
pointer-events: auto; pointer-events: auto;
/* Allow alerts to be interactive */ /* 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();