summaryrefslogtreecommitdiff
path: root/web/static/js/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/static/js/app.js')
-rw-r--r--web/static/js/app.js77
1 files changed, 77 insertions, 0 deletions
diff --git a/web/static/js/app.js b/web/static/js/app.js
new file mode 100644
index 0000000..a96c05d
--- /dev/null
+++ b/web/static/js/app.js
@@ -0,0 +1,77 @@
+// Personal Dashboard JavaScript
+
+// Auto-refresh every 5 minutes
+const AUTO_REFRESH_INTERVAL = 5 * 60 * 1000; // 5 minutes in milliseconds
+
+// Initialize auto-refresh on page load
+document.addEventListener('DOMContentLoaded', function() {
+ // Set up auto-refresh
+ setInterval(autoRefresh, AUTO_REFRESH_INTERVAL);
+});
+
+// Auto-refresh function
+async function autoRefresh() {
+ console.log('Auto-refreshing data...');
+ try {
+ const response = await fetch('/api/refresh', {
+ method: 'POST'
+ });
+
+ if (response.ok) {
+ // Reload the page to show updated data
+ window.location.reload();
+ }
+ } catch (error) {
+ console.error('Auto-refresh failed:', error);
+ }
+}
+
+// Manual refresh function
+async function refreshData() {
+ const button = event.target;
+ const originalText = button.textContent;
+
+ // Show loading state
+ button.disabled = true;
+ button.innerHTML = 'Refreshing...<span class="spinner"></span>';
+
+ try {
+ const response = await fetch('/api/refresh', {
+ method: 'POST'
+ });
+
+ if (response.ok) {
+ // Update last updated time
+ const now = new Date();
+ const timeString = now.toLocaleTimeString('en-US', {
+ hour: 'numeric',
+ minute: '2-digit'
+ });
+ document.getElementById('last-updated').textContent = timeString;
+
+ // Reload the page to show updated data
+ setTimeout(() => {
+ window.location.reload();
+ }, 500);
+ } else {
+ throw new Error('Refresh failed');
+ }
+ } catch (error) {
+ console.error('Refresh failed:', error);
+ alert('Failed to refresh data. Please try again.');
+ button.disabled = false;
+ button.textContent = originalText;
+ }
+}
+
+// Filter tasks by status
+function filterTasks(status) {
+ // This will be implemented in Phase 2
+ console.log('Filter tasks:', status);
+}
+
+// Toggle task completion
+function toggleTask(taskId) {
+ // This will be implemented in Phase 2
+ console.log('Toggle task:', taskId);
+}