From 61751a48c4a4e4280b9e2df13b138bdf4463e930 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96zt=C3=BCrk?= Date: Mon, 4 May 2026 00:35:04 +0300 Subject: [PATCH] =?UTF-8?q?SqlQueryManager=20i=C3=A7erisinde=20Modal=20Sql?= =?UTF-8?q?DataFiles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ISqlObjectManagerAppService.cs | 5 ++ .../SqlDataFileDto.cs | 9 +++ .../SqlObjectManagerAppService.cs | 30 ++++++++ .../Seeds/LanguagesData.json | 6 ++ ui/src/services/sql-query-manager.service.ts | 9 +++ ui/src/views/developerKit/SqlQueryManager.tsx | 72 +++++++++++++++++++ 6 files changed, 131 insertions(+) create mode 100644 api/modules/Sozsoft.SqlQueryManager/Sozsoft.SqlQueryManager.Application.Contracts/SqlDataFileDto.cs diff --git a/api/modules/Sozsoft.SqlQueryManager/Sozsoft.SqlQueryManager.Application.Contracts/ISqlObjectManagerAppService.cs b/api/modules/Sozsoft.SqlQueryManager/Sozsoft.SqlQueryManager.Application.Contracts/ISqlObjectManagerAppService.cs index b2e35bf..72fc605 100644 --- a/api/modules/Sozsoft.SqlQueryManager/Sozsoft.SqlQueryManager.Application.Contracts/ISqlObjectManagerAppService.cs +++ b/api/modules/Sozsoft.SqlQueryManager/Sozsoft.SqlQueryManager.Application.Contracts/ISqlObjectManagerAppService.cs @@ -39,4 +39,9 @@ public interface ISqlObjectManagerAppService : IApplicationService /// Non-existing files are ignored. /// Task DeleteSqlDataFilesAsync(DeleteSqlDataFilesDto input); + + /// + /// Lists .sql files currently available under DbMigrator Seeds/SqlData. + /// + Task> GetSqlDataFilesAsync(); } diff --git a/api/modules/Sozsoft.SqlQueryManager/Sozsoft.SqlQueryManager.Application.Contracts/SqlDataFileDto.cs b/api/modules/Sozsoft.SqlQueryManager/Sozsoft.SqlQueryManager.Application.Contracts/SqlDataFileDto.cs new file mode 100644 index 0000000..9aec930 --- /dev/null +++ b/api/modules/Sozsoft.SqlQueryManager/Sozsoft.SqlQueryManager.Application.Contracts/SqlDataFileDto.cs @@ -0,0 +1,9 @@ +using System; + +namespace Sozsoft.SqlQueryManager.Application.Contracts; + +public class SqlDataFileDto +{ + public string FileName { get; set; } = string.Empty; + public DateTime CreatedAt { get; set; } +} diff --git a/api/modules/Sozsoft.SqlQueryManager/Sozsoft.SqlQueryManager.Application/SqlObjectManagerAppService.cs b/api/modules/Sozsoft.SqlQueryManager/Sozsoft.SqlQueryManager.Application/SqlObjectManagerAppService.cs index 401072e..8ad7553 100644 --- a/api/modules/Sozsoft.SqlQueryManager/Sozsoft.SqlQueryManager.Application/SqlObjectManagerAppService.cs +++ b/api/modules/Sozsoft.SqlQueryManager/Sozsoft.SqlQueryManager.Application/SqlObjectManagerAppService.cs @@ -616,6 +616,36 @@ public class SqlObjectManagerAppService : ApplicationService, ISqlObjectManagerA return Task.CompletedTask; } + [HttpGet("api/app/sql-object-manager/sql-data-files")] + public Task> GetSqlDataFilesAsync() + { + ValidateTenantAccess(); + + try + { + var outputPath = ResolveSqlDataOutputPath(); + if (!Directory.Exists(outputPath)) + return Task.FromResult(new List()); + + var files = Directory.GetFiles(outputPath, "*.sql", SearchOption.TopDirectoryOnly) + .Select(f => new SqlDataFileDto + { + FileName = Path.GetFileName(f)!, + CreatedAt = File.GetCreationTime(f) + }) + .Where(x => !string.IsNullOrWhiteSpace(x.FileName)) + .OrderBy(x => x.FileName, StringComparer.OrdinalIgnoreCase) + .ToList(); + + return Task.FromResult(files); + } + catch (Exception ex) + { + _logger.LogError(ex, "Failed to list SQL seed files: {Message}", ex.Message); + return Task.FromResult(new List()); + } + } + private string ResolveSqlDataOutputPath() { const string dbMigratorName = "Sozsoft.Platform.DbMigrator"; diff --git a/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json b/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json index 4ffd921..8a2c024 100644 --- a/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json +++ b/api/src/Sozsoft.Platform.DbMigrator/Seeds/LanguagesData.json @@ -16821,6 +16821,12 @@ "en": "Edit Table", "tr": "Tablo Düzenle" }, + { + "resourceName": "Platform", + "key": "App.SqlQueryManager.SqlDataFiles", + "en": "SQL Data Files", + "tr": "SQL Veri Dosyaları" + }, { "resourceName": "Platform", "key": "App.SqlQueryManager.EditModeDescription", diff --git a/ui/src/services/sql-query-manager.service.ts b/ui/src/services/sql-query-manager.service.ts index 5fac552..0412a58 100644 --- a/ui/src/services/sql-query-manager.service.ts +++ b/ui/src/services/sql-query-manager.service.ts @@ -68,6 +68,15 @@ export class SqlObjectManagerService { }, { apiName: this.apiName, ...config }, ) + + getSqlDataFiles = (config?: Partial) => + apiService.fetchData<{ fileName: string; createdAt: string }[], void>( + { + method: 'GET', + url: '/api/app/sql-object-manager/sql-data-files', + }, + { apiName: this.apiName, ...config }, + ) } export const sqlObjectManagerService = new SqlObjectManagerService() diff --git a/ui/src/views/developerKit/SqlQueryManager.tsx b/ui/src/views/developerKit/SqlQueryManager.tsx index 1e1ae9e..07216b0 100644 --- a/ui/src/views/developerKit/SqlQueryManager.tsx +++ b/ui/src/views/developerKit/SqlQueryManager.tsx @@ -19,6 +19,7 @@ import { useStoreState } from '@/store/store' import { APP_NAME } from '@/constants/app.constant' import { UiEvalService } from '@/services/UiEvalService' import { FcAcceptDatabase } from 'react-icons/fc' +import { FaFolderOpen } from "react-icons/fa" interface SqlManagerState { dataSources: DataSourceDto[] @@ -78,6 +79,9 @@ const SqlQueryManager = () => { const [showCopyResultDialog, setShowCopyResultDialog] = useState(false) const [copyDialogMode, setCopyDialogMode] = useState<'objects' | 'sql'>('objects') const [sqlScriptForCopy, setSqlScriptForCopy] = useState('') + const [showSqlDataFilesDialog, setShowSqlDataFilesDialog] = useState(false) + const [isLoadingSqlDataFiles, setIsLoadingSqlDataFiles] = useState(false) + const [sqlDataFiles, setSqlDataFiles] = useState<{ fileName: string; createdAt: string }[]>([]) useEffect(() => { loadDataSources() @@ -852,6 +856,28 @@ GO`, const copyErrorCount = copyResults.filter((x) => x.status === 'error').length const copySkippedCount = copyResults.filter((x) => x.status === 'skipped').length + const handleOpenSqlDataFilesDialog = async () => { + setShowSqlDataFilesDialog(true) + setIsLoadingSqlDataFiles(true) + + try { + const response = await sqlObjectManagerService.getSqlDataFiles() + setSqlDataFiles(response.data || []) + } catch (error: any) { + setSqlDataFiles([]) + toast.push( + + {error.response?.data?.error?.message || + translate('::App.Platform.FailedToLoadFiles') || + 'SQL dosya listesi yuklenemedi.'} + , + { placement: 'top-center' }, + ) + } finally { + setIsLoadingSqlDataFiles(false) + } + } + return ( {translate('::ListForms.ListForm.DbMigrate') || 'DB Migrate'} +
@@ -1053,6 +1089,42 @@ GO`,

+ setShowSqlDataFilesDialog(false)} + onRequestClose={() => setShowSqlDataFilesDialog(false)} + contentClassName="max-h-[90vh] overflow-hidden" + > +
+
+ {translate('::App.SqlQueryManager.SqlDataFiles') || 'SqlData Files'} +
+ + {isLoadingSqlDataFiles ? ( +

+ {translate('::App.Platform.Loading') || 'Loading...'} +

+ ) : sqlDataFiles.length === 0 ? ( +

+ {translate('::App.SqlQueryManager.NoSqlDataFiles') || 'SqlData klasorunde .sql dosyasi bulunamadi.'} +

+ ) : ( +
+
    + {sqlDataFiles.map((file) => ( +
  • + {file.fileName} + + {new Date(file.createdAt).toLocaleString()} + +
  • + ))} +
+
+ )} +
+
+ {/* Template Confirmation Dialog */}