Skip to content

Commit dd9d669

Browse files
committed
Fix ESLint errors in demo pages
- Remove unused imports and variables from DirectoryPage.js - Remove unused imports and variables from SearchPage.js - Remove unused imports and variables from StatusPage.js - Clean up unused functions and state variables - Demo now builds successfully without warnings or errors
1 parent b59c4e9 commit dd9d669

File tree

3 files changed

+11
-146
lines changed

3 files changed

+11
-146
lines changed

demo/src/pages/DirectoryPage.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,7 @@ import {
99
AlertCircle,
1010
RefreshCw
1111
} from 'lucide-react';
12-
import {
13-
getDirectories,
14-
getDirectory,
15-
addDirectory,
16-
updateDirectory,
17-
removeDirectory
18-
} from '../services/api';
12+
// Removed unused API imports - using mockApi instead
1913
import { mockApi } from '../services/mockApi';
2014

2115
const DirectoryPage = () => {

demo/src/pages/SearchPage.js

Lines changed: 9 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
import React, { useState, useEffect } from 'react';
2-
import { Search, Image as ImageIcon, Loader2, AlertCircle, Play } from 'lucide-react';
3-
import { createQuery, search, getSearchLogs, getFile } from '../services/api';
2+
import { Image as ImageIcon, AlertCircle, Play } from 'lucide-react';
3+
// Removed unused imports: Loader2, getFile
44
import { sampleQueries, mockApi } from '../services/mockApi';
55

66
const SearchPage = () => {
7-
const [query, setQuery] = useState('');
87
const [isSearching, setIsSearching] = useState(false);
98
const [results, setResults] = useState([]);
109
const [error, setError] = useState(null);
1110
const [searchLogs, setSearchLogs] = useState([]);
1211
const [imageUrls, setImageUrls] = useState({});
13-
const [loadingImages, setLoadingImages] = useState(false);
14-
const [searchStartTime, setSearchStartTime] = useState(null);
15-
const [elapsedTime, setElapsedTime] = useState(0);
16-
const [searchConfig, setSearchConfig] = useState({
12+
// Removed loadingImages - not needed for demo
13+
// Removed searchStartTime - not needed for demo
14+
const [searchConfig] = useState({
1715
num_images_to_retrieve: 10,
1816
include_base_images_in_preview: false,
1917
verbose: false,
@@ -38,18 +36,7 @@ const SearchPage = () => {
3836
};
3937
}, [imageUrls]);
4038

41-
// Timer for elapsed time during search
42-
useEffect(() => {
43-
let interval;
44-
if (isSearching && searchStartTime) {
45-
interval = setInterval(() => {
46-
setElapsedTime(Date.now() - searchStartTime);
47-
}, 100);
48-
} else {
49-
setElapsedTime(0);
50-
}
51-
return () => clearInterval(interval);
52-
}, [isSearching, searchStartTime]);
39+
// Removed elapsed time timer - not needed for demo
5340

5441
const loadSearchLogs = async () => {
5542
try {
@@ -62,31 +49,9 @@ const SearchPage = () => {
6249
}
6350
};
6451

65-
const fetchImage = async (filePath) => {
66-
try {
67-
const response = await getFile(filePath);
68-
const blob = new Blob([response.data], { type: 'image/jpeg' });
69-
return URL.createObjectURL(blob);
70-
} catch (err) {
71-
console.error('Failed to fetch image:', err);
72-
return null;
73-
}
74-
};
52+
// Removed fetchImage function - not needed for demo
7553

76-
const loadImages = async (imagePaths) => {
77-
setLoadingImages(true);
78-
const newImageUrls = {};
79-
80-
for (const path of imagePaths) {
81-
const url = await fetchImage(path);
82-
if (url) {
83-
newImageUrls[path] = url;
84-
}
85-
}
86-
87-
setImageUrls(prev => ({ ...prev, ...newImageUrls }));
88-
setLoadingImages(false);
89-
};
54+
// Removed loadImages function - not needed for demo
9055

9156
const handleSampleQuery = async (sampleQuery) => {
9257
setIsSearching(true);
@@ -104,7 +69,6 @@ const SearchPage = () => {
10469
try {
10570
// Record start time right before the actual query request
10671
const searchStartTime = Date.now();
107-
setSearchStartTime(searchStartTime);
10872

10973
// Use mock API for demo
11074
const searchResponse = await mockApi.search(sampleQuery.id, searchConfig);
@@ -136,88 +100,7 @@ const SearchPage = () => {
136100
}
137101
};
138102

139-
const handleSearch = async (e) => {
140-
e.preventDefault();
141-
if (!query.trim()) return;
142-
143-
setIsSearching(true);
144-
setError(null);
145-
setResults([]);
146-
147-
// Clear previous image URLs
148-
Object.values(imageUrls).forEach(url => {
149-
if (url.startsWith('blob:')) {
150-
URL.revokeObjectURL(url);
151-
}
152-
});
153-
setImageUrls({});
154-
155-
try {
156-
// Record start time right before the actual query request
157-
const searchStartTime = Date.now();
158-
setSearchStartTime(searchStartTime);
159-
160-
// Create query
161-
const queryResponse = await createQuery(query);
162-
const queryId = queryResponse.data.qid;
163-
164-
// Perform search
165-
const searchResponse = await search(queryId, searchConfig);
166-
const searchData = searchResponse.data;
167-
168-
const searchEndTime = Date.now();
169-
const frontendTiming = searchEndTime - searchStartTime;
170-
171-
setResults({
172-
queryId,
173-
results: searchData.results || [],
174-
baseImages: searchData.base_images || [],
175-
previewUrl: searchData.preview_url,
176-
timings: {
177-
...searchData.timings,
178-
frontend_total_time: frontendTiming / 1000
179-
},
180-
verboseResults: searchData.verbose_results || {}
181-
});
182-
183-
// Load images for display
184-
if (searchData.results && searchData.results.length > 0) {
185-
loadImages(searchData.results);
186-
}
187-
188-
// Reload search logs
189-
await loadSearchLogs();
190-
} catch (err) {
191-
setError(err.response?.data?.detail || err.message || 'Search failed');
192-
} finally {
193-
setIsSearching(false);
194-
}
195-
};
196-
197-
const renderImage = (imageData, index) => {
198-
if (typeof imageData === 'string') {
199-
// Base64 image
200-
return (
201-
<img
202-
key={index}
203-
src={`data:image/jpeg;base64,${imageData}`}
204-
alt={`Search result ${index + 1}`}
205-
className="w-full h-48 object-cover rounded-lg"
206-
/>
207-
);
208-
} else if (imageData.id) {
209-
// Image ID - would need to fetch actual image
210-
return (
211-
<div
212-
key={index}
213-
className="w-full h-48 bg-gray-200 rounded-lg flex items-center justify-center"
214-
>
215-
<span className="text-gray-500">Image ID: {imageData.id}</span>
216-
</div>
217-
);
218-
}
219-
return null;
220-
};
103+
// Removed unused functions: handleSearch and renderImage
221104

222105
return (
223106
<div className="space-y-6">
@@ -399,12 +282,6 @@ const SearchPage = () => {
399282
<div>
400283
<h3 className="text-lg font-medium text-gray-900 mb-3">
401284
Retrieved Images ({results.results.length})
402-
{loadingImages && (
403-
<span className="ml-2 text-sm text-gray-500">
404-
<Loader2 className="inline h-4 w-4 animate-spin mr-1" />
405-
Loading images...
406-
</span>
407-
)}
408285
</h3>
409286
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
410287
{results.results.map((result, index) => {

demo/src/pages/StatusPage.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,7 @@ import {
1010
Image as ImageIcon,
1111
Clock
1212
} from 'lucide-react';
13-
import {
14-
getHealth,
15-
getServiceStatus,
16-
getDirectories,
17-
getGenerators,
18-
getSearchLogs
19-
} from '../services/api';
13+
// Removed unused API imports - using mockApi instead
2014
import { mockApi } from '../services/mockApi';
2115

2216
const StatusPage = () => {

0 commit comments

Comments
 (0)