testing / admin.html
youngtoaster's picture
add a exit button on the login page to go back to the home page - Initial Deployment
337d870 verified
Raw History Blame Contribute Delete
11.5 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Panel - Unnoticed</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://unpkg.com/feather-icons"></script>
<style>
body {
background: #f8fafc;
}
.sidebar {
width: 250px;
transition: all 0.3s;
}
.main-content {
margin-left: 250px;
transition: all 0.3s;
}
@media (max-width: 768px) {
.sidebar {
margin-left: -250px;
}
.main-content {
margin-left: 0;
}
.sidebar.active {
margin-left: 0;
}
.main-content.active {
margin-left: 250px;
}
}
</style>
</head>
<body class="font-sans">
<!-- Login Modal -->
<div id="loginModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
<div class="bg-white rounded-lg p-8 max-w-md w-full mx-4">
<h2 class="text-2xl font-bold mb-6 text-center">Admin Login</h2>
<form id="loginForm">
<div class="mb-4">
<label for="username" class="block text-gray-700 mb-2">Username</label>
<input type="text" id="username" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" required>
</div>
<div class="mb-6">
<label for="password" class="block text-gray-700 mb-2">Password</label>
<input type="password" id="password" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" required>
</div>
<button type="submit" class="w-full bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700 transition mb-3">Login</button>
<button type="button" onclick="window.location.href='/'" class="w-full bg-gray-600 text-white py-2 px-4 rounded-md hover:bg-gray-700 transition">Exit to Home</button>
</form>
<p id="loginError" class="text-red-500 mt-4 text-center hidden">Invalid credentials. Please try again.</p>
</div>
</div>
<!-- Main Admin Layout (hidden until login) -->
<div id="adminLayout" class="hidden">
<!-- Sidebar -->
<div class="sidebar fixed inset-y-0 left-0 bg-gray-800 text-white z-40">
<div class="p-4 border-b border-gray-700">
<h1 class="text-xl font-semibold">Unnoticed Admin</h1>
</div>
<nav class="mt-6">
<a href="#" class="block py-2 px-4 bg-gray-700">Dashboard</a>
<a href="#music-management" class="block py-2 px-4 hover:bg-gray-700 transition">Music Management</a>
<a href="#settings" class="block py-2 px-4 hover:bg-gray-700 transition">Settings</a>
<a href="/" class="block py-2 px-4 hover:bg-gray-700 transition">View Site</a>
<a href="#" id="logoutBtn" class="block py-2 px-4 hover:bg-gray-700 transition">Logout</a>
</nav>
</div>
<!-- Main Content -->
<div class="main-content min-h-screen">
<!-- Top Bar -->
<div class="bg-white shadow-sm border-b border-gray-200 p-4 flex justify-between items-center">
<button id="sidebarToggle" class="md:hidden">
<i data-feather="menu"></i>
</button>
<h2 class="text-lg font-semibold">Admin Dashboard</h2>
<div class="flex items-center space-x-4">
<span>Welcome, Admin</span>
<div class="w-8 h-8 bg-gray-300 rounded-full"></div>
</div>
</div>
<!-- Dashboard Content -->
<div class="p-6">
<!-- Music Management Section -->
<section id="music-management" class="mb-8">
<h3 class="text-xl font-semibold mb-4">Music Management</h3>
<div class="bg-white shadow rounded-lg p-6 mb-6">
<h4 class="text-lg font-medium mb-4">Add New Track</h4>
<form id="addTrackForm" class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="block text-gray-700 mb-2">Title</label>
<input type="text" class="w-full px-3 py-2 border border-gray-300 rounded-md" required>
</div>
<div>
<label class="block text-gray-700 mb-2">Platform Link</label>
<input type="url" class="w-full px-3 py-2 border border-gray-300 rounded-md" required>
</div>
<div>
<label class="block text-gray-700 mb-2">Album Art URL</label>
<input type="url" class="w-full px-3 py-2 border border-gray-300 rounded-md">
</div>
<div>
<label class="block text-gray-700 mb-2">Audio File/URL</label>
<input type="file" accept="audio/*" class="w-full px-3 py-2 border border-gray-300 rounded-md">
</div>
<div class="md:col-span-2">
<button type="submit" class="bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700 transition">Add Track</button>
</div>
</form>
</div>
<div class="bg-white shadow rounded-lg p-6">
<h4 class="text-lg font-medium mb-4">Current Tracks</h4>
<div class="overflow-x-auto">
<table class="min-w-full">
<thead>
<tr class="border-b">
<th class="py-2 px-4 text-left">Title</th>
<th class="py-2 px-4 text-left">Platform</th>
<th class="py-2 px-4 text-left">Actions</th>
</tr>
</thead>
<tbody>
<tr class="border-b">
<td class="py-2 px-4">Sample Track 1</td>
<td class="py-2 px-4">Spotify</td>
<td class="py-2 px-4">
<button class="text-blue-600 hover:text-blue-800 mr-2">Edit</button>
<button class="text-red-600 hover:text-red-800">Delete</button>
</td>
</tr>
<tr class="border-b">
<td class="py-2 px-4">Sample Track 2</td>
<td class="py-2 px-4">YouTube</td>
<td class="py-2 px-4">
<button class="text-blue-600 hover:text-blue-800 mr-2">Edit</button>
<button class="text-red-600 hover:text-red-800">Delete</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<!-- Settings Section -->
<section id="settings">
<h3 class="text-xl font-semibold mb-4">Settings</h3>
<div class="bg-white shadow rounded-lg p-6">
<div class="mb-4">
<label class="flex items-center space-x-2">
<input type="checkbox" id="fullSongToggle" class="rounded text-blue-600">
<span>Enable full song playback (instead of preview)</span>
</label>
</div>
<div class="mb-4">
<label class="block text-gray-700 mb-2">Scrape Interval (minutes)</label>
<input type="number" value="60" min="5" class="w-full px-3 py-2 border border-gray-300 rounded-md max-w-xs">
</div>
<div>
<button class="bg-blue-600 text-white py-2 px-4 rounded-md hover:bg-blue-700 transition">Save Settings</button>
</div>
</div>
</section>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
feather.replace();
// Check if already logged in
if (localStorage.getItem('adminLoggedIn') === 'true') {
document.getElementById('loginModal').classList.add('hidden');
document.getElementById('adminLayout').classList.remove('hidden');
}
// Login form handling
document.getElementById('loginForm').addEventListener('submit', function(e) {
e.preventDefault();
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
if (username === 'youngtoaster' && password === '160582') {
localStorage.setItem('adminLoggedIn', 'true');
document.getElementById('loginModal').classList.add('hidden');
document.getElementById('adminLayout').classList.remove('hidden');
} else {
document.getElementById('loginError').classList.remove('hidden');
}
});
// Logout functionality
document.getElementById('logoutBtn').addEventListener('click', function() {
localStorage.removeItem('adminLoggedIn');
location.reload();
});
// Mobile sidebar toggle
document.getElementById('sidebarToggle').addEventListener('click', function() {
document.querySelector('.sidebar').classList.toggle('active');
document.querySelector('.main-content').classList.toggle('active');
});
// Full song toggle functionality
const fullSongToggle = document.getElementById('fullSongToggle');
if (localStorage.getItem('fullSongEnabled') === 'true') {
fullSongToggle.checked = true;
}
fullSongToggle.addEventListener('change', function() {
localStorage.setItem('fullSongEnabled', this.checked);
});
});
</script>
</body>
</html>