From 0d0b68a8f9e7f52ec7145ad516963a00da8d90f4 Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 23 May 2023 12:52:09 +0200 Subject: [PATCH 1/6] add Website to .gitignore for dev-branch --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index a471f98..339d2ff 100644 --- a/.gitignore +++ b/.gitignore @@ -17,5 +17,4 @@ riderModule.iml /dataSources/ /dataSources.local.xml /.idea -cover.jpg -cover.png \ No newline at end of file +Website/ \ No newline at end of file From 5674adbd5ef5ee1d453ae777eddbee8d3a61039b Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 23 May 2023 13:16:37 +0200 Subject: [PATCH 2/6] Added CORS for localhost --- Tranga-API/Program.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Tranga-API/Program.cs b/Tranga-API/Program.cs index 9ee8650..3c4c4c6 100644 --- a/Tranga-API/Program.cs +++ b/Tranga-API/Program.cs @@ -28,13 +28,24 @@ var builder = WebApplication.CreateBuilder(args); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); builder.Services.AddControllers().AddNewtonsoftJson(); + +string corsHeader = "Tranga"; +builder.Services.AddCors(options => +{ + options.AddPolicy(name: corsHeader, + policy => + { + policy.WithOrigins("http://localhost", "http://127.0.0.1", "http://localhost:63342"); + }); +}); + var app = builder.Build(); app.UseSwagger(); app.UseSwaggerUI(); app.UseSwagger(); app.UseSwaggerUI(); -app.MapGet("/GetAvailableControllers", () => taskManager.GetAvailableConnectors()); +app.UseCors(corsHeader); app.MapGet("/GetKnownPublications", () => taskManager.GetAllPublications()); From 947b521163ed6a4de2f3d9ada472790113fda988 Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 23 May 2023 13:17:05 +0200 Subject: [PATCH 3/6] Changed API: GetAvailableControllers, GetKnownPublications, GetPublicationsFromConnector to Tranga/* --- Tranga-API/Program.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Tranga-API/Program.cs b/Tranga-API/Program.cs index 3c4c4c6..d74f39f 100644 --- a/Tranga-API/Program.cs +++ b/Tranga-API/Program.cs @@ -47,9 +47,11 @@ app.UseSwaggerUI(); app.UseCors(corsHeader); -app.MapGet("/GetKnownPublications", () => taskManager.GetAllPublications()); +app.MapGet("/Tranga/GetAvailableControllers", () => taskManager.GetAvailableConnectors()); -app.MapGet("/GetPublicationsFromConnector", (string connectorName, string title) => +app.MapGet("/Tranga/GetKnownPublications", () => taskManager.GetAllPublications()); + +app.MapGet("/Tranga/GetPublicationsFromConnector", (string connectorName, string title) => { Connector? connector = taskManager.GetAvailableConnectors().FirstOrDefault(con => con.Key == connectorName).Value; if (connector is null) From a966bd788d3b69ce6e646fe8a23787181f1fd2a5 Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 23 May 2023 14:45:51 +0200 Subject: [PATCH 4/6] Return array for GetAvailableControllers --- Tranga-API/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tranga-API/Program.cs b/Tranga-API/Program.cs index d74f39f..b0fb94b 100644 --- a/Tranga-API/Program.cs +++ b/Tranga-API/Program.cs @@ -47,7 +47,7 @@ app.UseSwaggerUI(); app.UseCors(corsHeader); -app.MapGet("/Tranga/GetAvailableControllers", () => taskManager.GetAvailableConnectors()); +app.MapGet("/Tranga/GetAvailableControllers", () => taskManager.GetAvailableConnectors().Keys.ToArray()); app.MapGet("/Tranga/GetKnownPublications", () => taskManager.GetAllPublications()); From 39fa905733e9e6a201fc35a470ec1825ac46fc34 Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 23 May 2023 18:11:18 +0200 Subject: [PATCH 5/6] Access-Control-Allow-Methods --- Tranga-API/Program.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Tranga-API/Program.cs b/Tranga-API/Program.cs index b0fb94b..778e976 100644 --- a/Tranga-API/Program.cs +++ b/Tranga-API/Program.cs @@ -36,6 +36,7 @@ builder.Services.AddCors(options => policy => { policy.WithOrigins("http://localhost", "http://127.0.0.1", "http://localhost:63342"); + policy.WithMethods("GET", "POST", "DELETE"); }); }); From 2fa96e9793bd8c4c5ddccdfbee99d8f31bf9c9c5 Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 23 May 2023 18:52:27 +0200 Subject: [PATCH 6/6] undo gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 339d2ff..a471f98 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ riderModule.iml /dataSources/ /dataSources.local.xml /.idea -Website/ \ No newline at end of file +cover.jpg +cover.png \ No newline at end of file