SCGR commited on
Commit
cb0b78c
·
1 Parent(s): f920192

loading state hadnling

Browse files
frontend/src/components/ExportModal.tsx CHANGED
@@ -13,7 +13,6 @@ interface ExportModalProps {
13
  droneImagesCount: number;
14
  isLoading?: boolean;
15
  exportSuccess?: boolean;
16
- isPageLoading?: boolean;
17
  variant?: 'bulk' | 'single';
18
  onNavigateToList?: () => void;
19
  onNavigateAndExport?: () => void;
@@ -27,7 +26,6 @@ export default function ExportModal({
27
  droneImagesCount,
28
  isLoading = false,
29
  exportSuccess = false,
30
- isPageLoading = false,
31
  variant = 'bulk',
32
  onNavigateAndExport
33
  }: ExportModalProps) {
@@ -69,22 +67,6 @@ export default function ExportModal({
69
  return (
70
  <div className={styles.fullSizeModalOverlay} onClick={handleClose}>
71
  <div className={styles.fullSizeModalContent} onClick={(e) => e.stopPropagation()}>
72
- {isPageLoading && (
73
- <div className={styles.loadingOverlay}>
74
- <div className="flex flex-col items-center gap-4">
75
- <Spinner className="text-ifrcRed" />
76
- <div className="flex flex-col items-center gap-4 mt-4">
77
- <Button
78
- name="cancel-page-loading"
79
- variant="tertiary"
80
- onClick={handleClose}
81
- >
82
- Cancel
83
- </Button>
84
- </div>
85
- </div>
86
- </div>
87
- )}
88
  {isLoading && (
89
  <div className={styles.loadingOverlay}>
90
  <div className="flex flex-col items-center gap-4">
@@ -161,22 +143,6 @@ export default function ExportModal({
161
  return (
162
  <div className={styles.fullSizeModalOverlay} onClick={handleClose}>
163
  <div className={styles.fullSizeModalContent} onClick={(e) => e.stopPropagation()}>
164
- {isPageLoading && (
165
- <div className={styles.loadingOverlay}>
166
- <div className="flex flex-col items-center gap-4">
167
- <Spinner className="text-ifrcRed" />
168
- <div className="flex flex-col items-center gap-4 mt-4">
169
- <Button
170
- name="cancel-page-loading"
171
- variant="tertiary"
172
- onClick={handleClose}
173
- >
174
- Cancel
175
- </Button>
176
- </div>
177
- </div>
178
- </div>
179
- )}
180
  {isLoading && (
181
  <div className={styles.loadingOverlay}>
182
  <div className="flex flex-col items-center gap-4">
 
13
  droneImagesCount: number;
14
  isLoading?: boolean;
15
  exportSuccess?: boolean;
 
16
  variant?: 'bulk' | 'single';
17
  onNavigateToList?: () => void;
18
  onNavigateAndExport?: () => void;
 
26
  droneImagesCount,
27
  isLoading = false,
28
  exportSuccess = false,
 
29
  variant = 'bulk',
30
  onNavigateAndExport
31
  }: ExportModalProps) {
 
67
  return (
68
  <div className={styles.fullSizeModalOverlay} onClick={handleClose}>
69
  <div className={styles.fullSizeModalContent} onClick={(e) => e.stopPropagation()}>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  {isLoading && (
71
  <div className={styles.loadingOverlay}>
72
  <div className="flex flex-col items-center gap-4">
 
143
  return (
144
  <div className={styles.fullSizeModalOverlay} onClick={handleClose}>
145
  <div className={styles.fullSizeModalContent} onClick={(e) => e.stopPropagation()}>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  {isLoading && (
147
  <div className={styles.loadingOverlay}>
148
  <div className="flex flex-col items-center gap-4">
frontend/src/pages/ExplorePage/ExplorePage.tsx CHANGED
@@ -480,39 +480,47 @@ export default function ExplorePage() {
480
 
481
  return (
482
  <PageContainer>
483
- <div className="max-w-7xl mx-auto">
484
- <div className={styles.tabSelector}>
485
- <SegmentInput
486
- name="explore-view"
487
- value={view}
488
- onChange={(value) => {
489
- if (value === 'explore' || value === 'mapDetails') {
490
- setView(value);
491
- if (value === 'mapDetails' && captions.length > 0) {
492
- if (captions[0]?.image_id && captions[0].image_id !== 'undefined' && captions[0].image_id !== 'null') {
493
- navigate(`/map/${captions[0].image_id}`);
494
- } else {
495
- console.error('Invalid image_id for navigation:', captions[0]?.image_id);
496
- }
497
- }
498
- }
499
- }}
500
- options={viewOptions}
501
- keySelector={(o) => o.key}
502
- labelSelector={(o) => o.label}
503
- />
504
-
505
- {/* Export Dataset Button */}
506
- <Button
507
- name="export-dataset"
508
- variant="secondary"
509
- onClick={() => setShowExportModal(true)}
510
- >
511
- Export
512
- </Button>
513
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
514
 
515
- {view === 'explore' ? (
516
  <div className="space-y-6">
517
  {/* Search and Filters */}
518
  <div className="mb-6 space-y-4">
@@ -647,6 +655,7 @@ export default function ExplorePage() {
647
  </div>
648
  )}
649
  </div>
 
650
 
651
  {/* Export Selection Modal */}
652
  <ExportModal
@@ -667,7 +676,6 @@ export default function ExplorePage() {
667
  droneImagesCount={filtered.filter(img => img.image_type === 'drone_image').length}
668
  isLoading={isExporting}
669
  exportSuccess={exportSuccess}
670
- isPageLoading={isLoadingContent}
671
  />
672
  </PageContainer>
673
  );
 
480
 
481
  return (
482
  <PageContainer>
483
+ {isLoadingContent ? (
484
+ <div className="flex flex-col items-center justify-center min-h-[60vh]">
485
+ <div className="flex flex-col items-center gap-4">
486
+ <Spinner className="text-ifrcRed" />
487
+ <div>Loading examples...</div>
488
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
489
  </div>
490
+ ) : (
491
+ <div className="max-w-7xl mx-auto">
492
+ <div className={styles.tabSelector}>
493
+ <SegmentInput
494
+ name="explore-view"
495
+ value={view}
496
+ onChange={(value) => {
497
+ if (value === 'explore' || value === 'mapDetails') {
498
+ setView(value);
499
+ if (value === 'mapDetails' && captions.length > 0) {
500
+ if (captions[0]?.image_id && captions[0].image_id !== 'undefined' && captions[0].image_id !== 'null') {
501
+ navigate(`/map/${captions[0].image_id}`);
502
+ } else {
503
+ console.error('Invalid image_id for navigation:', captions[0]?.image_id);
504
+ }
505
+ }
506
+ }
507
+ }}
508
+ options={viewOptions}
509
+ keySelector={(o) => o.key}
510
+ labelSelector={(o) => o.label}
511
+ />
512
+
513
+ {/* Export Dataset Button */}
514
+ <Button
515
+ name="export-dataset"
516
+ variant="secondary"
517
+ onClick={() => setShowExportModal(true)}
518
+ >
519
+ Export
520
+ </Button>
521
+ </div>
522
 
523
+ {view === 'explore' ? (
524
  <div className="space-y-6">
525
  {/* Search and Filters */}
526
  <div className="mb-6 space-y-4">
 
655
  </div>
656
  )}
657
  </div>
658
+ )}
659
 
660
  {/* Export Selection Modal */}
661
  <ExportModal
 
676
  droneImagesCount={filtered.filter(img => img.image_type === 'drone_image').length}
677
  isLoading={isExporting}
678
  exportSuccess={exportSuccess}
 
679
  />
680
  </PageContainer>
681
  );
frontend/src/pages/MapDetailsPage/MapDetailPage.tsx CHANGED
@@ -1390,7 +1390,6 @@ export default function MapDetailPage() {
1390
  droneImagesCount={map.image_type === 'drone_image' ? 1 : 0}
1391
  isLoading={isExporting}
1392
  exportSuccess={exportSuccess}
1393
- isPageLoading={loading}
1394
  variant="single"
1395
  onNavigateToList={() => {
1396
  setShowExportModal(false);
 
1390
  droneImagesCount={map.image_type === 'drone_image' ? 1 : 0}
1391
  isLoading={isExporting}
1392
  exportSuccess={exportSuccess}
 
1393
  variant="single"
1394
  onNavigateToList={() => {
1395
  setShowExportModal(false);