Gaurav vashistha commited on
Commit
e1f623b
·
1 Parent(s): 06e46fc

Bugfix: Restore real API connection to Glassmorphism UI

Browse files
Files changed (1) hide show
  1. dashboard.html +34 -47
dashboard.html CHANGED
@@ -391,11 +391,25 @@
391
  <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
392
  </svg>
393
  `;
394
- setTimeout(() => {
395
- alert("Success: Catalog pushed to storefront!");
396
- deployBtn.innerHTML = originalContent;
397
- deployBtn.disabled = false;
398
- }, 1500);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
399
  });
400
  copyBtn.addEventListener('click', () => {
401
  const textToCopy = jsonOutput.innerText;
@@ -403,52 +417,25 @@
403
  const originalIcon = copyIcon.innerText;
404
  copyIcon.style.opacity = '0';
405
  copyIcon.style.transform = 'scale(0.8)';
406
- setTimeout(() => {
407
- copyIcon.innerText = 'check';
408
- copyIcon.classList.remove('text-neutral-500');
409
- copyIcon.classList.add('text-amber-500');
410
- copyIcon.classList.add('animate-copy-success');
411
- copyIcon.style.opacity = '1';
412
- copyIcon.style.transform = 'scale(1)';
413
- copyBtn.classList.add('copy-active');
414
- }, 150);
415
- setTimeout(() => {
416
- copyIcon.style.opacity = '0';
417
- copyIcon.style.transform = 'scale(0.8)';
418
- setTimeout(() => {
419
- copyIcon.innerText = originalIcon;
420
- copyIcon.classList.remove('text-amber-500', 'animate-copy-success');
421
- copyIcon.classList.add('text-neutral-500');
422
- copyIcon.style.opacity = '1';
423
- copyIcon.style.transform = 'scale(1)';
424
- copyBtn.classList.remove('copy-active');
425
- }, 150);
426
- }, 2000);
427
- });
428
- });
429
- downloadBtn.addEventListener('click', () => {
430
- const dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(jsonOutput.innerText);
431
- const downloadAnchorNode = document.createElement('a');
432
- downloadAnchorNode.setAttribute("href", dataStr);
433
- downloadAnchorNode.setAttribute("download", "merchflow_output.json");
434
- document.body.appendChild(downloadAnchorNode);
435
- downloadAnchorNode.click();
436
- downloadAnchorNode.remove();
437
- });
438
- startBtn.addEventListener('click', async () => {
439
- if (!selectedFile) {
440
- alert("Please select a file first.");
441
- return;
442
- }
443
- startBtn.innerHTML = '<div class="absolute inset-0 flex items-center justify-center gap-2 lg:gap-3"><svg class="animate-spin h-4 w-4 lg:h-5 lg:w-5 text-white" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle><path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path></svg><span class="text-white text-base lg:text-lg font-bold tracking-wide">Synthesizing...</span></div>';
444
- startBtn.disabled = true;
445
- startBtn.classList.remove('animate-pulse-slow', 'animate-glow-pulse');
446
- setTimeout(() => {
447
  isCatalogGenerated = true;
 
 
 
448
  startBtn.innerHTML = '<div class="absolute inset-0 flex items-center justify-center gap-2 lg:gap-3 relative z-10"><span class="text-white text-base lg:text-lg font-bold tracking-wide group-hover:scale-105 transition-transform">Start Agent Workflow</span><span class="material-symbols-outlined text-white text-lg lg:text-xl group-hover:translate-x-1 transition-transform">arrow_forward</span></div>';
449
  startBtn.disabled = false;
450
  startBtn.classList.add('animate-pulse-slow', 'animate-glow-pulse');
451
- }, 1500);
452
  });
453
  </script>
454
 
 
391
  <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
392
  </svg>
393
  `;
394
+ try {
395
+ const formData = new FormData();
396
+ formData.append('file', fileInput.files[0]);
397
+
398
+ const response = await fetch('/generate-catalog', {
399
+ method: 'POST',
400
+ body: formData
401
+ });
402
+
403
+ const data = await response.json();
404
+ jsonOutput.textContent = JSON.stringify(data, null, 2);
405
+ isCatalogGenerated = true;
406
+ } catch (error) {
407
+ console.error("Error generating catalog:", error);
408
+ } finally {
409
+ startBtn.innerHTML = '<div class="absolute inset-0 flex items-center justify-center gap-2 lg:gap-3 relative z-10"><span class="text-white text-base lg:text-lg font-bold tracking-wide group-hover:scale-105 transition-transform">Start Agent Workflow</span><span class="material-symbols-outlined text-white text-lg lg:text-xl group-hover:translate-x-1 transition-transform">arrow_forward</span></div>';
410
+ startBtn.disabled = false;
411
+ startBtn.classList.add('animate-pulse-slow', 'animate-glow-pulse');
412
+ }
413
  });
414
  copyBtn.addEventListener('click', () => {
415
  const textToCopy = jsonOutput.innerText;
 
417
  const originalIcon = copyIcon.innerText;
418
  copyIcon.style.opacity = '0';
419
  copyIcon.style.transform = 'scale(0.8)';
420
+ try {
421
+ const formData = new FormData();
422
+ formData.append('file', fileInput.files[0]);
423
+
424
+ const response = await fetch('/generate-catalog', {
425
+ method: 'POST',
426
+ body: formData
427
+ });
428
+
429
+ const data = await response.json();
430
+ jsonOutput.textContent = JSON.stringify(data, null, 2);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
431
  isCatalogGenerated = true;
432
+ } catch (error) {
433
+ console.error("Error generating catalog:", error);
434
+ } finally {
435
  startBtn.innerHTML = '<div class="absolute inset-0 flex items-center justify-center gap-2 lg:gap-3 relative z-10"><span class="text-white text-base lg:text-lg font-bold tracking-wide group-hover:scale-105 transition-transform">Start Agent Workflow</span><span class="material-symbols-outlined text-white text-lg lg:text-xl group-hover:translate-x-1 transition-transform">arrow_forward</span></div>';
436
  startBtn.disabled = false;
437
  startBtn.classList.add('animate-pulse-slow', 'animate-glow-pulse');
438
+ }
439
  });
440
  </script>
441