Skip to content

Commit 605aa2d

Browse files
author
idf_karolisstr
committed
Update loading screen.
1 parent 496686a commit 605aa2d

18 files changed

Lines changed: 785 additions & 166 deletions

‎src/charts/timeSeries.ts‎

Lines changed: 15 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ export class TimeSeriesChart {
858858
const minLabelWidth = 1; // Minimum time difference to create a meaningful label
859859

860860
if (labelWidth < minLabelWidth) {
861-
console.log('Label too narrow, minimum width required:', minLabelWidth);
861+
// Label too narrow, minimum width required
862862
return; // Don't create the label
863863
}
864864

@@ -884,8 +884,8 @@ export class TimeSeriesChart {
884884
if (this.lastConfig) {
885885
this.updateDisplay(this.lastConfig);
886886
}
887-
} catch (error) {
888-
console.error('Failed to create label:', error);
887+
} catch (_error) {
888+
// Failed to create label - silent handling
889889
}
890890
}
891891

@@ -952,7 +952,7 @@ export class TimeSeriesChart {
952952

953953
return {
954954
silent: true, // Don't intercept mouse events - allow drawing over labels
955-
data: markAreaData as unknown, // ECharts markArea type is complex, using unknown for data compatibility
955+
data: markAreaData as never, // ECharts markArea expects complex nested array structure
956956
};
957957
}
958958

@@ -1029,15 +1029,7 @@ export class TimeSeriesChart {
10291029
}
10301030

10311031
const data = source.getData(config.xColumn, config.yColumn);
1032-
console.log('Retrieved data for columns:', {
1033-
xColumn: config.xColumn,
1034-
yColumn: config.yColumn,
1035-
dataLength: data.length,
1036-
firstFewPoints: data.slice(0, 3),
1037-
lastFewPoints: data.slice(-3),
1038-
sourceName: source.name,
1039-
sourceColumns: source.columns,
1040-
});
1032+
// Retrieved data for columns - debug info available if needed
10411033

10421034
// Apply configuration with defaults
10431035
const xType = config.xType || 'category';
@@ -1062,25 +1054,7 @@ export class TimeSeriesChart {
10621054
seriesData = data;
10631055
}
10641056

1065-
// Validate data for any invalid values
1066-
const invalidPoints = seriesData.filter((point) => {
1067-
const [x, y] = point;
1068-
const xNum = typeof x === 'string' ? parseFloat(x) : x;
1069-
return !Number.isFinite(xNum) || !Number.isFinite(y);
1070-
});
1071-
1072-
// eslint-disable-next-line no-console
1073-
console.log('Final series data for chart:', {
1074-
xType,
1075-
xColumn: config.xColumn,
1076-
processingType:
1077-
xType === 'category' && config.xColumn === 'index' ? 'row indices' : 'actual data',
1078-
totalPoints: seriesData.length,
1079-
invalidPoints: invalidPoints.length,
1080-
invalidSample: invalidPoints.slice(0, 3),
1081-
firstFewSeriesPoints: seriesData.slice(0, 3),
1082-
lastFewSeriesPoints: seriesData.slice(-3),
1083-
});
1057+
// Debug: Final series data for chart - xType, processing type, points validation
10841058

10851059
// Configure axes with proper auto-scaling
10861060
const xAxis: EChartOption.XAxis = {
@@ -1148,15 +1122,7 @@ export class TimeSeriesChart {
11481122
axisPointer: { type: 'cross' as const, snap },
11491123
};
11501124

1151-
// eslint-disable-next-line no-console
1152-
console.log('Chart configuration debug:', {
1153-
showArea,
1154-
xType,
1155-
yType,
1156-
seriesDataLength: seriesData.length,
1157-
firstPoint: seriesData[0],
1158-
lastPoint: seriesData[seriesData.length - 1],
1159-
});
1125+
// Debug: Chart configuration - area display, axis types, data points
11601126

11611127
this.chart.setOption(
11621128
{
@@ -1349,12 +1315,7 @@ function getCurrentChartConfig(xColumn: string, yColumn: string): TimeSeriesConf
13491315
// Helper to get xType value - default to numeric for all columns
13501316
const xTypeValue = elXType ? (elXType as { value?: string }).value : undefined;
13511317

1352-
// eslint-disable-next-line no-console
1353-
console.log('X-axis type detection:', {
1354-
xColumn,
1355-
xTypeDropdownValue: xTypeValue,
1356-
elXType: elXType?.id,
1357-
});
1318+
// Debug: X-axis type detection logic
13581319

13591320
const xType: 'category' | 'time' | 'value' = (() => {
13601321
// Respect user's explicit choice
@@ -1376,8 +1337,7 @@ function getCurrentChartConfig(xColumn: string, yColumn: string): TimeSeriesConf
13761337
return 'value';
13771338
})();
13781339

1379-
// eslint-disable-next-line no-console
1380-
console.log('X-axis type result:', xType);
1340+
// Debug: X-axis type result
13811341

13821342
// Helper to get yType value
13831343
const yTypeValue = elYType ? (elYType as { value?: string }).value : undefined;
@@ -1465,7 +1425,7 @@ function bindUIControls(chart: TimeSeriesChart): void {
14651425

14661426
if (!selectedLabelValue || selectedLabelValue === '') {
14671427
// No label selected, show error or create default
1468-
console.warn('No active label selected for drawing mode');
1428+
// No active label selected for drawing mode
14691429
// Revert button state
14701430
btnLabelMode.setAttribute('aria-pressed', 'false');
14711431
btnLabelMode.classList.remove('active');
@@ -1496,14 +1456,7 @@ function bindUIControls(chart: TimeSeriesChart): void {
14961456
const xDropdown = document.querySelector('#x-axis');
14971457
const yDropdown = document.querySelector('#y-axis');
14981458

1499-
// eslint-disable-next-line no-console
1500-
console.log('Dropdown element references:', {
1501-
xDropdown: xDropdown?.id,
1502-
yDropdown: yDropdown?.id,
1503-
sameElement: xDropdown === yDropdown,
1504-
xValue: (xDropdown as { value?: string } | null)?.value,
1505-
yValue: (yDropdown as { value?: string } | null)?.value,
1506-
});
1459+
// Debug: Dropdown element references and values
15071460

15081461
const updateChart = () => {
15091462
// Don't update chart if we have no data sources at all
@@ -1525,17 +1478,13 @@ function bindUIControls(chart: TimeSeriesChart): void {
15251478
const xColumn = (xDropdown as { value?: string } | null)?.value || 'index';
15261479
const yColumn = (yDropdown as { value?: string } | null)?.value || 'value';
15271480

1528-
console.log('updateChart called with:', { xColumn, yColumn });
1481+
// updateChart called with debug info available
15291482

15301483
// Only update if we have valid column values
15311484
if (xColumn && yColumn && xColumn !== '' && yColumn !== '') {
15321485
// Get current configuration from all UI controls
15331486
const config = getCurrentChartConfig(xColumn, yColumn);
1534-
console.log('Generated config:', {
1535-
xColumn: config.xColumn,
1536-
yColumn: config.yColumn,
1537-
xType: config.xType,
1538-
});
1487+
// Generated config debug info available
15391488
chart.updateDisplay(config);
15401489
}
15411490
};
@@ -1550,11 +1499,11 @@ function bindUIControls(chart: TimeSeriesChart): void {
15501499
};
15511500

15521501
xDropdown?.addEventListener('change', () => {
1553-
console.log('X dropdown changed to:', (xDropdown as { value?: string } | null)?.value);
1502+
// X dropdown changed - debug info available
15541503
updateChart();
15551504
});
15561505
yDropdown?.addEventListener('change', () => {
1557-
console.log('Y dropdown changed to:', (yDropdown as { value?: string } | null)?.value);
1506+
// Y dropdown changed - debug info available
15581507
updateChart();
15591508
});
15601509

‎src/data/csvProcessor.ts‎

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,8 @@ export class CSVTimeSeriesData implements TimeSeriesData {
188188
);
189189
}
190190
})
191-
.catch((error: unknown) => {
192-
// eslint-disable-next-line no-console
193-
console.error('Failed to import dropdowns module:', error);
191+
.catch((_error: unknown) => {
192+
// Failed to import dropdowns module, falling back to basic label loading
194193
// Fallback: just load labels anyway
195194
void this.loadLabelsFromStorage();
196195
});
@@ -216,9 +215,8 @@ export class CSVTimeSeriesData implements TimeSeriesData {
216215
this.notifyLabelsChangedIfDefinitionsReady();
217216
}
218217
}
219-
} catch (error) {
220-
// eslint-disable-next-line no-console
221-
console.warn('Failed to load labels from storage:', error);
218+
} catch (_error) {
219+
// Failed to load labels from storage, continuing without stored labels
222220
}
223221
}
224222

@@ -240,12 +238,10 @@ export class CSVTimeSeriesData implements TimeSeriesData {
240238
};
241239
const result = await saveTimeSeriesLabel(labelRecord);
242240
if (!result.ok) {
243-
// eslint-disable-next-line no-console
244-
console.warn('Failed to save label to storage:', result.error);
241+
// Failed to save label to storage, continuing without persistence
245242
}
246-
} catch (error) {
247-
// eslint-disable-next-line no-console
248-
console.warn('Error saving label to storage:', error);
243+
} catch (_error) {
244+
// Error saving label to storage, continuing without persistence
249245
}
250246
}
251247

@@ -256,12 +252,10 @@ export class CSVTimeSeriesData implements TimeSeriesData {
256252
try {
257253
const result = await deleteTimeSeriesLabel(labelId);
258254
if (!result.ok) {
259-
// eslint-disable-next-line no-console
260-
console.warn('Failed to remove label from storage:', result.error);
255+
// Failed to remove label from storage, continuing anyway
261256
}
262-
} catch (error) {
263-
// eslint-disable-next-line no-console
264-
console.warn('Error removing label from storage:', error);
257+
} catch (_error) {
258+
// Error removing label from storage, continuing anyway
265259
}
266260
}
267261

@@ -300,9 +294,8 @@ export class CSVTimeSeriesData implements TimeSeriesData {
300294
);
301295
}
302296
})
303-
.catch((error: unknown) => {
304-
// eslint-disable-next-line no-console
305-
console.error('Failed to import dropdowns module:', error);
297+
.catch((_error: unknown) => {
298+
// Failed to import dropdowns module, falling back to basic notification
306299
// Fallback: notify anyway (better than no notification)
307300
this.notifyLabelsChanged();
308301
});

‎src/data/dataService.ts‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ export class DataService implements IDataService {
170170
/**
171171
* Add new data sources from uploaded files
172172
*/
173-
addDataSource(files: TDataFile[]): Result<readonly TimeSeriesData[], DataValidationError> {
173+
async addDataSource(
174+
files: TDataFile[]
175+
): Promise<Result<readonly TimeSeriesData[], DataValidationError>> {
174176
try {
175177
// Convert files to time series data
176178
const newDataSources = convertDataFilesToTimeSeries(files);
@@ -186,7 +188,7 @@ export class DataService implements IDataService {
186188
});
187189
this.emit('dataSourcesChanged', updatedSources);
188190

189-
return ok(updatedSources);
191+
return await Promise.resolve(ok(updatedSources));
190192
} catch (error) {
191193
return err(new DataValidationError('Failed to add data sources', error));
192194
}
@@ -195,7 +197,7 @@ export class DataService implements IDataService {
195197
/**
196198
* Remove a data source by ID
197199
*/
198-
removeDataSource(id: string): Result<void, DataValidationError> {
200+
async removeDataSource(id: string): Promise<Result<void, DataValidationError>> {
199201
try {
200202
// Remove from cache
201203
this.dataSourcesCache = this.dataSourcesCache.filter((source) => {
@@ -211,7 +213,7 @@ export class DataService implements IDataService {
211213
this.emit('dataSourceRemoved', id);
212214
this.emit('dataSourcesChanged', this.dataSourcesCache);
213215

214-
return ok(undefined);
216+
return await Promise.resolve(ok(undefined));
215217
} catch (error) {
216218
return err(new DataValidationError('Failed to remove data source', error));
217219
}
@@ -220,10 +222,12 @@ export class DataService implements IDataService {
220222
/**
221223
* Get metadata for a specific data source
222224
*/
223-
getDataSourceMetadata(id: string): Result<DataSourceMetadata | null, DataValidationError> {
225+
async getDataSourceMetadata(
226+
id: string
227+
): Promise<Result<DataSourceMetadata | null, DataValidationError>> {
224228
try {
225229
const metadata = this.metadataCache.get(id) || null;
226-
return ok(metadata);
230+
return await Promise.resolve(ok(metadata));
227231
} catch (error) {
228232
return err(new DataValidationError('Failed to get data source metadata', error));
229233
}
@@ -374,7 +378,7 @@ export class DataService implements IDataService {
374378

375379
const listeners = this.eventListeners.get(event);
376380
if (listeners) {
377-
listeners.push(listener);
381+
listeners.push(listener as (data: unknown) => void);
378382
}
379383

380384
// Return unsubscribe function
@@ -392,7 +396,7 @@ export class DataService implements IDataService {
392396
): void {
393397
const listeners = this.eventListeners.get(event);
394398
if (listeners) {
395-
const index = listeners.indexOf(listener);
399+
const index = listeners.indexOf(listener as (data: unknown) => void);
396400
if (index >= 0) {
397401
listeners.splice(index, 1);
398402
}
@@ -407,8 +411,8 @@ export class DataService implements IDataService {
407411
listeners.forEach((listener) => {
408412
try {
409413
listener(data);
410-
} catch (error) {
411-
console.error(`Error in ${event} listener:`, error);
414+
} catch (_error) {
415+
// Silent error handling for event listeners
412416
}
413417
});
414418
}

‎src/main.ts‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ async function initializeApplication(): Promise<void> {
7070
if (sourcesResult.ok) {
7171
timeSeriesChart.setDataSources(sourcesResult.value);
7272
} else {
73-
// eslint-disable-next-line no-console
74-
console.error('Failed to load initial data sources:', sourcesResult.error);
73+
// Failed to load initial data sources, continuing with empty chart
7574
}
7675
// Always mark as complete to not block loading
7776
markLoadingStepComplete('data-loaded');
@@ -93,9 +92,8 @@ async function initializeApplication(): Promise<void> {
9392
try {
9493
await loadHistoryEntries();
9594
markLoadingStepComplete('ui-setup');
96-
} catch (error: unknown) {
97-
// eslint-disable-next-line no-console
98-
console.error('Failed to load history entries:', error);
95+
} catch (_error: unknown) {
96+
// Failed to load history entries, continuing without history
9997
markLoadingStepComplete('ui-setup');
10098
}
10199

@@ -118,17 +116,14 @@ async function initializeApplication(): Promise<void> {
118116
).__resetDatabase = async () => {
119117
const result = await resetDatabase();
120118
if (result.ok) {
121-
// eslint-disable-next-line no-console
122-
console.log('Database reset successfully. Please refresh the page.');
119+
// Database reset successfully, refresh page manually
123120
} else {
124-
// eslint-disable-next-line no-console
125-
console.error('Failed to reset database:', result.error);
121+
// Failed to reset database, check browser console for details
126122
}
127123
};
128124
}
129-
} catch (error: unknown) {
130-
// eslint-disable-next-line no-console
131-
console.error('Failed to initialize application:', error);
125+
} catch (_error: unknown) {
126+
// Failed to initialize application, forcing loading completion to prevent stuck state
132127
// Force complete loading even on error to not leave user stuck
133128
const { forceCompleteLoading } = await import('./ui/loadingScreen');
134129
forceCompleteLoading();

‎src/platform/storage.ts‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ export async function saveRecord(
115115
if (!db.objectStoreNames.contains(storeName)) {
116116
const availableStores = Array.from(db.objectStoreNames).join(', ');
117117
const errorMsg = `Object store '${storeName}' not found. Available stores: ${availableStores}. Database version: ${String(db.version)}`;
118-
console.error('Storage Error:', errorMsg);
119118
return err(new StorageError(errorMsg));
120119
}
121120

@@ -169,7 +168,7 @@ export async function resetDatabase(): Promise<Result<void, StorageError>> {
169168
const deleteReq = indexedDB.deleteDatabase(DB_NAME);
170169
await new Promise<void>((resolve, reject) => {
171170
deleteReq.onsuccess = () => {
172-
console.log('Database deleted successfully');
171+
// Database deleted successfully
173172
resolve();
174173
};
175174
deleteReq.onerror = () => {
@@ -179,7 +178,7 @@ export async function resetDatabase(): Promise<Result<void, StorageError>> {
179178

180179
// Reopen to trigger creation with current schema
181180
await openDatabase();
182-
console.log('Database reset and recreated successfully');
181+
// Database reset and recreated successfully
183182
return ok(undefined);
184183
} catch (error) {
185184
return err(new StorageError('Failed to reset database', error));

0 commit comments

Comments
 (0)