318 lines
14 KiB
Text
318 lines
14 KiB
Text
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>@ViewData["Title"] - Web</title>
|
|
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
|
|
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
|
<link rel="stylesheet" href="~/Web.styles.css" asp-append-version="true" />
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
|
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css" />
|
|
|
|
</head>
|
|
<body>
|
|
|
|
<div class="wrapper d-flex align-items-stretch">
|
|
<nav id="sidebar" class="active">
|
|
<h1><a class="logo">OS</a></h1>
|
|
<ul class="list-unstyled components mb-5">
|
|
<li class="sidebarCollapse">
|
|
<a asp-controller="admin" asp-action="index"><span class="bi bi-speedometer"></span> Admin</a>
|
|
</li>
|
|
<li>
|
|
<a asp-controller="Page" asp-action="index"><span class="bi bi-file-earmark-fill"></span> Pages</a>
|
|
</li>
|
|
<li>
|
|
<a asp-controller="banner" asp-action="index"><span class="bi bi-card-image"></span> Banners</a>
|
|
</li>
|
|
<li>
|
|
<a asp-controller="footer" asp-action="index"><span class="bi bi-c-circle-fill"></span> Footer</a>
|
|
</li>
|
|
<li>
|
|
<a asp-controller="address" asp-action="index"><span class="bi bi-pin-map"></span> Address</a>
|
|
</li>
|
|
<li>
|
|
<a asp-controller="SocialMedia" asp-action="index"><span class="bi bi-collection-play-fill"></span> Social Media</a>
|
|
</li>
|
|
<li>
|
|
|
|
<a asp-controller="Questionnaire" asp-action="index"><span class="bi bi-question-circle"></span> Survey</a>
|
|
</li>
|
|
<li>
|
|
<a asp-controller="SurveyAnalysis" asp-action="index"><span class="bi bi-graph-up-arrow"></span> Analyzer</a>
|
|
</li>
|
|
<li>
|
|
|
|
<a asp-controller="UserResponse" asp-action="index"><span class="bi bi-clipboard-data"></span> Response</a>
|
|
</li>
|
|
<li>
|
|
|
|
<a asp-controller="UserResponseStatus" asp-action="index"><span class="bi bi-heart-pulse"></span> User status</a>
|
|
</li>
|
|
<li>
|
|
<a asp-controller="newsletters" asp-action="index"><span class="bi bi-newspaper"></span> Subscibers</a>
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
</nav>
|
|
|
|
<!-- Page Content -->
|
|
<div id="content">
|
|
|
|
<nav class="navbar navbar-expand-lg navbar-light bg-brimary">
|
|
<div class="container-fluid">
|
|
<button type="button" id="sidebarCollapse" class="btn btn-primary">
|
|
<i class="bi bi-list"></i>
|
|
<span class="sr-only">Toggle Menu</span>
|
|
</button>
|
|
<button class="navbar-toggler btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
|
aria-expanded="false" aria-label="Toggle navigation">
|
|
<i class="bi bi-list"></i>
|
|
<span class="sr-only"></span>
|
|
</button>
|
|
|
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
|
<ul class="nav navbar-nav ml-auto">
|
|
|
|
<span class="dropdown m-2">
|
|
<button class="bg-transparent text-white btn-sm dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
|
|
<span class="badge badge-danger" id="notificationCount">0</span>
|
|
</button>
|
|
<ul class="dropdown-menu" id="notificationDropdown">
|
|
<li>
|
|
<a class="dropdown-item" href="#">
|
|
|
|
<div id="notifications">
|
|
|
|
</div>
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</span>
|
|
|
|
|
|
|
|
<span class="dropdown m-2">
|
|
<button class="btn btn-primary btn-sm dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
|
|
Account
|
|
</button>
|
|
<ul class="dropdown-menu">
|
|
<li><a class="dropdown-item" asp-controller="Roles" asp-action="index">Roles</a></li>
|
|
<li><a class="dropdown-item" asp-controller="Users" asp-action="index">Users</a></li>
|
|
</ul>
|
|
</span>
|
|
<li class="nav-item m-2">
|
|
<form asp-area="Admin" asp-controller="Admin" asp-action="Logout" method="post">
|
|
<button type="submit" class="btn btn-danger btn-sm"><span class="bi bi-box-arrow-left"></span> Logout</button>
|
|
</form>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
|
|
<main>
|
|
|
|
@RenderBody()
|
|
</main>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
|
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
|
<script src="~/js/site.js" asp-append-version="true"></script>
|
|
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/microsoft-signalr/5.0.11/signalr.min.js"></script>
|
|
<script type="text/javascript">
|
|
// Establish a connection to the SignalR hub
|
|
const connection = new signalR.HubConnectionBuilder()
|
|
.withUrl("/notificationHub")
|
|
.build();
|
|
|
|
// Function to load notifications from local storage
|
|
function loadNotifications() {
|
|
const notificationsList = document.getElementById("notifications");
|
|
const notificationCount = document.getElementById("notificationCount");
|
|
|
|
// Retrieve notifications from local storage
|
|
const storedNotifications = JSON.parse(localStorage.getItem("notifications")) || [];
|
|
|
|
// Update the notification count
|
|
notificationCount.textContent = storedNotifications.length;
|
|
|
|
// Add each stored notification to the list
|
|
storedNotifications.forEach(notification => {
|
|
const div = document.createElement("div");
|
|
div.className = "list-group-item";
|
|
|
|
const link = document.createElement("a");
|
|
link.href = `/admin/UserResponseStatus/UserResponsesStatus?UserEmail=${notification.email}`;
|
|
link.textContent = notification.text;
|
|
link.addEventListener("click", () => {
|
|
removeNotification(div, notification.id);
|
|
});
|
|
|
|
div.appendChild(link);
|
|
notificationsList.appendChild(div);
|
|
});
|
|
}
|
|
|
|
// Function to add a notification to the list
|
|
function addNotification(userName, email) {
|
|
const notificationsList = document.getElementById("notifications");
|
|
const notificationCount = document.getElementById("notificationCount");
|
|
|
|
// Create a unique ID for the notification
|
|
const notificationId = Date.now();
|
|
|
|
// Create notification item
|
|
const div = document.createElement("div");
|
|
div.className = "list-group-item";
|
|
|
|
const link = document.createElement("a");
|
|
link.href = `/admin/UserResponseStatus/UserResponsesStatus?UserEmail=${email}`;
|
|
link.textContent = ` ${userName}`;
|
|
link.addEventListener("click", () => {
|
|
removeNotification(div, notificationId);
|
|
});
|
|
|
|
div.appendChild(link);
|
|
notificationsList.appendChild(div);
|
|
|
|
// Update the notification count
|
|
notificationCount.textContent = parseInt(notificationCount.textContent) + 1;
|
|
|
|
// Store the notification in local storage
|
|
const storedNotifications = JSON.parse(localStorage.getItem("notifications")) || [];
|
|
storedNotifications.push({ id: notificationId, text: link.textContent, email: email });
|
|
localStorage.setItem("notifications", JSON.stringify(storedNotifications));
|
|
}
|
|
|
|
// Function to remove a notification
|
|
function removeNotification(div, id) {
|
|
div.remove();
|
|
|
|
// Update the notification count
|
|
const notificationCount = document.getElementById("notificationCount");
|
|
notificationCount.textContent = parseInt(notificationCount.textContent) - 1;
|
|
|
|
// Remove the notification from local storage
|
|
let storedNotifications = JSON.parse(localStorage.getItem("notifications")) || [];
|
|
storedNotifications = storedNotifications.filter(notification => notification.id !== id);
|
|
localStorage.setItem("notifications", JSON.stringify(storedNotifications));
|
|
}
|
|
|
|
// Receive notification from the server
|
|
connection.on("ReceiveNotification", function (userName, email) {
|
|
addNotification(userName, email);
|
|
});
|
|
|
|
// Start the connection
|
|
connection.start().then(loadNotifications).catch(function (err) {
|
|
return console.error(err.toString());
|
|
});
|
|
</script>
|
|
|
|
|
|
@* <script type="text/javascript">
|
|
// Establish a connection to the SignalR hub
|
|
const connection = new signalR.HubConnectionBuilder()
|
|
.withUrl("/notificationHub")
|
|
.build();
|
|
|
|
// Function to load notifications from local storage
|
|
function loadNotifications() {
|
|
const notificationsList = document.getElementById("notifications");
|
|
const notificationCount = document.getElementById("notificationCount");
|
|
|
|
// Retrieve notifications from local storage
|
|
const storedNotifications = JSON.parse(localStorage.getItem("notifications")) || [];
|
|
|
|
// Update the notification count
|
|
notificationCount.textContent = storedNotifications.length;
|
|
|
|
// Add each stored notification to the list
|
|
storedNotifications.forEach(notification => {
|
|
const div = document.createElement("div");
|
|
div.className = "list-group-item";
|
|
div.textContent = notification.text;
|
|
|
|
// Add click event to remove notification
|
|
div.addEventListener("click", () => {
|
|
removeNotification(div, notification.id);
|
|
});
|
|
|
|
notificationsList.appendChild(div);
|
|
});
|
|
}
|
|
|
|
// Function to add a notification to the list
|
|
function addNotification(userName, email) {
|
|
const notificationsList = document.getElementById("notifications");
|
|
const notificationCount = document.getElementById("notificationCount");
|
|
|
|
// Create a unique ID for the notification
|
|
const notificationId = Date.now();
|
|
|
|
// Create notification item
|
|
const div = document.createElement("div");
|
|
div.className = "list-group-item";
|
|
div.textContent = `New submission from ${userName}`;
|
|
|
|
// Add click event to remove notification
|
|
div.addEventListener("click", () => {
|
|
removeNotification(div, notificationId);
|
|
});
|
|
|
|
// Append the new notification
|
|
notificationsList.appendChild(div);
|
|
|
|
// Update the notification count
|
|
notificationCount.textContent = parseInt(notificationCount.textContent) + 1;
|
|
|
|
// Store the notification in local storage
|
|
const storedNotifications = JSON.parse(localStorage.getItem("notifications")) || [];
|
|
storedNotifications.push({ id: notificationId, text: div.textContent });
|
|
localStorage.setItem("notifications", JSON.stringify(storedNotifications));
|
|
}
|
|
|
|
// Function to remove a notification
|
|
function removeNotification(div, id) {
|
|
div.remove();
|
|
|
|
// Update the notification count
|
|
const notificationCount = document.getElementById("notificationCount");
|
|
notificationCount.textContent = parseInt(notificationCount.textContent) - 1;
|
|
|
|
// Remove the notification from local storage
|
|
let storedNotifications = JSON.parse(localStorage.getItem("notifications")) || [];
|
|
storedNotifications = storedNotifications.filter(notification => notification.id !== id);
|
|
localStorage.setItem("notifications", JSON.stringify(storedNotifications));
|
|
}
|
|
|
|
// Receive notification from the server
|
|
connection.on("ReceiveNotification", function (userName, email) {
|
|
addNotification(userName, email);
|
|
});
|
|
|
|
// Start the connection
|
|
connection.start().then(loadNotifications).catch(function (err) {
|
|
return console.error(err.toString());
|
|
});
|
|
</script> *@
|
|
|
|
|
|
|
|
@await RenderSectionAsync("Scripts", required: false)
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|