dylanebert commited on
Commit
fab97fd
·
1 Parent(s): b36b020
Files changed (1) hide show
  1. viewer/src/routes/+page.svelte +26 -19
viewer/src/routes/+page.svelte CHANGED
@@ -277,6 +277,7 @@
277
 
278
  let statusMessage = "";
279
  const baseURL = "https://dylanebert-research-tracker-backend.hf.space";
 
280
 
281
  const addEntry = async () => {
282
  if (!("Name" in selection)) return;
@@ -342,7 +343,7 @@
342
  method: "POST",
343
  headers: {
344
  "Content-Type": "application/json",
345
- "Authorization": "Bearer " + import.meta.env.VITE_HF_TOKEN,
346
  },
347
  body: JSON.stringify(row),
348
  });
@@ -366,7 +367,7 @@
366
  method: "POST",
367
  headers: {
368
  "Content-Type": "application/json",
369
- "Authorization": "Bearer " + import.meta.env.VITE_HF_TOKEN,
370
  },
371
  body: JSON.stringify({ value }),
372
  });
@@ -391,7 +392,7 @@
391
  method: "POST",
392
  headers: {
393
  "Content-Type": "application/json",
394
- "Authorization": "Bearer " + import.meta.env.VITE_HF_TOKEN,
395
  },
396
  body: JSON.stringify(row),
397
  });
@@ -425,7 +426,7 @@
425
  method: "POST",
426
  headers: {
427
  "Content-Type": "application/json",
428
- "Authorization": "Bearer " + import.meta.env.VITE_HF_TOKEN,
429
  },
430
  body: JSON.stringify(row),
431
  });
@@ -459,7 +460,7 @@
459
  method: "POST",
460
  headers: {
461
  "Content-Type": "application/json",
462
- "Authorization": "Bearer " + import.meta.env.VITE_HF_TOKEN,
463
  },
464
  body: JSON.stringify(row),
465
  });
@@ -492,7 +493,7 @@
492
  method: "POST",
493
  headers: {
494
  "Content-Type": "application/json",
495
- "Authorization": "Bearer " + import.meta.env.VITE_HF_TOKEN,
496
  },
497
  body: JSON.stringify(row),
498
  });
@@ -525,7 +526,7 @@
525
  method: "POST",
526
  headers: {
527
  "Content-Type": "application/json",
528
- "Authorization": "Bearer " + import.meta.env.VITE_HF_TOKEN,
529
  },
530
  body: JSON.stringify(row),
531
  });
@@ -558,7 +559,7 @@
558
  method: "POST",
559
  headers: {
560
  "Content-Type": "application/json",
561
- "Authorization": "Bearer " + import.meta.env.VITE_HF_TOKEN,
562
  },
563
  body: JSON.stringify(row),
564
  });
@@ -591,7 +592,7 @@
591
  method: "POST",
592
  headers: {
593
  "Content-Type": "application/json",
594
- "Authorization": "Bearer " + import.meta.env.VITE_HF_TOKEN,
595
  },
596
  body: JSON.stringify(row),
597
  });
@@ -624,7 +625,7 @@
624
  method: "POST",
625
  headers: {
626
  "Content-Type": "application/json",
627
- "Authorization": "Bearer " + import.meta.env.VITE_HF_TOKEN,
628
  },
629
  body: JSON.stringify(row),
630
  });
@@ -657,14 +658,20 @@
657
  const fetchRows = async () => {
658
  if (fetching) return;
659
  fetching = true;
660
- const response = await fetch(baseURL + "/data", {
661
- method: "GET",
662
- headers: {
663
- "Authorization": "Bearer " + import.meta.env.VITE_HF_TOKEN,
664
- },
665
- });
666
- rows = await response.json();
667
- fetching = false;
 
 
 
 
 
 
668
  };
669
  </script>
670
 
@@ -674,7 +681,7 @@
674
  </div>
675
  {:else if fetching}
676
  <div style="text-align: center; margin-top: 1rem;">
677
- <p>Fetching data from https://dylanebert-research-tracker-backend.hf.space/data</p>
678
  </div>
679
  {:else}
680
  <div style="text-align: center; margin-top: 1rem;">
 
277
 
278
  let statusMessage = "";
279
  const baseURL = "https://dylanebert-research-tracker-backend.hf.space";
280
+ // const baseURL = "http://localhost:8000";
281
 
282
  const addEntry = async () => {
283
  if (!("Name" in selection)) return;
 
343
  method: "POST",
344
  headers: {
345
  "Content-Type": "application/json",
346
+ Authorization: "Bearer " + import.meta.env.VITE_HF_TOKEN,
347
  },
348
  body: JSON.stringify(row),
349
  });
 
367
  method: "POST",
368
  headers: {
369
  "Content-Type": "application/json",
370
+ Authorization: "Bearer " + import.meta.env.VITE_HF_TOKEN,
371
  },
372
  body: JSON.stringify({ value }),
373
  });
 
392
  method: "POST",
393
  headers: {
394
  "Content-Type": "application/json",
395
+ Authorization: "Bearer " + import.meta.env.VITE_HF_TOKEN,
396
  },
397
  body: JSON.stringify(row),
398
  });
 
426
  method: "POST",
427
  headers: {
428
  "Content-Type": "application/json",
429
+ Authorization: "Bearer " + import.meta.env.VITE_HF_TOKEN,
430
  },
431
  body: JSON.stringify(row),
432
  });
 
460
  method: "POST",
461
  headers: {
462
  "Content-Type": "application/json",
463
+ Authorization: "Bearer " + import.meta.env.VITE_HF_TOKEN,
464
  },
465
  body: JSON.stringify(row),
466
  });
 
493
  method: "POST",
494
  headers: {
495
  "Content-Type": "application/json",
496
+ Authorization: "Bearer " + import.meta.env.VITE_HF_TOKEN,
497
  },
498
  body: JSON.stringify(row),
499
  });
 
526
  method: "POST",
527
  headers: {
528
  "Content-Type": "application/json",
529
+ Authorization: "Bearer " + import.meta.env.VITE_HF_TOKEN,
530
  },
531
  body: JSON.stringify(row),
532
  });
 
559
  method: "POST",
560
  headers: {
561
  "Content-Type": "application/json",
562
+ Authorization: "Bearer " + import.meta.env.VITE_HF_TOKEN,
563
  },
564
  body: JSON.stringify(row),
565
  });
 
592
  method: "POST",
593
  headers: {
594
  "Content-Type": "application/json",
595
+ Authorization: "Bearer " + import.meta.env.VITE_HF_TOKEN,
596
  },
597
  body: JSON.stringify(row),
598
  });
 
625
  method: "POST",
626
  headers: {
627
  "Content-Type": "application/json",
628
+ Authorization: "Bearer " + import.meta.env.VITE_HF_TOKEN,
629
  },
630
  body: JSON.stringify(row),
631
  });
 
658
  const fetchRows = async () => {
659
  if (fetching) return;
660
  fetching = true;
661
+ statusMessage = `<span>Fetching data from https://dylanebert-research-tracker-backend.hf.space/data"</span>`;
662
+ try {
663
+ const response = await fetch(baseURL + "/data", {
664
+ method: "GET",
665
+ headers: {
666
+ Authorization: "Bearer " + import.meta.env.VITE_HF_TOKEN,
667
+ },
668
+ });
669
+ rows = await response.json();
670
+ fetching = false;
671
+ } catch (e) {
672
+ console.error(e);
673
+ statusMessage = `<span style="color: red;">Error: Failed to fetch data from https://dylanebert-research-tracker-backend.hf.space/data</span>`;
674
+ }
675
  };
676
  </script>
677
 
 
681
  </div>
682
  {:else if fetching}
683
  <div style="text-align: center; margin-top: 1rem;">
684
+ <p>{@html statusMessage}</p>
685
  </div>
686
  {:else}
687
  <div style="text-align: center; margin-top: 1rem;">