-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
245 lines (235 loc) · 20.1 KB
/
Copy pathindex.html
File metadata and controls
245 lines (235 loc) · 20.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<!DOCTYPE html>
<html lang="en" class="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Universal CSV Interactive Dashboard</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%233b82f6'><path d='M9 17v-2m3 2v-4m3 4v-6m2 10H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z'/></svg>">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/papaparse@5.4.1/papaparse.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.1/dist/chart.umd.min.js"></script>
<link rel="stylesheet" href="css/styles.css">
</head>
<body class="bg-gray-900 min-h-screen" style="background-image: radial-gradient(ellipse at 50% 0%, rgba(59, 130, 246, 0.06) 0%, transparent 60%);">
<div id="app" class="flex flex-col min-h-screen">
<!-- Header -->
<header class="bg-gray-800/80 backdrop-blur-md border-b border-gray-700/50 sticky top-0 z-40">
<div class="max-w-full mx-auto px-4 sm:px-6 py-3 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">
<div class="flex items-center gap-3">
<div class="w-9 h-9 rounded-lg bg-gradient-to-br from-blue-500 to-blue-700 flex items-center justify-center shadow-lg shadow-blue-500/20">
<svg class="w-5 h-5 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 17v-2m3 2v-4m3 4v-6m2 10H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
</svg>
</div>
<h1 class="text-lg font-bold text-white tracking-tight">Universal CSV Dashboard</h1>
</div>
<div class="flex items-center gap-3">
<div id="file-info" class="hidden sm:flex items-center gap-2 text-xs font-medium text-gray-300 px-3 py-1.5 bg-gray-700/50 border border-gray-600/50 rounded-lg">
<span id="file-name"></span>
<span id="file-stats"></span>
</div>
</div>
</div>
</header>
<!-- Main Content -->
<main class="flex-1 overflow-hidden">
<!-- Drop Zone / File Input -->
<section id="drop-zone-section" class="p-4 sm:p-6 lg:p-8">
<div class="max-w-6xl mx-auto">
<div id="drop-zone" class="relative border-2 border-dashed border-gray-600/50 rounded-2xl p-12 sm:p-16 text-center cursor-pointer hover:border-blue-500/50 transition-all duration-300 bg-gray-800/20">
<div class="relative z-10">
<div class="mx-auto w-20 h-20 rounded-2xl bg-gradient-to-br from-blue-500/10 to-blue-600/5 border border-blue-500/10 flex items-center justify-center mb-6">
<svg class="w-10 h-10 text-blue-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"></path>
</svg>
</div>
<p class="text-lg text-gray-300 font-medium">Drag & drop a CSV file here, or click to browse</p>
<p class="mt-2 text-sm text-gray-500">Supports files up to 50,000 rows</p>
<input type="file" id="file-input" accept=".csv" class="hidden" aria-label="Choose CSV file">
</div>
</div>
<div id="loading-indicator" class="hidden fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50">
<div class="bg-gray-800 border border-gray-700/50 rounded-2xl p-8 text-center max-w-md mx-4 shadow-2xl shadow-black/30">
<div class="relative w-14 h-14 mx-auto mb-5">
<div class="absolute inset-0 rounded-full border-4 border-blue-500/20"></div>
<div class="absolute inset-0 rounded-full border-4 border-t-blue-500 animate-spin"></div>
</div>
<p id="loading-text" class="text-gray-200 font-medium">Parsing CSV...</p>
<p id="loading-progress" class="text-sm text-gray-400 mt-2"></p>
</div>
</div>
</div>
</section>
<!-- Dashboard Content (hidden until file loaded) -->
<section id="dashboard-section" class="hidden p-4 sm:p-6 lg:p-8">
<div class="max-w-6xl mx-auto">
<!-- KPI Cards Row -->
<div id="kpi-row" class="grid grid-cols-1 sm:grid-cols-2 gap-4 mb-6 animate-fade-in"></div>
<!-- Data Summary Card -->
<div id="data-summary" class="hidden bg-gray-800/60 border border-gray-700/50 rounded-2xl shadow-lg shadow-black/10 p-5 mb-6 backdrop-blur-sm">
<div class="flex items-center justify-between mb-4">
<h3 class="font-semibold text-gray-100">Data Summary</h3>
<button id="toggle-summary" class="text-sm font-medium text-blue-400 hover:text-blue-300 transition-colors">Show details</button>
</div>
<div id="summary-stats" class="flex flex-wrap gap-5 text-sm text-gray-400 mb-3">
<span class="flex items-center gap-1.5"><span class="inline-block w-2 h-2 rounded-full bg-blue-500"></span><strong class="text-gray-300">Rows:</strong> <span id="summary-rows">0</span></span>
<span class="flex items-center gap-1.5"><span class="inline-block w-2 h-2 rounded-full bg-purple-500"></span><strong class="text-gray-300">Columns:</strong> <span id="summary-columns">0</span></span>
</div>
<div id="summary-details" class="hidden overflow-x-auto">
<table class="w-full text-sm">
<thead>
<tr class="border-b border-gray-700/50">
<th class="text-left py-2.5 px-3 text-gray-500 font-medium text-xs uppercase tracking-wider">Column</th>
<th class="text-left py-2.5 px-3 text-gray-500 font-medium text-xs uppercase tracking-wider">Type</th>
<th class="text-right py-2.5 px-3 text-gray-500 font-medium text-xs uppercase tracking-wider">Empty/Null</th>
<th class="text-right py-2.5 px-3 text-gray-500 font-medium text-xs uppercase tracking-wider">Unique</th>
</tr>
</thead>
<tbody id="summary-body"></tbody>
</table>
</div>
</div>
<!-- Main Content Grid -->
<div class="grid grid-cols-1 lg:grid-cols-12 gap-4 lg:gap-6">
<!-- Sidebar: Filters -->
<aside id="filters-sidebar" class="lg:col-span-3 space-y-4">
<!-- Global Search -->
<div class="bg-gray-800/60 border border-gray-700/50 rounded-2xl shadow-lg shadow-black/10 p-4 backdrop-blur-sm">
<h3 class="font-semibold text-gray-100 mb-3 text-sm uppercase tracking-wider">Global Search</h3>
<div class="relative">
<svg class="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path>
</svg>
<input type="text" id="global-search" placeholder="Search all columns..." class="w-full pl-9 pr-4 py-2 border border-gray-600/50 rounded-xl bg-gray-900/50 text-gray-200 placeholder-gray-500 focus:ring-2 focus:ring-blue-500/50 focus:border-blue-500/50 text-sm transition-all duration-200">
</div>
</div>
<!-- Column Filters -->
<div id="column-filters" class="bg-gray-800/60 border border-gray-700/50 rounded-2xl shadow-lg shadow-black/10 p-4 max-h-[60vh] overflow-y-auto backdrop-blur-sm">
<h3 class="font-semibold text-gray-100 mb-3 text-sm uppercase tracking-wider">Column Filters</h3>
<div id="filters-container" class="space-y-3"></div>
</div>
<!-- Active Filters Summary -->
<div id="active-filters-summary" class="hidden bg-gray-800/60 border border-gray-700/50 rounded-2xl shadow-lg shadow-black/10 p-4 backdrop-blur-sm">
<div class="flex items-center justify-between mb-3">
<h3 class="font-semibold text-gray-100 text-sm uppercase tracking-wider">Active Filters</h3>
<button id="clear-all-filters" class="text-xs font-medium text-blue-400 hover:text-blue-300 transition-colors">Clear All</button>
</div>
<div id="active-filters-tags" class="flex flex-wrap gap-2"></div>
</div>
</aside>
<!-- Main Content Area -->
<div class="lg:col-span-9 space-y-4 lg:space-y-6">
<!-- Chart Section -->
<div id="chart-section" class="bg-gray-800/60 border border-gray-700/50 rounded-2xl shadow-lg shadow-black/10 backdrop-blur-sm">
<div class="p-4 lg:p-5 border-b border-gray-700/50 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">
<h2 class="font-semibold text-gray-100">Visualization</h2>
<div class="flex flex-wrap items-center gap-2 lg:gap-3">
<div class="flex items-center gap-1.5">
<label class="text-xs text-gray-400 font-medium">Chart:</label>
<select id="chart-type" class="px-2.5 py-1.5 border border-gray-600/50 rounded-lg bg-gray-900/50 text-gray-200 focus:ring-2 focus:ring-blue-500/50 focus:border-blue-500/50 text-xs transition-all duration-200">
<option value="bar">Vertical Bar</option>
<option value="line">Line</option>
<option value="scatter">Scatter Plot</option>
<option value="doughnut">Pie/Donut</option>
</select>
</div>
<div class="flex items-center gap-1.5">
<label class="text-xs text-gray-400 font-medium">X:</label>
<select id="chart-x-axis" class="px-2.5 py-1.5 border border-gray-600/50 rounded-lg bg-gray-900/50 text-gray-200 focus:ring-2 focus:ring-blue-500/50 focus:border-blue-500/50 text-xs transition-all duration-200"></select>
</div>
<div class="flex items-center gap-1.5">
<label class="text-xs text-gray-400 font-medium">Y:</label>
<select id="chart-y-axis" class="px-2.5 py-1.5 border border-gray-600/50 rounded-lg bg-gray-900/50 text-gray-200 focus:ring-2 focus:ring-blue-500/50 focus:border-blue-500/50 text-xs transition-all duration-200"></select>
</div>
<div class="flex items-center gap-1.5">
<label class="text-xs text-gray-400 font-medium">Group:</label>
<select id="chart-group-by" class="px-2.5 py-1.5 border border-gray-600/50 rounded-lg bg-gray-900/50 text-gray-200 focus:ring-2 focus:ring-blue-500/50 focus:border-blue-500/50 text-xs transition-all duration-200">
<option value="">None</option>
</select>
</div>
<button id="export-chart" class="px-3 py-1.5 bg-gradient-to-r from-blue-600 to-blue-500 hover:from-blue-500 hover:to-blue-400 text-white text-xs font-medium rounded-lg transition-all duration-200 shadow-lg shadow-blue-500/20 hover:shadow-blue-500/30 flex items-center gap-1.5">
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"></path>
</svg>
Export
</button>
</div>
</div>
<div class="p-4 lg:p-5 h-80 lg:h-96">
<canvas id="main-chart"></canvas>
</div>
</div>
<!-- Data Table Section -->
<div id="table-section" class="bg-gray-800/60 border border-gray-700/50 rounded-2xl shadow-lg shadow-black/10 backdrop-blur-sm">
<div class="p-4 lg:p-5 border-b border-gray-700/50 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">
<h2 class="font-semibold text-gray-100">Data Table</h2>
<div class="flex flex-wrap items-center gap-2 lg:gap-3">
<div class="flex items-center gap-1.5">
<label class="text-xs text-gray-400 font-medium">Rows:</label>
<select id="rows-per-page" class="px-2.5 py-1.5 border border-gray-600/50 rounded-lg bg-gray-900/50 text-gray-200 focus:ring-2 focus:ring-blue-500/50 focus:border-blue-500/50 text-xs transition-all duration-200">
<option value="10">10</option>
<option value="25" selected>25</option>
<option value="50">50</option>
<option value="100">100</option>
</select>
</div>
<button id="column-visibility-btn" class="px-3 py-1.5 border border-gray-600/50 rounded-lg bg-gray-900/50 text-gray-300 text-xs font-medium hover:bg-gray-700/50 transition-all duration-200 flex items-center gap-1.5">
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"></path>
</svg>
Visibility
</button>
<button id="export-data" class="px-3 py-1.5 bg-gradient-to-r from-emerald-600 to-emerald-500 hover:from-emerald-500 hover:to-emerald-400 text-white text-xs font-medium rounded-lg transition-all duration-200 shadow-lg shadow-emerald-500/20 hover:shadow-emerald-500/30 flex items-center gap-1.5">
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"></path>
</svg>
Export CSV
</button>
</div>
</div>
<div class="p-0 overflow-x-auto">
<table id="data-table" class="w-full text-sm"></table>
</div>
<div class="p-4 lg:p-5 border-t border-gray-700/50 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">
<div id="table-info" class="text-sm text-gray-400"></div>
<div id="pagination" class="flex items-center gap-1.5"></div>
</div>
</div>
</div>
</div>
</div>
</section>
</main>
<!-- Column Visibility Modal -->
<div id="column-visibility-modal" class="hidden fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4">
<div class="bg-gray-800 border border-gray-700/50 rounded-2xl shadow-2xl shadow-black/30 max-w-md w-full max-h-[80vh] overflow-y-auto">
<div class="p-5 border-b border-gray-700/50 flex items-center justify-between">
<h3 class="font-semibold text-gray-100">Column Visibility</h3>
<button id="close-column-modal" class="text-gray-400 hover:text-gray-200 transition-colors p-1 rounded-lg hover:bg-gray-700/50">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
</svg>
</button>
</div>
<div class="p-5">
<div id="column-visibility-list" class="space-y-2"></div>
</div>
<div class="p-5 border-t border-gray-700/50 flex justify-end gap-3">
<button id="column-modal-cancel" class="px-4 py-2 border border-gray-600/50 rounded-xl text-gray-300 text-sm font-medium hover:bg-gray-700/50 transition-all duration-200">Cancel</button>
<button id="column-modal-apply" class="px-5 py-2 bg-gradient-to-r from-blue-600 to-blue-500 hover:from-blue-500 hover:to-blue-400 text-white text-sm font-medium rounded-xl transition-all duration-200 shadow-lg shadow-blue-500/20">Apply</button>
</div>
</div>
</div>
</div>
<script src="js/utils.js"></script>
<script src="js/csv-parser.js"></script>
<script src="js/state.js"></script>
<script src="js/kpi-cards.js"></script>
<script src="js/data-summary.js"></script>
<script src="js/chart-engine.js"></script>
<script src="js/data-table.js"></script>
<script src="js/filters.js"></script>
<script src="js/main.js"></script>
</body>
</html>