Spaces:
Running

undefined / admin-dashboard.html
thakurihem's picture
Create a full-stack web application called **IntelliFarm Pro — Smart Farm Management System**, designed to help farms manage multiple agricultural enterprises such as crops, poultry, horticulture, beekeeping, and small-scale agro-food production. The system should include **role-based dashboards** for Admin, Farm Manager, Technician, and Worker, each with specific access permissions and CRUD capabilities. The platform must support secure **JWT authentication**, encrypted passwords, and user management with role-based access control. Core features should include **farm and enterprise management** with GPS mapping, **field operations tracking** for sowing, irrigation, and harvesting, **disease and pest management** with photos, notes, and weather-based risk prediction, **irrigation and soil management**, **inventory tracking** for inputs like fertilizers and seeds, and **financial modules** for expenses, income, and profit analysis. It should also include **reports and analytics dashboards** with visual charts for yield, expenses, and productivity, exportable as PDF or Excel. The system must allow **task and workforce management** with mobile-friendly worker portals, **notifications and communication tools** (in-app chat, SMS, email alerts), and **real-time monitoring** for production and economic insights. The frontend should be built with **React.js and Tailwind CSS** using Chart.js or Recharts for analytics, while the backend should use **Node.js with Express** and **PostgreSQL** as the database. Deploy the application using **Docker and AWS (or GCP)**, integrating APIs like OpenWeather for weather data and Twilio or EmailJS for notifications. Ensure robust **security** (CSRF protection, input validation, encrypted data) and a responsive, modular design with dashboards, analytics, and sample seed data for testing. Optionally, include future-ready features like **AI-based crop recommendations**, **IoT sensor integration**, and **NDVI satellite monitoring** for precision agriculture.
7eeea54 verified
Raw History Blame Contribute Delete
18.3 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Dashboard | CropSync Nexus</title>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
<style>
.sidebar {
transition: all 0.3s ease;
}
.dashboard-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}
</style>
</head>
<body class="bg-gray-100">
<div class="flex h-screen overflow-hidden">
<!-- Sidebar -->
<div class="sidebar bg-primary-800 text-white w-64 flex-shrink-0">
<div class="p-4 flex items-center border-b border-primary-700">
<i data-feather="sun" class="h-6 w-6"></i>
<span class="ml-2 text-xl font-bold">CropSync Nexus</span>
</div>
<nav class="p-4">
<div class="mb-8">
<p class="text-xs uppercase text-primary-300 mb-2">Admin Panel</p>
<a href="/admin-dashboard" class="flex items-center py-2 px-3 bg-primary-700 rounded-md text-white">
<i data-feather="home" class="h-4 w-4 mr-2"></i> Dashboard
</a>
<a href="/admin/users" class="flex items-center py-2 px-3 hover:bg-primary-700 rounded-md mt-1">
<i data-feather="users" class="h-4 w-4 mr-2"></i> User Management
</a>
<a href="/admin/enterprises" class="flex items-center py-2 px-3 hover:bg-primary-700 rounded-md mt-1">
<i data-feather="map" class="h-4 w-4 mr-2"></i> Farm Enterprises
</a>
<a href="/admin/reports" class="flex items-center py-2 px-3 hover:bg-primary-700 rounded-md mt-1">
<i data-feather="bar-chart-2" class="h-4 w-4 mr-2"></i> Reports
</a>
<a href="/admin/settings" class="flex items-center py-2 px-3 hover:bg-primary-700 rounded-md mt-1">
<i data-feather="settings" class="h-4 w-4 mr-2"></i> System Settings
</a>
</div>
<div>
<p class="text-xs uppercase text-primary-300 mb-2">Quick Actions</p>
<a href="/admin/tasks" class="flex items-center py-2 px-3 hover:bg-primary-700 rounded-md">
<i data-feather="check-circle" class="h-4 w-4 mr-2"></i> Task Management
</a>
<a href="/admin/inventory" class="flex items-center py-2 px-3 hover:bg-primary-700 rounded-md mt-1">
<i data-feather="package" class="h-4 w-4 mr-2"></i> Inventory
</a>
<a href="/admin/finance" class="flex items-center py-2 px-3 hover:bg-primary-700 rounded-md mt-1">
<i data-feather="dollar-sign" class="h-4 w-4 mr-2"></i> Financials
</a>
</div>
</nav>
</div>
<!-- Main Content -->
<div class="flex-1 overflow-auto">
<!-- Top Navigation -->
<header class="bg-white shadow-sm">
<div class="flex justify-between items-center px-6 py-4">
<div class="flex items-center">
<button id="sidebarToggle" class="mr-4 text-gray-500 hover:text-gray-700">
<i data-feather="menu"></i>
</button>
<h1 class="text-xl font-semibold text-gray-800">Admin Dashboard</h1>
</div>
<div class="flex items-center space-x-4">
<div class="relative">
<button id="notificationsBtn" class="p-1 text-gray-500 hover:text-gray-700">
<i data-feather="bell"></i>
<span class="absolute top-0 right-0 h-2 w-2 rounded-full bg-red-500"></span>
</button>
</div>
<div class="relative">
<button id="messagesBtn" class="p-1 text-gray-500 hover:text-gray-700">
<i data-feather="mail"></i>
</button>
</div>
<div class="relative">
<button id="userMenuBtn" class="flex items-center text-sm focus:outline-none">
<img class="h-8 w-8 rounded-full" src="http://static.photos/people/200x200/1" alt="User profile">
<span class="ml-2 text-gray-700">Admin User</span>
<i data-feather="chevron-down" class="ml-1 h-4 w-4 text-gray-500"></i>
</button>
</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 p-6 rounded-lg shadow-sm transition-all duration-300">
<div class="flex justify-between items-start">
<div>
<p class="text-sm font-medium text-gray-500">Total Users</p>
<h3 class="text-2xl font-bold mt-1">142</h3>
</div>
<div class="p-2 bg-primary-100 rounded-md">
<i data-feather="users" class="text-primary-600 h-5 w-5"></i>
</div>
</div>
<p class="text-xs text-gray-500 mt-2"><span class="text-green-500">+5.2%</span> from last month</p>
</div>
<div class="dashboard-card bg-white p-6 rounded-lg shadow-sm transition-all duration-300">
<div class="flex justify-between items-start">
<div>
<p class="text-sm font-medium text-gray-500">Active Farms</p>
<h3 class="text-2xl font-bold mt-1">24</h3>
</div>
<div class="p-2 bg-green-100 rounded-md">
<i data-feather="map-pin" class="text-green-600 h-5 w-5"></i>
</div>
</div>
<p class="text-xs text-gray-500 mt-2"><span class="text-green-500">+2 new</span> this week</p>
</div>
<div class="dashboard-card bg-white p-6 rounded-lg shadow-sm transition-all duration-300">
<div class="flex justify-between items-start">
<div>
<p class="text-sm font-medium text-gray-500">Tasks Completed</p>
<h3 class="text-2xl font-bold mt-1">87%</h3>
</div>
<div class="p-2 bg-blue-100 rounded-md">
<i data-feather="check-circle" class="text-blue-600 h-5 w-5"></i>
</div>
</div>
<p class="text-xs text-gray-500 mt-2"><span class="text-green-500">+12%</span> efficiency</p>
</div>
<div class="dashboard-card bg-white p-6 rounded-lg shadow-sm transition-all duration-300">
<div class="flex justify-between items-start">
<div>
<p class="text-sm font-medium text-gray-500">Monthly Revenue</p>
<h3 class="text-2xl font-bold mt-1">$28,450</h3>
</div>
<div class="p-2 bg-yellow-100 rounded-md">
<i data-feather="dollar-sign" class="text-yellow-600 h-5 w-5"></i>
</div>
</div>
<p class="text-xs text-gray-500 mt-2"><span class="text-green-500">+8.3%</span> from last month</p>
</div>
</div>
<!-- Charts Row -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6">
<div class="bg-white p-6 rounded-lg shadow-sm">
<div class="flex justify-between items-center mb-4">
<h2 class="text-lg font-semibold text-gray-800">Farm Productivity</h2>
<select class="text-sm border border-gray-300 rounded-md px-2 py-1 focus:outline-none focus:ring-1 focus:ring-primary-500">
<option>Last 7 Days</option>
<option>Last 30 Days</option>
<option selected>This Year</option>
</select>
</div>
<canvas id="productivityChart" height="250"></canvas>
</div>
<div class="bg-white p-6 rounded-lg shadow-sm">
<div class="flex justify-between items-center mb-4">
<h2 class="text-lg font-semibold text-gray-800">Enterprise Distribution</h2>
<div class="text-sm text-gray-500">Total: 24 Farms</div>
</div>
<div id="enterpriseChart" class="h-64"></div>
</div>
</div>
<!-- Recent Activity & Quick Actions -->
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<div class="lg:col-span-2 bg-white p-6 rounded-lg shadow-sm">
<div class="flex justify-between items-center mb-4">
<h2 class="text-lg font-semibold text-gray-800">Recent Activity</h2>
<a href="#" class="text-sm text-primary-600 hover:text-primary-700">View All</a>
</div>
<div class="space-y-4">
<div class="flex items-start">
<div class="flex-shrink-0 bg-primary-100 rounded-full p-2">
<i data-feather="user-plus" class="text-primary-600 h-4 w-4"></i>
</div>
<div class="ml-3">
<p class="text-sm font-medium text-gray-800">New technician added</p>
<p class="text-xs text-gray-500">John Doe was added to Farm #5 by Admin</p>
<p class="text-xs text-gray-400 mt-1">2 hours ago</p>
</div>
</div>
<div class="flex items-start">
<div class="flex-shrink-0 bg-green-100 rounded-full p-2">
<i data-feather="check-circle" class="text-green-600 h-4 w-4"></i>
</div>
<div class="ml-3">
<p class="text-sm font-medium text-gray-800">Task completed</p>
<p class="text-xs text-gray-500">Harvesting in Field B-3 marked as complete</p>
<p class="text-xs text-gray-400 mt-1">5 hours ago</p>
</div>
</div>
<div class="flex items-start">
<div class="flex-shrink-0 bg-yellow-100 rounded-full p-2">
<i data-feather="alert-triangle" class="text-yellow-600 h-4 w-4"></i>
</div>
<div class="ml-3">
<p class="text-sm font-medium text-gray-800">Disease detected</p>
<p class="text-xs text-gray-500">Powdery mildew reported in Farm #2</p>
<p class="text-xs text-gray-400 mt-1">1 day ago</p>
</div>
</div>
<div class="flex items-start">
<div class="flex-shrink-0 bg-blue-100 rounded-full p-2">
<i data-feather="dollar-sign" class="text-blue-600 h-4 w-4"></i>
</div>
<div class="ml-3">
<p class="text-sm font-medium text-gray-800">New transaction</p>
<p class="text-xs text-gray-500">$1,240 revenue from tomato sales</p>
<p class="text-xs text-gray-400 mt-1">2 days ago</p>
</div>
</div>
</div>
</div>
<div class="bg-white p-6 rounded-lg shadow-sm">
<div class="flex justify-between items-center mb-4">
<h2 class="text-lg font-semibold text-gray-800">Quick Actions</h2>
</div>
<div class="space-y-3">
<a href="/admin/users/create" class="flex items-center px-4 py-3 bg-primary-50 rounded-md hover:bg-primary-100">
<i data-feather="user-plus" class="text-primary-600 h-5 w-5"></i>
<span class="ml-3 text-sm font-medium">Add New User</span>
</a>
<a href="/admin/tasks/create" class="flex items-center px-4 py-3 bg-green-50 rounded-md hover:bg-green-100">
<i data-feather="plus-circle" class="text-green-600 h-5 w-5"></i>
<span class="ml-3 text-sm font-medium">Create Task</span>
</a>
<a href="/admin/reports/generate" class="flex items-center px-4 py-3 bg-blue-50 rounded-md hover:bg-blue-100">
<i data-feather="file-text" class="text-blue-600 h-5 w-5"></i>
<span class="ml-3 text-sm font-medium">Generate Report</span>
</a>
<a href="/admin/inventory/add" class="flex items-center px-4 py-3 bg-purple-50 rounded-md hover:bg-purple-100">
<i data-feather="package" class="text-purple-600 h-5 w-5"></i>
<span class="ml-3 text-sm font-medium">Add Inventory</span>
</a>
</div>
</div>
</div>
</main>
</div>
</div>
<script>
feather.replace();
// Initialize productivity chart
const productivityCtx = document.getElementById('productivityChart').getContext('2d');
new Chart(productivityCtx, {
type: 'line',
data: {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
datasets: [
{
label: 'Yield (kg/ha)',
data: [1200, 1400, 1600, 1800, 2100, 2300, 2500, 2400, 2200, 2000, 1800, 1500],
borderColor: '#22c55e',
backgroundColor: 'rgba(34, 197, 94, 0.05)',
fill: true,
tension: 0.4
},
{
label: 'Revenue ($)',
data: [3200, 3800, 4200, 4500, 5200, 5800, 6200, 6000, 5500, 5000, 4500, 4000],
borderColor: '#3b82f6',
backgroundColor: 'rgba(59, 130, 246, 0.05)',
fill: true,
tension: 0.4
}
]
},
options: {
responsive: true,
plugins: {
legend: {
position: 'top',
},
tooltip: {
mode: 'index',
intersect: false,
}
},
scales: {
y: {
beginAtZero: true
}
}
}
});
// Initialize enterprise distribution chart
var enterpriseOptions = {
series: [44, 55, 41, 17, 15],
labels: ['Crops', 'Poultry', 'Horticulture', 'Beekeeping', 'Agro-Food'],
chart: {
type: 'donut',
height: 350
},
colors: ['#22c55e', '#3b82f6', '#f59e0b', '#8b5cf6', '#ec4899'],
responsive: [{
breakpoint: 480,
options: {
chart: {
width: 200
},
legend: {
position: 'bottom'
}
}
}]
};
var enterpriseChart = new ApexCharts(document.querySelector("#enterpriseChart"), enterpriseOptions);
enterpriseChart.render();
// Toggle sidebar
document.getElementById('sidebarToggle').addEventListener('click', function() {
document.querySelector('.sidebar').classList.toggle('hidden');
});
</script>
</body>
</html>