467 lines
12 KiB
HTML
467 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>Notification System Demo</title>
|
|
<link rel="icon" type="image/png" href="/admin/favicon.png" />
|
|
<link
|
|
rel="stylesheet"
|
|
href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css"
|
|
/>
|
|
<style>
|
|
body {
|
|
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
|
|
max-width: 800px;
|
|
margin: 50px auto;
|
|
padding: 20px;
|
|
background: #f5f5f5;
|
|
}
|
|
.demo-container {
|
|
background: white;
|
|
padding: 40px;
|
|
border-radius: 12px;
|
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
|
}
|
|
h1 {
|
|
color: #333;
|
|
margin-bottom: 10px;
|
|
}
|
|
.subtitle {
|
|
color: #666;
|
|
margin-bottom: 30px;
|
|
}
|
|
.button-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
gap: 15px;
|
|
margin-bottom: 30px;
|
|
}
|
|
button {
|
|
padding: 15px 25px;
|
|
border: none;
|
|
border-radius: 8px;
|
|
font-size: 15px;
|
|
font-weight: 500;
|
|
cursor: pointer;
|
|
transition: all 0.2s;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 10px;
|
|
}
|
|
.btn-success {
|
|
background: #10b981;
|
|
color: white;
|
|
}
|
|
.btn-success:hover {
|
|
background: #059669;
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
|
|
}
|
|
.btn-error {
|
|
background: #ef4444;
|
|
color: white;
|
|
}
|
|
.btn-error:hover {
|
|
background: #dc2626;
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
|
|
}
|
|
.btn-loading {
|
|
background: #667eea;
|
|
color: white;
|
|
}
|
|
.btn-loading:hover {
|
|
background: #5568d3;
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
|
|
}
|
|
.info-box {
|
|
background: #eff6ff;
|
|
border-left: 4px solid #3b82f6;
|
|
padding: 20px;
|
|
border-radius: 8px;
|
|
margin-top: 30px;
|
|
}
|
|
.info-box h3 {
|
|
margin-top: 0;
|
|
color: #1e40af;
|
|
}
|
|
.info-box ul {
|
|
margin-bottom: 0;
|
|
}
|
|
.info-box li {
|
|
margin-bottom: 8px;
|
|
color: #334155;
|
|
}
|
|
|
|
/* Notification Styles (copied from users.html) */
|
|
#notificationContainer {
|
|
position: fixed;
|
|
top: 20px;
|
|
right: 20px;
|
|
z-index: 9999;
|
|
max-width: 400px;
|
|
}
|
|
|
|
.notification {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
padding: 16px 20px;
|
|
margin-bottom: 12px;
|
|
border-radius: 8px;
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
background: white;
|
|
border-left: 4px solid;
|
|
animation: slideIn 0.3s ease-out, fadeOut 0.3s ease-in 2.7s;
|
|
opacity: 1;
|
|
transform: translateX(0);
|
|
min-width: 320px;
|
|
}
|
|
|
|
.notification.removing {
|
|
animation: slideOut 0.3s ease-in;
|
|
}
|
|
|
|
.notification-success {
|
|
border-left-color: #10b981;
|
|
background: linear-gradient(to right, #f0fdf4 0%, #ffffff 100%);
|
|
}
|
|
|
|
.notification-error {
|
|
border-left-color: #ef4444;
|
|
background: linear-gradient(to right, #fef2f2 0%, #ffffff 100%);
|
|
}
|
|
|
|
.notification-icon {
|
|
font-size: 24px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.notification-success .notification-icon {
|
|
color: #10b981;
|
|
}
|
|
|
|
.notification-error .notification-icon {
|
|
color: #ef4444;
|
|
}
|
|
|
|
.notification-content {
|
|
flex: 1;
|
|
}
|
|
|
|
.notification-title {
|
|
font-weight: 600;
|
|
font-size: 14px;
|
|
margin-bottom: 4px;
|
|
color: #111;
|
|
}
|
|
|
|
.notification-message {
|
|
font-size: 13px;
|
|
color: #666;
|
|
line-height: 1.4;
|
|
}
|
|
|
|
.notification-close {
|
|
background: none;
|
|
border: none;
|
|
font-size: 20px;
|
|
color: #999;
|
|
cursor: pointer;
|
|
padding: 0;
|
|
width: 24px;
|
|
height: 24px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
border-radius: 4px;
|
|
transition: all 0.2s;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.notification-close:hover {
|
|
background: rgba(0, 0, 0, 0.05);
|
|
color: #333;
|
|
}
|
|
|
|
@keyframes slideIn {
|
|
from {
|
|
transform: translateX(400px);
|
|
opacity: 0;
|
|
}
|
|
to {
|
|
transform: translateX(0);
|
|
opacity: 1;
|
|
}
|
|
}
|
|
|
|
@keyframes slideOut {
|
|
from {
|
|
transform: translateX(0);
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
transform: translateX(400px);
|
|
opacity: 0;
|
|
}
|
|
}
|
|
|
|
@keyframes fadeOut {
|
|
from {
|
|
opacity: 1;
|
|
}
|
|
to {
|
|
opacity: 0.7;
|
|
}
|
|
}
|
|
|
|
.loading-overlay {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background: rgba(0, 0, 0, 0.3);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
z-index: 9998;
|
|
backdrop-filter: blur(2px);
|
|
}
|
|
|
|
.loading-spinner-container {
|
|
background: white;
|
|
padding: 30px 40px;
|
|
border-radius: 12px;
|
|
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
|
|
text-align: center;
|
|
}
|
|
|
|
.loading-spinner-icon {
|
|
width: 50px;
|
|
height: 50px;
|
|
border: 4px solid #f3f3f3;
|
|
border-top: 4px solid #667eea;
|
|
border-radius: 50%;
|
|
animation: spin 1s linear infinite;
|
|
margin: 0 auto 15px;
|
|
}
|
|
|
|
.loading-spinner-text {
|
|
color: #333;
|
|
font-size: 16px;
|
|
font-weight: 500;
|
|
}
|
|
|
|
@keyframes spin {
|
|
0% {
|
|
transform: rotate(0deg);
|
|
}
|
|
100% {
|
|
transform: rotate(360deg);
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="demo-container">
|
|
<h1>🎨 Custom Notification System</h1>
|
|
<p class="subtitle">
|
|
Test the new notification system for user management
|
|
</p>
|
|
|
|
<div class="button-grid">
|
|
<button class="btn-success" onclick="testSuccess()">
|
|
<i class="bi bi-check-circle"></i>
|
|
Show Success
|
|
</button>
|
|
<button class="btn-error" onclick="testError()">
|
|
<i class="bi bi-x-circle"></i>
|
|
Show Error
|
|
</button>
|
|
<button class="btn-loading" onclick="testLoading()">
|
|
<i class="bi bi-hourglass-split"></i>
|
|
Show Loading
|
|
</button>
|
|
<button class="btn-success" onclick="testMultiple()">
|
|
<i class="bi bi-stack"></i>
|
|
Multiple Notifications
|
|
</button>
|
|
</div>
|
|
|
|
<div class="info-box">
|
|
<h3>✨ Features</h3>
|
|
<ul>
|
|
<li>
|
|
<strong>Custom Design:</strong> Beautiful, non-intrusive
|
|
notifications
|
|
</li>
|
|
<li>
|
|
<strong>Auto-dismiss:</strong> Notifications automatically fade
|
|
after 3 seconds
|
|
</li>
|
|
<li>
|
|
<strong>Manual Close:</strong> Click the X button to close
|
|
immediately
|
|
</li>
|
|
<li>
|
|
<strong>Loading Overlay:</strong> Full-screen loading indicator with
|
|
spinner
|
|
</li>
|
|
<li>
|
|
<strong>Smooth Animations:</strong> Slide-in and slide-out
|
|
transitions
|
|
</li>
|
|
<li>
|
|
<strong>Stack Support:</strong> Multiple notifications stack nicely
|
|
</li>
|
|
<li>
|
|
<strong>No Browser Alerts:</strong> Replaced with styled, modern
|
|
notifications
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div
|
|
class="info-box"
|
|
style="
|
|
background: #fef9c3;
|
|
border-left-color: #eab308;
|
|
margin-top: 15px;
|
|
"
|
|
>
|
|
<h3 style="color: #854d0e">💡 Usage in User Management</h3>
|
|
<ul>
|
|
<li>✅ Creating user → Shows loading, then success notification</li>
|
|
<li>✅ Updating user → Shows loading, then success notification</li>
|
|
<li>
|
|
✅ Changing password → Shows loading, then success notification
|
|
</li>
|
|
<li>✅ Deleting user → Shows loading, then success notification</li>
|
|
<li>❌ Any error → Shows error notification with details</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Notification Container -->
|
|
<div id="notificationContainer"></div>
|
|
|
|
<script>
|
|
// Custom notification system
|
|
function showNotification(type, title, message) {
|
|
const container = document.getElementById("notificationContainer");
|
|
const notification = document.createElement("div");
|
|
notification.className = `notification notification-${type}`;
|
|
|
|
const icon =
|
|
type === "success"
|
|
? '<i class="bi bi-check-circle-fill"></i>'
|
|
: '<i class="bi bi-exclamation-circle-fill"></i>';
|
|
|
|
notification.innerHTML = `
|
|
<div class="notification-icon">${icon}</div>
|
|
<div class="notification-content">
|
|
<div class="notification-title">${title}</div>
|
|
<div class="notification-message">${message}</div>
|
|
</div>
|
|
<button class="notification-close" onclick="closeNotification(this)">
|
|
<i class="bi bi-x"></i>
|
|
</button>
|
|
`;
|
|
|
|
container.appendChild(notification);
|
|
|
|
// Auto remove after 3 seconds
|
|
setTimeout(() => {
|
|
if (notification.parentElement) {
|
|
notification.classList.add("removing");
|
|
setTimeout(() => {
|
|
if (notification.parentElement) {
|
|
notification.remove();
|
|
}
|
|
}, 300);
|
|
}
|
|
}, 3000);
|
|
}
|
|
|
|
function closeNotification(button) {
|
|
const notification = button.closest(".notification");
|
|
notification.classList.add("removing");
|
|
setTimeout(() => {
|
|
notification.remove();
|
|
}, 300);
|
|
}
|
|
|
|
function showLoading(message = "Loading...") {
|
|
const overlay = document.createElement("div");
|
|
overlay.className = "loading-overlay";
|
|
overlay.id = "loadingOverlay";
|
|
overlay.innerHTML = `
|
|
<div class="loading-spinner-container">
|
|
<div class="loading-spinner-icon"></div>
|
|
<div class="loading-spinner-text">${message}</div>
|
|
</div>
|
|
`;
|
|
document.body.appendChild(overlay);
|
|
}
|
|
|
|
function hideLoading() {
|
|
const overlay = document.getElementById("loadingOverlay");
|
|
if (overlay) {
|
|
overlay.remove();
|
|
}
|
|
}
|
|
|
|
// Test functions
|
|
function testSuccess() {
|
|
showNotification(
|
|
"success",
|
|
"Success!",
|
|
"User has been saved successfully"
|
|
);
|
|
}
|
|
|
|
function testError() {
|
|
showNotification(
|
|
"error",
|
|
"Error",
|
|
"Failed to save user. Please try again."
|
|
);
|
|
}
|
|
|
|
function testLoading() {
|
|
showLoading("Saving user...");
|
|
setTimeout(() => {
|
|
hideLoading();
|
|
showNotification(
|
|
"success",
|
|
"Complete!",
|
|
"Operation finished successfully"
|
|
);
|
|
}, 2000);
|
|
}
|
|
|
|
function testMultiple() {
|
|
showNotification("success", "User Created", "John Doe has been added");
|
|
setTimeout(() => {
|
|
showNotification(
|
|
"success",
|
|
"Email Sent",
|
|
"Welcome email has been sent"
|
|
);
|
|
}, 500);
|
|
setTimeout(() => {
|
|
showNotification(
|
|
"success",
|
|
"Permissions Set",
|
|
"User permissions configured"
|
|
);
|
|
}, 1000);
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|