-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin-dashboard.html
103 lines (91 loc) · 3.25 KB
/
admin-dashboard.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Dashboard</title>
<style>
table {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
}
th,
td {
padding: 8px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background-color: #4eaa29;
}
</style>
</head>
<body>
<h1>Admin Dashboard</h1>
<a href="login.html">Back</a>
<h2>User Credentials</h2>
<table id="userTable">
<tr>
<th>Username</th>
<th>Email</th>
<th>Action</th>
</tr>
</table>
<script>
</script>
<h2>Subscriber List</h2>
<table id="subscriber-table">
<thead>
<tr>
<th>Email</th>
</tr>
</thead>
<tbody id="subscriber-list"></tbody>
</table>
<script>
// Displaying newsletter details when admin login
document.addEventListener("DOMContentLoaded", function () {
const subscriberTable = document.getElementById("subscriber-table");
const subscriberList = document.getElementById("subscriber-list");
// Retrieve subscriptions from local storage
const subscriptions =
JSON.parse(localStorage.getItem("newsletterSubscriptions")) || [];
// Display subscriptions in table format
subscriptions.forEach(function (email) {
const row = document.createElement("tr");
const cell = document.createElement("td");
cell.textContent = email;
row.appendChild(cell);
subscriberList.appendChild(row);
});
// Show the table
subscriberTable.style.display = "block";
});
</script>
<script>
//Displays the login details in admin dashboard
document.addEventListener("DOMContentLoaded", function () {
const users = JSON.parse(localStorage.getItem("users")) || [];
const tableBody = document.getElementById("userTable");
users.forEach((user) => {
const row = tableBody.insertRow();
row.insertCell(0).textContent = user.username;
row.insertCell(1).textContent = user.email;
const removeButton = document.createElement("button");
removeButton.textContent = "Remove";
removeButton.addEventListener("click", function () {
// Remove the user from the array
const index = users.findIndex((u) => u.username === user.username);
users.splice(index, 1);
// Update local storage
localStorage.setItem("users", JSON.stringify(users));
// Remove the row from the table
tableBody.deleteRow(row.rowIndex);
});
row.insertCell(2).appendChild(removeButton);
});
});
</script>
</body>
</html>