@@ -401,6 +401,139 @@ import { SchemaImporterService } from '../../../../services/schema-importer.serv
401401 </div>
402402 </div>
403403 }
404+
405+ <!-- Import Modal -->
406+ @if (showImportModal()) {
407+ <div class="modal d-block" tabindex="-1" role="dialog" (click)="showImportModal.set(false)">
408+ <div class="modal-dialog modal-lg" role="document" (click)="$event.stopPropagation()">
409+ <div class="modal-content">
410+ <div class="modal-header">
411+ <h5 class="modal-title">
412+ <i class="bi bi-file-earmark-arrow-up me-2"></i>
413+ Import Additional Entities
414+ </h5>
415+ <button
416+ type="button"
417+ class="btn-close"
418+ (click)="showImportModal.set(false)"
419+ aria-label="Close"
420+ ></button>
421+ </div>
422+ <div class="modal-body">
423+ <p class="text-muted mb-4">
424+ Import your database schema to automatically generate entity configurations. All
425+ discovered tables will be added to your existing entities.
426+ </p>
427+
428+ <div class="row g-3">
429+ <!-- JSON Import -->
430+ <div class="col-md-4">
431+ <div
432+ class="import-option p-4 border rounded text-center h-100"
433+ [class.active]="importMode() === 'json'"
434+ (click)="selectImportMode('json')"
435+ >
436+ <i class="bi bi-filetype-json display-4 text-primary mb-3 d-block"></i>
437+ <h6>Import JSON File</h6>
438+ <p class="text-muted small mb-0">Upload a JSON file with table definitions</p>
439+ </div>
440+ </div>
441+
442+ <!-- SQL Import -->
443+ <div class="col-md-4">
444+ <div
445+ class="import-option p-4 border rounded text-center h-100"
446+ [class.active]="importMode() === 'sql'"
447+ (click)="selectImportMode('sql')"
448+ >
449+ <i class="bi bi-file-earmark-code display-4 text-success mb-3 d-block"></i>
450+ <h6>Paste SQL</h6>
451+ <p class="text-muted small mb-0">Paste CREATE TABLE statements</p>
452+ </div>
453+ </div>
454+
455+ <!-- Manual Entry -->
456+ <div class="col-md-4">
457+ <div
458+ class="import-option p-4 border rounded text-center h-100"
459+ [class.active]="importMode() === 'manual'"
460+ (click)="selectImportMode('manual')"
461+ >
462+ <i class="bi bi-pencil-square display-4 text-warning mb-3 d-block"></i>
463+ <h6>Manual Entry</h6>
464+ <p class="text-muted small mb-0">Add entities manually one by one</p>
465+ </div>
466+ </div>
467+ </div>
468+
469+ <!-- JSON File Upload -->
470+ @if (importMode() === 'json') {
471+ <div class="mt-4">
472+ <label for="jsonFileModal" class="form-label">Select JSON Schema File</label>
473+ <input
474+ type="file"
475+ id="jsonFileModal"
476+ class="form-control"
477+ accept=".json"
478+ (change)="onFileSelected($event)"
479+ />
480+ <small class="form-text text-muted">
481+ Expected format: { "tables": [{ "name": "...", "schema": "...",
482+ "columns": [...] }] }
483+ </small>
484+ </div>
485+ }
486+
487+ <!-- SQL Paste -->
488+ @if (importMode() === 'sql') {
489+ <div class="mt-4">
490+ <label for="sqlInputModal" class="form-label">
491+ Paste CREATE TABLE Statements
492+ </label>
493+ <textarea
494+ id="sqlInputModal"
495+ class="form-control font-monospace"
496+ rows="10"
497+ placeholder="CREATE TABLE dbo.Users (
498+ Id INT PRIMARY KEY,
499+ Name NVARCHAR(100) NOT NULL,
500+ Email NVARCHAR(255) NOT NULL,
501+ CreatedAt DATETIME2
502+ );"
503+ [(ngModel)]="sqlInput"
504+ ></textarea>
505+ <button
506+ type="button"
507+ class="btn btn-primary mt-3"
508+ [disabled]="!sqlInput()"
509+ (click)="importSql()"
510+ >
511+ <i class="bi bi-upload me-1"></i>
512+ Parse and Import
513+ </button>
514+ </div>
515+ }
516+
517+ <!-- Manual Entry -->
518+ @if (importMode() === 'manual') {
519+ <div class="mt-4 text-center">
520+ <button type="button" class="btn btn-primary" (click)="addEntityFromModal()">
521+ <i class="bi bi-plus-lg me-1"></i>
522+ Add Entity Manually
523+ </button>
524+ </div>
525+ }
526+ </div>
527+ <div class="modal-footer">
528+ <button type="button" class="btn btn-secondary" (click)="closeImportModal()">
529+ Close
530+ </button>
531+ </div>
532+ </div>
533+ </div>
534+ </div>
535+ <div class="modal-backdrop show"></div>
536+ }
404537 </div>
405538 ` ,
406539 styles : `
@@ -504,8 +637,13 @@ export class EntitiesTabComponent {
504637 const entities = await this . schemaImporter . importAndGenerate ( file ) ;
505638 this . notifications . success ( `Imported ${ entities . length } entities` ) ;
506639 this . importMode . set ( null ) ;
640+ this . showImportModal . set ( false ) ;
641+ // Reset the file input
642+ input . value = '' ;
507643 } catch ( error ) {
508644 this . notifications . error ( error instanceof Error ? error . message : 'Failed to import schema' ) ;
645+ // Reset the file input even on error
646+ input . value = '' ;
509647 }
510648 }
511649
@@ -522,6 +660,7 @@ export class EntitiesTabComponent {
522660 this . notifications . success ( `Imported ${ entities . length } entities` ) ;
523661 this . sqlInput . set ( '' ) ;
524662 this . importMode . set ( null ) ;
663+ this . showImportModal . set ( false ) ;
525664 } catch ( error ) {
526665 this . notifications . error ( error instanceof Error ? error . message : 'Failed to parse SQL' ) ;
527666 }
@@ -533,6 +672,16 @@ export class EntitiesTabComponent {
533672 this . selectedEntityId . set ( entity . id ) ;
534673 }
535674
675+ addEntityFromModal ( ) : void {
676+ this . addEntity ( ) ;
677+ this . closeImportModal ( ) ;
678+ }
679+
680+ closeImportModal ( ) : void {
681+ this . showImportModal . set ( false ) ;
682+ this . importMode . set ( null ) ;
683+ }
684+
536685 deleteEntity ( id : string ) : void {
537686 if ( confirm ( 'Are you sure you want to delete this entity?' ) ) {
538687 this . configBuilder . removeEntity ( id ) ;
0 commit comments