Files
Prism_old/notes.html
T
2025-12-15 14:54:29 -06:00

288 lines
14 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Job Tracking - Notes</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/pocketbase@latest/dist/pocketbase.umd.js"></script>
<link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet">
<script src="https://cdn.quilljs.com/1.3.6/quill.js"></script>
</head>
<body class="min-h-screen bg-gradient-to-br from-gray-50 via-blue-50/30 to-indigo-50/40">
<!-- Navigation Header -->
<nav class="backdrop-blur-xl bg-white/70 border-b border-white/20 shadow-sm sticky top-0 z-40">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex flex-row justify-between items-center py-4 px-2">
<div class="flex items-center gap-4">
<a href="dashboard" class="text-indigo-600 hover:text-indigo-700 font-medium text-sm sm:text-base transition-colors">← Dashboard</a>
</div>
<div class="flex items-center gap-3 relative">
<div class="relative">
<button
onclick="toggleUserDropdown()"
class="w-10 h-10 rounded-full bg-gradient-to-br from-indigo-500 via-purple-500 to-pink-500 flex items-center justify-center text-white font-medium text-sm hover:scale-105 focus:outline-none transition-all duration-300 shadow-lg shadow-indigo-500/30 hover:shadow-indigo-500/50"
id="userAvatarBtn"
>
<span id="userInitials" class="text-xs font-semibold"></span>
</button>
<div
id="userDropdown"
class="hidden absolute right-0 mt-2 w-48 backdrop-blur-xl bg-white/80 rounded-2xl shadow-2xl border border-white/30 py-2 z-50 overflow-hidden"
>
<div class="px-4 py-3 border-b border-white/20">
<p class="text-xs text-gray-500 font-medium">Signed in as</p>
<p class="text-sm font-semibold text-gray-900 truncate mt-0.5" id="userEmail"></p>
</div>
<a
href="preferences"
class="block px-4 py-2.5 text-sm text-gray-700 hover:bg-white/40 focus:outline-none transition-colors font-medium"
>
Preferences
</a>
<button
onclick="logout()"
class="w-full text-left px-4 py-2.5 text-sm text-red-600 hover:bg-red-50/50 focus:outline-none transition-colors font-medium"
>
Logout
</button>
</div>
</div>
</div>
</div>
</div>
</nav>
<!-- Main Content -->
<main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<!-- Page Header -->
<div class="flex flex-col sm:flex-row justify-between items-start sm:items-center gap-4 mb-6">
<div>
<h1 class="text-xl sm:text-2xl font-bold text-gray-800 mb-2">Job Notes</h1>
<p class="text-sm sm:text-base text-gray-600">Manage job notes and reports</p>
</div>
<button
onclick="openNoteModal()"
class="w-full sm:w-auto bg-indigo-600 text-white px-4 sm:px-6 py-2 sm:py-3 rounded-lg text-sm sm:text-base font-medium hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 transition"
>
+ Add Note
</button>
</div>
<!-- Message Container -->
<div id="messageContainer" class="mb-4"></div>
<!-- Loading Indicator -->
<div id="loadingIndicator" class="text-center py-8">
<div class="inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-indigo-600"></div>
<p class="mt-2 text-gray-600">Loading notes...</p>
</div>
<!-- Reports Table Container -->
<div id="reportsTableContainer" class="hidden backdrop-blur-xl bg-white/60 rounded-2xl shadow-xl border border-white/30 overflow-hidden">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-3 sm:px-6 py-2 sm:py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Job</th>
<th class="px-3 sm:px-6 py-2 sm:py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Note</th>
<th class="px-3 sm:px-6 py-2 sm:py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Sentiment</th>
<th class="px-3 sm:px-6 py-2 sm:py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Date</th>
<th class="px-3 sm:px-6 py-2 sm:py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody id="notesTableBody" class="bg-white divide-y divide-gray-200">
</tbody>
</table>
</div>
</div>
<!-- Empty State -->
<div id="emptyState" class="hidden text-center py-12">
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
</svg>
<h3 class="mt-2 text-sm font-medium text-gray-900">No notes</h3>
<p class="mt-1 text-sm text-gray-500">Get started by creating a new note.</p>
<div class="mt-6">
<button
onclick="openNoteModal()"
class="inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
>
+ Add Note
</button>
</div>
</div>
</main>
<!-- Add/Edit Note Modal -->
<div id="noteModal" class="hidden fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto z-50">
<div class="relative top-0 sm:top-10 mx-auto p-4 sm:p-5 border-0 sm:border w-full sm:max-w-2xl shadow-lg rounded-none sm:rounded-md bg-white mb-0 sm:mb-10 min-h-screen sm:min-h-0">
<!-- Modal Header -->
<div class="flex justify-between items-center mb-4">
<h2 class="text-lg font-medium text-gray-900" id="noteModalTitle">Add Note</h2>
<button
onclick="closeNoteModal()"
class="text-gray-400 hover:text-gray-500"
>
<svg class="h-6 w-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
</svg>
</button>
</div>
<!-- Note Form -->
<form id="noteForm" class="space-y-4 max-h-[calc(100vh-200px)] overflow-y-auto pr-2">
<input type="hidden" id="noteId" name="id">
<div>
<label for="noteJob" class="block text-sm font-medium text-gray-700 mb-1">Job *</label>
<select id="noteJob" name="job" required class="w-full px-3 py-2 border-2 border-gray-300/60 rounded-xl backdrop-blur-sm bg-white/40 focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500/70 outline-none text-base transition-all shadow-sm">
<option value="">Select a job...</option>
</select>
</div>
<div>
<label for="noteEditor" class="block text-sm font-medium text-gray-700 mb-1">Note</label>
<div id="noteEditor" style="height: 200px;"></div>
<textarea id="noteContent" name="content" class="hidden"></textarea>
</div>
<div>
<label for="noteSentiment" class="block text-sm font-medium text-gray-700 mb-1">Sentiment</label>
<select id="noteSentiment" name="sentiment" class="w-full px-3 py-2 border-2 border-gray-300/60 rounded-xl backdrop-blur-sm bg-white/40 focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500/70 outline-none text-base transition-all shadow-sm">
<option value="">Select sentiment...</option>
<option value="Positive">Positive</option>
<option value="Negative">Negative</option>
<option value="Neutral">Neutral</option>
</select>
</div>
<div>
<label for="noteDate" class="block text-sm font-medium text-gray-700 mb-1">Date & Time</label>
<input type="datetime-local" id="noteDate" name="date" class="w-full px-3 py-2 border-2 border-gray-300/60 rounded-xl backdrop-blur-sm bg-white/40 focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500/70 outline-none text-base transition-all shadow-sm">
</div>
<div class="flex flex-col sm:flex-row justify-end space-y-2 sm:space-y-0 sm:space-x-3 pt-4 border-t">
<button
type="button"
onclick="closeNoteModal()"
class="w-full sm:w-auto px-4 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500 text-base"
>
Cancel
</button>
<button
type="submit"
class="w-full sm:w-auto px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 text-base"
>
Save Note
</button>
</div>
</form>
</div>
</div>
<script src="js/pocketbase.js"></script>
<script src="js/config.js"></script>
<script src="js/auth.js"></script>
<script src="js/preferences.js"></script>
<script src="js/jobs.js"></script>
<script src="js/notes.js"></script>
<script>
let noteEditor = null;
// Check authentication
checkAuth();
// Initialize dark mode
initializeDarkMode();
// Set user email and initials
const user = pb.authStore.model;
if (user) {
const email = user.email || '';
document.getElementById('userEmail').textContent = email;
// Set initials for avatar
const initials = email
.split('@')[0]
.split('.')
.map(part => part.charAt(0).toUpperCase())
.join('')
.substring(0, 2) || 'U';
document.getElementById('userInitials').textContent = initials;
}
// Toggle user dropdown
function toggleUserDropdown() {
const dropdown = document.getElementById('userDropdown');
dropdown.classList.toggle('hidden');
}
// Close dropdown when clicking outside
document.addEventListener('click', (e) => {
const dropdown = document.getElementById('userDropdown');
const button = document.getElementById('userAvatarBtn');
if (dropdown && !dropdown.contains(e.target) && !button.contains(e.target)) {
dropdown.classList.add('hidden');
}
});
// Make function globally accessible
window.toggleUserDropdown = toggleUserDropdown;
// Initialize Quill editor
noteEditor = new Quill('#noteEditor', {
theme: 'snow',
modules: {
toolbar: [
[{ 'header': [1, 2, 3, false] }],
['bold', 'italic', 'underline'],
['link'],
[{ 'list': 'ordered'}, { 'list': 'bullet' }]
]
}
});
// Set global reference
window.noteEditorInstance = noteEditor;
// Modal functions
function openNoteModal(noteId = null) {
document.getElementById('noteModal').classList.remove('hidden');
if (noteId) {
document.getElementById('noteModalTitle').textContent = 'Edit Note';
document.getElementById('noteId').value = noteId;
loadNoteForEdit(noteId);
} else {
document.getElementById('noteModalTitle').textContent = 'Add Note';
document.getElementById('noteForm').reset();
document.getElementById('noteId').value = '';
noteEditor.setContents([]);
loadJobsForSelect();
}
}
function closeNoteModal() {
document.getElementById('noteModal').classList.add('hidden');
document.getElementById('noteForm').reset();
document.getElementById('noteId').value = '';
noteEditor.setContents([]);
}
// Form submission
document.getElementById('noteForm').addEventListener('submit', async (e) => {
e.preventDefault();
if (noteEditor) {
const content = noteEditor.root.innerHTML;
document.getElementById('noteContent').value = content;
}
await saveNote();
});
// Load notes on page load
loadAllNotes();
</script>
</body>
</html>