Spaces:
Running
Running
Update flare-ui/src/app/components/apis/apis.component.ts
Browse files
flare-ui/src/app/components/apis/apis.component.ts
CHANGED
@@ -587,7 +587,9 @@ export class ApisComponent implements OnInit, OnDestroy {
|
|
587 |
let imported = 0;
|
588 |
let failed = 0;
|
589 |
const errors: string[] = [];
|
590 |
-
|
|
|
|
|
591 |
for (const api of apis) {
|
592 |
try {
|
593 |
await this.apiService.createAPI(api).toPromise();
|
@@ -595,6 +597,8 @@ export class ApisComponent implements OnInit, OnDestroy {
|
|
595 |
} catch (err: any) {
|
596 |
failed++;
|
597 |
const apiName = api.name || 'unnamed';
|
|
|
|
|
598 |
|
599 |
// Parse error message
|
600 |
let errorMsg = 'Unknown error';
|
@@ -607,7 +611,6 @@ export class ApisComponent implements OnInit, OnDestroy {
|
|
607 |
}
|
608 |
|
609 |
errors.push(`${apiName}: ${errorMsg}`);
|
610 |
-
console.error(`Failed to import API ${apiName}:`, err);
|
611 |
}
|
612 |
}
|
613 |
|
@@ -616,6 +619,15 @@ export class ApisComponent implements OnInit, OnDestroy {
|
|
616 |
if (imported > 0) {
|
617 |
this.loadAPIs();
|
618 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
619 |
|
620 |
// Build detailed message
|
621 |
let message = '';
|
@@ -658,7 +670,6 @@ export class ApisComponent implements OnInit, OnDestroy {
|
|
658 |
input.click();
|
659 |
}
|
660 |
|
661 |
-
// Yeni method ekle
|
662 |
private async showImportErrorsDialog(imported: number, failed: number, errors: string[]) {
|
663 |
try {
|
664 |
const { default: ImportResultsDialogComponent } = await import('../../dialogs/import-results-dialog/import-results-dialog.component');
|
@@ -678,6 +689,30 @@ export class ApisComponent implements OnInit, OnDestroy {
|
|
678 |
}
|
679 |
}
|
680 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
681 |
exportAPIs() {
|
682 |
const selectedAPIs = this.filteredAPIs.filter(api => !api.deleted);
|
683 |
|
|
|
587 |
let imported = 0;
|
588 |
let failed = 0;
|
589 |
const errors: string[] = [];
|
590 |
+
|
591 |
+
console.log('Starting API import, total APIs:', apis.length);
|
592 |
+
|
593 |
for (const api of apis) {
|
594 |
try {
|
595 |
await this.apiService.createAPI(api).toPromise();
|
|
|
597 |
} catch (err: any) {
|
598 |
failed++;
|
599 |
const apiName = api.name || 'unnamed';
|
600 |
+
|
601 |
+
console.error(`❌ Failed to import API ${apiName}:`, err);
|
602 |
|
603 |
// Parse error message
|
604 |
let errorMsg = 'Unknown error';
|
|
|
611 |
}
|
612 |
|
613 |
errors.push(`${apiName}: ${errorMsg}`);
|
|
|
614 |
}
|
615 |
}
|
616 |
|
|
|
619 |
if (imported > 0) {
|
620 |
this.loadAPIs();
|
621 |
}
|
622 |
+
|
623 |
+
// Always show dialog for import results
|
624 |
+
try {
|
625 |
+
await this.showImportResultsDialog(imported, failed, errors, 'API');
|
626 |
+
} catch (dialogError) {
|
627 |
+
console.error('Failed to show import dialog:', dialogError);
|
628 |
+
// Fallback to snackbar
|
629 |
+
this.showImportResultsSnackbar(imported, failed, errors);
|
630 |
+
}
|
631 |
|
632 |
// Build detailed message
|
633 |
let message = '';
|
|
|
670 |
input.click();
|
671 |
}
|
672 |
|
|
|
673 |
private async showImportErrorsDialog(imported: number, failed: number, errors: string[]) {
|
674 |
try {
|
675 |
const { default: ImportResultsDialogComponent } = await import('../../dialogs/import-results-dialog/import-results-dialog.component');
|
|
|
689 |
}
|
690 |
}
|
691 |
|
692 |
+
// Fallback method
|
693 |
+
private showImportResultsSnackbar(imported: number, failed: number, errors: string[]) {
|
694 |
+
let message = '';
|
695 |
+
if (imported > 0) {
|
696 |
+
message = `Successfully imported ${imported} API${imported > 1 ? 's' : ''}.`;
|
697 |
+
}
|
698 |
+
|
699 |
+
if (failed > 0) {
|
700 |
+
if (message) message += '\n\n';
|
701 |
+
message += `Failed to import ${failed} API${failed > 1 ? 's' : ''}:\n`;
|
702 |
+
message += errors.slice(0, 5).join('\n');
|
703 |
+
if (errors.length > 5) {
|
704 |
+
message += `\n... and ${errors.length - 5} more errors`;
|
705 |
+
}
|
706 |
+
}
|
707 |
+
|
708 |
+
this.snackBar.open(message, 'Close', {
|
709 |
+
duration: 10000,
|
710 |
+
panelClass: ['multiline-snackbar', failed > 0 ? 'error-snackbar' : 'success-snackbar'],
|
711 |
+
verticalPosition: 'top',
|
712 |
+
horizontalPosition: 'right'
|
713 |
+
});
|
714 |
+
}
|
715 |
+
|
716 |
exportAPIs() {
|
717 |
const selectedAPIs = this.filteredAPIs.filter(api => !api.deleted);
|
718 |
|