Spaces:
Runtime error
Runtime error
Refactor UI to theme variables + add Settings
Browse filesReplace many hard-coded colors/styles with CSS custom properties and restyle the app for a cohesive theme (App.jsx, index.css, CollectionsPage, HistoryPage, MediaHubPage, ProfilePage). Add new SettingsPage component and wire it into the main app navigation. Improve activity bar icons, header/footers, OTP modal, right-sidebar styling, buttons, and chat input layout. Add a Getting Started section to frontend README and include a Supabase implementation plan file.
Co-Authored-By: Amit Chakradeo <9371+amit@users.noreply.github.com>
- frontend-react/README.md +15 -0
- frontend-react/src/App.jsx +112 -87
- frontend-react/src/components/CollectionsPage.jsx +20 -20
- frontend-react/src/components/HistoryPage.jsx +55 -55
- frontend-react/src/components/MediaHubPage.jsx +54 -54
- frontend-react/src/components/ProfilePage.jsx +39 -39
- frontend-react/src/components/SettingsPage.jsx +77 -0
- frontend-react/src/index.css +21 -3
- supbase implementation implementation_plan +65 -0
frontend-react/README.md
CHANGED
|
@@ -7,6 +7,21 @@ Currently, two official plugins are available:
|
|
| 7 |
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
|
| 8 |
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
## React Compiler
|
| 11 |
|
| 12 |
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
|
|
|
| 7 |
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
|
| 8 |
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
|
| 9 |
|
| 10 |
+
## Getting Started
|
| 11 |
+
|
| 12 |
+
To get the project running locally, follow these steps:
|
| 13 |
+
|
| 14 |
+
1. **Install Dependencies**:
|
| 15 |
+
```bash
|
| 16 |
+
npm install
|
| 17 |
+
```
|
| 18 |
+
*Note: If you encounter dependency conflicts, use `npm install --legacy-peer-deps`.*
|
| 19 |
+
|
| 20 |
+
2. **Run the Development Server**:
|
| 21 |
+
```bash
|
| 22 |
+
npm run dev
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
## React Compiler
|
| 26 |
|
| 27 |
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
frontend-react/src/App.jsx
CHANGED
|
@@ -1,10 +1,16 @@
|
|
| 1 |
import React, { useState, useRef } from 'react';
|
| 2 |
-
import {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
import { AppProvider, useAppContext } from './components/AppContext';
|
| 4 |
import CollectionsPage from './components/CollectionsPage';
|
| 5 |
import ProfilePage from './components/ProfilePage';
|
| 6 |
import HistoryPage from './components/HistoryPage';
|
| 7 |
import MediaHubPage from './components/MediaHubPage';
|
|
|
|
| 8 |
import { SpecService, SessionService, PlanService, CredentialService, AssetService } from './services/api';
|
| 9 |
|
| 10 |
function MainApp() {
|
|
@@ -202,81 +208,93 @@ function MainApp() {
|
|
| 202 |
};
|
| 203 |
|
| 204 |
return (
|
| 205 |
-
<div className="flex h-screen w-full bg-[
|
| 206 |
|
| 207 |
{/* 1. LEFT SIDEBAR (Activity Bar) */}
|
| 208 |
-
<div className="flex flex-shrink-0 border-r border-[
|
| 209 |
{/* Activity Bar */}
|
| 210 |
-
<div className="w-12 bg-[
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
<button
|
| 212 |
onClick={() => setActivePage('collections')}
|
| 213 |
-
className={`p-2 rounded-lg transition-colors duration-200 ${activePage === 'collections' ? 'text-
|
| 214 |
title="Collections / Specs"
|
| 215 |
>
|
| 216 |
-
<
|
| 217 |
</button>
|
| 218 |
|
| 219 |
<button
|
| 220 |
onClick={() => setActivePage('testing')}
|
| 221 |
-
className={`p-2 rounded-lg transition-colors duration-200 ${activePage === 'testing' ? 'text-
|
| 222 |
title="Execution Workflow"
|
| 223 |
>
|
| 224 |
-
<
|
| 225 |
</button>
|
| 226 |
|
| 227 |
<button
|
| 228 |
onClick={() => setActivePage('profile')}
|
| 229 |
-
className={`p-2 rounded-lg transition-colors duration-200 ${activePage === 'profile' ? 'text-
|
| 230 |
title="Test User Profile"
|
| 231 |
>
|
| 232 |
-
<
|
| 233 |
</button>
|
| 234 |
|
| 235 |
<button
|
| 236 |
onClick={() => setActivePage('history')}
|
| 237 |
-
className={`p-2 rounded-lg transition-colors duration-200 ${activePage === 'history' ? 'text-
|
| 238 |
title="Execution History"
|
| 239 |
>
|
| 240 |
-
<History size={
|
| 241 |
</button>
|
| 242 |
|
| 243 |
<button
|
| 244 |
onClick={() => setActivePage('media')}
|
| 245 |
-
className={`p-2 rounded-lg transition-colors duration-200 ${activePage === 'media' ? 'text-
|
| 246 |
title="Media Hub (Docs/Audio/Video)"
|
| 247 |
>
|
| 248 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
</button>
|
| 250 |
</div>
|
| 251 |
</div>
|
| 252 |
|
| 253 |
-
<div className="flex-1 flex flex-col bg-[
|
| 254 |
|
| 255 |
{activePage === 'testing' && (
|
| 256 |
<div className="flex-1 flex flex-col overflow-hidden animate-in fade-in duration-300">
|
| 257 |
{/* Header / Tabs */}
|
| 258 |
-
<div className="h-10 flex items-center justify-between border-b border-[
|
| 259 |
-
<div className="flex items-center space-x-2 italic text-sm text-
|
| 260 |
-
<LayoutTemplate size={14} className="text-[
|
| 261 |
<span>{activeSpecName !== 'None' ? activeSpecName : 'workflow.plan'}</span>
|
| 262 |
{planTokenUsage && (
|
| 263 |
-
<span className="ml-4 text-[10px] text-
|
| 264 |
-
LLM Plan: <span className="text-[
|
| 265 |
</span>
|
| 266 |
)}
|
| 267 |
{totalScenarioTokens.total > 0 && (
|
| 268 |
-
<span className="ml-2 text-[10px] text-
|
| 269 |
-
Scenario Total: <span className="text-emerald-
|
| 270 |
</span>
|
| 271 |
)}
|
| 272 |
</div>
|
| 273 |
{/* Base URL Input in Header */}
|
| 274 |
{activeSpecId && (
|
| 275 |
<div className="flex items-center space-x-2 text-xs">
|
| 276 |
-
<span className="text-
|
| 277 |
<input
|
| 278 |
type="text"
|
| 279 |
-
className="bg-[
|
| 280 |
value={activeBaseUrl || ""}
|
| 281 |
onChange={(e) => setActiveBaseUrl(e.target.value)}
|
| 282 |
onBlur={async () => {
|
|
@@ -296,9 +314,9 @@ function MainApp() {
|
|
| 296 |
<div className="max-w-4xl mx-auto space-y-4">
|
| 297 |
{!executionPlan ? (
|
| 298 |
<div className="flex flex-col items-center justify-center py-20 text-center opacity-70">
|
| 299 |
-
<Zap size={64} className="text-[
|
| 300 |
-
<h1 className="text-2xl font-light text-
|
| 301 |
-
<p className="mt-2 text-
|
| 302 |
{activeSpecId ? "Specify a test scenario below to generate an API execution workflow." : "Load a collection from the sidebar to begin."}
|
| 303 |
</p>
|
| 304 |
</div>
|
|
@@ -308,86 +326,86 @@ function MainApp() {
|
|
| 308 |
const isRunning = executingStep === step.step;
|
| 309 |
const res = stepResults[step.step];
|
| 310 |
return (
|
| 311 |
-
|
| 312 |
-
<div className="p-4 flex items-center justify-between bg-[
|
| 313 |
<div>
|
| 314 |
<div className="flex items-center space-x-2">
|
| 315 |
-
<span className="bg-[
|
| 316 |
-
<span className="text-sm font-medium text-
|
| 317 |
</div>
|
| 318 |
-
<p className="text-xs text-
|
| 319 |
</div>
|
| 320 |
<button
|
| 321 |
onClick={() => executeStep(step)}
|
| 322 |
disabled={isRunning}
|
| 323 |
-
className="bg-[
|
| 324 |
>
|
| 325 |
{isRunning ? <RefreshCw size={14} className="animate-spin" /> : <Zap size={14} />}
|
| 326 |
<span>{isRunning ? 'Executing...' : 'Execute'}</span>
|
| 327 |
</button>
|
| 328 |
</div>
|
| 329 |
|
| 330 |
-
|
| 331 |
{res && (
|
| 332 |
-
<div className="p-4 space-y-4 bg-[
|
| 333 |
{/* Analysis */}
|
| 334 |
-
<div className={`p-3 text-
|
| 335 |
<div className="flex items-center justify-between mb-1">
|
| 336 |
<div className="font-semibold">AI Analysis</div>
|
| 337 |
{res.token_usage && (
|
| 338 |
-
<div className="text-[10px] text-
|
| 339 |
{res.token_usage.total_tokens} tokens (P:{res.token_usage.prompt_tokens} / C:{res.token_usage.completion_tokens})
|
| 340 |
</div>
|
| 341 |
)}
|
| 342 |
</div>
|
| 343 |
-
<div className="text-
|
| 344 |
{res.analysis.extracted_variables && Object.keys(res.analysis.extracted_variables).length > 0 && (
|
| 345 |
-
<div className="mt-2 text-[
|
| 346 |
)}
|
| 347 |
</div>
|
| 348 |
|
| 349 |
<div className="grid grid-cols-2 gap-4">
|
| 350 |
{/* Request Container */}
|
| 351 |
<div className="space-y-2">
|
| 352 |
-
<div className="text-
|
| 353 |
-
<div className="bg-[
|
| 354 |
-
<div className="text-[
|
| 355 |
|
| 356 |
{res.request.headers && Object.keys(res.request.headers).length > 0 && (
|
| 357 |
<div className="space-y-1">
|
| 358 |
-
<div className="text-[10px] text-
|
| 359 |
{Object.entries(res.request.headers).map(([k,v]) => (
|
| 360 |
-
<div key={k} className="text-[
|
| 361 |
))}
|
| 362 |
</div>
|
| 363 |
)}
|
| 364 |
|
| 365 |
{res.request.query_params && Object.keys(res.request.query_params).length > 0 && (
|
| 366 |
<div className="space-y-1">
|
| 367 |
-
<div className="text-[10px] text-
|
| 368 |
{Object.entries(res.request.query_params).map(([k,v]) => (
|
| 369 |
-
<div key={k} className="text-[
|
| 370 |
))}
|
| 371 |
</div>
|
| 372 |
)}
|
| 373 |
|
| 374 |
{res.request.body && <div className="space-y-1">
|
| 375 |
-
<div className="text-[10px] text-
|
| 376 |
-
<pre className="text-[
|
| 377 |
</div>}
|
| 378 |
|
| 379 |
{res.request.form_data && Object.keys(res.request.form_data).length > 0 && (
|
| 380 |
<div className="space-y-1">
|
| 381 |
-
<div className="text-[10px] text-
|
| 382 |
-
<pre className="text-[
|
| 383 |
</div>
|
| 384 |
)}
|
| 385 |
|
| 386 |
{res.request.files && Object.keys(res.request.files).length > 0 && (
|
| 387 |
<div className="space-y-1">
|
| 388 |
-
<div className="text-[10px] text-
|
| 389 |
{Object.entries(res.request.files).map(([k,v]) => (
|
| 390 |
-
<div key={k} className="text-[
|
| 391 |
))}
|
| 392 |
</div>
|
| 393 |
)}
|
|
@@ -395,9 +413,9 @@ function MainApp() {
|
|
| 395 |
</div>
|
| 396 |
{/* Response Container */}
|
| 397 |
<div className="space-y-2">
|
| 398 |
-
<div className="text-
|
| 399 |
-
<div className="bg-[
|
| 400 |
-
<pre className="text-[
|
| 401 |
{(() => {
|
| 402 |
try { return JSON.stringify(JSON.parse(res.response.body), null, 2); }
|
| 403 |
catch { return res.response.body; }
|
|
@@ -417,30 +435,30 @@ function MainApp() {
|
|
| 417 |
{/* OTP PROMPT MODAL/OVERLAY */}
|
| 418 |
{otpPrompt && (
|
| 419 |
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4">
|
| 420 |
-
<div className="bg-[
|
| 421 |
-
<div className="p-4 border-b border-[
|
| 422 |
-
<h3 className="text-sm font-semibold text-
|
| 423 |
-
<Zap size={16} className="text-[
|
| 424 |
<span>OTP Required</span>
|
| 425 |
</h3>
|
| 426 |
-
<button onClick={() => setOtpPrompt(null)} className="text-
|
| 427 |
<Trash2 size={16} />
|
| 428 |
</button>
|
| 429 |
</div>
|
| 430 |
<div className="p-6 space-y-4">
|
| 431 |
-
<p className="text-xs text-
|
| 432 |
The API response indicates that an OTP or verification code is required.
|
| 433 |
Please enter it below to save it to your session context.
|
| 434 |
</p>
|
| 435 |
<div className="space-y-2">
|
| 436 |
-
<label className="text-[10px] text-
|
| 437 |
-
Field Name: <span className="text-[
|
| 438 |
</label>
|
| 439 |
<input
|
| 440 |
type="text"
|
| 441 |
autoFocus
|
| 442 |
placeholder="Enter Code..."
|
| 443 |
-
className="w-full bg-[
|
| 444 |
value={otpInput}
|
| 445 |
onChange={e => setOtpInput(e.target.value)}
|
| 446 |
onKeyDown={e => { if (e.key === 'Enter') handleOtpSubmit(); }}
|
|
@@ -449,13 +467,13 @@ function MainApp() {
|
|
| 449 |
<div className="flex space-x-2 pt-2">
|
| 450 |
<button
|
| 451 |
onClick={handleOtpSubmit}
|
| 452 |
-
className="flex-1 bg-[
|
| 453 |
>
|
| 454 |
Save & Continue
|
| 455 |
</button>
|
| 456 |
<button
|
| 457 |
onClick={() => setOtpPrompt(null)}
|
| 458 |
-
className="px-4 border border-[
|
| 459 |
>
|
| 460 |
Cancel
|
| 461 |
</button>
|
|
@@ -468,10 +486,13 @@ function MainApp() {
|
|
| 468 |
</div>
|
| 469 |
|
| 470 |
{/* Bottom Chat Input */}
|
| 471 |
-
<div className="p-
|
| 472 |
-
<div className="max-w-
|
|
|
|
|
|
|
|
|
|
| 473 |
<textarea
|
| 474 |
-
placeholder={activeSpecId ? "Describe
|
| 475 |
disabled={!activeSpecId || isPlanning}
|
| 476 |
value={scenario}
|
| 477 |
onChange={e => setScenario(e.target.value)}
|
|
@@ -481,17 +502,20 @@ function MainApp() {
|
|
| 481 |
handleGeneratePlan();
|
| 482 |
}
|
| 483 |
}}
|
| 484 |
-
className="w-full bg-transparent text-
|
| 485 |
-
style={{ height: '44px' }}
|
| 486 |
/>
|
| 487 |
<button
|
| 488 |
onClick={handleGeneratePlan}
|
| 489 |
disabled={!activeSpecId || isPlanning || !scenario.trim()}
|
| 490 |
-
className="p-
|
| 491 |
>
|
| 492 |
-
{isPlanning ? <RefreshCw className="animate-spin" size={
|
| 493 |
</button>
|
| 494 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 495 |
</div>
|
| 496 |
</div>
|
| 497 |
)}
|
|
@@ -500,15 +524,16 @@ function MainApp() {
|
|
| 500 |
{activePage === 'profile' && <ProfilePage />}
|
| 501 |
{activePage === 'history' && <HistoryPage />}
|
| 502 |
{activePage === 'media' && <MediaHubPage />}
|
|
|
|
| 503 |
</div>
|
| 504 |
|
| 505 |
{/* 3. RIGHT SIDEBAR (Context Variables) */}
|
| 506 |
-
<div className={`flex flex-shrink-0 bg-[
|
| 507 |
{/* Toggle Button (when closed, we might want it lingering on the UI or just controlled via header - we will put a small hovering toggle) */}
|
| 508 |
<div className="w-full h-full flex flex-col overflow-hidden whitespace-nowrap">
|
| 509 |
-
<div className="h-10 flex items-center justify-between px-4 shrink-0 border-b border-[
|
| 510 |
-
<span className="font-semibold text-xs tracking-wider text-
|
| 511 |
-
<button onClick={() => setRightPanelOpen(false)} className="text-
|
| 512 |
<ChevronRight size={16} />
|
| 513 |
</button>
|
| 514 |
</div>
|
|
@@ -517,15 +542,15 @@ function MainApp() {
|
|
| 517 |
{/* Session Context */}
|
| 518 |
<div>
|
| 519 |
<div className="flex items-center justify-between mb-2">
|
| 520 |
-
<h3 className="text-xs uppercase text-
|
| 521 |
-
<button onClick={() => refreshSessionContext()} className="text-
|
| 522 |
</div>
|
| 523 |
-
<div className="bg-[
|
| 524 |
{Object.keys(sessionContextVars || {}).length === 0 ? (
|
| 525 |
-
<span className="text-
|
| 526 |
) : (
|
| 527 |
Object.entries(sessionContextVars).map(([k,v]) => (
|
| 528 |
-
<div key={k} className="flex"><span className="text-[
|
| 529 |
))
|
| 530 |
)}
|
| 531 |
</div>
|
|
@@ -533,16 +558,16 @@ function MainApp() {
|
|
| 533 |
|
| 534 |
{/* Test User Credentials */}
|
| 535 |
<div>
|
| 536 |
-
<h3 className="text-xs uppercase text-
|
| 537 |
-
<div className="bg-[
|
| 538 |
{Object.keys(storedCredentials || {}).length === 0 ? (
|
| 539 |
-
<span className="text-
|
| 540 |
) : (
|
| 541 |
Object.entries(storedCredentials).filter(([k]) => k !== '_clear').map(([k,v]) => {
|
| 542 |
const isSensitive = k.toLowerCase().match(/(password|token|jwt|secret|bearer)/);
|
| 543 |
const displayVal = isSensitive && v ? String(v).slice(0,4) + '****' + String(v).slice(-2) : String(v);
|
| 544 |
return (
|
| 545 |
-
<div key={k} className="flex"><span className="text-[
|
| 546 |
)
|
| 547 |
})
|
| 548 |
)}
|
|
@@ -556,7 +581,7 @@ function MainApp() {
|
|
| 556 |
{!rightPanelOpen && (
|
| 557 |
<button
|
| 558 |
onClick={() => setRightPanelOpen(true)}
|
| 559 |
-
className="absolute right-0 top-1/2 transform -translate-y-1/2 p-1 bg-[
|
| 560 |
>
|
| 561 |
<ChevronLeft size={20} />
|
| 562 |
</button>
|
|
|
|
| 1 |
import React, { useState, useRef } from 'react';
|
| 2 |
+
import {
|
| 3 |
+
MessageSquare, LayoutTemplate, Settings, Database, History,
|
| 4 |
+
ChevronRight, ChevronLeft, Send, Zap, Trash2, RefreshCw,
|
| 5 |
+
Upload, Image, FileText, Music, Video, Filter,
|
| 6 |
+
User, Layers, FolderOpen, Globe, X
|
| 7 |
+
} from 'lucide-react';
|
| 8 |
import { AppProvider, useAppContext } from './components/AppContext';
|
| 9 |
import CollectionsPage from './components/CollectionsPage';
|
| 10 |
import ProfilePage from './components/ProfilePage';
|
| 11 |
import HistoryPage from './components/HistoryPage';
|
| 12 |
import MediaHubPage from './components/MediaHubPage';
|
| 13 |
+
import SettingsPage from './components/SettingsPage';
|
| 14 |
import { SpecService, SessionService, PlanService, CredentialService, AssetService } from './services/api';
|
| 15 |
|
| 16 |
function MainApp() {
|
|
|
|
| 208 |
};
|
| 209 |
|
| 210 |
return (
|
| 211 |
+
<div className="flex h-screen w-full bg-[var(--bg-primary)] text-[var(--text-secondary)] font-sans selection:bg-[var(--accent-primary)]/30 overflow-hidden">
|
| 212 |
|
| 213 |
{/* 1. LEFT SIDEBAR (Activity Bar) */}
|
| 214 |
+
<div className="flex flex-shrink-0 border-r border-[var(--border-subtle)] h-full">
|
| 215 |
{/* Activity Bar */}
|
| 216 |
+
<div className="w-12 bg-[var(--bg-secondary)] flex flex-col items-center py-4 space-y-6">
|
| 217 |
+
{/* Logo */}
|
| 218 |
+
<div className="mb-2 p-2 rounded-xl bg-[var(--accent-gradient)] shadow-lg shadow-[var(--accent-primary)]/20">
|
| 219 |
+
<Globe size={20} className="text-white" />
|
| 220 |
+
</div>
|
| 221 |
<button
|
| 222 |
onClick={() => setActivePage('collections')}
|
| 223 |
+
className={`p-2 rounded-lg transition-colors duration-200 ${activePage === 'collections' ? 'text-[var(--text-primary)] bg-[var(--accent-primary)]/10' : 'text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]'}`}
|
| 224 |
title="Collections / Specs"
|
| 225 |
>
|
| 226 |
+
<Layers size={22} strokeWidth={1.5} />
|
| 227 |
</button>
|
| 228 |
|
| 229 |
<button
|
| 230 |
onClick={() => setActivePage('testing')}
|
| 231 |
+
className={`p-2 rounded-lg transition-colors duration-200 ${activePage === 'testing' ? 'text-[var(--text-primary)] bg-[var(--accent-primary)]/10' : 'text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]'}`}
|
| 232 |
title="Execution Workflow"
|
| 233 |
>
|
| 234 |
+
<MessageSquare size={22} strokeWidth={1.5} />
|
| 235 |
</button>
|
| 236 |
|
| 237 |
<button
|
| 238 |
onClick={() => setActivePage('profile')}
|
| 239 |
+
className={`p-2 rounded-lg transition-colors duration-200 ${activePage === 'profile' ? 'text-[var(--text-primary)] bg-[var(--accent-primary)]/10' : 'text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]'}`}
|
| 240 |
title="Test User Profile"
|
| 241 |
>
|
| 242 |
+
<User size={22} strokeWidth={1.5} />
|
| 243 |
</button>
|
| 244 |
|
| 245 |
<button
|
| 246 |
onClick={() => setActivePage('history')}
|
| 247 |
+
className={`p-2 rounded-lg transition-colors duration-200 ${activePage === 'history' ? 'text-[var(--text-primary)] bg-[var(--accent-primary)]/10' : 'text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]'}`}
|
| 248 |
title="Execution History"
|
| 249 |
>
|
| 250 |
+
<History size={22} strokeWidth={1.5} />
|
| 251 |
</button>
|
| 252 |
|
| 253 |
<button
|
| 254 |
onClick={() => setActivePage('media')}
|
| 255 |
+
className={`p-2 rounded-lg transition-colors duration-200 ${activePage === 'media' ? 'text-[var(--text-primary)] bg-[var(--accent-primary)]/10' : 'text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]'}`}
|
| 256 |
title="Media Hub (Docs/Audio/Video)"
|
| 257 |
>
|
| 258 |
+
<FolderOpen size={22} strokeWidth={1.5} />
|
| 259 |
+
</button>
|
| 260 |
+
|
| 261 |
+
<button
|
| 262 |
+
onClick={() => setActivePage('settings')}
|
| 263 |
+
className={`p-2 rounded-lg transition-colors duration-200 ${activePage === 'settings' ? 'text-[var(--text-primary)] bg-[var(--accent-primary)]/10' : 'text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]'}`}
|
| 264 |
+
title="System Settings"
|
| 265 |
+
>
|
| 266 |
+
<Settings size={22} strokeWidth={1.5} />
|
| 267 |
</button>
|
| 268 |
</div>
|
| 269 |
</div>
|
| 270 |
|
| 271 |
+
<div className="flex-1 flex flex-col bg-[var(--bg-primary)] min-w-0 min-h-0 relative">
|
| 272 |
|
| 273 |
{activePage === 'testing' && (
|
| 274 |
<div className="flex-1 flex flex-col overflow-hidden animate-in fade-in duration-300">
|
| 275 |
{/* Header / Tabs */}
|
| 276 |
+
<div className="h-10 flex items-center justify-between border-b border-[var(--border-subtle)] bg-[var(--bg-secondary)] px-4">
|
| 277 |
+
<div className="flex items-center space-x-2 italic text-sm text-[var(--text-primary)]">
|
| 278 |
+
<LayoutTemplate size={14} className="text-[var(--accent-primary)]" />
|
| 279 |
<span>{activeSpecName !== 'None' ? activeSpecName : 'workflow.plan'}</span>
|
| 280 |
{planTokenUsage && (
|
| 281 |
+
<span className="ml-4 text-[10px] text-[var(--text-secondary)] font-mono bg-[var(--bg-tertiary)] px-2 py-0.5 rounded border border-[var(--border-subtle)]">
|
| 282 |
+
LLM Plan: <span className="text-[var(--accent-primary)]">{planTokenUsage.total_tokens}</span>
|
| 283 |
</span>
|
| 284 |
)}
|
| 285 |
{totalScenarioTokens.total > 0 && (
|
| 286 |
+
<span className="ml-2 text-[10px] text-[var(--text-secondary)] font-mono bg-[var(--bg-primary)] px-2 py-0.5 rounded border border-emerald-500/30">
|
| 287 |
+
Scenario Total: <span className="text-emerald-500">{totalScenarioTokens.total}</span> tokens
|
| 288 |
</span>
|
| 289 |
)}
|
| 290 |
</div>
|
| 291 |
{/* Base URL Input in Header */}
|
| 292 |
{activeSpecId && (
|
| 293 |
<div className="flex items-center space-x-2 text-xs">
|
| 294 |
+
<span className="text-[var(--text-secondary)] font-mono">BASE_URL:</span>
|
| 295 |
<input
|
| 296 |
type="text"
|
| 297 |
+
className="bg-[var(--bg-tertiary)] border border-[var(--border-subtle)] text-[var(--text-primary)] px-2 py-1 outline-none focus:border-[var(--accent-primary)] w-64 rounded-sm font-mono"
|
| 298 |
value={activeBaseUrl || ""}
|
| 299 |
onChange={(e) => setActiveBaseUrl(e.target.value)}
|
| 300 |
onBlur={async () => {
|
|
|
|
| 314 |
<div className="max-w-4xl mx-auto space-y-4">
|
| 315 |
{!executionPlan ? (
|
| 316 |
<div className="flex flex-col items-center justify-center py-20 text-center opacity-70">
|
| 317 |
+
<Zap size={64} className="text-[var(--accent-primary)] mb-6 opacity-30" />
|
| 318 |
+
<h1 className="text-2xl font-light text-[var(--text-primary)]">AI API Testing Assistant</h1>
|
| 319 |
+
<p className="mt-2 text-[var(--text-secondary)] max-w-lg">
|
| 320 |
{activeSpecId ? "Specify a test scenario below to generate an API execution workflow." : "Load a collection from the sidebar to begin."}
|
| 321 |
</p>
|
| 322 |
</div>
|
|
|
|
| 326 |
const isRunning = executingStep === step.step;
|
| 327 |
const res = stepResults[step.step];
|
| 328 |
return (
|
| 329 |
+
<div key={step.step} className="bg-[var(--bg-secondary)] border border-[var(--border-subtle)] rounded-lg overflow-hidden shadow-sm">
|
| 330 |
+
<div className="p-4 flex items-center justify-between bg-[var(--bg-tertiary)] border-b border-[var(--border-subtle)]">
|
| 331 |
<div>
|
| 332 |
<div className="flex items-center space-x-2">
|
| 333 |
+
<span className="bg-[var(--bg-primary)] text-[var(--text-secondary)] text-xs px-2 py-0.5 rounded font-mono border border-[var(--border-subtle)]">Step {step.step}</span>
|
| 334 |
+
<span className="text-sm font-medium text-[var(--text-primary)]">{step.endpoint}</span>
|
| 335 |
</div>
|
| 336 |
+
<p className="text-xs text-[var(--text-secondary)] mt-1">{step.purpose}</p>
|
| 337 |
</div>
|
| 338 |
<button
|
| 339 |
onClick={() => executeStep(step)}
|
| 340 |
disabled={isRunning}
|
| 341 |
+
className="bg-[var(--accent-gradient)] hover:opacity-90 disabled:opacity-50 text-white px-4 py-1.5 text-xs rounded transition flex items-center space-x-2 shadow-lg"
|
| 342 |
>
|
| 343 |
{isRunning ? <RefreshCw size={14} className="animate-spin" /> : <Zap size={14} />}
|
| 344 |
<span>{isRunning ? 'Executing...' : 'Execute'}</span>
|
| 345 |
</button>
|
| 346 |
</div>
|
| 347 |
|
| 348 |
+
{/* Results Dropdown Area */}
|
| 349 |
{res && (
|
| 350 |
+
<div className="p-4 space-y-4 bg-[var(--bg-primary)] text-xs font-mono">
|
| 351 |
{/* Analysis */}
|
| 352 |
+
<div className={`p-3 text-[var(--text-primary)] border-l-4 ${res.analysis.status === 'success' ? 'border-emerald-500 bg-emerald-500/10' : 'border-red-500 bg-red-500/10'}`}>
|
| 353 |
<div className="flex items-center justify-between mb-1">
|
| 354 |
<div className="font-semibold">AI Analysis</div>
|
| 355 |
{res.token_usage && (
|
| 356 |
+
<div className="text-[10px] text-[var(--text-secondary)] font-mono">
|
| 357 |
{res.token_usage.total_tokens} tokens (P:{res.token_usage.prompt_tokens} / C:{res.token_usage.completion_tokens})
|
| 358 |
</div>
|
| 359 |
)}
|
| 360 |
</div>
|
| 361 |
+
<div className="text-[var(--text-secondary)]">{res.analysis.response_summary || (res.analysis.status === 'success' ? 'Step completed successfully.' : 'Step encountered an error.')}</div>
|
| 362 |
{res.analysis.extracted_variables && Object.keys(res.analysis.extracted_variables).length > 0 && (
|
| 363 |
+
<div className="mt-2 text-[var(--accent-primary)]">Extracted: {JSON.stringify(res.analysis.extracted_variables)}</div>
|
| 364 |
)}
|
| 365 |
</div>
|
| 366 |
|
| 367 |
<div className="grid grid-cols-2 gap-4">
|
| 368 |
{/* Request Container */}
|
| 369 |
<div className="space-y-2">
|
| 370 |
+
<div className="text-[var(--text-secondary)] font-semibold">Request</div>
|
| 371 |
+
<div className="bg-[var(--bg-tertiary)] p-3 rounded text-[var(--text-secondary)] border border-[var(--border-subtle)] overflow-x-auto space-y-3">
|
| 372 |
+
<div className="text-[var(--accent-primary)] font-bold">{res.request.method} <span className="text-[var(--accent-secondary)] font-normal">{res.request.url}</span></div>
|
| 373 |
|
| 374 |
{res.request.headers && Object.keys(res.request.headers).length > 0 && (
|
| 375 |
<div className="space-y-1">
|
| 376 |
+
<div className="text-[10px] text-[var(--text-secondary)] uppercase font-bold">Headers</div>
|
| 377 |
{Object.entries(res.request.headers).map(([k,v]) => (
|
| 378 |
+
<div key={k} className="text-[var(--accent-primary)]"><span className="text-[var(--text-secondary)]">{k}:</span> {v}</div>
|
| 379 |
))}
|
| 380 |
</div>
|
| 381 |
)}
|
| 382 |
|
| 383 |
{res.request.query_params && Object.keys(res.request.query_params).length > 0 && (
|
| 384 |
<div className="space-y-1">
|
| 385 |
+
<div className="text-[10px] text-[var(--text-secondary)] uppercase font-bold">Query Params</div>
|
| 386 |
{Object.entries(res.request.query_params).map(([k,v]) => (
|
| 387 |
+
<div key={k} className="text-[var(--accent-primary)]"><span className="text-[var(--text-secondary)]">{k}=</span>{v}</div>
|
| 388 |
))}
|
| 389 |
</div>
|
| 390 |
)}
|
| 391 |
|
| 392 |
{res.request.body && <div className="space-y-1">
|
| 393 |
+
<div className="text-[10px] text-[var(--text-secondary)] uppercase font-bold">Body</div>
|
| 394 |
+
<pre className="text-[var(--accent-primary)]">{JSON.stringify(res.request.body, null, 2)}</pre>
|
| 395 |
</div>}
|
| 396 |
|
| 397 |
{res.request.form_data && Object.keys(res.request.form_data).length > 0 && (
|
| 398 |
<div className="space-y-1">
|
| 399 |
+
<div className="text-[10px] text-[var(--text-secondary)] uppercase font-bold">Form Data</div>
|
| 400 |
+
<pre className="text-[var(--accent-primary)]">{JSON.stringify(res.request.form_data, null, 2)}</pre>
|
| 401 |
</div>
|
| 402 |
)}
|
| 403 |
|
| 404 |
{res.request.files && Object.keys(res.request.files).length > 0 && (
|
| 405 |
<div className="space-y-1">
|
| 406 |
+
<div className="text-[10px] text-[var(--text-secondary)] uppercase font-bold">Files</div>
|
| 407 |
{Object.entries(res.request.files).map(([k,v]) => (
|
| 408 |
+
<div key={k} className="text-[var(--accent-secondary)]"><span className="text-[var(--text-secondary)]">{k}:</span> {v}</div>
|
| 409 |
))}
|
| 410 |
</div>
|
| 411 |
)}
|
|
|
|
| 413 |
</div>
|
| 414 |
{/* Response Container */}
|
| 415 |
<div className="space-y-2">
|
| 416 |
+
<div className="text-[var(--text-secondary)] font-semibold">Response ({res.response.status_code})</div>
|
| 417 |
+
<div className="bg-[var(--bg-tertiary)] p-3 rounded text-[var(--text-secondary)] border border-[var(--border-subtle)] overflow-x-auto max-h-64">
|
| 418 |
+
<pre className="text-[var(--accent-secondary)]">
|
| 419 |
{(() => {
|
| 420 |
try { return JSON.stringify(JSON.parse(res.response.body), null, 2); }
|
| 421 |
catch { return res.response.body; }
|
|
|
|
| 435 |
{/* OTP PROMPT MODAL/OVERLAY */}
|
| 436 |
{otpPrompt && (
|
| 437 |
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4">
|
| 438 |
+
<div className="bg-[var(--bg-secondary)] border border-[var(--border-subtle)] rounded-lg shadow-2xl w-full max-w-md overflow-hidden animate-in fade-in zoom-in duration-200">
|
| 439 |
+
<div className="p-4 border-b border-[var(--border-subtle)] bg-[var(--bg-tertiary)] flex items-center justify-between">
|
| 440 |
+
<h3 className="text-sm font-semibold text-[var(--text-primary)] flex items-center space-x-2">
|
| 441 |
+
<Zap size={16} className="text-[var(--accent-primary)]" />
|
| 442 |
<span>OTP Required</span>
|
| 443 |
</h3>
|
| 444 |
+
<button onClick={() => setOtpPrompt(null)} className="text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition">
|
| 445 |
<Trash2 size={16} />
|
| 446 |
</button>
|
| 447 |
</div>
|
| 448 |
<div className="p-6 space-y-4">
|
| 449 |
+
<p className="text-xs text-[var(--text-secondary)]">
|
| 450 |
The API response indicates that an OTP or verification code is required.
|
| 451 |
Please enter it below to save it to your session context.
|
| 452 |
</p>
|
| 453 |
<div className="space-y-2">
|
| 454 |
+
<label className="text-[10px] text-[var(--text-secondary)] font-bold uppercase tracking-wider">
|
| 455 |
+
Field Name: <span className="text-[var(--accent-primary)] font-mono lowercase">{otpPrompt.otpFieldName}</span>
|
| 456 |
</label>
|
| 457 |
<input
|
| 458 |
type="text"
|
| 459 |
autoFocus
|
| 460 |
placeholder="Enter Code..."
|
| 461 |
+
className="w-full bg-[var(--bg-primary)] border border-[var(--border-subtle)] text-[var(--text-primary)] p-3 text-sm rounded outline-none focus:border-[var(--accent-primary)] font-mono"
|
| 462 |
value={otpInput}
|
| 463 |
onChange={e => setOtpInput(e.target.value)}
|
| 464 |
onKeyDown={e => { if (e.key === 'Enter') handleOtpSubmit(); }}
|
|
|
|
| 467 |
<div className="flex space-x-2 pt-2">
|
| 468 |
<button
|
| 469 |
onClick={handleOtpSubmit}
|
| 470 |
+
className="flex-1 bg-[var(--accent-gradient)] hover:opacity-90 text-white py-2 text-xs font-semibold rounded transition shadow-lg"
|
| 471 |
>
|
| 472 |
Save & Continue
|
| 473 |
</button>
|
| 474 |
<button
|
| 475 |
onClick={() => setOtpPrompt(null)}
|
| 476 |
+
className="px-4 border border-[var(--border-subtle)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] py-2 text-xs rounded transition"
|
| 477 |
>
|
| 478 |
Cancel
|
| 479 |
</button>
|
|
|
|
| 486 |
</div>
|
| 487 |
|
| 488 |
{/* Bottom Chat Input */}
|
| 489 |
+
<div className="p-2 border-t border-[var(--border-subtle)] shrink-0 bg-[var(--bg-primary)]">
|
| 490 |
+
<div className="max-w-6xl mx-auto flex items-end space-x-2 bg-[var(--bg-tertiary)] border border-[var(--border-subtle)] rounded-lg focus-within:border-[var(--accent-primary)] transition-all duration-200 shadow-lg overflow-hidden p-1.5 group">
|
| 491 |
+
<div className="mb-1 ml-1 text-[var(--accent-primary)] opacity-40 group-focus-within:opacity-100 transition-opacity">
|
| 492 |
+
<Zap size={16} />
|
| 493 |
+
</div>
|
| 494 |
<textarea
|
| 495 |
+
placeholder={activeSpecId ? "Describe test scenario..." : "Load an API Collection first."}
|
| 496 |
disabled={!activeSpecId || isPlanning}
|
| 497 |
value={scenario}
|
| 498 |
onChange={e => setScenario(e.target.value)}
|
|
|
|
| 502 |
handleGeneratePlan();
|
| 503 |
}
|
| 504 |
}}
|
| 505 |
+
className="w-full bg-transparent text-xs resize-none outline-none py-1.5 px-1 max-h-32 min-h-[32px] text-[var(--text-primary)] placeholder-[var(--text-secondary)] disabled:opacity-50"
|
|
|
|
| 506 |
/>
|
| 507 |
<button
|
| 508 |
onClick={handleGeneratePlan}
|
| 509 |
disabled={!activeSpecId || isPlanning || !scenario.trim()}
|
| 510 |
+
className="p-1.5 mb-0.5 rounded-md bg-[var(--accent-gradient)] hover:opacity-90 disabled:opacity-50 transition-all text-white shadow-md active:scale-95 flex-shrink-0"
|
| 511 |
>
|
| 512 |
+
{isPlanning ? <RefreshCw className="animate-spin" size={16} /> : <Send size={16} />}
|
| 513 |
</button>
|
| 514 |
</div>
|
| 515 |
+
<div className="max-w-6xl mx-auto mt-1 flex justify-between items-center px-2">
|
| 516 |
+
<p className="text-[9px] text-[var(--text-secondary)] opacity-40 font-medium">Press Enter to run</p>
|
| 517 |
+
{activeSpecId && <p className="text-[9px] text-[var(--accent-primary)] font-mono opacity-60 truncate ml-4">{activeSpecName}</p>}
|
| 518 |
+
</div>
|
| 519 |
</div>
|
| 520 |
</div>
|
| 521 |
)}
|
|
|
|
| 524 |
{activePage === 'profile' && <ProfilePage />}
|
| 525 |
{activePage === 'history' && <HistoryPage />}
|
| 526 |
{activePage === 'media' && <MediaHubPage />}
|
| 527 |
+
{activePage === 'settings' && <SettingsPage />}
|
| 528 |
</div>
|
| 529 |
|
| 530 |
{/* 3. RIGHT SIDEBAR (Context Variables) */}
|
| 531 |
+
<div className={`flex flex-shrink-0 bg-[var(--bg-secondary)] border-l border-[var(--border-subtle)] transition-all duration-300 ${rightPanelOpen && activePage === 'testing' ? 'w-72' : 'w-0'}`}>
|
| 532 |
{/* Toggle Button (when closed, we might want it lingering on the UI or just controlled via header - we will put a small hovering toggle) */}
|
| 533 |
<div className="w-full h-full flex flex-col overflow-hidden whitespace-nowrap">
|
| 534 |
+
<div className="h-10 flex items-center justify-between px-4 shrink-0 border-b border-[var(--border-subtle)]">
|
| 535 |
+
<span className="font-semibold text-xs tracking-wider text-[var(--text-secondary)] uppercase">Context & Variables</span>
|
| 536 |
+
<button onClick={() => setRightPanelOpen(false)} className="text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition">
|
| 537 |
<ChevronRight size={16} />
|
| 538 |
</button>
|
| 539 |
</div>
|
|
|
|
| 542 |
{/* Session Context */}
|
| 543 |
<div>
|
| 544 |
<div className="flex items-center justify-between mb-2">
|
| 545 |
+
<h3 className="text-xs uppercase text-[var(--text-secondary)] font-semibold">Session Extracted</h3>
|
| 546 |
+
<button onClick={() => refreshSessionContext()} className="text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition" title="Refresh Context"><RefreshCw size={12}/></button>
|
| 547 |
</div>
|
| 548 |
+
<div className="bg-[var(--bg-tertiary)] p-3 rounded text-xs border border-[var(--border-subtle)] text-[var(--text-secondary)] font-mono space-y-1">
|
| 549 |
{Object.keys(sessionContextVars || {}).length === 0 ? (
|
| 550 |
+
<span className="text-[var(--text-secondary)] italic opacity-50">No variables extracted safely yet</span>
|
| 551 |
) : (
|
| 552 |
Object.entries(sessionContextVars).map(([k,v]) => (
|
| 553 |
+
<div key={k} className="flex"><span className="text-[var(--accent-primary)] w-24 truncate">{k}:</span> <span className="text-[var(--accent-secondary)] truncate flex-1 ml-2">"{String(v)}"</span></div>
|
| 554 |
))
|
| 555 |
)}
|
| 556 |
</div>
|
|
|
|
| 558 |
|
| 559 |
{/* Test User Credentials */}
|
| 560 |
<div>
|
| 561 |
+
<h3 className="text-xs uppercase text-[var(--text-secondary)] font-semibold mb-2">Test Credentials</h3>
|
| 562 |
+
<div className="bg-[var(--bg-tertiary)] p-3 rounded text-xs border border-[var(--border-subtle)] text-[var(--text-secondary)] font-mono space-y-1">
|
| 563 |
{Object.keys(storedCredentials || {}).length === 0 ? (
|
| 564 |
+
<span className="text-[var(--text-secondary)] italic opacity-50">No credentials loaded</span>
|
| 565 |
) : (
|
| 566 |
Object.entries(storedCredentials).filter(([k]) => k !== '_clear').map(([k,v]) => {
|
| 567 |
const isSensitive = k.toLowerCase().match(/(password|token|jwt|secret|bearer)/);
|
| 568 |
const displayVal = isSensitive && v ? String(v).slice(0,4) + '****' + String(v).slice(-2) : String(v);
|
| 569 |
return (
|
| 570 |
+
<div key={k} className="flex"><span className="text-[var(--accent-primary)] w-24 truncate">{k}:</span> <span className="text-[var(--accent-secondary)] truncate flex-1 ml-2">"{displayVal}"</span></div>
|
| 571 |
)
|
| 572 |
})
|
| 573 |
)}
|
|
|
|
| 581 |
{!rightPanelOpen && (
|
| 582 |
<button
|
| 583 |
onClick={() => setRightPanelOpen(true)}
|
| 584 |
+
className="absolute right-0 top-1/2 transform -translate-y-1/2 p-1 bg-[var(--bg-secondary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] rounded-l-md border border-r-0 border-[var(--border-subtle)] shadow-lg transition-all"
|
| 585 |
>
|
| 586 |
<ChevronLeft size={20} />
|
| 587 |
</button>
|
frontend-react/src/components/CollectionsPage.jsx
CHANGED
|
@@ -35,22 +35,22 @@ const CollectionsPage = ({ onCollectionSelected }) => {
|
|
| 35 |
);
|
| 36 |
|
| 37 |
return (
|
| 38 |
-
<div className="flex-1 flex flex-col bg-[
|
| 39 |
{/* Header */}
|
| 40 |
-
<div className="h-14 border-b border-[
|
| 41 |
<div className="flex items-center space-x-4">
|
| 42 |
-
<h1 className="text-lg font-medium text-
|
| 43 |
-
<Database size={20} className="text-[
|
| 44 |
<span>API Collections</span>
|
| 45 |
</h1>
|
| 46 |
</div>
|
| 47 |
<div className="flex items-center space-x-3">
|
| 48 |
<div className="relative">
|
| 49 |
-
<Search size={14} className="absolute left-3 top-1/2 -translate-y-1/2 text-
|
| 50 |
<input
|
| 51 |
type="text"
|
| 52 |
placeholder="Search collections..."
|
| 53 |
-
className="bg-[
|
| 54 |
value={searchQuery}
|
| 55 |
onChange={e => setSearchQuery(e.target.value)}
|
| 56 |
/>
|
|
@@ -58,7 +58,7 @@ const CollectionsPage = ({ onCollectionSelected }) => {
|
|
| 58 |
<button
|
| 59 |
onClick={() => fileInputRef.current?.click()}
|
| 60 |
disabled={isUploading}
|
| 61 |
-
className="bg-[
|
| 62 |
>
|
| 63 |
{isUploading ? <RefreshCw size={14} className="animate-spin" /> : <Plus size={14} />}
|
| 64 |
<span>{isUploading ? 'Uploading...' : 'Upload Spec'}</span>
|
|
@@ -76,13 +76,13 @@ const CollectionsPage = ({ onCollectionSelected }) => {
|
|
| 76 |
<div className="flex-1 overflow-y-auto p-6">
|
| 77 |
{isLoading ? (
|
| 78 |
<div className="flex flex-col items-center justify-center h-64">
|
| 79 |
-
<RefreshCw size={48} className="text-[
|
| 80 |
-
<p className="text-
|
| 81 |
</div>
|
| 82 |
) : filteredSpecs.length === 0 ? (
|
| 83 |
<div className="flex flex-col items-center justify-center h-64 opacity-50">
|
| 84 |
-
<Database size={64} className="mb-4 text-
|
| 85 |
-
<p className="text-
|
| 86 |
</div>
|
| 87 |
) : (
|
| 88 |
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
|
|
@@ -90,29 +90,29 @@ const CollectionsPage = ({ onCollectionSelected }) => {
|
|
| 90 |
<div
|
| 91 |
key={spec.id}
|
| 92 |
onClick={() => { loadSpec(spec.id); onCollectionSelected(); }}
|
| 93 |
-
className={`group bg-[
|
| 94 |
>
|
| 95 |
-
<div className={`p-4 rounded-xl border mb-4 transition ${activeSpecId === spec.id ? 'bg-[
|
| 96 |
-
<LayoutTemplate size={32} className={activeSpecId === spec.id ? 'text-[
|
| 97 |
</div>
|
| 98 |
|
| 99 |
<div className="w-full">
|
| 100 |
-
<div className="text-sm font-semibold text-
|
| 101 |
-
<div className="text-[10px] text-
|
| 102 |
</div>
|
| 103 |
|
| 104 |
-
<div className="mt-4 pt-4 border-t border-[
|
| 105 |
-
<span className="text-[10px] text-
|
| 106 |
<button
|
| 107 |
onClick={(e) => { e.stopPropagation(); deleteSpec(spec.id); }}
|
| 108 |
-
className="p-1.5 text-
|
| 109 |
>
|
| 110 |
<Trash2 size={14} />
|
| 111 |
</button>
|
| 112 |
</div>
|
| 113 |
|
| 114 |
{activeSpecId === spec.id && (
|
| 115 |
-
<div className="absolute top-2 right-2 flex items-center bg-[
|
| 116 |
<Check size={8} className="mr-1" />
|
| 117 |
Active
|
| 118 |
</div>
|
|
|
|
| 35 |
);
|
| 36 |
|
| 37 |
return (
|
| 38 |
+
<div className="flex-1 flex flex-col bg-[var(--bg-primary)] overflow-hidden animate-in fade-in slide-in-from-bottom-2 duration-300">
|
| 39 |
{/* Header */}
|
| 40 |
+
<div className="h-14 border-b border-[var(--border-subtle)] flex items-center justify-between px-6 bg-[var(--bg-secondary)]">
|
| 41 |
<div className="flex items-center space-x-4">
|
| 42 |
+
<h1 className="text-lg font-medium text-[var(--text-primary)] flex items-center space-x-2">
|
| 43 |
+
<Database size={20} className="text-[var(--accent-primary)]" />
|
| 44 |
<span>API Collections</span>
|
| 45 |
</h1>
|
| 46 |
</div>
|
| 47 |
<div className="flex items-center space-x-3">
|
| 48 |
<div className="relative">
|
| 49 |
+
<Search size={14} className="absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)]" />
|
| 50 |
<input
|
| 51 |
type="text"
|
| 52 |
placeholder="Search collections..."
|
| 53 |
+
className="bg-[var(--bg-tertiary)] border border-[var(--border-subtle)] text-[var(--text-primary)] text-xs pl-9 pr-3 py-1.5 rounded-md w-64 outline-none focus:border-[var(--accent-primary)]"
|
| 54 |
value={searchQuery}
|
| 55 |
onChange={e => setSearchQuery(e.target.value)}
|
| 56 |
/>
|
|
|
|
| 58 |
<button
|
| 59 |
onClick={() => fileInputRef.current?.click()}
|
| 60 |
disabled={isUploading}
|
| 61 |
+
className="bg-[var(--accent-gradient)] hover:opacity-90 text-white px-4 py-1.5 text-xs rounded flex items-center space-x-2 transition shadow-lg"
|
| 62 |
>
|
| 63 |
{isUploading ? <RefreshCw size={14} className="animate-spin" /> : <Plus size={14} />}
|
| 64 |
<span>{isUploading ? 'Uploading...' : 'Upload Spec'}</span>
|
|
|
|
| 76 |
<div className="flex-1 overflow-y-auto p-6">
|
| 77 |
{isLoading ? (
|
| 78 |
<div className="flex flex-col items-center justify-center h-64">
|
| 79 |
+
<RefreshCw size={48} className="text-[var(--bg-tertiary)] animate-spin mb-4" />
|
| 80 |
+
<p className="text-[var(--text-secondary)] text-sm">Loading collections...</p>
|
| 81 |
</div>
|
| 82 |
) : filteredSpecs.length === 0 ? (
|
| 83 |
<div className="flex flex-col items-center justify-center h-64 opacity-50">
|
| 84 |
+
<Database size={64} className="mb-4 text-[var(--bg-tertiary)]" />
|
| 85 |
+
<p className="text-[var(--text-secondary)]">No collections found. Upload a Swagger/OpenAPI spec to get started.</p>
|
| 86 |
</div>
|
| 87 |
) : (
|
| 88 |
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
|
|
|
|
| 90 |
<div
|
| 91 |
key={spec.id}
|
| 92 |
onClick={() => { loadSpec(spec.id); onCollectionSelected(); }}
|
| 93 |
+
className={`group bg-[var(--bg-secondary)] border rounded-lg p-5 cursor-pointer transition relative overflow-hidden flex flex-col items-center text-center ${activeSpecId === spec.id ? 'border-[var(--accent-primary)] bg-[var(--accent-primary)]/5 ring-1 ring-[var(--accent-primary)]' : 'border-[var(--border-subtle)] hover:border-[var(--text-secondary)]/30 hover:bg-[var(--bg-tertiary)]'}`}
|
| 94 |
>
|
| 95 |
+
<div className={`p-4 rounded-xl border mb-4 transition ${activeSpecId === spec.id ? 'bg-[var(--bg-primary)] border-[var(--accent-primary)]' : 'bg-[var(--bg-primary)] border-[var(--border-subtle)]'}`}>
|
| 96 |
+
<LayoutTemplate size={32} className={activeSpecId === spec.id ? 'text-[var(--accent-primary)]' : 'text-[var(--text-secondary)]'} />
|
| 97 |
</div>
|
| 98 |
|
| 99 |
<div className="w-full">
|
| 100 |
+
<div className="text-sm font-semibold text-[var(--text-primary)] truncate" title={spec.name}>{spec.name}</div>
|
| 101 |
+
<div className="text-[10px] text-[var(--text-secondary)] mt-1 uppercase tracking-widest font-bold">API Specification</div>
|
| 102 |
</div>
|
| 103 |
|
| 104 |
+
<div className="mt-4 pt-4 border-t border-[var(--border-subtle)] w-full flex items-center justify-between">
|
| 105 |
+
<span className="text-[10px] text-[var(--text-secondary)] opacity-50">ID: {spec.id.slice(0,8)}...</span>
|
| 106 |
<button
|
| 107 |
onClick={(e) => { e.stopPropagation(); deleteSpec(spec.id); }}
|
| 108 |
+
className="p-1.5 text-[var(--text-secondary)] hover:text-red-400 hover:bg-red-400/10 rounded transition"
|
| 109 |
>
|
| 110 |
<Trash2 size={14} />
|
| 111 |
</button>
|
| 112 |
</div>
|
| 113 |
|
| 114 |
{activeSpecId === spec.id && (
|
| 115 |
+
<div className="absolute top-2 right-2 flex items-center bg-[var(--accent-primary)] text-white text-[8px] font-bold px-2 py-1 rounded shadow-lg uppercase tracking-wider">
|
| 116 |
<Check size={8} className="mr-1" />
|
| 117 |
Active
|
| 118 |
</div>
|
frontend-react/src/components/HistoryPage.jsx
CHANGED
|
@@ -131,33 +131,33 @@ const HistoryPage = () => {
|
|
| 131 |
};
|
| 132 |
|
| 133 |
return (
|
| 134 |
-
<div className="flex-1 flex flex-col bg-[
|
| 135 |
{/* Header */}
|
| 136 |
-
<div className="h-14 border-b border-[
|
| 137 |
<div className="flex items-center space-x-4">
|
| 138 |
-
<h1 className="text-lg font-medium text-
|
| 139 |
-
<History size={20} className="text-[
|
| 140 |
<span>Execution History</span>
|
| 141 |
</h1>
|
| 142 |
-
<span className="text-xs bg-[
|
| 143 |
{groupedSessions.length} sessions
|
| 144 |
</span>
|
| 145 |
</div>
|
| 146 |
|
| 147 |
<div className="flex items-center space-x-3">
|
| 148 |
<div className="relative">
|
| 149 |
-
<Search className="absolute left-3 top-1/2 -translate-y-1/2 text-
|
| 150 |
<input
|
| 151 |
type="text"
|
| 152 |
placeholder="Search specs, scenarios..."
|
| 153 |
value={searchQuery}
|
| 154 |
onChange={e => setSearchQuery(e.target.value)}
|
| 155 |
-
className="bg-[
|
| 156 |
/>
|
| 157 |
</div>
|
| 158 |
<button
|
| 159 |
onClick={fetchHistory}
|
| 160 |
-
className="p-2 text-
|
| 161 |
title="Refresh History"
|
| 162 |
>
|
| 163 |
<Activity size={18} />
|
|
@@ -178,16 +178,16 @@ const HistoryPage = () => {
|
|
| 178 |
|
| 179 |
{isLoading ? (
|
| 180 |
<div className="flex-1 flex flex-col items-center justify-center space-y-4 opacity-50">
|
| 181 |
-
<Activity size={32} className="text-[
|
| 182 |
-
<p className="text-sm font-light text-
|
| 183 |
</div>
|
| 184 |
) : filteredSessions.length === 0 ? (
|
| 185 |
<div className="flex-1 flex flex-col items-center justify-center p-12 text-center">
|
| 186 |
-
<div className="w-16 h-16 bg-[
|
| 187 |
-
<History size={32} className="text-
|
| 188 |
</div>
|
| 189 |
-
<h3 className="text-lg font-light text-
|
| 190 |
-
<p className="text-sm text-
|
| 191 |
Run some test scenarios on the Workflow page to see execution logs appear here.
|
| 192 |
</p>
|
| 193 |
</div>
|
|
@@ -199,8 +199,8 @@ const HistoryPage = () => {
|
|
| 199 |
key={session.session_id}
|
| 200 |
className={`group border transition-all duration-200 overflow-hidden rounded-xl ${
|
| 201 |
expandedSessionId === session.session_id
|
| 202 |
-
? 'bg-[
|
| 203 |
-
: 'bg-[
|
| 204 |
}`}
|
| 205 |
>
|
| 206 |
{/* Session Header (Collapsible) */}
|
|
@@ -218,12 +218,12 @@ const HistoryPage = () => {
|
|
| 218 |
</div>
|
| 219 |
|
| 220 |
<div className="flex-1 min-w-0">
|
| 221 |
-
<div className="flex items-center space-x-2 text-[10px] font-bold uppercase tracking-wider text-
|
| 222 |
-
<span className="text-[
|
| 223 |
<span>•</span>
|
| 224 |
<span>{session.steps.length} steps</span>
|
| 225 |
</div>
|
| 226 |
-
<div className="text-sm text-
|
| 227 |
{session.scenario}
|
| 228 |
</div>
|
| 229 |
</div>
|
|
@@ -231,27 +231,27 @@ const HistoryPage = () => {
|
|
| 231 |
<div className="flex items-center shrink-0 ml-6 space-x-4">
|
| 232 |
<button
|
| 233 |
onClick={(e) => { e.stopPropagation(); handleDeleteSession(session.session_id); }}
|
| 234 |
-
className="p-2 text-
|
| 235 |
title="Delete Session"
|
| 236 |
>
|
| 237 |
<Trash2 size={16} />
|
| 238 |
</button>
|
| 239 |
<button
|
| 240 |
onClick={(e) => { e.stopPropagation(); handleImport(session); }}
|
| 241 |
-
className="p-2 text-
|
| 242 |
title="Import to Testing Workspace"
|
| 243 |
>
|
| 244 |
<ArrowRight size={16} className="group-hover/btn:translate-x-0.5 transition-transform" />
|
| 245 |
<span className="text-[10px] uppercase font-bold tracking-tight hidden group-hover/btn:inline">Import</span>
|
| 246 |
</button>
|
| 247 |
<div className="flex flex-col items-end">
|
| 248 |
-
<div className="flex items-center text-xs text-
|
| 249 |
<Clock size={12} className="mr-1" />
|
| 250 |
{formatDate(session.timestamp)}
|
| 251 |
</div>
|
| 252 |
<ChevronRight
|
| 253 |
size={16}
|
| 254 |
-
className={`text-
|
| 255 |
/>
|
| 256 |
</div>
|
| 257 |
</div>
|
|
@@ -263,28 +263,28 @@ const HistoryPage = () => {
|
|
| 263 |
|
| 264 |
{/* Session Extraction History */}
|
| 265 |
{session.context_variables && Object.keys(session.context_variables).length > 0 && (
|
| 266 |
-
<div className="mb-6 bg-[
|
| 267 |
-
<h4 className="text-[10px] font-bold uppercase text-
|
| 268 |
-
<Activity size={12} className="mr-2 text-[
|
| 269 |
Session Extraction History
|
| 270 |
</h4>
|
| 271 |
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-3">
|
| 272 |
{Object.entries(session.context_variables).map(([k, v]) => (
|
| 273 |
-
<div key={k} className="flex flex-col space-y-1 bg-[
|
| 274 |
-
<span className="text-[9px] text-[
|
| 275 |
-
<span className="text-xs text-[
|
| 276 |
</div>
|
| 277 |
))}
|
| 278 |
</div>
|
| 279 |
</div>
|
| 280 |
)}
|
| 281 |
|
| 282 |
-
<div className="pt-4 border-t border-[
|
| 283 |
{session.steps.map((item) => (
|
| 284 |
-
<div key={item.id} className="border border-[
|
| 285 |
<div
|
| 286 |
onClick={() => setExpandedStepId(expandedStepId === item.id ? null : item.id)}
|
| 287 |
-
className="p-3 flex items-center justify-between cursor-pointer hover:bg-[
|
| 288 |
>
|
| 289 |
<div className="flex items-center space-x-3">
|
| 290 |
<span className={`px-2 py-0.5 rounded text-[10px] font-mono ${
|
|
@@ -292,30 +292,30 @@ const HistoryPage = () => {
|
|
| 292 |
}`}>
|
| 293 |
Step {item.step}
|
| 294 |
</span>
|
| 295 |
-
<span className="text-xs text-
|
| 296 |
</div>
|
| 297 |
<ChevronRight
|
| 298 |
size={14}
|
| 299 |
-
className={`text-
|
| 300 |
/>
|
| 301 |
</div>
|
| 302 |
|
| 303 |
{/* Step Details */}
|
| 304 |
{expandedStepId === item.id && (
|
| 305 |
-
<div className="p-4 bg-[
|
| 306 |
{/* AI Analysis Result */}
|
| 307 |
<div className={`p-4 rounded-lg border-l-4 ${
|
| 308 |
item.analysis?.status === 'success' ? 'border-emerald-500 bg-emerald-500/5' : 'border-red-500 bg-red-500/5'
|
| 309 |
}`}>
|
| 310 |
-
<div className="text-[10px] font-bold uppercase text-
|
| 311 |
-
<p className="text-xs text-
|
| 312 |
{item.analysis?.response_summary || "Summary not available."}
|
| 313 |
</p>
|
| 314 |
{item.analysis?.extracted_variables && Object.keys(item.analysis.extracted_variables).length > 0 && (
|
| 315 |
<div className="mt-3 flex flex-wrap gap-2">
|
| 316 |
{Object.entries(item.analysis.extracted_variables).map(([k, v]) => (
|
| 317 |
-
<div key={k} className="px-2 py-1 bg-[
|
| 318 |
-
{k}: <span className="text-[
|
| 319 |
</div>
|
| 320 |
))}
|
| 321 |
</div>
|
|
@@ -325,48 +325,48 @@ const HistoryPage = () => {
|
|
| 325 |
{/* Request/Response Grid */}
|
| 326 |
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
| 327 |
<div className="space-y-2">
|
| 328 |
-
<div className="text-[9px] uppercase font-bold text-
|
| 329 |
<ArrowRight size={10} className="mr-1" />
|
| 330 |
Request Details
|
| 331 |
</div>
|
| 332 |
-
<div className="bg-[
|
| 333 |
-
<div className="text-[
|
| 334 |
|
| 335 |
{item.request.headers && Object.keys(item.request.headers).length > 0 && (
|
| 336 |
<div>
|
| 337 |
-
<div className="text-
|
| 338 |
{Object.entries(item.request.headers).map(([k,v]) => (
|
| 339 |
-
<div key={k} className="text-[
|
| 340 |
))}
|
| 341 |
</div>
|
| 342 |
)}
|
| 343 |
|
| 344 |
{item.request.query_params && Object.keys(item.request.query_params).length > 0 && (
|
| 345 |
<div>
|
| 346 |
-
<div className="text-
|
| 347 |
{Object.entries(item.request.query_params).map(([k,v]) => (
|
| 348 |
-
<div key={k} className="text-[
|
| 349 |
))}
|
| 350 |
</div>
|
| 351 |
)}
|
| 352 |
|
| 353 |
{item.request.body && <div>
|
| 354 |
-
<div className="text-
|
| 355 |
-
<pre className="text-
|
| 356 |
</div>}
|
| 357 |
|
| 358 |
{item.request.form_data && Object.keys(item.request.form_data).length > 0 && (
|
| 359 |
<div>
|
| 360 |
-
<div className="text-
|
| 361 |
-
<pre className="text-
|
| 362 |
</div>
|
| 363 |
)}
|
| 364 |
|
| 365 |
{item.request.files && Object.keys(item.request.files).length > 0 && (
|
| 366 |
<div>
|
| 367 |
-
<div className="text-
|
| 368 |
{Object.entries(item.request.files).map(([k,v]) => (
|
| 369 |
-
<div key={k} className="text-[
|
| 370 |
))}
|
| 371 |
</div>
|
| 372 |
)}
|
|
@@ -374,12 +374,12 @@ const HistoryPage = () => {
|
|
| 374 |
</div>
|
| 375 |
|
| 376 |
<div className="space-y-2">
|
| 377 |
-
<div className="text-[9px] uppercase font-bold text-
|
| 378 |
<Zap size={10} className="mr-1" />
|
| 379 |
Response Body ({item.response.status_code})
|
| 380 |
</div>
|
| 381 |
-
<div className="bg-[
|
| 382 |
-
<pre className="text-[
|
| 383 |
{(() => {
|
| 384 |
try { return JSON.stringify(JSON.parse(item.response.body), null, 2); }
|
| 385 |
catch { return item.response.body; }
|
|
|
|
| 131 |
};
|
| 132 |
|
| 133 |
return (
|
| 134 |
+
<div className="flex-1 flex flex-col bg-[var(--bg-primary)] overflow-hidden animate-in fade-in slide-in-from-bottom-2 duration-300">
|
| 135 |
{/* Header */}
|
| 136 |
+
<div className="h-14 border-b border-[var(--border-subtle)] flex items-center justify-between px-6 bg-[var(--bg-secondary)] shrink-0">
|
| 137 |
<div className="flex items-center space-x-4">
|
| 138 |
+
<h1 className="text-lg font-medium text-[var(--text-primary)] flex items-center space-x-2">
|
| 139 |
+
<History size={20} className="text-[var(--accent-primary)]" />
|
| 140 |
<span>Execution History</span>
|
| 141 |
</h1>
|
| 142 |
+
<span className="text-xs bg-[var(--bg-tertiary)] text-[var(--text-secondary)] px-2 py-0.5 rounded-full font-mono border border-[var(--border-subtle)]">
|
| 143 |
{groupedSessions.length} sessions
|
| 144 |
</span>
|
| 145 |
</div>
|
| 146 |
|
| 147 |
<div className="flex items-center space-x-3">
|
| 148 |
<div className="relative">
|
| 149 |
+
<Search className="absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)]" size={14} />
|
| 150 |
<input
|
| 151 |
type="text"
|
| 152 |
placeholder="Search specs, scenarios..."
|
| 153 |
value={searchQuery}
|
| 154 |
onChange={e => setSearchQuery(e.target.value)}
|
| 155 |
+
className="bg-[var(--bg-tertiary)] border border-[var(--border-subtle)] text-[var(--text-primary)] pl-9 pr-4 py-1.5 text-xs rounded-lg outline-none focus:border-[var(--accent-primary)] w-64 transition-all"
|
| 156 |
/>
|
| 157 |
</div>
|
| 158 |
<button
|
| 159 |
onClick={fetchHistory}
|
| 160 |
+
className="p-2 text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] rounded-lg transition-colors"
|
| 161 |
title="Refresh History"
|
| 162 |
>
|
| 163 |
<Activity size={18} />
|
|
|
|
| 178 |
|
| 179 |
{isLoading ? (
|
| 180 |
<div className="flex-1 flex flex-col items-center justify-center space-y-4 opacity-50">
|
| 181 |
+
<Activity size={32} className="text-[var(--accent-primary)] animate-pulse" />
|
| 182 |
+
<p className="text-sm font-light text-[var(--text-secondary)]">Loading history records...</p>
|
| 183 |
</div>
|
| 184 |
) : filteredSessions.length === 0 ? (
|
| 185 |
<div className="flex-1 flex flex-col items-center justify-center p-12 text-center">
|
| 186 |
+
<div className="w-16 h-16 bg-[var(--bg-secondary)] border border-[var(--border-subtle)] rounded-2xl flex items-center justify-center mb-6">
|
| 187 |
+
<History size={32} className="text-[var(--text-secondary)] opacity-30" />
|
| 188 |
</div>
|
| 189 |
+
<h3 className="text-lg font-light text-[var(--text-primary)]">No History Found</h3>
|
| 190 |
+
<p className="text-sm text-[var(--text-secondary)] max-w-xs mt-2">
|
| 191 |
Run some test scenarios on the Workflow page to see execution logs appear here.
|
| 192 |
</p>
|
| 193 |
</div>
|
|
|
|
| 199 |
key={session.session_id}
|
| 200 |
className={`group border transition-all duration-200 overflow-hidden rounded-xl ${
|
| 201 |
expandedSessionId === session.session_id
|
| 202 |
+
? 'bg-[var(--bg-secondary)] border-[var(--accent-primary)]/50 shadow-2xl'
|
| 203 |
+
: 'bg-[var(--bg-secondary)]/50 border-[var(--border-subtle)] hover:border-[var(--text-secondary)]/30'
|
| 204 |
}`}
|
| 205 |
>
|
| 206 |
{/* Session Header (Collapsible) */}
|
|
|
|
| 218 |
</div>
|
| 219 |
|
| 220 |
<div className="flex-1 min-w-0">
|
| 221 |
+
<div className="flex items-center space-x-2 text-[10px] font-bold uppercase tracking-wider text-[var(--text-secondary)] mb-1">
|
| 222 |
+
<span className="text-[var(--accent-primary)]">{session.spec_name}</span>
|
| 223 |
<span>•</span>
|
| 224 |
<span>{session.steps.length} steps</span>
|
| 225 |
</div>
|
| 226 |
+
<div className="text-sm text-[var(--text-primary)] font-medium truncate">
|
| 227 |
{session.scenario}
|
| 228 |
</div>
|
| 229 |
</div>
|
|
|
|
| 231 |
<div className="flex items-center shrink-0 ml-6 space-x-4">
|
| 232 |
<button
|
| 233 |
onClick={(e) => { e.stopPropagation(); handleDeleteSession(session.session_id); }}
|
| 234 |
+
className="p-2 text-[var(--text-secondary)] hover:text-red-500 hover:bg-red-500/10 rounded-lg transition-all"
|
| 235 |
title="Delete Session"
|
| 236 |
>
|
| 237 |
<Trash2 size={16} />
|
| 238 |
</button>
|
| 239 |
<button
|
| 240 |
onClick={(e) => { e.stopPropagation(); handleImport(session); }}
|
| 241 |
+
className="p-2 text-[var(--text-secondary)] hover:text-[var(--accent-primary)] hover:bg-[var(--bg-tertiary)] rounded-lg transition-all flex items-center space-x-2 group/btn"
|
| 242 |
title="Import to Testing Workspace"
|
| 243 |
>
|
| 244 |
<ArrowRight size={16} className="group-hover/btn:translate-x-0.5 transition-transform" />
|
| 245 |
<span className="text-[10px] uppercase font-bold tracking-tight hidden group-hover/btn:inline">Import</span>
|
| 246 |
</button>
|
| 247 |
<div className="flex flex-col items-end">
|
| 248 |
+
<div className="flex items-center text-xs text-[var(--text-secondary)] font-mono mb-1">
|
| 249 |
<Clock size={12} className="mr-1" />
|
| 250 |
{formatDate(session.timestamp)}
|
| 251 |
</div>
|
| 252 |
<ChevronRight
|
| 253 |
size={16}
|
| 254 |
+
className={`text-[var(--text-secondary)] transition-transform duration-200 ${expandedSessionId === session.session_id ? 'rotate-90' : ''}`}
|
| 255 |
/>
|
| 256 |
</div>
|
| 257 |
</div>
|
|
|
|
| 263 |
|
| 264 |
{/* Session Extraction History */}
|
| 265 |
{session.context_variables && Object.keys(session.context_variables).length > 0 && (
|
| 266 |
+
<div className="mb-6 bg-[var(--bg-primary)] border border-[var(--border-subtle)] rounded-lg p-4">
|
| 267 |
+
<h4 className="text-[10px] font-bold uppercase text-[var(--text-secondary)] mb-3 tracking-wider flex items-center">
|
| 268 |
+
<Activity size={12} className="mr-2 text-[var(--accent-primary)]" />
|
| 269 |
Session Extraction History
|
| 270 |
</h4>
|
| 271 |
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-3">
|
| 272 |
{Object.entries(session.context_variables).map(([k, v]) => (
|
| 273 |
+
<div key={k} className="flex flex-col space-y-1 bg-[var(--bg-tertiary)] p-2 rounded border border-[var(--border-subtle)]">
|
| 274 |
+
<span className="text-[9px] text-[var(--accent-primary)] font-mono">{k}</span>
|
| 275 |
+
<span className="text-xs text-[var(--accent-secondary)] truncate">"{String(v)}"</span>
|
| 276 |
</div>
|
| 277 |
))}
|
| 278 |
</div>
|
| 279 |
</div>
|
| 280 |
)}
|
| 281 |
|
| 282 |
+
<div className="pt-4 border-t border-[var(--border-subtle)] space-y-3">
|
| 283 |
{session.steps.map((item) => (
|
| 284 |
+
<div key={item.id} className="border border-[var(--border-subtle)] rounded-lg overflow-hidden bg-[var(--bg-primary)]">
|
| 285 |
<div
|
| 286 |
onClick={() => setExpandedStepId(expandedStepId === item.id ? null : item.id)}
|
| 287 |
+
className="p-3 flex items-center justify-between cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors"
|
| 288 |
>
|
| 289 |
<div className="flex items-center space-x-3">
|
| 290 |
<span className={`px-2 py-0.5 rounded text-[10px] font-mono ${
|
|
|
|
| 292 |
}`}>
|
| 293 |
Step {item.step}
|
| 294 |
</span>
|
| 295 |
+
<span className="text-xs text-[var(--text-primary)] font-medium">{item.request.method} {item.request.url.split('/').pop()}</span>
|
| 296 |
</div>
|
| 297 |
<ChevronRight
|
| 298 |
size={14}
|
| 299 |
+
className={`text-[var(--text-secondary)] transition-transform duration-200 ${expandedStepId === item.id ? 'rotate-90' : ''}`}
|
| 300 |
/>
|
| 301 |
</div>
|
| 302 |
|
| 303 |
{/* Step Details */}
|
| 304 |
{expandedStepId === item.id && (
|
| 305 |
+
<div className="p-4 bg-[var(--bg-primary)] border-t border-[var(--border-subtle)] space-y-4 animate-in fade-in duration-200">
|
| 306 |
{/* AI Analysis Result */}
|
| 307 |
<div className={`p-4 rounded-lg border-l-4 ${
|
| 308 |
item.analysis?.status === 'success' ? 'border-emerald-500 bg-emerald-500/5' : 'border-red-500 bg-red-500/5'
|
| 309 |
}`}>
|
| 310 |
+
<div className="text-[10px] font-bold uppercase text-[var(--text-secondary)] mb-2">AI Step Analysis</div>
|
| 311 |
+
<p className="text-xs text-[var(--text-primary)] leading-relaxed">
|
| 312 |
{item.analysis?.response_summary || "Summary not available."}
|
| 313 |
</p>
|
| 314 |
{item.analysis?.extracted_variables && Object.keys(item.analysis.extracted_variables).length > 0 && (
|
| 315 |
<div className="mt-3 flex flex-wrap gap-2">
|
| 316 |
{Object.entries(item.analysis.extracted_variables).map(([k, v]) => (
|
| 317 |
+
<div key={k} className="px-2 py-1 bg-[var(--bg-tertiary)] rounded text-[9px] text-[var(--accent-primary)] font-mono border border-[var(--border-subtle)]">
|
| 318 |
+
{k}: <span className="text-[var(--accent-secondary)]">"{String(v)}"</span>
|
| 319 |
</div>
|
| 320 |
))}
|
| 321 |
</div>
|
|
|
|
| 325 |
{/* Request/Response Grid */}
|
| 326 |
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
| 327 |
<div className="space-y-2">
|
| 328 |
+
<div className="text-[9px] uppercase font-bold text-[var(--text-secondary)] flex items-center">
|
| 329 |
<ArrowRight size={10} className="mr-1" />
|
| 330 |
Request Details
|
| 331 |
</div>
|
| 332 |
+
<div className="bg-[var(--bg-secondary)] border border-[var(--border-subtle)] rounded p-3 text-[10px] font-mono overflow-auto max-h-48 space-y-3">
|
| 333 |
+
<div className="text-[var(--accent-primary)] font-bold mb-2 break-all">{item.request.method} {item.request.url}</div>
|
| 334 |
|
| 335 |
{item.request.headers && Object.keys(item.request.headers).length > 0 && (
|
| 336 |
<div>
|
| 337 |
+
<div className="text-[var(--text-secondary)] font-bold uppercase mb-1">Headers</div>
|
| 338 |
{Object.entries(item.request.headers).map(([k,v]) => (
|
| 339 |
+
<div key={k} className="text-[var(--accent-primary)]"><span className="text-[var(--text-secondary)]">{k}:</span> {v}</div>
|
| 340 |
))}
|
| 341 |
</div>
|
| 342 |
)}
|
| 343 |
|
| 344 |
{item.request.query_params && Object.keys(item.request.query_params).length > 0 && (
|
| 345 |
<div>
|
| 346 |
+
<div className="text-[var(--text-secondary)] font-bold uppercase mb-1">Query Params</div>
|
| 347 |
{Object.entries(item.request.query_params).map(([k,v]) => (
|
| 348 |
+
<div key={k} className="text-[var(--accent-primary)]"><span className="text-[var(--text-secondary)]">{k}=</span>{v}</div>
|
| 349 |
))}
|
| 350 |
</div>
|
| 351 |
)}
|
| 352 |
|
| 353 |
{item.request.body && <div>
|
| 354 |
+
<div className="text-[var(--text-secondary)] font-bold uppercase mb-1">Body</div>
|
| 355 |
+
<pre className="text-[var(--text-secondary)]">{JSON.stringify(item.request.body, null, 2)}</pre>
|
| 356 |
</div>}
|
| 357 |
|
| 358 |
{item.request.form_data && Object.keys(item.request.form_data).length > 0 && (
|
| 359 |
<div>
|
| 360 |
+
<div className="text-[var(--text-secondary)] font-bold uppercase mb-1">Form Data</div>
|
| 361 |
+
<pre className="text-[var(--text-secondary)]">{JSON.stringify(item.request.form_data, null, 2)}</pre>
|
| 362 |
</div>
|
| 363 |
)}
|
| 364 |
|
| 365 |
{item.request.files && Object.keys(item.request.files).length > 0 && (
|
| 366 |
<div>
|
| 367 |
+
<div className="text-[var(--text-secondary)] font-bold uppercase mb-1">Files</div>
|
| 368 |
{Object.entries(item.request.files).map(([k,v]) => (
|
| 369 |
+
<div key={k} className="text-[var(--accent-secondary)]"><span className="text-[var(--text-secondary)]">{k}:</span> {v}</div>
|
| 370 |
))}
|
| 371 |
</div>
|
| 372 |
)}
|
|
|
|
| 374 |
</div>
|
| 375 |
|
| 376 |
<div className="space-y-2">
|
| 377 |
+
<div className="text-[9px] uppercase font-bold text-[var(--text-secondary)] flex items-center">
|
| 378 |
<Zap size={10} className="mr-1" />
|
| 379 |
Response Body ({item.response.status_code})
|
| 380 |
</div>
|
| 381 |
+
<div className="bg-[var(--bg-secondary)] border border-[var(--border-subtle)] rounded p-3 text-[10px] font-mono overflow-auto max-h-48">
|
| 382 |
+
<pre className="text-[var(--accent-secondary)]">
|
| 383 |
{(() => {
|
| 384 |
try { return JSON.stringify(JSON.parse(item.response.body), null, 2); }
|
| 385 |
catch { return item.response.body; }
|
frontend-react/src/components/MediaHubPage.jsx
CHANGED
|
@@ -97,26 +97,26 @@ const MediaHubPage = () => {
|
|
| 97 |
|
| 98 |
const getIcon = (category) => {
|
| 99 |
switch(category) {
|
| 100 |
-
case 'images': return <ImageIcon size={20} className="text-
|
| 101 |
-
case 'audio': return <Music size={20} className="text-
|
| 102 |
-
case 'video': return <Video size={20} className="text-
|
| 103 |
-
default: return <File size={20} className="text-
|
| 104 |
}
|
| 105 |
};
|
| 106 |
|
| 107 |
return (
|
| 108 |
-
<div className="flex-1 flex flex-col bg-[
|
| 109 |
{/* Header */}
|
| 110 |
-
<div className="h-14 border-b border-[
|
| 111 |
<div className="flex items-center space-x-4">
|
| 112 |
-
<h1 className="text-lg font-medium text-
|
| 113 |
-
<div className="h-6 w-px bg-[
|
| 114 |
<div className="flex space-x-2">
|
| 115 |
{['all', 'documents', 'images', 'audio', 'video'].map(cat => (
|
| 116 |
<button
|
| 117 |
key={cat}
|
| 118 |
onClick={() => setActiveCategory(cat)}
|
| 119 |
-
className={`px-3 py-1 text-xs capitalize rounded-full transition ${activeCategory === cat ? 'bg-[
|
| 120 |
>
|
| 121 |
{cat}
|
| 122 |
</button>
|
|
@@ -125,18 +125,18 @@ const MediaHubPage = () => {
|
|
| 125 |
</div>
|
| 126 |
<div className="flex items-center space-x-3">
|
| 127 |
<div className="relative">
|
| 128 |
-
<Search size={14} className="absolute left-3 top-1/2 -translate-y-1/2 text-
|
| 129 |
<input
|
| 130 |
type="text"
|
| 131 |
placeholder="Search assets, tags, descriptions..."
|
| 132 |
-
className="bg-[
|
| 133 |
value={searchQuery}
|
| 134 |
onChange={e => setSearchQuery(e.target.value)}
|
| 135 |
/>
|
| 136 |
</div>
|
| 137 |
<button
|
| 138 |
onClick={() => setShowUploadModal(true)}
|
| 139 |
-
className="bg-[
|
| 140 |
>
|
| 141 |
<Upload size={14} />
|
| 142 |
<span>Upload Asset</span>
|
|
@@ -146,15 +146,15 @@ const MediaHubPage = () => {
|
|
| 146 |
|
| 147 |
<div className="flex-1 flex overflow-hidden">
|
| 148 |
{/* Sidebar: Collections */}
|
| 149 |
-
<div className="w-64 border-r border-[
|
| 150 |
<div className="flex items-center justify-between mb-4">
|
| 151 |
-
<h3 className="text-[10px] uppercase font-bold text-
|
| 152 |
-
<button onClick={() => setShowNewCollectionModal(true)} className="text-
|
| 153 |
</div>
|
| 154 |
<div className="flex-1 overflow-y-auto space-y-1">
|
| 155 |
<button
|
| 156 |
onClick={() => setActiveCollectionId(null)}
|
| 157 |
-
className={`w-full flex items-center space-x-2 px-3 py-2 rounded text-xs transition ${!activeCollectionId ? 'bg-[
|
| 158 |
>
|
| 159 |
<Folder size={14} />
|
| 160 |
<span>All Assets</span>
|
|
@@ -163,7 +163,7 @@ const MediaHubPage = () => {
|
|
| 163 |
<button
|
| 164 |
key={col.id}
|
| 165 |
onClick={() => setActiveCollectionId(col.id)}
|
| 166 |
-
className={`w-full flex items-center justify-between px-3 py-2 rounded text-xs transition ${activeCollectionId === col.id ? 'bg-[
|
| 167 |
>
|
| 168 |
<div className="flex items-center space-x-2">
|
| 169 |
<Folder size={14} />
|
|
@@ -178,22 +178,22 @@ const MediaHubPage = () => {
|
|
| 178 |
<div className="flex-1 overflow-y-auto p-6">
|
| 179 |
{isLoading ? (
|
| 180 |
<div className="flex items-center justify-center h-64">
|
| 181 |
-
<Upload size={48} className="text-[
|
| 182 |
</div>
|
| 183 |
) : filteredAssets.length === 0 ? (
|
| 184 |
<div className="flex flex-col items-center justify-center h-64 opacity-50">
|
| 185 |
-
<ImageIcon size={64} className="mb-4 text-
|
| 186 |
-
<p className="text-
|
| 187 |
</div>
|
| 188 |
) : (
|
| 189 |
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
|
| 190 |
{filteredAssets.map(asset => (
|
| 191 |
-
<div key={asset.id} className="bg-[
|
| 192 |
-
<div className="h-32 bg-[
|
| 193 |
{asset.category === 'images' ? (
|
| 194 |
<div className="w-full h-full bg-cover bg-center opacity-40 group-hover:opacity-60 transition" style={{ backgroundImage: `url(${import.meta.env.VITE_BACKEND_URL}/uploads/${asset.path})` }} />
|
| 195 |
) : (
|
| 196 |
-
<div className="text-
|
| 197 |
)}
|
| 198 |
<div className="absolute inset-0 flex items-center justify-center">
|
| 199 |
{getIcon(asset.category)}
|
|
@@ -202,20 +202,20 @@ const MediaHubPage = () => {
|
|
| 202 |
<div className="p-3 space-y-2">
|
| 203 |
<div className="flex items-start justify-between">
|
| 204 |
<div className="truncate pr-4">
|
| 205 |
-
<div className="text-xs font-medium text-
|
| 206 |
-
<div className="text-[10px] text-
|
| 207 |
</div>
|
| 208 |
-
<button onClick={() => handleDeleteAsset(asset.id)} className="text-
|
| 209 |
<Trash2 size={14} />
|
| 210 |
</button>
|
| 211 |
</div>
|
| 212 |
{asset.description && (
|
| 213 |
-
<p className="text-[10px] text-
|
| 214 |
)}
|
| 215 |
{asset.tags && asset.tags.length > 0 && (
|
| 216 |
<div className="flex flex-wrap gap-1 pt-1">
|
| 217 |
{asset.tags.map(tag => (
|
| 218 |
-
<span key={tag} className="bg-[
|
| 219 |
<Tags size={8} />
|
| 220 |
<span>{tag}</span>
|
| 221 |
</span>
|
|
@@ -233,18 +233,18 @@ const MediaHubPage = () => {
|
|
| 233 |
{/* Upload Modal */}
|
| 234 |
{showUploadModal && (
|
| 235 |
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4">
|
| 236 |
-
<div className="bg-[
|
| 237 |
-
<div className="p-4 border-b border-[
|
| 238 |
-
<h3 className="text-sm font-semibold text-
|
| 239 |
-
<Upload size={16} className="text-[
|
| 240 |
<span>Upload New Asset</span>
|
| 241 |
</h3>
|
| 242 |
-
<button onClick={() => setShowUploadModal(false)} className="text-
|
| 243 |
</div>
|
| 244 |
<div className="p-6 space-y-4">
|
| 245 |
<div
|
| 246 |
onClick={() => document.getElementById('asset-file-input').click()}
|
| 247 |
-
className="border-2 border-dashed border-[
|
| 248 |
>
|
| 249 |
<input
|
| 250 |
id="asset-file-input"
|
|
@@ -256,35 +256,35 @@ const MediaHubPage = () => {
|
|
| 256 |
<div className="text-center">
|
| 257 |
<Check size={32} className="text-green-500 mb-2 mx-auto" />
|
| 258 |
<div className="text-xs text-white font-medium">{selectedFile.name}</div>
|
| 259 |
-
<div className="text-[10px] text-
|
| 260 |
</div>
|
| 261 |
) : (
|
| 262 |
<div className="text-center">
|
| 263 |
-
<Upload size={32} className="text-
|
| 264 |
-
<div className="text-xs text-
|
| 265 |
-
<div className="text-[10px] text-
|
| 266 |
</div>
|
| 267 |
)}
|
| 268 |
</div>
|
| 269 |
|
| 270 |
<div className="space-y-3">
|
| 271 |
<div className="space-y-1">
|
| 272 |
-
<label className="text-[10px] uppercase font-bold text-
|
| 273 |
<textarea
|
| 274 |
placeholder="Explain what this file is for (e.g. 'This is the Aadhar card used for user identity verification')"
|
| 275 |
-
className="w-full bg-[
|
| 276 |
value={uploadForm.description}
|
| 277 |
onChange={e => setUploadForm({...uploadForm, description: e.target.value})}
|
| 278 |
/>
|
| 279 |
</div>
|
| 280 |
<div className="space-y-1">
|
| 281 |
-
<label className="text-[10px] uppercase font-bold text-
|
| 282 |
<div className="relative">
|
| 283 |
-
<Tags size={14} className="absolute left-3 top-1/2 -translate-y-1/2 text-
|
| 284 |
<input
|
| 285 |
type="text"
|
| 286 |
placeholder="aadhar, identity, personal, legal"
|
| 287 |
-
className="w-full bg-[
|
| 288 |
value={uploadForm.tags}
|
| 289 |
onChange={e => setUploadForm({...uploadForm, tags: e.target.value})}
|
| 290 |
/>
|
|
@@ -295,7 +295,7 @@ const MediaHubPage = () => {
|
|
| 295 |
<button
|
| 296 |
onClick={handleFileUpload}
|
| 297 |
disabled={!selectedFile || isUploading}
|
| 298 |
-
className="w-full bg-[
|
| 299 |
>
|
| 300 |
{isUploading ? <Upload className="animate-spin" size={16} /> : <Check size={16} />}
|
| 301 |
<span>{isUploading ? 'Uploading...' : 'Finalize Upload'}</span>
|
|
@@ -308,29 +308,29 @@ const MediaHubPage = () => {
|
|
| 308 |
{/* New Collection Modal */}
|
| 309 |
{showNewCollectionModal && (
|
| 310 |
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4">
|
| 311 |
-
<div className="bg-[
|
| 312 |
-
<div className="p-4 border-b border-[
|
| 313 |
-
<h3 className="text-sm font-semibold text-
|
| 314 |
-
<Plus size={16} className="text-
|
| 315 |
<span>New Collection</span>
|
| 316 |
</h3>
|
| 317 |
-
<button onClick={() => setShowNewCollectionModal(false)} className="text-
|
| 318 |
</div>
|
| 319 |
<div className="p-6 space-y-4">
|
| 320 |
<div className="space-y-3">
|
| 321 |
<div className="space-y-1">
|
| 322 |
-
<label className="text-[10px] uppercase font-bold text-
|
| 323 |
<input
|
| 324 |
type="text"
|
| 325 |
-
className="w-full bg-[
|
| 326 |
value={newColForm.name}
|
| 327 |
onChange={e => setNewColForm({...newColForm, name: e.target.value})}
|
| 328 |
/>
|
| 329 |
</div>
|
| 330 |
<div className="space-y-1">
|
| 331 |
-
<label className="text-[10px] uppercase font-bold text-
|
| 332 |
<textarea
|
| 333 |
-
className="w-full bg-[
|
| 334 |
value={newColForm.description}
|
| 335 |
onChange={e => setNewColForm({...newColForm, description: e.target.value})}
|
| 336 |
/>
|
|
@@ -338,7 +338,7 @@ const MediaHubPage = () => {
|
|
| 338 |
</div>
|
| 339 |
<button
|
| 340 |
onClick={handleCreateCollection}
|
| 341 |
-
className="w-full bg-
|
| 342 |
>
|
| 343 |
Create Collection
|
| 344 |
</button>
|
|
|
|
| 97 |
|
| 98 |
const getIcon = (category) => {
|
| 99 |
switch(category) {
|
| 100 |
+
case 'images': return <ImageIcon size={20} className="text-[var(--accent-secondary)]" />;
|
| 101 |
+
case 'audio': return <Music size={20} className="text-[var(--accent-secondary)]" />;
|
| 102 |
+
case 'video': return <Video size={20} className="text-[var(--accent-secondary)]" />;
|
| 103 |
+
default: return <File size={20} className="text-[var(--accent-primary)]" />;
|
| 104 |
}
|
| 105 |
};
|
| 106 |
|
| 107 |
return (
|
| 108 |
+
<div className="flex-1 flex flex-col bg-[var(--bg-primary)] overflow-hidden">
|
| 109 |
{/* Header */}
|
| 110 |
+
<div className="h-14 border-b border-[var(--border-subtle)] flex items-center justify-between px-6 bg-[var(--bg-secondary)]">
|
| 111 |
<div className="flex items-center space-x-4">
|
| 112 |
+
<h1 className="text-lg font-medium text-[var(--text-primary)]">Media Hub</h1>
|
| 113 |
+
<div className="h-6 w-px bg-[var(--border-subtle)]" />
|
| 114 |
<div className="flex space-x-2">
|
| 115 |
{['all', 'documents', 'images', 'audio', 'video'].map(cat => (
|
| 116 |
<button
|
| 117 |
key={cat}
|
| 118 |
onClick={() => setActiveCategory(cat)}
|
| 119 |
+
className={`px-3 py-1 text-xs capitalize rounded-full transition ${activeCategory === cat ? 'bg-[var(--accent-primary)] text-white shadow-sm' : 'text-[var(--text-secondary)] hover:text-[var(--text-primary)] bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)]'}`}
|
| 120 |
>
|
| 121 |
{cat}
|
| 122 |
</button>
|
|
|
|
| 125 |
</div>
|
| 126 |
<div className="flex items-center space-x-3">
|
| 127 |
<div className="relative">
|
| 128 |
+
<Search size={14} className="absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)]" />
|
| 129 |
<input
|
| 130 |
type="text"
|
| 131 |
placeholder="Search assets, tags, descriptions..."
|
| 132 |
+
className="bg-[var(--bg-primary)] border border-[var(--border-subtle)] text-[var(--text-primary)] text-xs pl-9 pr-3 py-1.5 rounded-md w-64 outline-none focus:border-[var(--accent-primary)]"
|
| 133 |
value={searchQuery}
|
| 134 |
onChange={e => setSearchQuery(e.target.value)}
|
| 135 |
/>
|
| 136 |
</div>
|
| 137 |
<button
|
| 138 |
onClick={() => setShowUploadModal(true)}
|
| 139 |
+
className="bg-[var(--accent-gradient)] hover:opacity-90 text-white px-4 py-1.5 text-xs rounded flex items-center space-x-2 transition shadow-lg"
|
| 140 |
>
|
| 141 |
<Upload size={14} />
|
| 142 |
<span>Upload Asset</span>
|
|
|
|
| 146 |
|
| 147 |
<div className="flex-1 flex overflow-hidden">
|
| 148 |
{/* Sidebar: Collections */}
|
| 149 |
+
<div className="w-64 border-r border-[var(--border-subtle)] bg-[var(--bg-secondary)] flex flex-col p-4">
|
| 150 |
<div className="flex items-center justify-between mb-4">
|
| 151 |
+
<h3 className="text-[10px] uppercase font-bold text-[var(--text-secondary)] tracking-wider">Collections</h3>
|
| 152 |
+
<button onClick={() => setShowNewCollectionModal(true)} className="text-[var(--text-secondary)] hover:text-[var(--text-primary)]"><Plus size={16}/></button>
|
| 153 |
</div>
|
| 154 |
<div className="flex-1 overflow-y-auto space-y-1">
|
| 155 |
<button
|
| 156 |
onClick={() => setActiveCollectionId(null)}
|
| 157 |
+
className={`w-full flex items-center space-x-2 px-3 py-2 rounded text-xs transition ${!activeCollectionId ? 'bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border-subtle)]' : 'text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]'}`}
|
| 158 |
>
|
| 159 |
<Folder size={14} />
|
| 160 |
<span>All Assets</span>
|
|
|
|
| 163 |
<button
|
| 164 |
key={col.id}
|
| 165 |
onClick={() => setActiveCollectionId(col.id)}
|
| 166 |
+
className={`w-full flex items-center justify-between px-3 py-2 rounded text-xs transition ${activeCollectionId === col.id ? 'bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border-subtle)]' : 'text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] hover:text-[var(--text-primary)]'}`}
|
| 167 |
>
|
| 168 |
<div className="flex items-center space-x-2">
|
| 169 |
<Folder size={14} />
|
|
|
|
| 178 |
<div className="flex-1 overflow-y-auto p-6">
|
| 179 |
{isLoading ? (
|
| 180 |
<div className="flex items-center justify-center h-64">
|
| 181 |
+
<Upload size={48} className="text-[var(--bg-tertiary)] animate-pulse" />
|
| 182 |
</div>
|
| 183 |
) : filteredAssets.length === 0 ? (
|
| 184 |
<div className="flex flex-col items-center justify-center h-64 opacity-50">
|
| 185 |
+
<ImageIcon size={64} className="mb-4 text-[var(--bg-tertiary)]" />
|
| 186 |
+
<p className="text-[var(--text-secondary)]">No assets found in this category.</p>
|
| 187 |
</div>
|
| 188 |
) : (
|
| 189 |
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
|
| 190 |
{filteredAssets.map(asset => (
|
| 191 |
+
<div key={asset.id} className="bg-[var(--bg-secondary)] border border-[var(--border-subtle)] rounded-lg group hover:border-[var(--text-secondary)]/30 transition shadow-sm overflow-hidden">
|
| 192 |
+
<div className="h-32 bg-[var(--bg-primary)] flex items-center justify-center relative overflow-hidden">
|
| 193 |
{asset.category === 'images' ? (
|
| 194 |
<div className="w-full h-full bg-cover bg-center opacity-40 group-hover:opacity-60 transition" style={{ backgroundImage: `url(${import.meta.env.VITE_BACKEND_URL}/uploads/${asset.path})` }} />
|
| 195 |
) : (
|
| 196 |
+
<div className="text-[var(--text-secondary)] opacity-20 uppercase font-black text-4xl select-none">{asset.type.split('/')[1]}</div>
|
| 197 |
)}
|
| 198 |
<div className="absolute inset-0 flex items-center justify-center">
|
| 199 |
{getIcon(asset.category)}
|
|
|
|
| 202 |
<div className="p-3 space-y-2">
|
| 203 |
<div className="flex items-start justify-between">
|
| 204 |
<div className="truncate pr-4">
|
| 205 |
+
<div className="text-xs font-medium text-[var(--text-primary)] truncate" title={asset.name}>{asset.name}</div>
|
| 206 |
+
<div className="text-[10px] text-[var(--text-secondary)] mt-0.5 opacity-60">{(asset.size / 1024).toFixed(1)} KB • {asset.type.split('/')[1]}</div>
|
| 207 |
</div>
|
| 208 |
+
<button onClick={() => handleDeleteAsset(asset.id)} className="text-[var(--text-secondary)] hover:text-red-400 transition opacity-0 group-hover:opacity-100">
|
| 209 |
<Trash2 size={14} />
|
| 210 |
</button>
|
| 211 |
</div>
|
| 212 |
{asset.description && (
|
| 213 |
+
<p className="text-[10px] text-[var(--text-secondary)] line-clamp-2 italic leading-relaxed">"{asset.description}"</p>
|
| 214 |
)}
|
| 215 |
{asset.tags && asset.tags.length > 0 && (
|
| 216 |
<div className="flex flex-wrap gap-1 pt-1">
|
| 217 |
{asset.tags.map(tag => (
|
| 218 |
+
<span key={tag} className="bg-[var(--bg-primary)] border border-[var(--border-subtle)] text-[var(--accent-primary)] text-[9px] px-1.5 py-0.5 rounded flex items-center space-x-1 font-mono">
|
| 219 |
<Tags size={8} />
|
| 220 |
<span>{tag}</span>
|
| 221 |
</span>
|
|
|
|
| 233 |
{/* Upload Modal */}
|
| 234 |
{showUploadModal && (
|
| 235 |
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4">
|
| 236 |
+
<div className="bg-[var(--bg-secondary)] border border-[var(--border-subtle)] rounded-lg shadow-2xl w-full max-w-lg overflow-hidden animate-in fade-in zoom-in duration-200">
|
| 237 |
+
<div className="p-4 border-b border-[var(--border-subtle)] bg-[var(--bg-tertiary)] flex items-center justify-between">
|
| 238 |
+
<h3 className="text-sm font-semibold text-[var(--text-primary)] flex items-center space-x-2">
|
| 239 |
+
<Upload size={16} className="text-[var(--accent-primary)]" />
|
| 240 |
<span>Upload New Asset</span>
|
| 241 |
</h3>
|
| 242 |
+
<button onClick={() => setShowUploadModal(false)} className="text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition"><X size={18} /></button>
|
| 243 |
</div>
|
| 244 |
<div className="p-6 space-y-4">
|
| 245 |
<div
|
| 246 |
onClick={() => document.getElementById('asset-file-input').click()}
|
| 247 |
+
className="border-2 border-dashed border-[var(--border-subtle)] rounded-lg p-8 flex flex-col items-center justify-center cursor-pointer hover:border-[var(--accent-primary)] hover:bg-[var(--accent-primary)]/5 transition"
|
| 248 |
>
|
| 249 |
<input
|
| 250 |
id="asset-file-input"
|
|
|
|
| 256 |
<div className="text-center">
|
| 257 |
<Check size={32} className="text-green-500 mb-2 mx-auto" />
|
| 258 |
<div className="text-xs text-white font-medium">{selectedFile.name}</div>
|
| 259 |
+
<div className="text-[10px] text-[var(--text-secondary)] mt-1">{(selectedFile.size / 1024).toFixed(1)} KB</div>
|
| 260 |
</div>
|
| 261 |
) : (
|
| 262 |
<div className="text-center">
|
| 263 |
+
<Upload size={32} className="text-[var(--text-secondary)] opacity-30 mb-2 mx-auto" />
|
| 264 |
+
<div className="text-xs text-[var(--text-secondary)]">Drag and drop or click to browse</div>
|
| 265 |
+
<div className="text-[10px] text-[var(--text-secondary)] opacity-40 mt-1 italic">Format reasoning: Images, Audio, Video, Docs</div>
|
| 266 |
</div>
|
| 267 |
)}
|
| 268 |
</div>
|
| 269 |
|
| 270 |
<div className="space-y-3">
|
| 271 |
<div className="space-y-1">
|
| 272 |
+
<label className="text-[10px] uppercase font-bold text-[var(--text-secondary)] tracking-wider">Semantic Description (AI Hint)</label>
|
| 273 |
<textarea
|
| 274 |
placeholder="Explain what this file is for (e.g. 'This is the Aadhar card used for user identity verification')"
|
| 275 |
+
className="w-full bg-[var(--bg-primary)] border border-[var(--border-subtle)] text-[var(--text-primary)] p-2.5 text-xs rounded outline-none focus:border-[var(--accent-primary)] resize-none h-20"
|
| 276 |
value={uploadForm.description}
|
| 277 |
onChange={e => setUploadForm({...uploadForm, description: e.target.value})}
|
| 278 |
/>
|
| 279 |
</div>
|
| 280 |
<div className="space-y-1">
|
| 281 |
+
<label className="text-[10px] uppercase font-bold text-[var(--text-secondary)] tracking-wider">Tags (comma separated)</label>
|
| 282 |
<div className="relative">
|
| 283 |
+
<Tags size={14} className="absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)]" />
|
| 284 |
<input
|
| 285 |
type="text"
|
| 286 |
placeholder="aadhar, identity, personal, legal"
|
| 287 |
+
className="w-full bg-[var(--bg-primary)] border border-[var(--border-subtle)] text-[var(--text-primary)] pl-10 pr-3 py-2 text-xs rounded outline-none focus:border-[var(--accent-primary)] font-mono"
|
| 288 |
value={uploadForm.tags}
|
| 289 |
onChange={e => setUploadForm({...uploadForm, tags: e.target.value})}
|
| 290 |
/>
|
|
|
|
| 295 |
<button
|
| 296 |
onClick={handleFileUpload}
|
| 297 |
disabled={!selectedFile || isUploading}
|
| 298 |
+
className="w-full bg-[var(--accent-gradient)] hover:opacity-90 disabled:opacity-50 text-white py-2.5 text-sm font-semibold rounded transition flex items-center justify-center space-x-2"
|
| 299 |
>
|
| 300 |
{isUploading ? <Upload className="animate-spin" size={16} /> : <Check size={16} />}
|
| 301 |
<span>{isUploading ? 'Uploading...' : 'Finalize Upload'}</span>
|
|
|
|
| 308 |
{/* New Collection Modal */}
|
| 309 |
{showNewCollectionModal && (
|
| 310 |
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4">
|
| 311 |
+
<div className="bg-[var(--bg-secondary)] border border-[var(--border-subtle)] rounded-lg shadow-2xl w-full max-w-sm overflow-hidden animate-in fade-in zoom-in duration-200">
|
| 312 |
+
<div className="p-4 border-b border-[var(--border-subtle)] bg-[var(--bg-tertiary)] flex items-center justify-between">
|
| 313 |
+
<h3 className="text-sm font-semibold text-[var(--text-primary)] flex items-center space-x-2">
|
| 314 |
+
<Plus size={16} className="text-emerald-500" />
|
| 315 |
<span>New Collection</span>
|
| 316 |
</h3>
|
| 317 |
+
<button onClick={() => setShowNewCollectionModal(false)} className="text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition"><X size={18} /></button>
|
| 318 |
</div>
|
| 319 |
<div className="p-6 space-y-4">
|
| 320 |
<div className="space-y-3">
|
| 321 |
<div className="space-y-1">
|
| 322 |
+
<label className="text-[10px] uppercase font-bold text-[var(--text-secondary)] tracking-wider">Collection Name</label>
|
| 323 |
<input
|
| 324 |
type="text"
|
| 325 |
+
className="w-full bg-[var(--bg-primary)] border border-[var(--border-subtle)] text-[var(--text-primary)] px-3 py-2 text-xs rounded outline-none focus:border-[var(--accent-primary)]"
|
| 326 |
value={newColForm.name}
|
| 327 |
onChange={e => setNewColForm({...newColForm, name: e.target.value})}
|
| 328 |
/>
|
| 329 |
</div>
|
| 330 |
<div className="space-y-1">
|
| 331 |
+
<label className="text-[10px] uppercase font-bold text-[var(--text-secondary)] tracking-wider">Description</label>
|
| 332 |
<textarea
|
| 333 |
+
className="w-full bg-[var(--bg-primary)] border border-[var(--border-subtle)] text-[var(--text-primary)] p-2.5 text-xs rounded outline-none focus:border-[var(--accent-primary)] resize-none h-20"
|
| 334 |
value={newColForm.description}
|
| 335 |
onChange={e => setNewColForm({...newColForm, description: e.target.value})}
|
| 336 |
/>
|
|
|
|
| 338 |
</div>
|
| 339 |
<button
|
| 340 |
onClick={handleCreateCollection}
|
| 341 |
+
className="w-full bg-[var(--accent-gradient)] hover:opacity-90 text-white py-2.5 text-sm font-semibold rounded transition shadow-lg"
|
| 342 |
>
|
| 343 |
Create Collection
|
| 344 |
</button>
|
frontend-react/src/components/ProfilePage.jsx
CHANGED
|
@@ -55,18 +55,18 @@ const ProfilePage = () => {
|
|
| 55 |
|
| 56 |
if (!activeSpecId) {
|
| 57 |
return (
|
| 58 |
-
<div className="flex-1 flex flex-col items-center justify-center p-8 text-center bg-[
|
| 59 |
-
<div className="p-8 bg-[
|
| 60 |
-
<div className="w-16 h-16 bg-[
|
| 61 |
-
<Server size={32} className="text-
|
| 62 |
</div>
|
| 63 |
-
<h2 className="text-2xl font-semibold text-
|
| 64 |
-
<p className="text-
|
| 65 |
Test user profiles are isolated per collection. Please select an API specification first to manage its credentials.
|
| 66 |
</p>
|
| 67 |
<button
|
| 68 |
onClick={() => window.dispatchEvent(new CustomEvent('nav-change', { detail: 'collections' }))}
|
| 69 |
-
className="w-full py-3 bg-[
|
| 70 |
>
|
| 71 |
<Database size={16} />
|
| 72 |
<span>Browse Collections</span>
|
|
@@ -77,23 +77,23 @@ const ProfilePage = () => {
|
|
| 77 |
}
|
| 78 |
|
| 79 |
return (
|
| 80 |
-
<div className="flex-1 flex flex-col bg-[
|
| 81 |
{/* Header */}
|
| 82 |
-
<div className="h-14 border-b border-[
|
| 83 |
<div className="flex items-center space-x-4">
|
| 84 |
-
<h1 className="text-lg font-medium text-
|
| 85 |
-
<Settings size={20} className="text-[
|
| 86 |
<span>Test User Profile</span>
|
| 87 |
</h1>
|
| 88 |
-
<div className="h-6 w-px bg-[
|
| 89 |
-
<div className="text-xs text-
|
| 90 |
-
Current Spec: <span className="text-[
|
| 91 |
</div>
|
| 92 |
</div>
|
| 93 |
<button
|
| 94 |
onClick={handleSave}
|
| 95 |
disabled={isSaving}
|
| 96 |
-
className="bg-
|
| 97 |
>
|
| 98 |
{isSaving ? <RefreshCw size={14} className="animate-spin" /> : <Save size={14} />}
|
| 99 |
<span>Save Profile</span>
|
|
@@ -105,56 +105,56 @@ const ProfilePage = () => {
|
|
| 105 |
{/* Core Credentials */}
|
| 106 |
<section className="space-y-4">
|
| 107 |
<div className="flex items-center space-x-3 mb-6">
|
| 108 |
-
<div className="p-2 bg-[
|
| 109 |
-
<Lock size={18} className="text-[
|
| 110 |
</div>
|
| 111 |
-
<h3 className="text-sm font-semibold text-
|
| 112 |
</div>
|
| 113 |
|
| 114 |
-
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 bg-[
|
| 115 |
<div className="space-y-2">
|
| 116 |
-
<label className="text-[10px] uppercase font-bold text-
|
| 117 |
Full Name
|
| 118 |
</label>
|
| 119 |
<input
|
| 120 |
type="text"
|
| 121 |
-
className="w-full bg-[
|
| 122 |
value={profileForm.name}
|
| 123 |
onChange={e => setProfileForm({...profileForm, name: e.target.value})}
|
| 124 |
placeholder="e.g. John Doe"
|
| 125 |
/>
|
| 126 |
</div>
|
| 127 |
<div className="space-y-2">
|
| 128 |
-
<label className="text-[10px] uppercase font-bold text-
|
| 129 |
Email / Username
|
| 130 |
</label>
|
| 131 |
<input
|
| 132 |
type="text"
|
| 133 |
-
className="w-full bg-[
|
| 134 |
value={profileForm.email}
|
| 135 |
onChange={e => setProfileForm({...profileForm, email: e.target.value})}
|
| 136 |
placeholder="e.g. john.doe@example.com"
|
| 137 |
/>
|
| 138 |
</div>
|
| 139 |
<div className="space-y-2">
|
| 140 |
-
<label className="text-[10px] uppercase font-bold text-
|
| 141 |
Password
|
| 142 |
</label>
|
| 143 |
<input
|
| 144 |
type="password"
|
| 145 |
-
className="w-full bg-[
|
| 146 |
value={profileForm.password}
|
| 147 |
onChange={e => setProfileForm({...profileForm, password: e.target.value})}
|
| 148 |
placeholder="Leave blank to keep current"
|
| 149 |
/>
|
| 150 |
</div>
|
| 151 |
<div className="space-y-2">
|
| 152 |
-
<label className="text-[10px] uppercase font-bold text-
|
| 153 |
Static Access Token
|
| 154 |
</label>
|
| 155 |
<input
|
| 156 |
type="text"
|
| 157 |
-
className="w-full bg-[
|
| 158 |
value={profileForm.token}
|
| 159 |
onChange={e => setProfileForm({...profileForm, token: e.target.value})}
|
| 160 |
placeholder="Skip login flow with a manual token"
|
|
@@ -167,14 +167,14 @@ const ProfilePage = () => {
|
|
| 167 |
<section className="space-y-4">
|
| 168 |
<div className="flex items-center justify-between mb-4 px-1">
|
| 169 |
<div className="flex items-center space-x-3">
|
| 170 |
-
<div className="p-2 bg-
|
| 171 |
-
<Key size={18} className="text-
|
| 172 |
</div>
|
| 173 |
-
<h3 className="text-sm font-semibold text-
|
| 174 |
</div>
|
| 175 |
<button
|
| 176 |
onClick={() => setExtraKvs([...extraKvs, {key: '', val: ''}])}
|
| 177 |
-
className="text-xs bg-[
|
| 178 |
>
|
| 179 |
<Plus size={14} />
|
| 180 |
<span>Add Variables</span>
|
|
@@ -182,35 +182,35 @@ const ProfilePage = () => {
|
|
| 182 |
</div>
|
| 183 |
|
| 184 |
{extraKvs.length === 0 ? (
|
| 185 |
-
<div className="py-16 bg-[
|
| 186 |
-
<p className="text-
|
| 187 |
</div>
|
| 188 |
) : (
|
| 189 |
<div className="grid grid-cols-1 gap-3">
|
| 190 |
{extraKvs.map((kv, i) => (
|
| 191 |
<div key={i} className="flex space-x-3 group animate-in slide-in-from-left-2 duration-300">
|
| 192 |
-
<div className="flex-1 bg-[
|
| 193 |
-
<div className="bg-[
|
| 194 |
-
<span className="text-[10px] text-
|
| 195 |
</div>
|
| 196 |
<input
|
| 197 |
type="text"
|
| 198 |
placeholder="Key"
|
| 199 |
-
className="w-1/3 bg-transparent border-r border-[
|
| 200 |
value={kv.key}
|
| 201 |
onChange={e => { const n = [...extraKvs]; n[i].key = e.target.value; setExtraKvs(n); }}
|
| 202 |
/>
|
| 203 |
<input
|
| 204 |
type="text"
|
| 205 |
placeholder="Value"
|
| 206 |
-
className="flex-1 bg-transparent text-[
|
| 207 |
value={kv.val}
|
| 208 |
onChange={e => { const n = [...extraKvs]; n[i].val = e.target.value; setExtraKvs(n); }}
|
| 209 |
/>
|
| 210 |
</div>
|
| 211 |
<button
|
| 212 |
onClick={() => setExtraKvs(extraKvs.filter((_, idx) => idx !== i))}
|
| 213 |
-
className="text-
|
| 214 |
>
|
| 215 |
<Trash2 size={16} />
|
| 216 |
</button>
|
|
|
|
| 55 |
|
| 56 |
if (!activeSpecId) {
|
| 57 |
return (
|
| 58 |
+
<div className="flex-1 flex flex-col items-center justify-center p-8 text-center bg-[var(--bg-primary)] animate-in fade-in duration-500">
|
| 59 |
+
<div className="p-8 bg-[var(--bg-secondary)] border border-[var(--border-subtle)] rounded-3xl shadow-2xl max-w-md w-full animate-in zoom-in duration-300">
|
| 60 |
+
<div className="w-16 h-16 bg-[var(--bg-tertiary)] border border-[var(--border-subtle)] rounded-2xl flex items-center justify-center mx-auto mb-6">
|
| 61 |
+
<Server size={32} className="text-[var(--text-secondary)] opacity-50" />
|
| 62 |
</div>
|
| 63 |
+
<h2 className="text-2xl font-semibold text-[var(--text-primary)] mb-2">No Collection Selected</h2>
|
| 64 |
+
<p className="text-[var(--text-secondary)] text-sm mb-8 leading-relaxed">
|
| 65 |
Test user profiles are isolated per collection. Please select an API specification first to manage its credentials.
|
| 66 |
</p>
|
| 67 |
<button
|
| 68 |
onClick={() => window.dispatchEvent(new CustomEvent('nav-change', { detail: 'collections' }))}
|
| 69 |
+
className="w-full py-3 bg-[var(--accent-gradient)] hover:opacity-90 text-white text-sm font-bold rounded-xl transition shadow-lg flex items-center justify-center space-x-2"
|
| 70 |
>
|
| 71 |
<Database size={16} />
|
| 72 |
<span>Browse Collections</span>
|
|
|
|
| 77 |
}
|
| 78 |
|
| 79 |
return (
|
| 80 |
+
<div className="flex-1 flex flex-col bg-[var(--bg-primary)] overflow-hidden animate-in fade-in slide-in-from-bottom-2 duration-300">
|
| 81 |
{/* Header */}
|
| 82 |
+
<div className="h-14 border-b border-[var(--border-subtle)] flex items-center justify-between px-6 bg-[var(--bg-secondary)]">
|
| 83 |
<div className="flex items-center space-x-4">
|
| 84 |
+
<h1 className="text-lg font-medium text-[var(--text-primary)] flex items-center space-x-2">
|
| 85 |
+
<Settings size={20} className="text-[var(--accent-primary)]" />
|
| 86 |
<span>Test User Profile</span>
|
| 87 |
</h1>
|
| 88 |
+
<div className="h-6 w-px bg-[var(--border-subtle)]" />
|
| 89 |
+
<div className="text-xs text-[var(--text-secondary)]">
|
| 90 |
+
Current Spec: <span className="text-[var(--accent-primary)] font-mono">{activeSpecName}</span>
|
| 91 |
</div>
|
| 92 |
</div>
|
| 93 |
<button
|
| 94 |
onClick={handleSave}
|
| 95 |
disabled={isSaving}
|
| 96 |
+
className="bg-[var(--accent-gradient)] hover:opacity-90 text-white px-6 py-1.5 text-xs font-semibold rounded-lg flex items-center space-x-2 transition shadow-lg disabled:opacity-50"
|
| 97 |
>
|
| 98 |
{isSaving ? <RefreshCw size={14} className="animate-spin" /> : <Save size={14} />}
|
| 99 |
<span>Save Profile</span>
|
|
|
|
| 105 |
{/* Core Credentials */}
|
| 106 |
<section className="space-y-4">
|
| 107 |
<div className="flex items-center space-x-3 mb-6">
|
| 108 |
+
<div className="p-2 bg-[var(--accent-primary)]/10 border border-[var(--accent-primary)]/20 rounded-lg">
|
| 109 |
+
<Lock size={18} className="text-[var(--accent-primary)]" />
|
| 110 |
</div>
|
| 111 |
+
<h3 className="text-sm font-semibold text-[var(--text-primary)]">Core Authentication</h3>
|
| 112 |
</div>
|
| 113 |
|
| 114 |
+
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 bg-[var(--bg-secondary)] p-6 rounded-2xl border border-[var(--border-subtle)] shadow-sm">
|
| 115 |
<div className="space-y-2">
|
| 116 |
+
<label className="text-[10px] uppercase font-bold text-[var(--text-secondary)] tracking-wider flex items-center gap-2">
|
| 117 |
Full Name
|
| 118 |
</label>
|
| 119 |
<input
|
| 120 |
type="text"
|
| 121 |
+
className="w-full bg-[var(--bg-primary)] border border-[var(--border-subtle)] text-[var(--text-primary)] p-2.5 text-sm rounded-lg outline-none focus:border-[var(--accent-primary)] transition-colors"
|
| 122 |
value={profileForm.name}
|
| 123 |
onChange={e => setProfileForm({...profileForm, name: e.target.value})}
|
| 124 |
placeholder="e.g. John Doe"
|
| 125 |
/>
|
| 126 |
</div>
|
| 127 |
<div className="space-y-2">
|
| 128 |
+
<label className="text-[10px] uppercase font-bold text-[var(--text-secondary)] tracking-wider flex items-center gap-2">
|
| 129 |
Email / Username
|
| 130 |
</label>
|
| 131 |
<input
|
| 132 |
type="text"
|
| 133 |
+
className="w-full bg-[var(--bg-primary)] border border-[var(--border-subtle)] text-[var(--text-primary)] p-2.5 text-sm rounded-lg outline-none focus:border-[var(--accent-primary)] transition-colors"
|
| 134 |
value={profileForm.email}
|
| 135 |
onChange={e => setProfileForm({...profileForm, email: e.target.value})}
|
| 136 |
placeholder="e.g. john.doe@example.com"
|
| 137 |
/>
|
| 138 |
</div>
|
| 139 |
<div className="space-y-2">
|
| 140 |
+
<label className="text-[10px] uppercase font-bold text-[var(--text-secondary)] tracking-wider flex items-center gap-2">
|
| 141 |
Password
|
| 142 |
</label>
|
| 143 |
<input
|
| 144 |
type="password"
|
| 145 |
+
className="w-full bg-[var(--bg-primary)] border border-[var(--border-subtle)] text-[var(--text-primary)] p-2.5 text-sm rounded-lg outline-none focus:border-[var(--accent-primary)] transition-colors"
|
| 146 |
value={profileForm.password}
|
| 147 |
onChange={e => setProfileForm({...profileForm, password: e.target.value})}
|
| 148 |
placeholder="Leave blank to keep current"
|
| 149 |
/>
|
| 150 |
</div>
|
| 151 |
<div className="space-y-2">
|
| 152 |
+
<label className="text-[10px] uppercase font-bold text-[var(--text-secondary)] tracking-wider flex items-center gap-2">
|
| 153 |
Static Access Token
|
| 154 |
</label>
|
| 155 |
<input
|
| 156 |
type="text"
|
| 157 |
+
className="w-full bg-[var(--bg-primary)] border border-[var(--border-subtle)] text-[var(--text-primary)] p-2.5 text-sm rounded-lg outline-none focus:border-[var(--accent-primary)] transition-colors"
|
| 158 |
value={profileForm.token}
|
| 159 |
onChange={e => setProfileForm({...profileForm, token: e.target.value})}
|
| 160 |
placeholder="Skip login flow with a manual token"
|
|
|
|
| 167 |
<section className="space-y-4">
|
| 168 |
<div className="flex items-center justify-between mb-4 px-1">
|
| 169 |
<div className="flex items-center space-x-3">
|
| 170 |
+
<div className="p-2 bg-[var(--accent-secondary)]/10 border border-[var(--accent-secondary)]/20 rounded-lg">
|
| 171 |
+
<Key size={18} className="text-[var(--accent-secondary)]" />
|
| 172 |
</div>
|
| 173 |
+
<h3 className="text-sm font-semibold text-[var(--text-primary)]">Custom Fields & Context</h3>
|
| 174 |
</div>
|
| 175 |
<button
|
| 176 |
onClick={() => setExtraKvs([...extraKvs, {key: '', val: ''}])}
|
| 177 |
+
className="text-xs bg-[var(--bg-tertiary)] hover:bg-[var(--bg-secondary)] text-[var(--text-primary)] px-3 py-1.5 rounded-lg border border-[var(--border-subtle)] flex items-center gap-1.5 transition shadow-sm"
|
| 178 |
>
|
| 179 |
<Plus size={14} />
|
| 180 |
<span>Add Variables</span>
|
|
|
|
| 182 |
</div>
|
| 183 |
|
| 184 |
{extraKvs.length === 0 ? (
|
| 185 |
+
<div className="py-16 bg-[var(--bg-secondary)] border-2 border-dashed border-[var(--border-subtle)] rounded-2xl text-center shadow-inner">
|
| 186 |
+
<p className="text-[var(--text-secondary)] text-sm italic">No custom variables defined. Use these for OTPs, User IDs, or custom test data pointers.</p>
|
| 187 |
</div>
|
| 188 |
) : (
|
| 189 |
<div className="grid grid-cols-1 gap-3">
|
| 190 |
{extraKvs.map((kv, i) => (
|
| 191 |
<div key={i} className="flex space-x-3 group animate-in slide-in-from-left-2 duration-300">
|
| 192 |
+
<div className="flex-1 bg-[var(--bg-secondary)] border border-[var(--border-subtle)] rounded-xl overflow-hidden shadow-sm flex items-center group-hover:border-[var(--text-secondary)]/30 transition-colors">
|
| 193 |
+
<div className="bg-[var(--bg-primary)] border-r border-[var(--border-subtle)] px-3 py-2 flex items-center justify-center">
|
| 194 |
+
<span className="text-[10px] text-[var(--text-secondary)] font-bold uppercase tracking-tighter w-4 text-center">KV</span>
|
| 195 |
</div>
|
| 196 |
<input
|
| 197 |
type="text"
|
| 198 |
placeholder="Key"
|
| 199 |
+
className="w-1/3 bg-transparent border-r border-[var(--border-subtle)] text-[var(--accent-primary)] px-4 py-2.5 text-xs outline-none focus:bg-[var(--bg-tertiary)] transition-colors font-mono"
|
| 200 |
value={kv.key}
|
| 201 |
onChange={e => { const n = [...extraKvs]; n[i].key = e.target.value; setExtraKvs(n); }}
|
| 202 |
/>
|
| 203 |
<input
|
| 204 |
type="text"
|
| 205 |
placeholder="Value"
|
| 206 |
+
className="flex-1 bg-transparent text-[var(--accent-secondary)] px-4 py-2.5 text-xs outline-none focus:bg-[var(--bg-tertiary)] transition-colors font-mono"
|
| 207 |
value={kv.val}
|
| 208 |
onChange={e => { const n = [...extraKvs]; n[i].val = e.target.value; setExtraKvs(n); }}
|
| 209 |
/>
|
| 210 |
</div>
|
| 211 |
<button
|
| 212 |
onClick={() => setExtraKvs(extraKvs.filter((_, idx) => idx !== i))}
|
| 213 |
+
className="text-[var(--text-secondary)] hover:text-red-400 p-2 opacity-0 group-hover:opacity-100 transition-all self-center"
|
| 214 |
>
|
| 215 |
<Trash2 size={16} />
|
| 216 |
</button>
|
frontend-react/src/components/SettingsPage.jsx
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import React from 'react';
|
| 2 |
+
import { Settings, Shield, Bell, Cpu } from 'lucide-react';
|
| 3 |
+
|
| 4 |
+
const SettingsPage = () => {
|
| 5 |
+
return (
|
| 6 |
+
<div className="flex-1 overflow-y-auto p-8 bg-[var(--bg-primary)] animate-in fade-in duration-300">
|
| 7 |
+
<div className="max-w-4xl mx-auto">
|
| 8 |
+
<header className="mb-10">
|
| 9 |
+
<h1 className="text-3xl font-bold text-[var(--text-primary)] mb-2">Settings</h1>
|
| 10 |
+
<p className="text-[var(--text-secondary)]">Manage your workspace and application preferences.</p>
|
| 11 |
+
</header>
|
| 12 |
+
|
| 13 |
+
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
| 14 |
+
{/* General Section */}
|
| 15 |
+
<section className="bg-[var(--bg-secondary)] border border-[var(--border-subtle)] rounded-xl p-6 shadow-sm">
|
| 16 |
+
<div className="flex items-center space-x-3 mb-4">
|
| 17 |
+
<Settings className="text-[var(--accent-primary)]" size={20} />
|
| 18 |
+
<h2 className="text-lg font-semibold text-[var(--text-primary)]">General</h2>
|
| 19 |
+
</div>
|
| 20 |
+
<div className="space-y-4">
|
| 21 |
+
<div className="flex items-center justify-between p-3 bg-[var(--bg-tertiary)] rounded-lg border border-[var(--border-subtle)]">
|
| 22 |
+
<span className="text-sm text-[var(--text-primary)]">Dark Mode</span>
|
| 23 |
+
<div className="w-10 h-5 bg-[var(--accent-primary)] rounded-full relative">
|
| 24 |
+
<div className="absolute right-0.5 top-0.5 w-4 h-4 bg-white rounded-full shadow-sm"></div>
|
| 25 |
+
</div>
|
| 26 |
+
</div>
|
| 27 |
+
<div className="p-3 bg-[var(--bg-tertiary)] rounded-lg border border-[var(--border-subtle)] opacity-50 cursor-not-allowed">
|
| 28 |
+
<span className="text-xs text-[var(--text-secondary)] uppercase font-bold tracking-wider">UI Scale</span>
|
| 29 |
+
<div className="mt-2 h-1 bg-[var(--bg-secondary)] rounded-full overflow-hidden">
|
| 30 |
+
<div className="w-1/2 h-full bg-[var(--accent-primary)]"></div>
|
| 31 |
+
</div>
|
| 32 |
+
</div>
|
| 33 |
+
</div>
|
| 34 |
+
</section>
|
| 35 |
+
|
| 36 |
+
{/* AI Configuration */}
|
| 37 |
+
<section className="bg-[var(--bg-secondary)] border border-[var(--border-subtle)] rounded-xl p-6 shadow-sm">
|
| 38 |
+
<div className="flex items-center space-x-3 mb-4">
|
| 39 |
+
<Cpu className="text-[var(--accent-primary)]" size={20} />
|
| 40 |
+
<h2 className="text-lg font-semibold text-[var(--text-primary)]">AI Engine</h2>
|
| 41 |
+
</div>
|
| 42 |
+
<div className="space-y-4">
|
| 43 |
+
<div className="p-3 bg-[var(--bg-tertiary)] rounded-lg border border-[var(--border-subtle)]">
|
| 44 |
+
<label className="text-[10px] text-[var(--text-secondary)] uppercase font-bold mb-1 block">Provider</label>
|
| 45 |
+
<div className="text-sm text-[var(--text-primary)]">OpenAI GPT-4o</div>
|
| 46 |
+
</div>
|
| 47 |
+
<div className="p-3 bg-[var(--bg-tertiary)] rounded-lg border border-[var(--border-subtle)]">
|
| 48 |
+
<label className="text-[10px] text-[var(--text-secondary)] uppercase font-bold mb-1 block">Streaming</label>
|
| 49 |
+
<div className="text-xs text-[var(--accent-primary)]">Enabled</div>
|
| 50 |
+
</div>
|
| 51 |
+
</div>
|
| 52 |
+
</section>
|
| 53 |
+
|
| 54 |
+
{/* Security */}
|
| 55 |
+
<section className="bg-[var(--bg-secondary)] border border-[var(--border-subtle)] rounded-xl p-6 shadow-sm">
|
| 56 |
+
<div className="flex items-center space-x-3 mb-4">
|
| 57 |
+
<Shield className="text-[var(--accent-primary)]" size={20} />
|
| 58 |
+
<h2 className="text-lg font-semibold text-[var(--text-primary)]">Security</h2>
|
| 59 |
+
</div>
|
| 60 |
+
<div className="space-y-4 text-center py-4">
|
| 61 |
+
<p className="text-xs text-[var(--text-secondary)] px-4">Workspace encryption and access controls are managed by the administrator.</p>
|
| 62 |
+
<button className="text-xs text-[var(--accent-primary)] hover:underline">View Policy</button>
|
| 63 |
+
</div>
|
| 64 |
+
</section>
|
| 65 |
+
|
| 66 |
+
{/* placeholder for other sections */}
|
| 67 |
+
<div className="bg-[var(--bg-secondary)] border border-[var(--border-subtle)] border-dashed rounded-xl p-6 flex flex-col items-center justify-center text-center opacity-40">
|
| 68 |
+
<Bell className="mb-2" size={24} />
|
| 69 |
+
<p className="text-xs">More settings coming soon</p>
|
| 70 |
+
</div>
|
| 71 |
+
</div>
|
| 72 |
+
</div>
|
| 73 |
+
</div>
|
| 74 |
+
);
|
| 75 |
+
};
|
| 76 |
+
|
| 77 |
+
export default SettingsPage;
|
frontend-react/src/index.css
CHANGED
|
@@ -1,8 +1,25 @@
|
|
| 1 |
@import "tailwindcss";
|
| 2 |
|
| 3 |
@layer base {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
body {
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
}
|
| 7 |
}
|
| 8 |
|
|
@@ -15,8 +32,9 @@
|
|
| 15 |
background: transparent;
|
| 16 |
}
|
| 17 |
::-webkit-scrollbar-thumb {
|
| 18 |
-
|
|
|
|
| 19 |
}
|
| 20 |
::-webkit-scrollbar-thumb:hover {
|
| 21 |
-
|
| 22 |
}
|
|
|
|
| 1 |
@import "tailwindcss";
|
| 2 |
|
| 3 |
@layer base {
|
| 4 |
+
:root {
|
| 5 |
+
--bg-primary: #0b0b0f;
|
| 6 |
+
--bg-secondary: #111117;
|
| 7 |
+
--bg-tertiary: #18181f;
|
| 8 |
+
|
| 9 |
+
--accent-primary: #6366f1;
|
| 10 |
+
--accent-secondary: #8b5cf6;
|
| 11 |
+
--accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
|
| 12 |
+
|
| 13 |
+
--text-primary: #f8fafc;
|
| 14 |
+
--text-secondary: #a1a1aa;
|
| 15 |
+
|
| 16 |
+
--border-subtle: #26262b;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
body {
|
| 20 |
+
background-color: var(--bg-primary);
|
| 21 |
+
color: var(--text-primary);
|
| 22 |
+
@apply antialiased overflow-hidden;
|
| 23 |
}
|
| 24 |
}
|
| 25 |
|
|
|
|
| 32 |
background: transparent;
|
| 33 |
}
|
| 34 |
::-webkit-scrollbar-thumb {
|
| 35 |
+
background: var(--border-subtle);
|
| 36 |
+
border-radius: 9999px;
|
| 37 |
}
|
| 38 |
::-webkit-scrollbar-thumb:hover {
|
| 39 |
+
background: var(--text-secondary);
|
| 40 |
}
|
supbase implementation implementation_plan
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Supabase Database Integration Plan
|
| 2 |
+
|
| 3 |
+
Replace the local SQLite database with Supabase (PostgreSQL). No auth changes. Data models stay the same.
|
| 4 |
+
|
| 5 |
+
## How It Works
|
| 6 |
+
|
| 7 |
+
The backend already uses SQLAlchemy ORM and already reads `DATABASE_URL` from the environment. Supabase provides a standard PostgreSQL connection string, so all we need to do is:
|
| 8 |
+
1. Create the tables in Supabase.
|
| 9 |
+
2. Set the `DATABASE_URL` env variable to point to Supabase.
|
| 10 |
+
3. Remove the SQLite migration logic (no longer needed).
|
| 11 |
+
4. Install the `psycopg2` PostgreSQL driver.
|
| 12 |
+
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
## Proposed Changes
|
| 16 |
+
|
| 17 |
+
### Backend
|
| 18 |
+
|
| 19 |
+
#### [MODIFY] [database.py](file:///C:/Users/amitk/OneDrive/Desktop/Testing/backend/database.py)
|
| 20 |
+
- Remove [run_migrations()](file:///C:/Users/amitk/OneDrive/Desktop/Testing/backend/database.py#101-162) function and the `connect_args` SQLite workaround.
|
| 21 |
+
- Add a check: if no `DATABASE_URL` is set, raise a clear error instead of defaulting to SQLite.
|
| 22 |
+
- Ensure `create_all()` runs on startup to create any missing tables in Supabase automatically.
|
| 23 |
+
|
| 24 |
+
#### [MODIFY] [requirements.txt](file:///C:/Users/amitk/OneDrive/Desktop/Testing/requirements.txt)
|
| 25 |
+
- Add `psycopg2-binary` (PostgreSQL driver for Python).
|
| 26 |
+
|
| 27 |
+
#### [MODIFY] [.env.example](file:///C:/Users/amitk/OneDrive/Desktop/Testing/.env.example)
|
| 28 |
+
- Add `SUPABASE_DB_URL` or `DATABASE_URL` example pointing to the Supabase connection string format.
|
| 29 |
+
|
| 30 |
+
### Supabase Setup (One-time, manual)
|
| 31 |
+
|
| 32 |
+
> [!IMPORTANT]
|
| 33 |
+
> You need to get your Supabase **Connection String** (Session Mode / Pooler) from your project's **Settings → Database** page.
|
| 34 |
+
|
| 35 |
+
The connection string format is:
|
| 36 |
+
```
|
| 37 |
+
postgresql://postgres.<project-ref>:<password>@aws-0-<region>.pooler.supabase.com:5432/postgres
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
Set this as `DATABASE_URL` in your `.env` file. SQLAlchemy's `create_all()` will automatically create the tables on first boot.
|
| 41 |
+
|
| 42 |
+
---
|
| 43 |
+
|
| 44 |
+
## Tables That Will Be Created
|
| 45 |
+
|
| 46 |
+
| Table | Description |
|
| 47 |
+
|---|---|
|
| 48 |
+
| `spec_documents` | API collections/specs with credentials and plans |
|
| 49 |
+
| `sessions` | Active test sessions and context |
|
| 50 |
+
| `execution_history` | Step-by-step results from test runs |
|
| 51 |
+
| `collections` | Logical groupings for assets |
|
| 52 |
+
| `assets` | Uploaded files (audio, video, docs, images) |
|
| 53 |
+
| `asset_collections` | Many-to-many junction table |
|
| 54 |
+
|
| 55 |
+
---
|
| 56 |
+
|
| 57 |
+
## Verification Plan
|
| 58 |
+
|
| 59 |
+
### Automated Tests
|
| 60 |
+
- Run `npm run dev` and start the backend — no startup errors should occur.
|
| 61 |
+
- Upload a spec, run a plan, and verify data persists in Supabase's Table Editor.
|
| 62 |
+
|
| 63 |
+
### Manual Verification
|
| 64 |
+
- Visit Supabase → Table Editor and confirm all 6 tables exist with the correct columns.
|
| 65 |
+
- Add a collection, then restart the server — data should still be present.
|