ommore86 commited on
Commit
a808ca0
·
1 Parent(s): 96874c5

Update index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +46 -47
templates/index.html CHANGED
@@ -15,29 +15,6 @@
15
  <div class="bg-gradient-to-b from-indigo-200 via-white to-indigo-100">
16
  <div class="bg-gradient-to-b from-indigo-50 via-white to-indigo-100">
17
 
18
- <!-- Sidebar -->
19
- <div id="sidebar"
20
- class="fixed top-0 left-0 h-full w-64 bg-white shadow-xl border-r border-gray-200 transform -translate-x-full transition-transform duration-300 z-40">
21
- <div class="p-6">
22
- <h2 class="text-lg font-semibold text-gray-800 mb-4">Uploaded PDF</h2>
23
- <div id="sidebarFileName" class="text-sm text-gray-600 italic mb-6">No file uploaded</div>
24
-
25
- <button id="btnSummarize"
26
- class="w-full bg-indigo-500 hover:bg-indigo-600 text-white py-2 rounded disabled:opacity-50" disabled>
27
- Summarize
28
- </button>
29
-
30
- <div id="summaryBox"
31
- class="mt-6 max-h-64 overflow-y-auto text-sm text-gray-700 p-3 border rounded bg-gray-50 hidden"></div>
32
- </div>
33
- </div>
34
-
35
- <!-- Sidebar Toggle Button -->
36
- <button id="sidebarToggle"
37
- class="fixed top-4 left-4 z-50 bg-indigo-500 hover:bg-indigo-600 text-white p-2 rounded shadow">
38
-
39
- </button>
40
-
41
  <!-- Header -->
42
  <header class="fixed inset-x-0 top-0 z-50 bg-white/70 backdrop-blur-md shadow-sm">
43
  <div class="max-w-7xl mx-auto px-6 py-3 flex items-center justify-between">
@@ -122,6 +99,19 @@
122
  </button>
123
  </div>
124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  <!-- Chat Box -->
126
  <div id="chatBox"
127
  class="space-y-3 max-w-3xl max-h-96 overflow-y-auto px-4 py-4 border rounded-lg bg-white shadow-inner mx-auto">
@@ -443,34 +433,43 @@
443
  }
444
  };
445
 
 
 
446
  // Summarize logic
447
  btnSummarize.onclick = async () => {
448
- btnSummarize.disabled = true;
449
- btnSummarize.textContent = "Summarizing…";
450
-
451
- try {
452
- const res = await fetch("/summarize", {
453
- method: "POST",
454
- headers: { "Content-Type": "application/json" },
455
- body: JSON.stringify({ file_id: fileId }),
456
- });
457
- const data = await res.json();
 
 
 
 
 
 
 
458
 
459
- if (res.ok) {
460
- summaryBox.textContent = data.summary || "No summary available.";
461
- summaryBox.classList.remove("hidden");
462
- } else {
463
- summaryBox.textContent = data.error || "Summarization failed.";
464
- summaryBox.classList.remove("hidden");
465
- }
466
- } catch (err) {
467
- summaryBox.textContent = "Error summarizing file.";
468
- summaryBox.classList.remove("hidden");
469
- }
470
 
471
- btnSummarize.disabled = false;
472
- btnSummarize.textContent = "Summarize";
473
- };
 
 
 
 
 
 
 
 
 
 
474
 
475
  </script>
476
 
 
15
  <div class="bg-gradient-to-b from-indigo-200 via-white to-indigo-100">
16
  <div class="bg-gradient-to-b from-indigo-50 via-white to-indigo-100">
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  <!-- Header -->
19
  <header class="fixed inset-x-0 top-0 z-50 bg-white/70 backdrop-blur-md shadow-sm">
20
  <div class="max-w-7xl mx-auto px-6 py-3 flex items-center justify-between">
 
99
  </button>
100
  </div>
101
 
102
+ <!-- Summarize Section -->
103
+ <div class="mt-6">
104
+ <button id="btnSummarize"
105
+ class="bg-indigo-500 hover:bg-indigo-600 text-white px-4 py-2 rounded disabled:opacity-50" disabled>
106
+ Summarize PDF
107
+ </button>
108
+
109
+ <div id="summaryBox"
110
+ class="mt-4 max-h-64 overflow-y-auto text-sm text-gray-700 p-3 border rounded bg-gray-50 hidden">
111
+ </div>
112
+ </div>
113
+
114
+
115
  <!-- Chat Box -->
116
  <div id="chatBox"
117
  class="space-y-3 max-w-3xl max-h-96 overflow-y-auto px-4 py-4 border rounded-lg bg-white shadow-inner mx-auto">
 
433
  }
434
  };
435
 
436
+
437
+
438
  // Summarize logic
439
  btnSummarize.onclick = async () => {
440
+ if (!window.currentFileId) {
441
+ summaryBox.textContent = "⚠️ Please upload a PDF first.";
442
+ summaryBox.classList.remove("hidden");
443
+ return;
444
+ }
445
+
446
+ btnSummarize.disabled = true;
447
+ btnSummarize.textContent = "Summarizing…";
448
+ summaryBox.textContent = "⏳ Generating summary...";
449
+ summaryBox.classList.remove("hidden");
450
+
451
+ try {
452
+ const res = await fetch("/summarize", {
453
+ method: "POST",
454
+ headers: { "Content-Type": "application/json" },
455
+ body: JSON.stringify({ file_id: window.currentFileId }),
456
+ });
457
 
458
+ const data = await res.json();
 
 
 
 
 
 
 
 
 
 
459
 
460
+ if (res.ok) {
461
+ summaryBox.textContent = data.summary || "No summary available.";
462
+ } else {
463
+ summaryBox.textContent = "❌ " + (data.error || "Summarization failed.");
464
+ }
465
+ } catch (err) {
466
+ summaryBox.textContent = "❌ Error summarizing file.";
467
+ }
468
+
469
+ btnSummarize.disabled = false;
470
+ btnSummarize.textContent = "Summarize PDF";
471
+ };
472
+
473
 
474
  </script>
475