From b7c976295661ebca73aeec4a256f7b44f5866b70 Mon Sep 17 00:00:00 2001 From: Joe Milazzo Date: Tue, 2 May 2023 19:59:30 -0500 Subject: [PATCH] Release Testing Final Stretch (#1952) * Fixed a bug breaking ability to save server settings * Fixed a case where if a user updated appsetting.json, the DB wouldn't update to stay in alignment. --- API/Startup.cs | 12 +++++++++++- API/config/appsettings.Development.json | 2 +- .../manage-settings/manage-settings.component.ts | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/API/Startup.cs b/API/Startup.cs index e916e1c50..8e8a2e1ce 100644 --- a/API/Startup.cs +++ b/API/Startup.cs @@ -32,6 +32,7 @@ using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.ResponseCompression; using Microsoft.AspNetCore.StaticFiles; +using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -294,8 +295,17 @@ public class Startup { // We don't update the index.html in local as we don't serve from there UpdateBaseUrlInIndex(basePath); - } + // Update DB with what's in config + var dataContext = serviceProvider.GetRequiredService(); + var setting = dataContext.ServerSetting.SingleOrDefault(x => x.Key == ServerSettingKey.BaseUrl); + if (setting != null) + { + setting.Value = basePath; + } + + dataContext.SaveChanges(); + } app.UseRouting(); diff --git a/API/config/appsettings.Development.json b/API/config/appsettings.Development.json index 2a9bbdd2c..a1767e9d8 100644 --- a/API/config/appsettings.Development.json +++ b/API/config/appsettings.Development.json @@ -2,5 +2,5 @@ "TokenKey": "super secret unguessable key", "Port": 5000, "IpAddresses": "", - "BaseUrl": "/" + "BaseUrl": "/joe/" } \ No newline at end of file diff --git a/UI/Web/src/app/admin/manage-settings/manage-settings.component.ts b/UI/Web/src/app/admin/manage-settings/manage-settings.component.ts index 682a9ddce..1122fd34a 100644 --- a/UI/Web/src/app/admin/manage-settings/manage-settings.component.ts +++ b/UI/Web/src/app/admin/manage-settings/manage-settings.component.ts @@ -83,7 +83,7 @@ export class ManageSettingsComponent implements OnInit { async saveSettings() { const modelSettings = this.settingsForm.value; - + modelSettings.bookmarksDirectory = this.serverSettings.bookmarksDirectory; this.settingsService.updateServerSettings(modelSettings).pipe(take(1)).subscribe((settings: ServerSettings) => { this.serverSettings = settings; this.resetForm();