Spaces:
Running
Running
make it have a slide menu which is admin log in to see the analytics, students who want to eat, and students whp have actually ate
Browse files- components/slide-menu.js +148 -0
- index.html +12 -3
components/slide-menu.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class SlideMenu extends HTMLElement {
|
| 2 |
+
constructor() {
|
| 3 |
+
super();
|
| 4 |
+
this.attachShadow({ mode: 'open' });
|
| 5 |
+
this.shadowRoot.innerHTML = `
|
| 6 |
+
<style>
|
| 7 |
+
:host {
|
| 8 |
+
position: fixed;
|
| 9 |
+
top: 0;
|
| 10 |
+
right: -300px;
|
| 11 |
+
width: 300px;
|
| 12 |
+
height: 100vh;
|
| 13 |
+
background: white;
|
| 14 |
+
box-shadow: -2px 0 10px rgba(0,0,0,0.1);
|
| 15 |
+
transition: right 0.3s ease;
|
| 16 |
+
z-index: 1000;
|
| 17 |
+
padding: 20px;
|
| 18 |
+
box-sizing: border-box;
|
| 19 |
+
}
|
| 20 |
+
:host(.open) {
|
| 21 |
+
right: 0;
|
| 22 |
+
}
|
| 23 |
+
.close-btn {
|
| 24 |
+
position: absolute;
|
| 25 |
+
top: 10px;
|
| 26 |
+
right: 10px;
|
| 27 |
+
background: none;
|
| 28 |
+
border: none;
|
| 29 |
+
font-size: 20px;
|
| 30 |
+
cursor: pointer;
|
| 31 |
+
}
|
| 32 |
+
h2 {
|
| 33 |
+
margin-top: 0;
|
| 34 |
+
color: #3b82f6;
|
| 35 |
+
}
|
| 36 |
+
.login-form {
|
| 37 |
+
margin-bottom: 20px;
|
| 38 |
+
}
|
| 39 |
+
input {
|
| 40 |
+
width: 100%;
|
| 41 |
+
padding: 8px;
|
| 42 |
+
margin: 5px 0;
|
| 43 |
+
border: 1px solid #ddd;
|
| 44 |
+
border-radius: 4px;
|
| 45 |
+
}
|
| 46 |
+
button {
|
| 47 |
+
background: #3b82f6;
|
| 48 |
+
color: white;
|
| 49 |
+
border: none;
|
| 50 |
+
padding: 8px 16px;
|
| 51 |
+
border-radius: 4px;
|
| 52 |
+
cursor: pointer;
|
| 53 |
+
width: 100%;
|
| 54 |
+
}
|
| 55 |
+
.admin-section {
|
| 56 |
+
display: none;
|
| 57 |
+
}
|
| 58 |
+
.stats {
|
| 59 |
+
margin: 15px 0;
|
| 60 |
+
}
|
| 61 |
+
.stat-item {
|
| 62 |
+
display: flex;
|
| 63 |
+
justify-content: space-between;
|
| 64 |
+
margin-bottom: 8px;
|
| 65 |
+
}
|
| 66 |
+
</style>
|
| 67 |
+
<div>
|
| 68 |
+
<button class="close-btn">×</button>
|
| 69 |
+
<h2>Admin Panel</h2>
|
| 70 |
+
|
| 71 |
+
<div class="login-form">
|
| 72 |
+
<input type="text" id="username" placeholder="Username">
|
| 73 |
+
<input type="password" id="password" placeholder="Password">
|
| 74 |
+
<button id="login-btn">Login</button>
|
| 75 |
+
</div>
|
| 76 |
+
|
| 77 |
+
<div class="admin-section">
|
| 78 |
+
<div class="stats">
|
| 79 |
+
<h3>Attendance Analytics</h3>
|
| 80 |
+
<div class="stat-item">
|
| 81 |
+
<span>Expected:</span>
|
| 82 |
+
<span id="expected-count">0</span>
|
| 83 |
+
</div>
|
| 84 |
+
<div class="stat-item">
|
| 85 |
+
<span>Actual:</span>
|
| 86 |
+
<span id="actual-count">0</span>
|
| 87 |
+
</div>
|
| 88 |
+
<div class="stat-item">
|
| 89 |
+
<span>Not Coming:</span>
|
| 90 |
+
<span id="not-coming-count">0</span>
|
| 91 |
+
</div>
|
| 92 |
+
</div>
|
| 93 |
+
<button id="refresh-btn">Refresh Data</button>
|
| 94 |
+
</div>
|
| 95 |
+
</div>
|
| 96 |
+
`;
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
connectedCallback() {
|
| 100 |
+
this.shadowRoot.querySelector('.close-btn').addEventListener('click', () => {
|
| 101 |
+
this.classList.remove('open');
|
| 102 |
+
});
|
| 103 |
+
|
| 104 |
+
this.shadowRoot.querySelector('#login-btn').addEventListener('click', () => {
|
| 105 |
+
this.attemptLogin();
|
| 106 |
+
});
|
| 107 |
+
|
| 108 |
+
this.shadowRoot.querySelector('#refresh-btn').addEventListener('click', () => {
|
| 109 |
+
this.fetchAttendanceData();
|
| 110 |
+
});
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
attemptLogin() {
|
| 114 |
+
const username = this.shadowRoot.querySelector('#username').value;
|
| 115 |
+
const password = this.shadowRoot.querySelector('#password').value;
|
| 116 |
+
|
| 117 |
+
// Simple hardcoded admin login for demo
|
| 118 |
+
if (username === 'admin' && password === 'admin123') {
|
| 119 |
+
this.shadowRoot.querySelector('.login-form').style.display = 'none';
|
| 120 |
+
this.shadowRoot.querySelector('.admin-section').style.display = 'block';
|
| 121 |
+
this.fetchAttendanceData();
|
| 122 |
+
} else {
|
| 123 |
+
alert('Invalid credentials');
|
| 124 |
+
}
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
async fetchAttendanceData() {
|
| 128 |
+
try {
|
| 129 |
+
// In a real app, this would fetch from your actual data source
|
| 130 |
+
// For demo, we'll use localStorage to simulate stored attendance
|
| 131 |
+
let records = JSON.parse(localStorage.getItem('attendanceRecords') || '[]');
|
| 132 |
+
|
| 133 |
+
// Calculate stats
|
| 134 |
+
const expected = records.filter(r => r.attendance === 'yes').length;
|
| 135 |
+
const actual = records.filter(r => r.attendance === 'yes' && r.timestamp > new Date(Date.now() - 3600000).toISOString()).length;
|
| 136 |
+
const notComing = records.filter(r => r.attendance === 'no').length;
|
| 137 |
+
|
| 138 |
+
this.shadowRoot.querySelector('#expected-count').textContent = expected;
|
| 139 |
+
this.shadowRoot.querySelector('#actual-count').textContent = actual;
|
| 140 |
+
this.shadowRoot.querySelector('#not-coming-count').textContent = notComing;
|
| 141 |
+
|
| 142 |
+
} catch (error) {
|
| 143 |
+
console.error('Error fetching attendance data:', error);
|
| 144 |
+
}
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
customElements.define('slide-menu', SlideMenu);
|
index.html
CHANGED
|
@@ -188,10 +188,17 @@
|
|
| 188 |
<p class="mt-1">Data will be saved to <a href="https://github.com/amiroyottt/WASTE-LESS/blob/main/DATA" class="text-blue-600 hover:underline" target="_blank">GitHub repository</a></p>
|
| 189 |
</footer>
|
| 190 |
</div>
|
| 191 |
-
|
|
|
|
|
|
|
| 192 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
// Update current time and date
|
| 194 |
-
|
| 195 |
const now = new Date();
|
| 196 |
const timeElement = document.getElementById('current-time');
|
| 197 |
const dateElement = document.getElementById('current-date');
|
|
@@ -690,5 +697,7 @@
|
|
| 690 |
});
|
| 691 |
});
|
| 692 |
</script>
|
| 693 |
-
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=EHDEM/skibidi-wasless" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p><p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=EHDEM/WASTELESS-V4" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p>
|
|
|
|
|
|
|
| 694 |
</html>
|
|
|
|
| 188 |
<p class="mt-1">Data will be saved to <a href="https://github.com/amiroyottt/WASTE-LESS/blob/main/DATA" class="text-blue-600 hover:underline" target="_blank">GitHub repository</a></p>
|
| 189 |
</footer>
|
| 190 |
</div>
|
| 191 |
+
<slide-menu></slide-menu>
|
| 192 |
+
<button id="admin-btn" style="position: fixed; right: 20px; bottom: 20px; background: #3b82f6; color: white; border: none; border-radius: 50%; width: 50px; height: 50px; font-size: 20px; cursor: pointer; box-shadow: 0 2px 10px rgba(0,0,0,0.2);">⚙️</button>
|
| 193 |
+
|
| 194 |
<script>
|
| 195 |
+
// Admin button functionality
|
| 196 |
+
document.getElementById('admin-btn').addEventListener('click', () => {
|
| 197 |
+
document.querySelector('slide-menu').classList.toggle('open');
|
| 198 |
+
});
|
| 199 |
+
|
| 200 |
// Update current time and date
|
| 201 |
+
function updateDateTime() {
|
| 202 |
const now = new Date();
|
| 203 |
const timeElement = document.getElementById('current-time');
|
| 204 |
const dateElement = document.getElementById('current-date');
|
|
|
|
| 697 |
});
|
| 698 |
});
|
| 699 |
</script>
|
| 700 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=EHDEM/skibidi-wasless" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p><p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=EHDEM/WASTELESS-V4" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p>
|
| 701 |
+
<script src="components/slide-menu.js"></script>
|
| 702 |
+
</body>
|
| 703 |
</html>
|