updateweb
This commit is contained in:
@@ -13,126 +13,366 @@
|
||||
href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css"
|
||||
/>
|
||||
<style>
|
||||
:root {
|
||||
--primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
--sidebar-width: 250px;
|
||||
--transition-speed: 0.3s;
|
||||
}
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
||||
"Helvetica Neue", Arial, sans-serif;
|
||||
background-color: #f8f9fa;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Sidebar Styles */
|
||||
.sidebar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100vh;
|
||||
width: 250px;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
width: var(--sidebar-width);
|
||||
background: var(--primary-gradient);
|
||||
padding: 20px;
|
||||
color: white;
|
||||
overflow-y: auto;
|
||||
transition: all var(--transition-speed) ease;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.sidebar-brand {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
margin-bottom: 30px;
|
||||
text-align: center;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.sidebar-menu {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.sidebar-menu li {
|
||||
margin-bottom: 10px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.sidebar-menu a {
|
||||
color: white;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
text-decoration: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 12px 15px;
|
||||
border-radius: 8px;
|
||||
transition: background 0.3s;
|
||||
transition: all 0.25s ease;
|
||||
font-size: 0.95rem;
|
||||
}
|
||||
.sidebar-menu a:hover,
|
||||
|
||||
.sidebar-menu a:hover {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
color: white;
|
||||
transform: translateX(5px);
|
||||
}
|
||||
|
||||
.sidebar-menu a.active {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
color: white;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.sidebar-menu i {
|
||||
margin-right: 10px;
|
||||
margin-right: 12px;
|
||||
font-size: 1.2rem;
|
||||
width: 24px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Main Content */
|
||||
.main-content {
|
||||
margin-left: 250px;
|
||||
margin-left: var(--sidebar-width);
|
||||
padding: 30px;
|
||||
min-height: 100vh;
|
||||
transition: margin-left var(--transition-speed) ease;
|
||||
}
|
||||
|
||||
/* Top Bar */
|
||||
.top-bar {
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border-radius: 10px;
|
||||
padding: 25px 30px;
|
||||
border-radius: 12px;
|
||||
margin-bottom: 30px;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
animation: slideDown 0.4s ease;
|
||||
}
|
||||
|
||||
@keyframes slideDown {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(-20px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.top-bar h3 {
|
||||
margin: 0;
|
||||
font-size: 1.75rem;
|
||||
color: #2c3e50;
|
||||
}
|
||||
|
||||
.top-bar p {
|
||||
margin: 5px 0 0 0;
|
||||
color: #6c757d;
|
||||
}
|
||||
|
||||
/* Live Stats Cards - Enhanced */
|
||||
.stat-card {
|
||||
background: white;
|
||||
border-radius: 10px;
|
||||
padding: 25px;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
transition: transform 0.2s;
|
||||
border-radius: 12px;
|
||||
padding: 30px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
display: block;
|
||||
border: 2px solid transparent;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.stat-card::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 4px;
|
||||
background: var(--primary-gradient);
|
||||
transform: scaleX(0);
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.stat-card:hover {
|
||||
transform: translateY(-5px);
|
||||
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
|
||||
transform: translateY(-8px) scale(1.02);
|
||||
box-shadow: 0 12px 24px rgba(102, 126, 234, 0.3);
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
.stat-card:hover::before {
|
||||
transform: scaleX(1);
|
||||
}
|
||||
|
||||
.stat-card:active {
|
||||
transform: translateY(-4px) scale(1.01);
|
||||
}
|
||||
|
||||
.stat-card h6 {
|
||||
color: #6c757d;
|
||||
margin-bottom: 10px;
|
||||
margin-bottom: 15px;
|
||||
font-size: 0.9rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.stat-card h2 {
|
||||
color: #2c3e50;
|
||||
margin: 0;
|
||||
margin: 10px 0;
|
||||
font-weight: 700;
|
||||
font-size: 2.5rem;
|
||||
}
|
||||
|
||||
.stat-card .stat-icon {
|
||||
font-size: 2.5rem;
|
||||
opacity: 0.2;
|
||||
position: absolute;
|
||||
right: 20px;
|
||||
top: 20px;
|
||||
}
|
||||
|
||||
.stat-link {
|
||||
color: #667eea;
|
||||
font-size: 0.9rem;
|
||||
margin-top: 10px;
|
||||
display: inline-block;
|
||||
margin-top: 15px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
font-weight: 600;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.stat-link i {
|
||||
margin-left: 5px;
|
||||
transition: transform 0.2s ease;
|
||||
}
|
||||
|
||||
.stat-card:hover .stat-link i {
|
||||
transform: translateX(5px);
|
||||
}
|
||||
|
||||
/* Quick Action Cards - Enhanced */
|
||||
.action-card {
|
||||
background: white;
|
||||
border-radius: 10px;
|
||||
padding: 30px;
|
||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 12px;
|
||||
padding: 35px 25px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
|
||||
text-align: center;
|
||||
transition: transform 0.2s;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
cursor: pointer;
|
||||
border: 2px solid transparent;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.action-card::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: var(--primary-gradient);
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s ease;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.action-card:hover {
|
||||
transform: translateY(-5px);
|
||||
transform: translateY(-8px) scale(1.03);
|
||||
box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
.action-card:hover::after {
|
||||
opacity: 0.05;
|
||||
}
|
||||
|
||||
.action-card * {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.action-card i {
|
||||
font-size: 3rem;
|
||||
margin-bottom: 15px;
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.action-card:hover i {
|
||||
transform: scale(1.1) rotate(5deg);
|
||||
}
|
||||
|
||||
.action-card h6 {
|
||||
font-weight: 600;
|
||||
font-size: 1rem;
|
||||
margin: 0;
|
||||
color: #2c3e50;
|
||||
}
|
||||
|
||||
/* Buttons */
|
||||
.btn-view-site {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
background: var(--primary-gradient);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px 25px;
|
||||
padding: 12px 28px;
|
||||
border-radius: 8px;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
|
||||
}
|
||||
|
||||
.btn-view-site:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-logout {
|
||||
background: #dc3545;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px 20px;
|
||||
padding: 12px 24px;
|
||||
border-radius: 8px;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s ease;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.btn-logout:hover {
|
||||
background: #c82333;
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
|
||||
}
|
||||
|
||||
/* Responsive Design */
|
||||
@media (max-width: 768px) {
|
||||
.sidebar {
|
||||
transform: translateX(-100%);
|
||||
}
|
||||
|
||||
.sidebar.active {
|
||||
transform: translateX(0);
|
||||
}
|
||||
|
||||
.main-content {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.top-bar {
|
||||
flex-direction: column;
|
||||
gap: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Loading Animation */
|
||||
.loading {
|
||||
display: inline-block;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border: 3px solid rgba(102, 126, 234, 0.3);
|
||||
border-radius: 50%;
|
||||
border-top-color: #667eea;
|
||||
animation: spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
/* Section Headings */
|
||||
.section-heading {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
color: #2c3e50;
|
||||
margin: 40px 0 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.section-heading::after {
|
||||
content: "";
|
||||
flex: 1;
|
||||
height: 2px;
|
||||
background: linear-gradient(to right, #667eea, transparent);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
@@ -165,6 +405,11 @@
|
||||
<li>
|
||||
<a href="/admin/pages.html"><i class="bi bi-file-text"></i> Pages</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/admin/media-library.html"
|
||||
><i class="bi bi-images"></i> Media Library</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/admin/menu.html"><i class="bi bi-list"></i> Menu</a>
|
||||
</li>
|
||||
@@ -199,36 +444,50 @@
|
||||
<div class="row">
|
||||
<div class="col-md-3 mb-4">
|
||||
<a href="/admin/products.html" class="stat-card">
|
||||
<i class="bi bi-box stat-icon"></i>
|
||||
<h6>Total Products</h6>
|
||||
<h2 id="productCount">-</h2>
|
||||
<span class="stat-link">Manage →</span>
|
||||
<h2 id="productCount"><span class="loading"></span></h2>
|
||||
<span class="stat-link"
|
||||
>Manage <i class="bi bi-arrow-right"></i
|
||||
></span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-md-3 mb-4">
|
||||
<a href="/admin/portfolio.html" class="stat-card">
|
||||
<i class="bi bi-easel stat-icon"></i>
|
||||
<h6>Portfolio Projects</h6>
|
||||
<h2 id="projectCount">-</h2>
|
||||
<span class="stat-link">Manage →</span>
|
||||
<h2 id="projectCount"><span class="loading"></span></h2>
|
||||
<span class="stat-link"
|
||||
>Manage <i class="bi bi-arrow-right"></i
|
||||
></span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-md-3 mb-4">
|
||||
<a href="/admin/blog.html" class="stat-card">
|
||||
<i class="bi bi-newspaper stat-icon"></i>
|
||||
<h6>Blog Posts</h6>
|
||||
<h2 id="blogCount">-</h2>
|
||||
<span class="stat-link">Manage →</span>
|
||||
<h2 id="blogCount"><span class="loading"></span></h2>
|
||||
<span class="stat-link"
|
||||
>Manage <i class="bi bi-arrow-right"></i
|
||||
></span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-md-3 mb-4">
|
||||
<a href="/admin/pages.html" class="stat-card">
|
||||
<i class="bi bi-file-text stat-icon"></i>
|
||||
<h6>Custom Pages</h6>
|
||||
<h2 id="pageCount">-</h2>
|
||||
<span class="stat-link">Manage →</span>
|
||||
<h2 id="pageCount"><span class="loading"></span></h2>
|
||||
<span class="stat-link"
|
||||
>Manage <i class="bi bi-arrow-right"></i
|
||||
></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Quick Actions -->
|
||||
<h4 class="mt-5 mb-4">Quick Actions</h4>
|
||||
<h4 class="section-heading">
|
||||
<i class="bi bi-lightning-fill"></i> Quick Actions
|
||||
</h4>
|
||||
<div class="row">
|
||||
<div class="col-md-3 mb-4">
|
||||
<a href="/admin/homepage.html" class="text-decoration-none">
|
||||
@@ -244,7 +503,7 @@
|
||||
class="text-decoration-none"
|
||||
>
|
||||
<div class="action-card">
|
||||
<i class="bi bi-plus-circle text-primary"></i>
|
||||
<i class="bi bi-plus-circle-fill text-primary"></i>
|
||||
<h6>Add New Product</h6>
|
||||
</div>
|
||||
</a>
|
||||
@@ -252,7 +511,7 @@
|
||||
<div class="col-md-3 mb-4">
|
||||
<a href="/admin/blog.html?action=create" class="text-decoration-none">
|
||||
<div class="action-card">
|
||||
<i class="bi bi-plus-circle text-info"></i>
|
||||
<i class="bi bi-file-earmark-plus-fill text-info"></i>
|
||||
<h6>Create Blog Post</h6>
|
||||
</div>
|
||||
</a>
|
||||
@@ -263,7 +522,7 @@
|
||||
class="text-decoration-none"
|
||||
>
|
||||
<div class="action-card">
|
||||
<i class="bi bi-plus-circle text-warning"></i>
|
||||
<i class="bi bi-brush-fill text-warning"></i>
|
||||
<h6>Add Portfolio Project</h6>
|
||||
</div>
|
||||
</a>
|
||||
@@ -272,34 +531,14 @@
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="/admin/js/auth.js"></script>
|
||||
<script>
|
||||
// Check authentication
|
||||
async function checkAuth() {
|
||||
try {
|
||||
const response = await fetch("/api/admin/session");
|
||||
credentials: "include",
|
||||
if (!response.ok) {
|
||||
window.location.href = "/admin/login.html";
|
||||
return;
|
||||
}
|
||||
const data = await response.json();
|
||||
if (!data.authenticated) {
|
||||
window.location.href = "/admin/login.html";
|
||||
return;
|
||||
}
|
||||
document.getElementById("userName").textContent =
|
||||
data.user.name || data.user.email;
|
||||
loadDashboardStats();
|
||||
} catch (error) {
|
||||
window.location.href = "/admin/login.html";
|
||||
}
|
||||
}
|
||||
|
||||
// Load dashboard statistics
|
||||
async function loadDashboardStats() {
|
||||
try {
|
||||
const response = await fetch("/api/admin/dashboard/stats");
|
||||
credentials: "include",
|
||||
const response = await fetch("/api/admin/dashboard/stats", {
|
||||
credentials: "include",
|
||||
});
|
||||
const data = await response.json();
|
||||
if (data.success) {
|
||||
document.getElementById("productCount").textContent =
|
||||
@@ -308,27 +547,26 @@
|
||||
data.stats.projects;
|
||||
document.getElementById("blogCount").textContent = data.stats.blog;
|
||||
document.getElementById("pageCount").textContent = data.stats.pages;
|
||||
|
||||
// Update user name
|
||||
if (data.user && (data.user.name || data.user.email)) {
|
||||
document.getElementById("userName").textContent =
|
||||
data.user.name || data.user.email;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Failed to load stats:", error);
|
||||
}
|
||||
}
|
||||
|
||||
// Logout function
|
||||
async function logout() {
|
||||
try {
|
||||
const response = await fetch("/api/admin/logout", { method: "POST" });
|
||||
credentials: "include",
|
||||
if (response.ok) {
|
||||
window.location.href = "/admin/login.html";
|
||||
// Initialize - check auth then load stats
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
checkAuth().then((authenticated) => {
|
||||
if (authenticated) {
|
||||
loadDashboardStats();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Logout failed:", error);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize
|
||||
checkAuth();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user