Spaces:
Running
Running
Download index.html from lordjames82/test2: direct link, hf CLI and curl.
- Browser
- Download file 65.5 kB
-
https://huggingface.co/spaces/lordjames82/test2/resolve/main/index.html
- Command line
-
hf download hf://spaces/lordjames82/test2/index.html
-
curl -L -o index.html https://huggingface.co/spaces/lordjames82/test2/resolve/main/index.html
65.5 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Indirect Time 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>
.time-entry:hover .delete-btn {
opacity: 1;
}
.chart-container {
height: 300px;
}
@keyframes pulse {
0%, 100% {
opacity: 1;
}
50% {
opacity: 0.5;
}
}
.pulse {
animation: pulse 2s infinite;
}
.slide-in {
animation: slideIn 0.3s ease-out forwards;
}
@keyframes slideIn {
from {
transform: translateX(100%);
opacity: 0;
}
to {
transform: translateX(0);
opacity: 1;
}
}
</style>
</head>
<body class="bg-gray-50">
<div class="min-h-screen">
<!-- Header -->
<header class="bg-indigo-600 text-white shadow-lg">
<div class="container mx-auto px-4 py-6">
<div class="flex justify-between items-center">
<div class="flex items-center space-x-4">
<i class="fas fa-clock text-3xl"></i>
<h1 class="text-2xl font-bold">Indirect Time Management</h1>
</div>
<div class="flex items-center space-x-4">
<button id="manageEmployeesBtn" class="px-4 py-2 bg-indigo-700 rounded-lg hover:bg-indigo-800 flex items-center space-x-2">
<i class="fas fa-users"></i>
<span>Manage Employees</span>
</button>
<div class="relative">
<img id="currentUserAvatar" src="https://randomuser.me/api/portraits/women/44.jpg" alt="User" class="w-10 h-10 rounded-full border-2 border-white">
<span class="absolute bottom-0 right-0 w-3 h-3 bg-green-500 rounded-full"></span>
</div>
<span id="currentUserName" class="font-medium">Sarah Johnson</span>
</div>
</div>
</div>
</header>
<!-- Main Content -->
<main class="container mx-auto px-4 py-8">
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
<!-- Left Column -->
<div class="lg:col-span-2 space-y-8">
<!-- Time Entry Form -->
<div class="bg-white rounded-xl shadow-md p-6">
<h2 class="text-xl font-semibold mb-4 text-gray-800">Log Indirect Time</h2>
<form id="timeEntryForm" class="space-y-4">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label for="employeeSelect" class="block text-sm font-medium text-gray-700 mb-1">Employee</label>
<select id="employeeSelect" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
<!-- Employees will be populated here -->
</select>
</div>
<div>
<label for="activityType" class="block text-sm font-medium text-gray-700 mb-1">Activity Type</label>
<select id="activityType" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
<option value="">Select activity type</option>
<option value="meeting">Meetings</option>
<option value="training">Training</option>
<option value="admin">Administrative</option>
<option value="break">Breaks</option>
<option value="support">Support</option>
<option value="other">Other</option>
</select>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label for="project" class="block text-sm font-medium text-gray-700 mb-1">Project/Department</label>
<select id="project" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
<option value="">Select project</option>
<option value="project-a">Project A</option>
<option value="project-b">Project B</option>
<option value="hr">HR Department</option>
<option value="it">IT Support</option>
<option value="general">General</option>
</select>
</div>
<div>
<label for="description" class="block text-sm font-medium text-gray-700 mb-1">Description</label>
<textarea id="description" rows="2" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500" placeholder="Brief description of the activity"></textarea>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label for="startTime" class="block text-sm font-medium text-gray-700 mb-1">Start Time</label>
<input type="datetime-local" id="startTime" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
</div>
<div>
<label for="endTime" class="block text-sm font-medium text-gray-700 mb-1">End Time</label>
<input type="datetime-local" id="endTime" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
</div>
</div>
<div class="flex justify-end">
<button type="submit" class="px-6 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition duration-300 flex items-center space-x-2">
<i class="fas fa-plus"></i>
<span>Add Time Entry</span>
</button>
</div>
</form>
</div>
<!-- Recent Time Entries -->
<div class="bg-white rounded-xl shadow-md p-6">
<div class="flex justify-between items-center mb-4">
<h2 class="text-xl font-semibold text-gray-800">Recent Time Entries</h2>
<div class="flex space-x-2">
<select id="employeeFilter" class="px-3 py-1 border border-gray-300 rounded-lg text-sm">
<option value="all">All Employees</option>
<!-- Employee filter options will be added here -->
</select>
<select id="timeFilter" class="px-3 py-1 border border-gray-300 rounded-lg text-sm">
<option value="today">Today</option>
<option value="week">This Week</option>
<option value="month">This Month</option>
<option value="all">All Time</option>
</select>
<button id="exportBtn" class="px-3 py-1 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 text-sm flex items-center space-x-1">
<i class="fas fa-file-export text-sm"></i>
<span>Export</span>
</button>
</div>
</div>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Employee</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Date</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Activity</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Project</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Time</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody id="timeEntriesList" class="bg-white divide-y divide-gray-200">
<!-- Time entries will be added here dynamically -->
</tbody>
</table>
</div>
<div id="noEntriesMessage" class="text-center py-8 text-gray-500 hidden">
<i class="fas fa-clock text-4xl mb-2"></i>
<p>No time entries found. Add your first entry above.</p>
</div>
</div>
</div>
<!-- Right Column -->
<div class="space-y-8">
<!-- Summary Card -->
<div class="bg-white rounded-xl shadow-md p-6">
<h2 class="text-xl font-semibold mb-4 text-gray-800">Time Summary</h2>
<div class="space-y-4">
<div class="flex justify-between items-center">
<div class="flex items-center space-x-3">
<div class="w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center">
<i class="fas fa-clock text-indigo-600"></i>
</div>
<div>
<p class="text-sm text-gray-500">Today</p>
<p class="font-medium" id="todayHours">0h 0m</p>
</div>
</div>
<div class="text-right">
<p class="text-sm text-gray-500">This Week</p>
<p class="font-medium" id="weekHours">0h 0m</p>
</div>
</div>
<div class="flex justify-between items-center pt-4 border-t border-gray-200">
<div class="flex items-center space-x-3">
<div class="w-10 h-10 rounded-full bg-green-100 flex items-center justify-center">
<i class="fas fa-calendar-alt text-green-600"></i>
</div>
<div>
<p class="text-sm text-gray-500">This Month</p>
<p class="font-medium" id="monthHours">0h 0m</p>
</div>
</div>
<div class="text-right">
<p class="text-sm text-gray-500">Last Month</p>
<p class="font-medium" id="lastMonthHours">0h 0m</p>
</div>
</div>
</div>
</div>
<!-- Employee Time Summary -->
<div class="bg-white rounded-xl shadow-md p-6">
<h2 class="text-xl font-semibold mb-4 text-gray-800">Employee Time</h2>
<div id="employeeTimeSummary" class="space-y-3">
<!-- Employee time summaries will be added here -->
</div>
</div>
<!-- Quick Actions -->
<div class="bg-white rounded-xl shadow-md p-6">
<h2 class="text-xl font-semibold mb-4 text-gray-800">Quick Actions</h2>
<div class="grid grid-cols-2 gap-3">
<button id="quickMeetingBtn" class="px-4 py-3 bg-blue-50 text-blue-600 rounded-lg hover:bg-blue-100 transition flex flex-col items-center">
<i class="fas fa-users text-xl mb-1"></i>
<span class="text-sm">Quick Meeting</span>
</button>
<button id="quickBreakBtn" class="px-4 py-3 bg-yellow-50 text-yellow-600 rounded-lg hover:bg-yellow-100 transition flex flex-col items-center">
<i class="fas fa-coffee text-xl mb-1"></i>
<span class="text-sm">Quick Break</span>
</button>
<button id="quickAdminBtn" class="px-4 py-3 bg-purple-50 text-purple-600 rounded-lg hover:bg-purple-100 transition flex flex-col items-center">
<i class="fas fa-file-alt text-xl mb-1"></i>
<span class="text-sm">Quick Admin</span>
</button>
<button id="quickTrainingBtn" class="px-4 py-3 bg-green-50 text-green-600 rounded-lg hover:bg-green-100 transition flex flex-col items-center">
<i class="fas fa-graduation-cap text-xl mb-1"></i>
<span class="text-sm">Quick Training</span>
</button>
</div>
</div>
</div>
</div>
</main>
</div>
<!-- Employee Management Modal -->
<div id="employeeModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
<div class="bg-white rounded-xl p-6 w-full max-w-2xl max-h-[90vh] overflow-y-auto">
<div class="flex justify-between items-center mb-4">
<h3 class="text-lg font-semibold">Manage Employees</h3>
<button id="closeEmployeeModalBtn" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<!-- Add Employee Form -->
<div class="bg-gray-50 p-4 rounded-lg mb-6">
<h4 class="font-medium text-gray-700 mb-3">Add New Employee</h4>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">First Name</label>
<input type="text" id="employeeFirstName" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Last Name</label>
<input type="text" id="employeeLastName" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Email</label>
<input type="email" id="employeeEmail" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Department</label>
<select id="employeeDepartment" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
<option value="hr">HR</option>
<option value="it">IT</option>
<option value="finance">Finance</option>
<option value="operations">Operations</option>
<option value="marketing">Marketing</option>
<option value="sales">Sales</option>
</select>
</div>
</div>
<div class="mt-4">
<label class="block text-sm font-medium text-gray-700 mb-1">Avatar URL</label>
<div class="flex items-center space-x-4">
<input type="text" id="employeeAvatar" placeholder="https://example.com/avatar.jpg" class="flex-1 px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
<div class="w-12 h-12 rounded-full bg-gray-200 overflow-hidden">
<img id="employeeAvatarPreview" src="" alt="Preview" class="w-full h-full object-cover hidden">
</div>
</div>
</div>
<div class="flex justify-end mt-4">
<button id="addEmployeeBtn" class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700">Add Employee</button>
</div>
</div>
<!-- Employee List -->
<div>
<h4 class="font-medium text-gray-700 mb-3">Employee List</h4>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Employee</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Department</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Email</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody id="employeeList" class="bg-white divide-y divide-gray-200">
<!-- Employees will be added here -->
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- Export Modal -->
<div id="exportModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
<div class="bg-white rounded-xl p-6 w-full max-w-md">
<div class="flex justify-between items-center mb-4">
<h3 class="text-lg font-semibold">Export Time Entries</h3>
<button id="closeModalBtn" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Format</label>
<div class="flex space-x-4">
<label class="inline-flex items-center">
<input type="radio" name="exportFormat" value="csv" checked class="h-4 w-4 text-indigo-600 focus:ring-indigo-500">
<span class="ml-2">CSV</span>
</label>
<label class="inline-flex items-center">
<input type="radio" name="exportFormat" value="pdf" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500">
<span class="ml-2">PDF</span>
</label>
<label class="inline-flex items-center">
<input type="radio" name="exportFormat" value="excel" class="h-4 w-4 text-indigo-600 focus:ring-indigo-500">
<span class="ml-2">Excel</span>
</label>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Employee</label>
<select id="exportEmployeeFilter" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
<option value="all">All Employees</option>
<!-- Employee options will be added here -->
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Date Range</label>
<select id="exportDateRange" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
<option value="today">Today</option>
<option value="week">This Week</option>
<option value="month">This Month</option>
<option value="all">All Time</option>
<option value="custom">Custom Range</option>
</select>
</div>
<div id="customDateRange" class="hidden">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">From</label>
<input type="date" id="exportStartDate" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">To</label>
<input type="date" id="exportEndDate" class="w-full px-4 py-2 border border-gray-300 rounded-lg">
</div>
</div>
</div>
<div class="flex justify-end space-x-3 pt-4">
<button id="cancelExportBtn" class="px-4 py-2 border border-gray-300 rounded-lg hover:bg-gray-50">Cancel</button>
<button id="confirmExportBtn" class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700">Export</button>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
// Global variables
let timeEntries = JSON.parse(localStorage.getItem('timeEntries')) || [];
let employees = JSON.parse(localStorage.getItem('employees')) || [
{
id: 1,
firstName: 'Sarah',
lastName: 'Johnson',
email: 'sarah.johnson@example.com',
department: 'hr',
avatar: 'https://randomuser.me/api/portraits/women/44.jpg',
isCurrentUser: true
},
{
id: 2,
firstName: 'Michael',
lastName: 'Smith',
email: 'michael.smith@example.com',
department: 'it',
avatar: 'https://randomuser.me/api/portraits/men/32.jpg'
},
{
id: 3,
firstName: 'Emily',
lastName: 'Davis',
email: 'emily.davis@example.com',
department: 'finance',
avatar: 'https://randomuser.me/api/portraits/women/65.jpg'
}
];
let activityChart = null;
let currentUser = employees.find(emp => emp.isCurrentUser) || employees[0];
// Initialize the app when DOM is loaded
document.addEventListener('DOMContentLoaded', function() {
// Set current user display
if (currentUser) {
document.getElementById('currentUserAvatar').src = currentUser.avatar;
document.getElementById('currentUserName').textContent = `${currentUser.firstName} ${currentUser.lastName}`;
}
renderEmployeeSelects();
renderTimeEntries();
updateSummary();
renderEmployeeTimeSummary();
renderActivityChart();
setupEventListeners();
});
function setupEventListeners() {
// Form submission
document.getElementById('timeEntryForm').addEventListener('submit', function(e) {
e.preventDefault();
addTimeEntry();
});
// Time filter change
document.getElementById('timeFilter').addEventListener('change', function() {
renderTimeEntries();
});
// Employee filter change
document.getElementById('employeeFilter').addEventListener('change', function() {
renderTimeEntries();
});
// Export button
document.getElementById('exportBtn').addEventListener('click', function() {
renderExportEmployeeFilter();
document.getElementById('exportModal').classList.remove('hidden');
});
// Close modal buttons
document.getElementById('closeModalBtn').addEventListener('click', closeModal);
document.getElementById('cancelExportBtn').addEventListener('click', closeModal);
// Export date range change
document.getElementById('exportDateRange').addEventListener('change', function() {
if (this.value === 'custom') {
document.getElementById('customDateRange').classList.remove('hidden');
} else {
document.getElementById('customDateRange').classList.add('hidden');
}
});
// Confirm export
document.getElementById('confirmExportBtn').addEventListener('click', function() {
exportTimeEntries();
closeModal();
});
// Quick action buttons
document.getElementById('quickMeetingBtn').addEventListener('click', function() {
quickAddEntry('meeting', 'Quick Meeting');
});
document.getElementById('quickBreakBtn').addEventListener('click', function() {
quickAddEntry('break', 'Quick Break');
});
document.getElementById('quickAdminBtn').addEventListener('click', function() {
quickAddEntry('admin', 'Quick Admin Work');
});
document.getElementById('quickTrainingBtn').addEventListener('click', function() {
quickAddEntry('training', 'Quick Training');
});
// Employee management
document.getElementById('manageEmployeesBtn').addEventListener('click', function() {
renderEmployeeList();
document.getElementById('employeeModal').classList.remove('hidden');
});
document.getElementById('closeEmployeeModalBtn').addEventListener('click', function() {
document.getElementById('employeeModal').classList.add('hidden');
});
// Add employee
document.getElementById('addEmployeeBtn').addEventListener('click', function() {
addEmployee();
});
// Avatar URL preview
document.getElementById('employeeAvatar').addEventListener('input', function() {
const preview = document.getElementById('employeeAvatarPreview');
if (this.value) {
preview.src = this.value;
preview.classList.remove('hidden');
} else {
preview.classList.add('hidden');
}
});
}
function renderEmployeeSelects() {
// Render employee select in time entry form
const employeeSelect = document.getElementById('employeeSelect');
employeeSelect.innerHTML = '';
employees.forEach(employee => {
const option = document.createElement('option');
option.value = employee.id;
option.textContent = `${employee.firstName} ${employee.lastName}`;
if (employee.isCurrentUser) {
option.selected = true;
}
employeeSelect.appendChild(option);
});
// Render employee filter in time entries list
const employeeFilter = document.getElementById('employeeFilter');
employeeFilter.innerHTML = '<option value="all">All Employees</option>';
employees.forEach(employee => {
const option = document.createElement('option');
option.value = employee.id;
option.textContent = `${employee.firstName} ${employee.lastName}`;
employeeFilter.appendChild(option);
});
}
function renderExportEmployeeFilter() {
const exportEmployeeFilter = document.getElementById('exportEmployeeFilter');
exportEmployeeFilter.innerHTML = '<option value="all">All Employees</option>';
employees.forEach(employee => {
const option = document.createElement('option');
option.value = employee.id;
option.textContent = `${employee.firstName} ${employee.lastName}`;
exportEmployeeFilter.appendChild(option);
});
}
function renderEmployeeList() {
const employeeList = document.getElementById('employeeList');
employeeList.innerHTML = '';
if (employees.length === 0) {
employeeList.innerHTML = `
<tr>
<td colspan="4" class="px-6 py-4 text-center text-gray-500">
No employees found. Add your first employee.
</td>
</tr>
`;
return;
}
employees.forEach(employee => {
const row = document.createElement('tr');
row.className = 'hover:bg-gray-50';
row.innerHTML = `
<td class="px-6 py-4 whitespace-nowrap">
<div class="flex items-center">
<div class="flex-shrink-0 h-10 w-10">
<img class="h-10 w-10 rounded-full" src="${employee.avatar}" alt="${employee.firstName} ${employee.lastName}">
</div>
<div class="ml-4">
<div class="text-sm font-medium text-gray-900">${employee.firstName} ${employee.lastName}</div>
<div class="text-sm text-gray-500">${employee.email}</div>
</div>
</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-indigo-100 text-indigo-800">
${employee.department.toUpperCase()}
</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
${employee.email}
</td>
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
<button onclick="window.deleteEmployee(${employee.id})" class="text-red-600 hover:text-red-900 mr-3">
<i class="fas fa-trash"></i>
</button>
${employee.isCurrentUser ? '<span class="text-green-600">Current User</span>' : ''}
</td>
`;
employeeList.appendChild(row);
});
}
function addEmployee() {
const firstName = document.getElementById('employeeFirstName').value.trim();
const lastName = document.getElementById('employeeLastName').value.trim();
const email = document.getElementById('employeeEmail').value.trim();
const department = document.getElementById('employeeDepartment').value;
const avatar = document.getElementById('employeeAvatar').value.trim() || `https://ui-avatars.com/api/?name=${firstName}+${lastName}&background=random`;
if (!firstName || !lastName || !email) {
alert('Please fill in all required fields');
return;
}
// Simple email validation
if (!email.includes('@') || !email.includes('.')) {
alert('Please enter a valid email address');
return;
}
// Check if email already exists
if (employees.some(emp => emp.email === email)) {
alert('An employee with this email already exists');
return;
}
const newEmployee = {
id: Date.now(),
firstName,
lastName,
email,
department,
avatar,
isCurrentUser: false
};
employees.push(newEmployee);
saveEmployees();
renderEmployeeList();
renderEmployeeSelects();
// Reset form
document.getElementById('employeeFirstName').value = '';
document.getElementById('employeeLastName').value = '';
document.getElementById('employeeEmail').value = '';
document.getElementById('employeeAvatar').value = '';
document.getElementById('employeeAvatarPreview').src = '';
document.getElementById('employeeAvatarPreview').classList.add('hidden');
// Show success feedback
const addEmployeeBtn = document.getElementById('addEmployeeBtn');
const originalText = addEmployeeBtn.innerHTML;
addEmployeeBtn.innerHTML = '<i class="fas fa-check mr-2"></i> Employee Added';
addEmployeeBtn.classList.add('bg-green-600', 'hover:bg-green-700');
setTimeout(() => {
addEmployeeBtn.innerHTML = originalText;
addEmployeeBtn.classList.remove('bg-green-600', 'hover:bg-green-700');
}, 2000);
}
function deleteEmployee(id) {
if (confirm('Are you sure you want to delete this employee? This will also delete all their time entries.')) {
// Delete employee
employees = employees.filter(emp => emp.id !== id);
// Delete time entries for this employee
timeEntries = timeEntries.filter(entry => entry.employeeId !== id);
// If we deleted the current user, set the first employee as current
if (currentUser && currentUser.id === id) {
if (employees.length > 0) {
currentUser = employees[0];
currentUser.isCurrentUser = true;
document.getElementById('currentUserAvatar').src = currentUser.avatar;
document.getElementById('currentUserName').textContent = `${currentUser.firstName} ${currentUser.lastName}`;
} else {
currentUser = null;
}
}
saveEmployees();
saveTimeEntries();
renderEmployeeList();
renderEmployeeSelects();
renderTimeEntries();
updateSummary();
renderEmployeeTimeSummary();
renderActivityChart();
}
}
function addTimeEntry() {
const employeeId = parseInt(document.getElementById('employeeSelect').value);
const activityType = document.getElementById('activityType').value;
const project = document.getElementById('project').value;
const description = document.getElementById('description').value;
const startTime = document.getElementById('startTime').value;
const endTime = document.getElementById('endTime').value;
if (!employeeId || !activityType || !project || !startTime || !endTime) {
alert('Please fill in all required fields');
return;
}
const startDate = new Date(startTime);
const endDate = new Date(endTime);
if (endDate <= startDate) {
alert('End time must be after start time');
return;
}
const durationMs = endDate - startDate;
const durationMinutes = Math.floor(durationMs / (1000 * 60));
if (durationMinutes <= 0) {
alert('Time entry must be at least 1 minute');
return;
}
const newEntry = {
id: Date.now(),
employeeId,
activityType,
project,
description,
startTime: startDate.toISOString(),
endTime: endDate.toISOString(),
duration: durationMinutes,
createdAt: new Date().toISOString()
};
timeEntries.unshift(newEntry);
saveTimeEntries();
renderTimeEntries();
updateSummary();
renderEmployeeTimeSummary();
renderActivityChart();
// Reset form
document.getElementById('timeEntryForm').reset();
document.getElementById('employeeSelect').value = currentUser ? currentUser.id : employees[0]?.id;
// Show success feedback
const submitBtn = document.getElementById('timeEntryForm').querySelector('button[type="submit"]');
const originalText = submitBtn.innerHTML;
submitBtn.innerHTML = '<i class="fas fa-check"></i><span>Entry Added</span>';
submitBtn.classList.add('bg-green-600', 'hover:bg-green-700');
setTimeout(() => {
submitBtn.innerHTML = originalText;
submitBtn.classList.remove('bg-green-600', 'hover:bg-green-700');
}, 2000);
}
function quickAddEntry(activityType, description) {
const now = new Date();
const endTime = new Date(now.getTime() + 30 * 60000); // 30 minutes from now
document.getElementById('activityType').value = activityType;
document.getElementById('project').value = 'general';
document.getElementById('description').value = description;
document.getElementById('startTime').value = formatDateTimeLocal(now);
document.getElementById('endTime').value = formatDateTimeLocal(endTime);
// Set current user as selected
if (currentUser) {
document.getElementById('employeeSelect').value = currentUser.id;
}
// Highlight the quick action button
const quickBtn = document.getElementById(`quick${activityType.charAt(0).toUpperCase() + activityType.slice(1)}Btn`);
quickBtn.classList.add('pulse');
setTimeout(() => {
quickBtn.classList.remove('pulse');
}, 2000);
}
function formatDateTimeLocal(date) {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
return `${year}-${month}-${day}T${hours}:${minutes}`;
}
function deleteTimeEntry(id) {
timeEntries = timeEntries.filter(entry => entry.id !== id);
saveTimeEntries();
renderTimeEntries();
updateSummary();
renderEmployeeTimeSummary();
renderActivityChart();
}
function saveTimeEntries() {
localStorage.setItem('timeEntries', JSON.stringify(timeEntries));
}
function saveEmployees() {
localStorage.setItem('employees', JSON.stringify(employees));
}
function renderTimeEntries() {
const timeFilterValue = document.getElementById('timeFilter').value;
const employeeFilterValue = document.getElementById('employeeFilter').value;
const now = new Date();
let filteredEntries = [...timeEntries];
// Filter by employee
if (employeeFilterValue !== 'all') {
filteredEntries = filteredEntries.filter(entry => entry.employeeId === parseInt(employeeFilterValue));
}
// Filter by time
switch (timeFilterValue) {
case 'today':
filteredEntries = filteredEntries.filter(entry => {
const entryDate = new Date(entry.startTime);
return entryDate.getDate() === now.getDate() &&
entryDate.getMonth() === now.getMonth() &&
entryDate.getFullYear() === now.getFullYear();
});
break;
case 'week':
const startOfWeek = new Date(now);
startOfWeek.setDate(now.getDate() - now.getDay());
startOfWeek.setHours(0, 0, 0, 0);
filteredEntries = filteredEntries.filter(entry => {
const entryDate = new Date(entry.startTime);
return entryDate >= startOfWeek;
});
break;
case 'month':
const startOfMonth = new Date(now.getFullYear(), now.getMonth(), 1);
filteredEntries = filteredEntries.filter(entry => {
const entryDate = new Date(entry.startTime);
return entryDate >= startOfMonth;
});
break;
// 'all' shows all entries
}
const timeEntriesList = document.getElementById('timeEntriesList');
const noEntriesMessage = document.getElementById('noEntriesMessage');
if (filteredEntries.length === 0) {
timeEntriesList.innerHTML = '';
noEntriesMessage.classList.remove('hidden');
return;
}
noEntriesMessage.classList.add('hidden');
let html = '';
filteredEntries.forEach(entry => {
const employee = employees.find(emp => emp.id === entry.employeeId);
const startDate = new Date(entry.startTime);
const endDate = new Date(entry.endTime);
const hours = Math.floor(entry.duration / 60);
const minutes = entry.duration % 60;
const durationText = hours > 0 ? `${hours}h ${minutes}m` : `${minutes}m`;
const activityIcons = {
'meeting': 'users',
'training': 'graduation-cap',
'admin': 'file-alt',
'break': 'coffee',
'support': 'headset',
'other': 'clock'
};
const activityColors = {
'meeting': 'bg-blue-100 text-blue-800',
'training': 'bg-green-100 text-green-800',
'admin': 'bg-purple-100 text-purple-800',
'break': 'bg-yellow-100 text-yellow-800',
'support': 'bg-red-100 text-red-800',
'other': 'bg-gray-100 text-gray-800'
};
html += `
<tr class="time-entry hover:bg-gray-50">
<td class="px-6 py-4 whitespace-nowrap">
<div class="flex items-center">
<div class="flex-shrink-0 h-10 w-10">
<img class="h-10 w-10 rounded-full" src="${employee ? employee.avatar : 'https://ui-avatars.com/api/?name=Unknown&background=random'}" alt="${employee ? `${employee.firstName} ${employee.lastName}` : 'Unknown'}">
</div>
<div class="ml-4">
<div class="text-sm font-medium text-gray-900">${employee ? `${employee.firstName} ${employee.lastName}` : 'Unknown Employee'}</div>
</div>
</div>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
${startDate.toLocaleDateString()}
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="flex items-center">
<div class="flex-shrink-0 h-10 w-10 flex items-center justify-center rounded-full ${activityColors[entry.activityType]}">
<i class="fas fa-${activityIcons[entry.activityType]}"></i>
</div>
<div class="ml-4">
<div class="text-sm font-medium text-gray-900">${getActivityName(entry.activityType)}</div>
<div class="text-sm text-gray-500 truncate max-w-xs">${entry.description}</div>
</div>
</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-indigo-100 text-indigo-800">
${getProjectName(entry.project)}
</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
${startDate.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'})} - ${endDate.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'})}
<div class="text-xs text-gray-400">${durationText}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
<button onclick="window.deleteTimeEntry(${entry.id})" class="delete-btn opacity-0 transition-opacity duration-200 text-red-600 hover:text-red-900">
<i class="fas fa-trash"></i>
</button>
</td>
</tr>
`;
});
timeEntriesList.innerHTML = html;
}
function getActivityName(type) {
const names = {
'meeting': 'Meeting',
'training': 'Training',
'admin': 'Administrative',
'break': 'Break',
'support': 'Support',
'other': 'Other'
};
return names[type] || type;
}
function getProjectName(project) {
const names = {
'project-a': 'Project A',
'project-b': 'Project B',
'hr': 'HR Department',
'it': 'IT Support',
'general': 'General'
};
return names[project] || project;
}
function updateSummary() {
const now = new Date();
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
const startOfWeek = new Date(now);
startOfWeek.setDate(now.getDate() - now.getDay());
startOfWeek.setHours(0, 0, 0, 0);
const startOfMonth = new Date(now.getFullYear(), now.getMonth(), 1);
const startOfLastMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1);
const endOfLastMonth = new Date(now.getFullYear(), now.getMonth(), 0);
let todayTotal = 0;
let weekTotal = 0;
let monthTotal = 0;
let lastMonthTotal = 0;
// Filter entries for current user if one exists
const currentUserId = currentUser ? currentUser.id : null;
const userEntries = currentUserId ? timeEntries.filter(entry => entry.employeeId === currentUserId) : timeEntries;
userEntries.forEach(entry => {
const entryDate = new Date(entry.startTime);
const minutes = entry.duration;
// Today
if (entryDate >= today) {
todayTotal += minutes;
}
// This week
if (entryDate >= startOfWeek) {
weekTotal += minutes;
}
// This month
if (entryDate >= startOfMonth) {
monthTotal += minutes;
}
// Last month
if (entryDate >= startOfLastMonth && entryDate <= endOfLastMonth) {
lastMonthTotal += minutes;
}
});
document.getElementById('todayHours').textContent = formatDuration(todayTotal);
document.getElementById('weekHours').textContent = formatDuration(weekTotal);
document.getElementById('monthHours').textContent = formatDuration(monthTotal);
document.getElementById('lastMonthHours').textContent = formatDuration(lastMonthTotal);
}
function renderEmployeeTimeSummary() {
const employeeTimeSummary = document.getElementById('employeeTimeSummary');
employeeTimeSummary.innerHTML = '';
if (employees.length === 0) {
employeeTimeSummary.innerHTML = '<p class="text-gray-500 text-center">No employees found</p>';
return;
}
const now = new Date();
const startOfWeek = new Date(now);
startOfWeek.setDate(now.getDate() - now.getDay());
startOfWeek.setHours(0, 0, 0, 0);
employees.forEach(employee => {
const employeeEntries = timeEntries.filter(entry => entry.employeeId === employee.id);
const weekEntries = employeeEntries.filter(entry => new Date(entry.startTime) >= startOfWeek);
const totalMinutes = weekEntries.reduce((sum, entry) => sum + entry.duration, 0);
const item = document.createElement('div');
item.className = 'flex items-center justify-between p-3 hover:bg-gray-50 rounded-lg';
item.innerHTML = `
<div class="flex items-center space-x-3">
<img src="${employee.avatar}" alt="${employee.firstName} ${employee.lastName}" class="w-10 h-10 rounded-full">
<div>
<p class="font-medium">${employee.firstName} ${employee.lastName}</p>
<p class="text-xs text-gray-500">${employee.department.toUpperCase()}</p>
</div>
</div>
<div class="text-right">
<p class="text-sm text-gray-500">This Week</p>
<p class="font-medium">${formatDuration(totalMinutes)}</p>
</div>
`;
employeeTimeSummary.appendChild(item);
});
}
function formatDuration(minutes) {
const hours = Math.floor(minutes / 60);
const mins = minutes % 60;
if (hours > 0) {
return `${hours}h ${mins}m`;
} else {
return `${mins}m`;
}
}
function renderActivityChart() {
const ctx = document.createElement('canvas');
ctx.id = 'activityChart';
ctx.className = 'chart-container';
const chartContainer = document.querySelector('.bg-white.rounded-xl.shadow-md.p-6');
const existingChart = document.getElementById('activityChart');
if (existingChart) {
chartContainer.removeChild(existingChart);
}
chartContainer.appendChild(ctx);
// Filter entries for current user if one exists
const currentUserId = currentUser ? currentUser.id : null;
const userEntries = currentUserId ? timeEntries.filter(entry => entry.employeeId === currentUserId) : timeEntries;
// Group by activity type
const activityGroups = {};
userEntries.forEach(entry => {
if (!activityGroups[entry.activityType]) {
activityGroups[entry.activityType] = 0;
}
activityGroups[entry.activityType] += entry.duration;
});
const labels = Object.keys(activityGroups).map(getActivityName);
const data = Object.values(activityGroups);
const backgroundColors = [
'rgba(99, 102, 241, 0.7)', // indigo
'rgba(16, 185, 129, 0.7)', // green
'rgba(139, 92, 246, 0.7)', // purple
'rgba(234, 179, 8, 0.7)', // yellow
'rgba(239, 68, 68, 0.7)', // red
'rgba(156, 163, 175, 0.7)' // gray
];
if (activityChart) {
activityChart.destroy();
}
activityChart = new Chart(ctx, {
type: 'doughnut',
data: {
labels: labels,
datasets: [{
data: data,
backgroundColor: backgroundColors,
borderWidth: 1
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
position: 'right',
},
tooltip: {
callbacks: {
label: function(context) {
const label = context.label || '';
const value = context.raw || 0;
const hours = Math.floor(value / 60);
const minutes = value % 60;
return `${label}: ${hours > 0 ? `${hours}h ${minutes}m` : `${minutes}m`}`;
}
}
}
}
}
});
}
function exportTimeEntries() {
const format = document.querySelector('input[name="exportFormat"]:checked').value;
const employeeFilter = document.getElementById('exportEmployeeFilter').value;
const range = document.getElementById('exportDateRange').value;
let filteredEntries = [...timeEntries];
let filename = 'indirect_time_entries';
// Filter by employee
if (employeeFilter !== 'all') {
filteredEntries = filteredEntries.filter(entry => entry.employeeId === parseInt(employeeFilter));
const employee = employees.find(emp => emp.id === parseInt(employeeFilter));
if (employee) {
filename += `_${employee.firstName}_${employee.lastName}`;
}
}
// Filter by date range
const now = new Date();
switch (range) {
case 'today':
filteredEntries = filteredEntries.filter(entry => {
const entryDate = new Date(entry.startTime);
return entryDate.getDate() === now.getDate() &&
entryDate.getMonth() === now.getMonth() &&
entryDate.getFullYear() === now.getFullYear();
});
filename += '_today';
break;
case 'week':
const startOfWeek = new Date(now);
startOfWeek.setDate(now.getDate() - now.getDay());
startOfWeek.setHours(0, 0, 0, 0);
filteredEntries = filteredEntries.filter(entry => {
const entryDate = new Date(entry.startTime);
return entryDate >= startOfWeek;
});
filename += '_this_week';
break;
case 'month':
const startOfMonth = new Date(now.getFullYear(), now.getMonth(), 1);
filteredEntries = filteredEntries.filter(entry => {
const entryDate = new Date(entry.startTime);
return entryDate >= startOfMonth;
});
filename += '_this_month';
break;
case 'custom':
const startDate = document.getElementById('exportStartDate').value;
const endDate = document.getElementById('exportEndDate').value;
if (!startDate || !endDate) {
alert('Please select both start and end dates');
return;
}
const start = new Date(startDate);
const end = new Date(endDate);
end.setHours(23, 59, 59, 999);
filteredEntries = filteredEntries.filter(entry => {
const entryDate = new Date(entry.startTime);
return entryDate >= start && entryDate <= end;
});
filename += `_from_${startDate}_to_${endDate}`;
break;
// 'all' uses all entries
}
if (filteredEntries.length === 0) {
alert('No entries to export for the selected range');
return;
}
// Prepare CSV content
let csvContent = "Employee,Date,Activity Type,Project,Description,Start Time,End Time,Duration (minutes)\n";
filteredEntries.forEach(entry => {
const employee = employees.find(emp => emp.id === entry.employeeId);
const startDate = new Date(entry.startTime);
const endDate = new Date(entry.endTime);
csvContent += `"${employee ? `${employee.firstName} ${employee.lastName}` : 'Unknown'}","${startDate.toLocaleDateString()}","${getActivityName(entry.activityType)}","${getProjectName(entry.project)}","${entry.description}","${startDate.toLocaleTimeString()}","${endDate.toLocaleTimeString()}","${entry.duration}"\n`;
});
// Create download link
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.setAttribute('href', url);
link.setAttribute('download', `${filename}.csv`);
link.style.visibility = 'hidden';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
// Show export success feedback
const exportBtn = document.getElementById('exportBtn');
const originalText = exportBtn.innerHTML;
exportBtn.innerHTML = '<i class="fas fa-check"></i><span>Exported</span>';
exportBtn.classList.add('bg-green-100', 'text-green-800');
setTimeout(() => {
exportBtn.innerHTML = originalText;
exportBtn.classList.remove('bg-green-100', 'text-green-800');
}, 2000);
}
function closeModal() {
document.getElementById('exportModal').classList.add('hidden');
}
// Make functions available globally
window.deleteTimeEntry = deleteTimeEntry;
window.deleteEmployee = deleteEmployee;
</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=lordjames82/test2" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Indirect Time 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>
.time-entry:hover .delete-btn {
opacity: 1;
}
.chart-container {
height: 300px;
}
@keyframes pulse {
0%, 100% {
opacity: 1;
}
50% {
opacity: 0.5;
}
}
.pulse {
animation: pulse 2s infinite;
}
.slide-in {
animation: slideIn 0.3s ease-out forwards;
}
@keyframes slideIn {
from {
transform: translateX(100%);
opacity: 0;
}
to {
transform: translateX(0);
opacity: 1;
}
}
</style>
</head>
<body class="bg-gray-50">
<div class="min-h-screen">
<!-- Header -->
<header class="bg-indigo-600 text-white shadow-lg">
<div class="container mx-auto px-4 py-6">
<div class="flex justify-between items-center">
<div class="flex items-center space-x-4">
<i class="fas fa-clock text-3xl"></i>
<h1 class="text-2xl font-bold">Indirect Time Management</h1>
</div>
<div class="flex items-center space-x-4">
<button id="manageEmployeesBtn" class="px-4 py-2 bg-indigo-700 rounded-lg hover:bg-indigo-800 flex items-center space-x-2">
<i class="fas fa-users"></i>
<span>Manage Employees</span>
</button>
<div class="relative">
<img id="currentUserAvatar" src="https://randomuser.me/api/portraits/women/44.jpg" alt="User" class="w-10 h-10 rounded-full border-2 border-white">
<span class="absolute bottom-0 right-0 w-3 h-3 bg-green-500 rounded-full"></span>
</div>
<span id="currentUserName" class="font-medium">Sarah Johnson</span>
</div>
</div>
</div>
</header>
<!-- Main Content -->
<main class="container mx-auto px-4 py-8">
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
<!-- Left Column -->
<div class="lg:col-span-2 space-y-8">
<!-- Time Entry Form -->
<div class="bg-white rounded-xl shadow-md p-6">
<h2 class="text-xl font-semibold mb-4 text-gray-800">Log Indirect Time</h2>
<form id="timeEntryForm" class="space-y-4">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label for="employeeSelect" class="block text-sm font-medium text-gray-700 mb-1">Employee</label>
<select id="employeeSelect" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
<!-- Employees will be populated here -->
</select>
</div>
<div>
<label for="activityType" class="block text-sm font-medium text-gray-700 mb-1">Activity Type</label>
<select id="activityType" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">
<option value="">Select activity type</option>
<option value="meeting">Meetings</option>
<option value="training">Training</option>
<option value="admin">Administrative</option>
<option value="break">Breaks</option>
<option value="support">Support</option>
<option value="other">Other</option>
</select>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label for="project" class="block text-sm font-medium text-gray-700 mb-1">Project/Department</label>
<select id="project" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500">