Spaces:
Running

hello-world / index.html
Eklipse21's picture
Add 3 files
c584a3d verified
Raw History Blame Contribute Delete
31.1 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Inventory Management System</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.sidebar {
transition: all 0.3s;
}
.sidebar.collapsed {
width: 70px;
}
.sidebar.collapsed .nav-text {
display: none;
}
.sidebar.collapsed .logo-text {
display: none;
}
.content {
transition: all 0.3s;
}
.content.expanded {
margin-left: 70px;
}
.dashboard-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}
.animate-pulse {
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes pulse {
0%, 100% {
opacity: 1;
}
50% {
opacity: 0.5;
}
}
</style>
</head>
<body class="bg-gray-100 font-sans">
<div class="flex h-screen overflow-hidden">
<!-- Sidebar -->
<div class="sidebar bg-indigo-800 text-white w-64 flex flex-col">
<div class="p-4 flex items-center justify-between border-b border-indigo-700">
<div class="flex items-center">
<i class="fas fa-boxes text-2xl mr-3"></i>
<span class="logo-text text-xl font-bold">InventoryPro</span>
</div>
<button id="toggleSidebar" class="text-white focus:outline-none">
<i class="fas fa-bars"></i>
</button>
</div>
<div class="p-4 border-b border-indigo-700 flex items-center">
<div class="w-10 h-10 rounded-full bg-indigo-600 flex items-center justify-center mr-3">
<i class="fas fa-user"></i>
</div>
<div>
<div class="font-medium">Admin User</div>
<div class="text-xs text-indigo-300">Administrator</div>
</div>
</div>
<nav class="flex-1 overflow-y-auto">
<div class="p-2">
<div class="text-xs uppercase text-indigo-400 font-bold mt-4 mb-2 px-3">Main</div>
<a href="#" class="nav-item flex items-center px-3 py-3 text-white bg-indigo-900 rounded-lg mb-1">
<i class="fas fa-tachometer-alt mr-3"></i>
<span class="nav-text">Dashboard</span>
</a>
<div class="text-xs uppercase text-indigo-400 font-bold mt-4 mb-2 px-3">Inventory</div>
<a href="#" class="nav-item flex items-center px-3 py-3 text-white hover:bg-indigo-700 rounded-lg mb-1">
<i class="fas fa-boxes mr-3"></i>
<span class="nav-text">Products</span>
</a>
<a href="#" class="nav-item flex items-center px-3 py-3 text-white hover:bg-indigo-700 rounded-lg mb-1">
<i class="fas fa-warehouse mr-3"></i>
<span class="nav-text">Stock Levels</span>
</a>
<a href="#" class="nav-item flex items-center px-3 py-3 text-white hover:bg-indigo-700 rounded-lg mb-1">
<i class="fas fa-exclamation-triangle mr-3"></i>
<span class="nav-text">Low Stock</span>
</a>
<div class="text-xs uppercase text-indigo-400 font-bold mt-4 mb-2 px-3">Sales</div>
<a href="#" class="nav-item flex items-center px-3 py-3 text-white hover:bg-indigo-700 rounded-lg mb-1">
<i class="fas fa-shopping-cart mr-3"></i>
<span class="nav-text">Sales Transactions</span>
</a>
<a href="#" class="nav-item flex items-center px-3 py-3 text-white hover:bg-indigo-700 rounded-lg mb-1">
<i class="fas fa-chart-line mr-3"></i>
<span class="nav-text">Sales Reports</span>
</a>
<div class="text-xs uppercase text-indigo-400 font-bold mt-4 mb-2 px-3">Administration</div>
<a href="#" class="nav-item flex items-center px-3 py-3 text-white hover:bg-indigo-700 rounded-lg mb-1">
<i class="fas fa-users mr-3"></i>
<span class="nav-text">User Management</span>
</a>
<a href="#" class="nav-item flex items-center px-3 py-3 text-white hover:bg-indigo-700 rounded-lg mb-1">
<i class="fas fa-file-pdf mr-3"></i>
<span class="nav-text">Generate Reports</span>
</a>
</div>
</nav>
<div class="p-4 border-t border-indigo-700">
<a href="#" class="flex items-center text-white hover:text-indigo-300">
<i class="fas fa-sign-out-alt mr-3"></i>
<span class="nav-text">Logout</span>
</a>
</div>
</div>
<!-- Main Content -->
<div class="content flex-1 overflow-y-auto">
<!-- Top Navigation -->
<header class="bg-white shadow-sm">
<div class="px-6 py-4 flex items-center justify-between">
<h1 class="text-2xl font-bold text-gray-800">Dashboard</h1>
<div class="flex items-center space-x-4">
<div class="relative">
<button class="p-2 rounded-full bg-gray-100 text-gray-600 hover:bg-gray-200 focus:outline-none">
<i class="fas fa-bell"></i>
</button>
<span class="absolute top-0 right-0 w-2 h-2 bg-red-500 rounded-full"></span>
</div>
<div class="relative">
<button class="p-2 rounded-full bg-gray-100 text-gray-600 hover:bg-gray-200 focus:outline-none">
<i class="fas fa-envelope"></i>
</button>
<span class="absolute top-0 right-0 w-2 h-2 bg-blue-500 rounded-full"></span>
</div>
<div class="relative">
<button id="userMenuButton" class="flex items-center space-x-2 focus:outline-none">
<div class="w-8 h-8 rounded-full bg-indigo-600 flex items-center justify-center text-white">
<i class="fas fa-user"></i>
</div>
<span class="text-gray-700">Admin</span>
<i class="fas fa-chevron-down text-gray-500"></i>
</button>
<div id="userMenu" class="hidden absolute right-0 mt-2 w-48 bg-white rounded-md shadow-lg py-1 z-10">
<a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Profile</a>
<a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Settings</a>
<a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Logout</a>
</div>
</div>
</div>
</div>
</header>
<!-- Dashboard Content -->
<main class="p-6">
<!-- Stats Cards -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-6">
<div class="dashboard-card bg-white rounded-lg shadow p-6 transition duration-300">
<div class="flex items-center justify-between">
<div>
<p class="text-gray-500">Total Products</p>
<h3 class="text-2xl font-bold text-gray-800" id="totalProducts">Loading...</h3>
</div>
<div class="p-3 rounded-full bg-blue-100 text-blue-600">
<i class="fas fa-boxes text-xl"></i>
</div>
</div>
<div class="mt-4">
<span class="text-green-500 text-sm font-semibold">+12%</span>
<span class="text-gray-500 text-sm ml-2">from last month</span>
</div>
</div>
<div class="dashboard-card bg-white rounded-lg shadow p-6 transition duration-300">
<div class="flex items-center justify-between">
<div>
<p class="text-gray-500">Total Stock Value</p>
<h3 class="text-2xl font-bold text-gray-800" id="stockValue">Loading...</h3>
</div>
<div class="p-3 rounded-full bg-green-100 text-green-600">
<i class="fas fa-dollar-sign text-xl"></i>
</div>
</div>
<div class="mt-4">
<span class="text-green-500 text-sm font-semibold">+8%</span>
<span class="text-gray-500 text-sm ml-2">from last month</span>
</div>
</div>
<div class="dashboard-card bg-white rounded-lg shadow p-6 transition duration-300">
<div class="flex items-center justify-between">
<div>
<p class="text-gray-500">Low Stock Items</p>
<h3 class="text-2xl font-bold text-gray-800" id="lowStockItems">Loading...</h3>
</div>
<div class="p-3 rounded-full bg-yellow-100 text-yellow-600">
<i class="fas fa-exclamation-triangle text-xl"></i>
</div>
</div>
<div class="mt-4">
<span class="text-red-500 text-sm font-semibold">+3</span>
<span class="text-gray-500 text-sm ml-2">since last week</span>
</div>
</div>
<div class="dashboard-card bg-white rounded-lg shadow p-6 transition duration-300">
<div class="flex items-center justify-between">
<div>
<p class="text-gray-500">Monthly Sales</p>
<h3 class="text-2xl font-bold text-gray-800" id="monthlySales">Loading...</h3>
</div>
<div class="p-3 rounded-full bg-purple-100 text-purple-600">
<i class="fas fa-chart-line text-xl"></i>
</div>
</div>
<div class="mt-4">
<span class="text-green-500 text-sm font-semibold">+15%</span>
<span class="text-gray-500 text-sm ml-2">from last month</span>
</div>
</div>
</div>
<!-- Charts and Recent Activity -->
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-6">
<div class="lg:col-span-2 bg-white rounded-lg shadow p-6">
<div class="flex items-center justify-between mb-4">
<h2 class="text-lg font-semibold text-gray-800">Sales Overview</h2>
<div class="flex space-x-2">
<button class="px-3 py-1 text-xs bg-indigo-100 text-indigo-700 rounded">Month</button>
<button class="px-3 py-1 text-xs bg-gray-100 text-gray-700 rounded">Year</button>
</div>
</div>
<div class="h-64">
<canvas id="salesChart"></canvas>
</div>
</div>
<div class="bg-white rounded-lg shadow p-6">
<h2 class="text-lg font-semibold text-gray-800 mb-4">Recent Activity</h2>
<div class="space-y-4" id="recentActivity">
<div class="animate-pulse flex items-start">
<div class="flex-shrink-0 h-10 w-10 rounded-full bg-gray-200"></div>
<div class="ml-3">
<div class="h-4 bg-gray-200 rounded w-3/4"></div>
<div class="mt-2 h-3 bg-gray-200 rounded w-1/2"></div>
</div>
</div>
<div class="animate-pulse flex items-start">
<div class="flex-shrink-0 h-10 w-10 rounded-full bg-gray-200"></div>
<div class="ml-3">
<div class="h-4 bg-gray-200 rounded w-3/4"></div>
<div class="mt-2 h-3 bg-gray-200 rounded w-1/2"></div>
</div>
</div>
<div class="animate-pulse flex items-start">
<div class="flex-shrink-0 h-10 w-10 rounded-full bg-gray-200"></div>
<div class="ml-3">
<div class="h-4 bg-gray-200 rounded w-3/4"></div>
<div class="mt-2 h-3 bg-gray-200 rounded w-1/2"></div>
</div>
</div>
</div>
</div>
</div>
<!-- Recent Products and Low Stock -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<div class="bg-white rounded-lg shadow overflow-hidden">
<div class="px-6 py-4 border-b border-gray-200">
<h2 class="text-lg font-semibold text-gray-800">Recent Products</h2>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Product</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Category</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Stock</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Price</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200" id="recentProducts">
<tr>
<td colspan="4" class="px-6 py-4 text-center text-gray-500">
Loading products...
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="bg-white rounded-lg shadow overflow-hidden">
<div class="px-6 py-4 border-b border-gray-200">
<h2 class="text-lg font-semibold text-gray-800">Low Stock Items</h2>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Product</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Current Stock</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Threshold</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Action</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200" id="lowStockTable">
<tr>
<td colspan="4" class="px-6 py-4 text-center text-gray-500">
Loading low stock items...
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</main>
</div>
</div>
<!-- Chart.js -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
// Toggle sidebar
document.getElementById('toggleSidebar').addEventListener('click', function() {
const sidebar = document.querySelector('.sidebar');
const content = document.querySelector('.content');
sidebar.classList.toggle('collapsed');
content.classList.toggle('expanded');
});
// Toggle user menu
document.getElementById('userMenuButton').addEventListener('click', function() {
document.getElementById('userMenu').classList.toggle('hidden');
});
// Close user menu when clicking outside
document.addEventListener('click', function(event) {
const userMenu = document.getElementById('userMenu');
const userMenuButton = document.getElementById('userMenuButton');
if (!userMenu.contains(event.target) && !userMenuButton.contains(event.target)) {
userMenu.classList.add('hidden');
}
});
// Mock API calls (in a real app, these would be actual API calls to your backend)
function fetchDashboardData() {
// Simulate API delay
setTimeout(() => {
// Update stats
document.getElementById('totalProducts').textContent = '1,248';
document.getElementById('stockValue').textContent = '$48,725';
document.getElementById('lowStockItems').textContent = '12';
document.getElementById('monthlySales').textContent = '$24,560';
// Update recent activity
const activities = [
{icon: 'fas fa-box', user: 'John Doe', action: 'added new product', time: '5 mins ago'},
{icon: 'fas fa-shopping-cart', user: 'Jane Smith', action: 'completed a sale', time: '12 mins ago'},
{icon: 'fas fa-exclamation-triangle', user: 'System', action: 'low stock alert', time: '25 mins ago'},
{icon: 'fas fa-user', user: 'Admin', action: 'updated user permissions', time: '1 hour ago'},
{icon: 'fas fa-file-pdf', user: 'Mike Johnson', action: 'generated sales report', time: '2 hours ago'}
];
const activityContainer = document.getElementById('recentActivity');
activityContainer.innerHTML = '';
activities.forEach(activity => {
const activityElement = document.createElement('div');
activityElement.className = 'flex items-start';
activityElement.innerHTML = `
<div class="flex-shrink-0 h-10 w-10 rounded-full bg-indigo-100 flex items-center justify-center text-indigo-600">
<i class="${activity.icon}"></i>
</div>
<div class="ml-3">
<p class="text-sm font-medium text-gray-900">${activity.user} <span class="text-gray-500">${activity.action}</span></p>
<p class="text-xs text-gray-500">${activity.time}</p>
</div>
`;
activityContainer.appendChild(activityElement);
});
// Update recent products
const products = [
{name: 'Wireless Headphones', category: 'Electronics', stock: 45, price: '$89.99'},
{name: 'Organic Cotton T-Shirt', category: 'Apparel', stock: 102, price: '$24.99'},
{name: 'Stainless Steel Water Bottle', category: 'Accessories', stock: 28, price: '$19.99'},
{name: 'Bluetooth Speaker', category: 'Electronics', stock: 15, price: '$129.99'},
{name: 'Yoga Mat', category: 'Fitness', stock: 63, price: '$34.99'}
];
const productsContainer = document.getElementById('recentProducts');
productsContainer.innerHTML = '';
products.forEach(product => {
const productRow = document.createElement('tr');
productRow.innerHTML = `
<td class="px-6 py-4 whitespace-nowrap">
<div class="flex items-center">
<div class="flex-shrink-0 h-10 w-10 bg-gray-200 rounded-full flex items-center justify-center">
<i class="fas fa-box text-gray-500"></i>
</div>
<div class="ml-4">
<div class="text-sm font-medium text-gray-900">${product.name}</div>
<div class="text-sm text-gray-500">SKU: ${Math.floor(100000 + Math.random() * 900000)}</div>
</div>
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-gray-900">${product.category}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">
${product.stock} in stock
</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
${product.price}
</td>
`;
productsContainer.appendChild(productRow);
});
// Update low stock items
const lowStockItems = [
{name: 'Wireless Earbuds', currentStock: 3, threshold: 10},
{name: 'Smart Watch', currentStock: 2, threshold: 5},
{name: 'Phone Case', currentStock: 4, threshold: 15},
{name: 'USB-C Cable', currentStock: 1, threshold: 10},
{name: 'Screen Protector', currentStock: 5, threshold: 20}
];
const lowStockContainer = document.getElementById('lowStockTable');
lowStockContainer.innerHTML = '';
lowStockItems.forEach(item => {
const stockRow = document.createElement('tr');
stockRow.innerHTML = `
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm font-medium text-gray-900">${item.name}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800">
${item.currentStock} left
</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
${item.threshold}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
<button class="text-indigo-600 hover:text-indigo-900">Reorder</button>
</td>
`;
lowStockContainer.appendChild(stockRow);
});
// Initialize chart
initSalesChart();
}, 1000);
}
function initSalesChart() {
const ctx = document.getElementById('salesChart').getContext('2d');
const salesChart = new Chart(ctx, {
type: 'line',
data: {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul'],
datasets: [{
label: 'Sales',
data: [12000, 19000, 15000, 18000, 22000, 21000, 24560],
backgroundColor: 'rgba(79, 70, 229, 0.05)',
borderColor: 'rgba(79, 70, 229, 1)',
borderWidth: 2,
pointBackgroundColor: 'rgba(79, 70, 229, 1)',
pointRadius: 4,
pointHoverRadius: 6,
tension: 0.3,
fill: true
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
display: false
},
tooltip: {
backgroundColor: 'rgba(0, 0, 0, 0.8)',
titleFont: {
size: 14
},
bodyFont: {
size: 12
},
callbacks: {
label: function(context) {
return '$' + context.raw.toLocaleString();
}
}
}
},
scales: {
y: {
beginAtZero: true,
grid: {
drawBorder: false
},
ticks: {
callback: function(value) {
return '$' + value.toLocaleString();
}
}
},
x: {
grid: {
display: false
}
}
}
}
});
}
// Initialize the dashboard when the page loads
document.addEventListener('DOMContentLoaded', function() {
fetchDashboardData();
});
// In a real application, you would have functions like these to interact with your backend API:
/*
async function fetchProducts() {
try {
const response = await fetch('/api/products', {
headers: {
'Authorization': `Bearer ${localStorage.getItem('token')}`
}
});
if (!response.ok) throw new Error('Failed to fetch products');
return await response.json();
} catch (error) {
console.error('Error fetching products:', error);
return [];
}
}
async function createProduct(productData) {
try {
const response = await fetch('/api/products', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${localStorage.getItem('token')}`
},
body: JSON.stringify(productData)
});
if (!response.ok) throw new Error('Failed to create product');
return await response.json();
} catch (error) {
console.error('Error creating product:', error);
return null;
}
}
// And similar functions for other CRUD operations
*/
</script>
<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=Eklipse21/hello-world" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>