fix notifications
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,78 +1,88 @@
|
||||
{{ define "notifications" }}
|
||||
{{ if .Notification }}
|
||||
<div id="notification-container" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
|
||||
<div class="bg-gray-800 rounded-lg shadow-lg max-w-md w-full mx-4 {{ if eq .NotificationType "error" }}border-l-4 border-red-500{{ else if eq .NotificationType "success" }}border-l-4 border-green-500{{ else }}border-l-4 border-blue-500{{ end }}">
|
||||
<div class="p-6">
|
||||
<div class="flex items-start">
|
||||
<div class="flex-shrink-0">
|
||||
{{ if eq .NotificationType "error" }}
|
||||
<svg class="h-6 w-6 text-red-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4v2m0 0a9 9 0 11-18 0 9 9 0 0118 0zm0-14a9 9 0 00-9 9m0 0a9 9 0 1018 0 9 9 0 00-18 0z" />
|
||||
</svg>
|
||||
{{ else if eq .NotificationType "success" }}
|
||||
<svg class="h-6 w-6 text-green-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
|
||||
</svg>
|
||||
{{ else }}
|
||||
<svg class="h-6 w-6 text-blue-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
|
||||
</svg>
|
||||
{{ end }}
|
||||
</div>
|
||||
<div class="ml-3 flex-1">
|
||||
<h3 class="text-lg font-medium {{ if eq .NotificationType "error" }}text-red-400{{ else if eq .NotificationType "success" }}text-green-400{{ else }}text-blue-400{{ end }}">
|
||||
{{ if eq .NotificationType "error" }}Error{{ else if eq .NotificationType "success" }}Success{{ else }}Information{{ end }}
|
||||
</h3>
|
||||
<div class="mt-2 text-sm text-gray-300">
|
||||
{{ .Notification }}
|
||||
</div>
|
||||
</div>
|
||||
<button onclick="closeNotification()" class="ml-3 text-gray-400 hover:text-gray-200">
|
||||
<svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor">
|
||||
<path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bg-gray-700 px-6 py-4 flex justify-end gap-3">
|
||||
<div id="notification-container" class="fixed top-4 right-4 max-w-md z-50">
|
||||
<div id="notification-toast" class="rounded-lg shadow-lg p-4 flex items-start gap-3 {{ if eq .NotificationType "error" }}bg-red-900 border-l-4 border-red-500{{ else if eq .NotificationType "success" }}bg-green-900 border-l-4 border-green-500{{ else }}bg-blue-900 border-l-4 border-blue-500{{ end }}" onmouseenter="pauseNotification()" onmouseleave="resumeNotification()">
|
||||
<div class="flex-shrink-0">
|
||||
{{ if eq .NotificationType "error" }}
|
||||
<button onclick="closeNotification()" class="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded font-medium transition">
|
||||
Dismiss
|
||||
</button>
|
||||
<svg class="h-5 w-5 text-red-400" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
{{ else if eq .NotificationType "success" }}
|
||||
<button onclick="closeNotification()" class="px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded font-medium transition">
|
||||
OK
|
||||
</button>
|
||||
<svg class="h-5 w-5 text-green-400" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
{{ else }}
|
||||
<button onclick="closeNotification()" class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded font-medium transition">
|
||||
OK
|
||||
</button>
|
||||
<svg class="h-5 w-5 text-blue-400" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd" />
|
||||
</svg>
|
||||
{{ end }}
|
||||
</div>
|
||||
<div class="flex-1">
|
||||
<p class="font-medium {{ if eq .NotificationType "error" }}text-red-200{{ else if eq .NotificationType "success" }}text-green-200{{ else }}text-blue-200{{ end }}">
|
||||
{{ .Notification }}
|
||||
</p>
|
||||
</div>
|
||||
<button onclick="closeNotification()" class="flex-shrink-0 text-gray-400 hover:text-white transition">
|
||||
<svg class="h-5 w-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<div id="notification-progress" class="mt-2 h-1 bg-gray-700 rounded" style="animation: shrink 5s linear forwards;"></div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
@keyframes shrink {
|
||||
from {
|
||||
width: 100%;
|
||||
}
|
||||
to {
|
||||
width: 0%;
|
||||
}
|
||||
}
|
||||
|
||||
#notification-progress.paused {
|
||||
animation-play-state: paused;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
var notificationTimeout;
|
||||
var isNotificationPaused = false;
|
||||
|
||||
function closeNotification() {
|
||||
var container = document.getElementById('notification-container');
|
||||
if (container) {
|
||||
container.remove();
|
||||
container.style.transition = 'opacity 0.3s ease-out';
|
||||
container.style.opacity = '0';
|
||||
setTimeout(function() {
|
||||
container.remove();
|
||||
}, 300);
|
||||
}
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var type = '{{ .NotificationType }}';
|
||||
if (type === 'success') {
|
||||
setTimeout(closeNotification, 5000);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var type = '{{ .NotificationType }}';
|
||||
if (type === 'success') {
|
||||
setTimeout(closeNotification, 5000);
|
||||
function pauseNotification() {
|
||||
isNotificationPaused = true;
|
||||
clearTimeout(notificationTimeout);
|
||||
var progress = document.getElementById('notification-progress');
|
||||
if (progress) {
|
||||
progress.classList.add('paused');
|
||||
}
|
||||
}
|
||||
|
||||
function resumeNotification() {
|
||||
if (isNotificationPaused) {
|
||||
isNotificationPaused = false;
|
||||
var progress = document.getElementById('notification-progress');
|
||||
if (progress) {
|
||||
progress.classList.remove('paused');
|
||||
}
|
||||
notificationTimeout = setTimeout(closeNotification, 5000);
|
||||
}
|
||||
}
|
||||
|
||||
// Auto-close after 5 seconds
|
||||
notificationTimeout = setTimeout(closeNotification, 5000);
|
||||
</script>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#https://adguardteam.github.io/HostlistsRegistry/assets/filter_27.txt
|
||||
#https://adguardteam.github.io/HostlistsRegistry/assets/filter_49.txt
|
||||
https://adguardteam.github.io/HostlistsRegistry/assets/filter_27.txt
|
||||
https://adguardteam.github.io/HostlistsRegistry/assets/filter_1.txt
|
||||
https://adguardteam.github.io/HostlistsRegistry/assets/filter_42.txt
|
||||
https://adguardteam.github.io/HostlistsRegistry/assets/filter_18.txt
|
||||
|
||||
Reference in New Issue
Block a user