From 39af771d91c54d25aa89cfee804a6f15e1e11bbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96zt=C3=BCrk?= Date: Thu, 30 Oct 2025 23:22:31 +0300 Subject: [PATCH] =?UTF-8?q?CustomEndpoint=20ve=20Dynamic=20Component=20d?= =?UTF-8?q?=C3=BCzenlemesi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomEndpointAppService.cs | 4 +- .../Seeds/ListFormSeeder.cs | 76 +++++++++---------- .../Seeds/MenusData.json | 28 +++---- .../Enums/LookUpQueryValues.cs | 4 +- .../PlatformConsts.cs | 11 ++- .../Kurs.Platform.Domain/Data/SeedConsts.cs | 8 +- .../Tenants/Seeds/TenantData.json | 2 +- .../components/developerKit/EntityEditor.tsx | 9 ++- .../components/developerKit/EntityManager.tsx | 20 ++++- ui/src/contexts/EntityContext.tsx | 5 ++ 10 files changed, 99 insertions(+), 68 deletions(-) diff --git a/api/src/Kurs.Platform.Application/CustomEndpoints/CustomEndpointAppService.cs b/api/src/Kurs.Platform.Application/CustomEndpoints/CustomEndpointAppService.cs index cafcbecf..f8799685 100644 --- a/api/src/Kurs.Platform.Application/CustomEndpoints/CustomEndpointAppService.cs +++ b/api/src/Kurs.Platform.Application/CustomEndpoints/CustomEndpointAppService.cs @@ -43,14 +43,14 @@ public class CustomEndpointAppService : PlatformAppService } [HttpGet("{**path}")] - [Authorize(PlatformConsts.AppCodes.CustomEndpoints.Get)] + [Authorize(PlatformConsts.AppCodes.DeveloperKits.Get)] public async Task GetAsync() { return await Execute("GET"); } [HttpPost("{**path}")] - [Authorize(PlatformConsts.AppCodes.CustomEndpoints.Post)] + [Authorize(PlatformConsts.AppCodes.DeveloperKits.Post)] public async Task PostAsync() { return await Execute("POST"); diff --git a/api/src/Kurs.Platform.DbMigrator/Seeds/ListFormSeeder.cs b/api/src/Kurs.Platform.DbMigrator/Seeds/ListFormSeeder.cs index d75bbcae..179ee4c0 100644 --- a/api/src/Kurs.Platform.DbMigrator/Seeds/ListFormSeeder.cs +++ b/api/src/Kurs.Platform.DbMigrator/Seeds/ListFormSeeder.cs @@ -10779,13 +10779,13 @@ public class ListFormSeeder : IDataSeedContributor, ITransientDependency }), CultureName = LanguageCodes.En, ListFormCode = ListFormCodes.Lists.CustomEndpoint, - Name = AppCodes.CustomEndpoints, - Title = AppCodes.CustomEndpoints, + Name = AppCodes.DeveloperKits.CustomEndpoints, + Title = AppCodes.DeveloperKits.CustomEndpoints, DataSourceCode = SeedConsts.DataSources.DefaultCode, IsTenant = true, IsBranch = false, IsOrganizationUnit = false, - Description = AppCodes.CustomEndpoints, + Description = AppCodes.DeveloperKits.CustomEndpoints, SelectCommandType = SelectCommandTypeEnum.Table, SelectCommand = TableNameResolver.GetFullTableName(nameof(TableNameEnum.CustomEndpoint)), KeyFieldName = "Id", @@ -10827,19 +10827,19 @@ public class ListFormSeeder : IDataSeedContributor, ITransientDependency ButtonPosition= UiCommandButtonPositionTypeEnum.Toolbar, Hint = "Swagger", Text = "Swagger", - AuthName=AppCodes.CustomEndpoints, + AuthName=AppCodes.DeveloperKits.CustomEndpoints, Url= swaggerRootUrl + "/swagger/index.html", }, }), PermissionJson = JsonSerializer.Serialize(new PermissionCrudDto { - C = AppCodes.CustomEndpoints + ".Create", - R = AppCodes.CustomEndpoints, - U = AppCodes.CustomEndpoints + ".Update", - D = AppCodes.CustomEndpoints + ".Delete", - E = AppCodes.CustomEndpoints + ".Export", - I = AppCodes.CustomEndpoints + ".Import", - A = AppCodes.CustomEndpoints + ".Activity", + C = AppCodes.DeveloperKits.CustomEndpoints + ".Create", + R = AppCodes.DeveloperKits.CustomEndpoints, + U = AppCodes.DeveloperKits.CustomEndpoints + ".Update", + D = AppCodes.DeveloperKits.CustomEndpoints + ".Delete", + E = AppCodes.DeveloperKits.CustomEndpoints + ".Export", + I = AppCodes.DeveloperKits.CustomEndpoints + ".Import", + A = AppCodes.DeveloperKits.CustomEndpoints + ".Activity", }), DeleteCommand = $"UPDATE \"{FullNameTable(TableNameEnum.CustomEndpoint)}\" SET \"DeleterId\"=@DeleterId, \"DeletionTime\"=CURRENT_TIMESTAMP, \"IsDeleted\"='true' WHERE \"Id\"=@Id", DeleteFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { @@ -10929,9 +10929,9 @@ public class ListFormSeeder : IDataSeedContributor, ITransientDependency }), PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto { - C = AppCodes.CustomEndpoints + ".Create", - R = AppCodes.CustomEndpoints, - U = AppCodes.CustomEndpoints + ".Update", + C = AppCodes.DeveloperKits.CustomEndpoints + ".Create", + R = AppCodes.DeveloperKits.CustomEndpoints, + U = AppCodes.DeveloperKits.CustomEndpoints + ".Update", E = true, I = true, Deny = false @@ -10960,9 +10960,9 @@ public class ListFormSeeder : IDataSeedContributor, ITransientDependency }), PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto { - C = AppCodes.CustomEndpoints + ".Create", - R = AppCodes.CustomEndpoints, - U = AppCodes.CustomEndpoints + ".Update", + C = AppCodes.DeveloperKits.CustomEndpoints + ".Create", + R = AppCodes.DeveloperKits.CustomEndpoints, + U = AppCodes.DeveloperKits.CustomEndpoints + ".Update", E = true, I = true, Deny = false @@ -10991,9 +10991,9 @@ public class ListFormSeeder : IDataSeedContributor, ITransientDependency }), PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto { - C = AppCodes.CustomEndpoints + ".Create", - R = AppCodes.CustomEndpoints, - U = AppCodes.CustomEndpoints + ".Update", + C = AppCodes.DeveloperKits.CustomEndpoints + ".Create", + R = AppCodes.DeveloperKits.CustomEndpoints, + U = AppCodes.DeveloperKits.CustomEndpoints + ".Update", E = true, I = true, Deny = false @@ -11022,9 +11022,9 @@ public class ListFormSeeder : IDataSeedContributor, ITransientDependency }), PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto { - C = AppCodes.CustomEndpoints + ".Create", - R = AppCodes.CustomEndpoints, - U = AppCodes.CustomEndpoints + ".Update", + C = AppCodes.DeveloperKits.CustomEndpoints + ".Create", + R = AppCodes.DeveloperKits.CustomEndpoints, + U = AppCodes.DeveloperKits.CustomEndpoints + ".Update", E = true, I = true, Deny = false @@ -11069,9 +11069,9 @@ public class ListFormSeeder : IDataSeedContributor, ITransientDependency }), PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto { - C = AppCodes.CustomEndpoints + ".Create", - R = AppCodes.CustomEndpoints, - U = AppCodes.CustomEndpoints + ".Update", + C = AppCodes.DeveloperKits.CustomEndpoints + ".Create", + R = AppCodes.DeveloperKits.CustomEndpoints, + U = AppCodes.DeveloperKits.CustomEndpoints + ".Update", E = true, I = true, Deny = false @@ -11100,9 +11100,9 @@ public class ListFormSeeder : IDataSeedContributor, ITransientDependency }), PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto { - C = AppCodes.CustomEndpoints + ".Create", - R = AppCodes.CustomEndpoints, - U = AppCodes.CustomEndpoints + ".Update", + C = AppCodes.DeveloperKits.CustomEndpoints + ".Create", + R = AppCodes.DeveloperKits.CustomEndpoints, + U = AppCodes.DeveloperKits.CustomEndpoints + ".Update", E = true, I = true, Deny = false @@ -11137,9 +11137,9 @@ public class ListFormSeeder : IDataSeedContributor, ITransientDependency }), PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto { - C = AppCodes.CustomEndpoints + ".Create", - R = AppCodes.CustomEndpoints, - U = AppCodes.CustomEndpoints + ".Update", + C = AppCodes.DeveloperKits.CustomEndpoints + ".Create", + R = AppCodes.DeveloperKits.CustomEndpoints, + U = AppCodes.DeveloperKits.CustomEndpoints + ".Update", E = true, I = true, Deny = false @@ -11168,9 +11168,9 @@ public class ListFormSeeder : IDataSeedContributor, ITransientDependency }), PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto { - C = AppCodes.CustomEndpoints + ".Create", - R = AppCodes.CustomEndpoints, - U = AppCodes.CustomEndpoints + ".Update", + C = AppCodes.DeveloperKits.CustomEndpoints + ".Create", + R = AppCodes.DeveloperKits.CustomEndpoints, + U = AppCodes.DeveloperKits.CustomEndpoints + ".Update", E = true, I = true, Deny = false @@ -11199,9 +11199,9 @@ public class ListFormSeeder : IDataSeedContributor, ITransientDependency }), PermissionJson = JsonSerializer.Serialize(new ListFormFieldPermissionDto { - C = AppCodes.CustomEndpoints + ".Create", - R = AppCodes.CustomEndpoints, - U = AppCodes.CustomEndpoints + ".Update", + C = AppCodes.DeveloperKits.CustomEndpoints + ".Create", + R = AppCodes.DeveloperKits.CustomEndpoints, + U = AppCodes.DeveloperKits.CustomEndpoints + ".Update", E = true, I = true, Deny = false diff --git a/api/src/Kurs.Platform.DbMigrator/Seeds/MenusData.json b/api/src/Kurs.Platform.DbMigrator/Seeds/MenusData.json index 314b76f5..bd258be7 100644 --- a/api/src/Kurs.Platform.DbMigrator/Seeds/MenusData.json +++ b/api/src/Kurs.Platform.DbMigrator/Seeds/MenusData.json @@ -1674,11 +1674,21 @@ "RequiredPermissionName": "App.AuditLogs", "IsDisabled": false }, + { + "ParentCode": "App.Administration", + "Code": "App.Forum", + "DisplayName": "App.Forum", + "Order": 5, + "Url": "/admin/forum", + "Icon": "FcLink", + "RequiredPermissionName": "App.ForumManagement.Publish", + "IsDisabled": false + }, { "ParentCode": "App.Administration", "Code": "App.DeveloperKit", "DisplayName": "App.DeveloperKit", - "Order": 3, + "Order": 6, "Url": null, "Icon": "FcAndroidOs", "RequiredPermissionName": null, @@ -1748,7 +1758,7 @@ "ParentCode": "App.Administration", "Code": "App.Reports.Management", "DisplayName": "App.Reports.Management", - "Order": 4, + "Order": 7, "Url": null, "Icon": "FcDocument", "RequiredPermissionName": null, @@ -1774,21 +1784,11 @@ "RequiredPermissionName": "App.Reports.Management", "IsDisabled": false }, - { - "ParentCode": "App.Administration", - "Code": "App.Forum", - "DisplayName": "App.Forum", - "Order": 5, - "Url": "/admin/forum", - "Icon": "FcLink", - "RequiredPermissionName": "App.ForumManagement.Publish", - "IsDisabled": false - }, { "ParentCode": "App.Administration", "Code": "App.Public", "DisplayName": "App.Public", - "Order": 6, + "Order": 8, "Url": null, "Icon": "FcGenealogy", "RequiredPermissionName": null, @@ -1898,7 +1898,7 @@ "ParentCode": "App.Administration", "Code": "App.Definitions", "DisplayName": "App.Definitions", - "Order": 7, + "Order": 9, "Url": null, "Icon": "FcFilingCabinet", "RequiredPermissionName": null, diff --git a/api/src/Kurs.Platform.Domain.Shared/Enums/LookUpQueryValues.cs b/api/src/Kurs.Platform.Domain.Shared/Enums/LookUpQueryValues.cs index 5729fb71..66eb3b1a 100644 --- a/api/src/Kurs.Platform.Domain.Shared/Enums/LookUpQueryValues.cs +++ b/api/src/Kurs.Platform.Domain.Shared/Enums/LookUpQueryValues.cs @@ -45,10 +45,10 @@ public static class LookupQueryValues public static string DataSourceValues = $"SELECT " + $"\"Code\" AS \"Key\", " + - $"\"Name\" AS \"Name\" " + + $"\"Code\" AS \"Name\" " + $"FROM \"{FullNameTable(TableNameEnum.DataSource)}\" " + $"WHERE \"IsDeleted\" = 'false' " + - $"ORDER BY \"Name\";"; + $"ORDER BY \"Code\";"; public static string BlogCategoryValues = $"SELECT " + diff --git a/api/src/Kurs.Platform.Domain.Shared/PlatformConsts.cs b/api/src/Kurs.Platform.Domain.Shared/PlatformConsts.cs index 3c06142f..803196f2 100644 --- a/api/src/Kurs.Platform.Domain.Shared/PlatformConsts.cs +++ b/api/src/Kurs.Platform.Domain.Shared/PlatformConsts.cs @@ -350,12 +350,15 @@ public static class PlatformConsts public const string Notification = Default + ".Notification"; } public const string BackgroundWorkers = Prefix.App + ".BackgroundWorkers"; - public static class CustomEndpoints + public static class DeveloperKits { - public const string Default = Prefix.App + ".CustomEndpoints"; - public const string Get = Default + ".Get"; - public const string Post = Default + ".Post"; + public const string Default = Prefix.App + ".DeveloperKit"; + public const string CustomEndpoints = Default + ".CustomEndpoints"; + + public const string Get = CustomEndpoints + ".Get"; + public const string Post = CustomEndpoints + ".Post"; } + public const string Blog = Prefix.App + ".Blog"; public const string Forum = Prefix.App + ".Forum"; public static class Parameters diff --git a/api/src/Kurs.Platform.Domain/Data/SeedConsts.cs b/api/src/Kurs.Platform.Domain/Data/SeedConsts.cs index 7b417e99..b5694f40 100644 --- a/api/src/Kurs.Platform.Domain/Data/SeedConsts.cs +++ b/api/src/Kurs.Platform.Domain/Data/SeedConsts.cs @@ -353,7 +353,13 @@ public static class SeedConsts } public const string BackgroundWorkers = Prefix.App + ".BackgroundWorkers"; public const string Forum = Prefix.App + ".Forum"; - public const string CustomEndpoints = Prefix.App + ".CustomEndpoints"; + + public static class DeveloperKits + { + public const string Default = Prefix.App + ".DeveloperKit"; + public const string CustomEndpoints = Default + ".CustomEndpoints"; + } + public static class Reports { public const string Default = Prefix.App + ".Reports"; diff --git a/api/src/Kurs.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json b/api/src/Kurs.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json index b0245779..ea30cad9 100644 --- a/api/src/Kurs.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json +++ b/api/src/Kurs.Platform.EntityFrameworkCore/Tenants/Seeds/TenantData.json @@ -63,7 +63,7 @@ "Url": "/dil/", "Method": "GET", "DataSourceCode": "Default", - "Sql": "SELECT * FROM PLanguage WHERE IsEnabled = @IsEnabled AND CultureName = @CultureName", + "Sql": "SELECT * FROM P_P_Language WHERE IsEnabled = @IsEnabled AND CultureName = @CultureName", "ParametersJson": [ { "Type": "P", diff --git a/ui/src/components/developerKit/EntityEditor.tsx b/ui/src/components/developerKit/EntityEditor.tsx index a7056450..9050ae92 100644 --- a/ui/src/components/developerKit/EntityEditor.tsx +++ b/ui/src/components/developerKit/EntityEditor.tsx @@ -18,7 +18,7 @@ const EntityEditor: React.FC = () => { const navigate = useNavigate() const { translate } = useLocalization() - const { getEntity, addEntity, updateEntity } = useEntities() + const { getEntity, addEntity, updateEntity, refreshEntities } = useEntities() const [name, setName] = useState('') const [displayName, setDisplayName] = useState('') @@ -145,12 +145,13 @@ const EntityEditor: React.FC = () => { } if (isEditing && id) { - updateEntity(id, entityData) + await updateEntity(id, entityData) } else { - addEntity(entityData) + await addEntity(entityData) } - navigate(ROUTES_ENUM.protected.saas.developerKit.entities) + // Başarılı kaydetme sonrasında Varlık Yönetimi sayfasına yönlendir + navigate(ROUTES_ENUM.protected.saas.developerKit.entities, { replace: true }) } catch (error) { console.error('Error saving entity:', error) alert('Failed to save entity. Please try again.') diff --git a/ui/src/components/developerKit/EntityManager.tsx b/ui/src/components/developerKit/EntityManager.tsx index 0d0c3d50..5d4e6e82 100644 --- a/ui/src/components/developerKit/EntityManager.tsx +++ b/ui/src/components/developerKit/EntityManager.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react' +import React, { useState, useEffect } from 'react' import { Link } from 'react-router-dom' import { useEntities } from '../../contexts/EntityContext' import { @@ -19,11 +19,27 @@ import { ROUTES_ENUM } from '@/routes/route.constant' import { useLocalization } from '@/utils/hooks/useLocalization' const EntityManager: React.FC = () => { - const { entities, deleteEntity, toggleEntityActiveStatus } = useEntities() + const { entities, deleteEntity, toggleEntityActiveStatus, refreshEntities } = useEntities() const [searchTerm, setSearchTerm] = useState('') const [filterActive, setFilterActive] = useState<'all' | 'active' | 'inactive'>('all') const { translate } = useLocalization() + // Sayfa odaklandığında varlıkları yenile + useEffect(() => { + const handleVisibilityChange = () => { + if (!document.hidden) { + refreshEntities() + } + } + + // Visibility change event listener ekle + document.addEventListener('visibilitychange', handleVisibilityChange) + + return () => { + document.removeEventListener('visibilitychange', handleVisibilityChange) + } + }, [refreshEntities]) + const filteredEntities = entities.filter((entity) => { const matchesSearch = entity.name.toLowerCase().includes(searchTerm.toLowerCase()) || diff --git a/ui/src/contexts/EntityContext.tsx b/ui/src/contexts/EntityContext.tsx index aeb6f424..6661323a 100644 --- a/ui/src/contexts/EntityContext.tsx +++ b/ui/src/contexts/EntityContext.tsx @@ -108,9 +108,14 @@ export const EntityProvider: React.FC<{ children: React.ReactNode }> = ({ setLoading(true); setError(null); const updatedEntity = await developerKitService.updateCustomEntity(id, entityData); + + // State'i güncelle setEntities((prev) => prev.map((entity) => (entity.id === id ? updatedEntity : entity)) ); + + // Güvenlik için tüm varlıkları yenile + await refreshEntities(); } catch (err) { setError(err instanceof Error ? err.message : "Failed to update entity"); throw err;