From 7e07e73ef51975000c116348b8c653ad8c0eef17 Mon Sep 17 00:00:00 2001 From: "DESKTOP-T0O5CDB\\DESK-555BD" Date: Tue, 18 Mar 2025 12:41:02 -0600 Subject: [PATCH 1/6] Display current odometer when incrementing. --- Helper/StaticHelper.cs | 2 +- wwwroot/js/vehicle.js | 53 +++++++++++++++++++++--------------------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/Helper/StaticHelper.cs b/Helper/StaticHelper.cs index 7c30a9b..67c5427 100644 --- a/Helper/StaticHelper.cs +++ b/Helper/StaticHelper.cs @@ -12,7 +12,7 @@ namespace CarCareTracker.Helper /// public static class StaticHelper { - public const string VersionNumber = "1.4.5"; + public const string VersionNumber = "1.4.6"; public const string DbName = "data/cartracker.db"; public const string UserConfigPath = "data/config/userConfig.json"; public const string LegacyUserConfigPath = "config/userConfig.json"; diff --git a/wwwroot/js/vehicle.js b/wwwroot/js/vehicle.js index 6ad3c97..e4d7a33 100644 --- a/wwwroot/js/vehicle.js +++ b/wwwroot/js/vehicle.js @@ -619,36 +619,37 @@ function getAndValidateSelectedRecurringReminder() { } } function getLastOdometerReadingAndIncrement(odometerFieldName) { - Swal.fire({ - title: 'Increment Last Reported Odometer Reading', - html: ` + $.get(`/Vehicle/GetMaxMileage?vehicleId=${GetVehicleId().vehicleId}`, function (currentOdometer) { + let additionalHtml = isNaN(currentOdometer) || currentOdometer == 0 ? '' : `Current Odometer: ${currentOdometer}
`; + Swal.fire({ + title: 'Increment Last Reported Odometer Reading', + html: `${additionalHtml} `, - confirmButtonText: 'Add', - focusConfirm: false, - preConfirm: () => { - const odometerIncrement = parseInt(globalParseFloat($("#inputOdometerIncrement").val())); - if (isNaN(odometerIncrement) || odometerIncrement <= 0) { - Swal.showValidationMessage(`Please enter a non-zero amount to increment`); - } - return { odometerIncrement } - }, - }).then(function (result) { - if (result.isConfirmed) { - var amountToIncrement = result.value.odometerIncrement; - $.get(`/Vehicle/GetMaxMileage?vehicleId=${GetVehicleId().vehicleId}`, function (data) { - var newAmount = data + amountToIncrement; - if (!isNaN(newAmount)) { - var odometerField = $(`#${odometerFieldName}`); - if (odometerField.length > 0) { - odometerField.val(newAmount); + confirmButtonText: 'Add', + focusConfirm: false, + preConfirm: () => { + const odometerIncrement = parseInt(globalParseFloat($("#inputOdometerIncrement").val())); + if (isNaN(odometerIncrement) || odometerIncrement < 0) { + Swal.showValidationMessage(`Please enter a positive amount to increment or 0 to use current odometer`); + } + return { odometerIncrement } + }, + }).then(function (result) { + if (result.isConfirmed) { + var amountToIncrement = result.value.odometerIncrement; + var newAmount = currentOdometer + amountToIncrement; + if (!isNaN(newAmount)) { + var odometerField = $(`#${odometerFieldName}`); + if (odometerField.length > 0) { + odometerField.val(newAmount); + } else { + errorToast(genericErrorMessage()); + } } else { errorToast(genericErrorMessage()); } - } else { - errorToast(genericErrorMessage()); - } - }); - } + } + }); }); } \ No newline at end of file From d7839a8a0550f6dfb4deec519c849cd0cf5716a4 Mon Sep 17 00:00:00 2001 From: "DESKTOP-T0O5CDB\\DESK-555BD" Date: Wed, 19 Mar 2025 12:57:25 -0600 Subject: [PATCH 2/6] Allow users to see server configuration passed in via environment variables or appsettings.json --- Controllers/HomeController.cs | 17 ++++++ Models/Settings/ServerSettingsViewModel.cs | 17 ++++++ Views/Home/_ServerConfig.cshtml | 62 ++++++++++++++++++++++ Views/Home/_Settings.cshtml | 15 +++++- wwwroot/js/settings.js | 9 ++++ 5 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 Models/Settings/ServerSettingsViewModel.cs create mode 100644 Views/Home/_ServerConfig.cshtml diff --git a/Controllers/HomeController.cs b/Controllers/HomeController.cs index 535fbe1..b80dbe9 100644 --- a/Controllers/HomeController.cs +++ b/Controllers/HomeController.cs @@ -555,6 +555,23 @@ namespace CarCareTracker.Controllers } return Json(false); } + [Authorize(Roles = nameof(UserData.IsRootUser))] + public IActionResult GetServerConfiguration() + { + var viewModel = new ServerSettingsViewModel + { + PostgresConnection = _config.GetServerPostgresConnection(), + AllowedFileExtensions = _config.GetAllowedFileUploadExtensions(), + CustomLogoURL = _config.GetLogoUrl(), + MessageOfTheDay = _config.GetMOTD(), + WebHookURL = _config.GetWebHookUrl(), + CustomWidgetsEnabled = _config.GetCustomWidgetsEnabled(), + InvariantAPIEnabled = _config.GetInvariantApi(), + SMTPConfig = _config.GetMailConfig(), + OIDCConfig = _config.GetOpenIDConfig() + }; + return PartialView("_ServerConfig", viewModel); + } [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] public IActionResult Error() { diff --git a/Models/Settings/ServerSettingsViewModel.cs b/Models/Settings/ServerSettingsViewModel.cs new file mode 100644 index 0000000..1b4e286 --- /dev/null +++ b/Models/Settings/ServerSettingsViewModel.cs @@ -0,0 +1,17 @@ +namespace CarCareTracker.Models +{ + public class ServerSettingsViewModel + { + public string LocaleInfo { get; set; } + public string PostgresConnection { get; set; } + public string AllowedFileExtensions { get; set; } + public string CustomLogoURL { get; set; } + public string MessageOfTheDay { get; set; } + public string WebHookURL { get; set; } + public bool CustomWidgetsEnabled { get; set; } + public bool InvariantAPIEnabled { get; set; } + public MailConfig SMTPConfig { get; set; } = new MailConfig(); + public OpenIDConfig OIDCConfig { get; set; } = new OpenIDConfig(); + + } +} diff --git a/Views/Home/_ServerConfig.cshtml b/Views/Home/_ServerConfig.cshtml new file mode 100644 index 0000000..73d6b6e --- /dev/null +++ b/Views/Home/_ServerConfig.cshtml @@ -0,0 +1,62 @@ +@using CarCareTracker.Helper +@inject IConfigHelper config +@inject ITranslationHelper translator +@model ServerSettingsViewModel +@{ + var userConfig = config.GetUserConfig(User); + var userLanguage = userConfig.UserLanguage; +} + + +@* *@ \ No newline at end of file diff --git a/Views/Home/_Settings.cshtml b/Views/Home/_Settings.cshtml index 2240d2c..10ef3e0 100644 --- a/Views/Home/_Settings.cshtml +++ b/Views/Home/_Settings.cshtml @@ -253,7 +253,14 @@
- @translator.Translate(userLanguage, "Server-wide Settings") +
+
+ @translator.Translate(userLanguage, "Server-wide Settings") +
+
+ +
+
@@ -355,6 +362,12 @@
+