diff --git a/src/Controllers/SettingsController.cs b/src/Controllers/SettingsController.cs index 5aab3d7..2bf2d9b 100644 --- a/src/Controllers/SettingsController.cs +++ b/src/Controllers/SettingsController.cs @@ -36,6 +36,14 @@ public class SettingsController : Controller return View(adminSettingsModel); } + [Authorize] + [HttpGet("Presets")] + public async Task> PresetsAsync() + { + AdminSettingsModel adminSettingsModel = await _ldap.GetAdminSettingsModelAsync(); + return adminSettingsModel.Presets; + } + [Authorize(Roles = "CanManageSettings")] [HttpPut("Admin")] public async Task UpdateAdminAsync([FromBody]AdminUpdateRequestModel adminSettingsRequestModel) diff --git a/src/Resources/Views.Shared._Layout.de.resx b/src/Resources/Views.Shared._Layout.de.resx index 54a4121..174cddd 100644 --- a/src/Resources/Views.Shared._Layout.de.resx +++ b/src/Resources/Views.Shared._Layout.de.resx @@ -43,7 +43,13 @@ Fehler beim Laden der Orte + + Fehler beim Laden der Vorlagen + Benutzer auswählen + + Vorlage auswählen + diff --git a/src/Views/Home/Assets.cshtml b/src/Views/Home/Assets.cshtml index 5aca7a3..660a5f8 100644 --- a/src/Views/Home/Assets.cshtml +++ b/src/Views/Home/Assets.cshtml @@ -192,6 +192,18 @@
+

@T["Preset"]

+
+ +
+
+ +
+ +
+

@T["Description"]

@@ -254,7 +266,7 @@
- diff --git a/src/Views/Settings/Admin.cshtml b/src/Views/Settings/Admin.cshtml index 44fd484..eef077f 100644 --- a/src/Views/Settings/Admin.cshtml +++ b/src/Views/Settings/Admin.cshtml @@ -101,7 +101,7 @@ - diff --git a/src/wwwroot/js/site.js b/src/wwwroot/js/site.js index 5347028..c1bd0c8 100644 --- a/src/wwwroot/js/site.js +++ b/src/wwwroot/js/site.js @@ -269,4 +269,36 @@ function unflatten(obj) { function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); +} + +async function loadPresetsIntoSelect(selectElement, selectedValue = null) { + try { + const response = await fetch('/Settings/Presets'); + const responseJson = await response.json(); + var presets = []; + for (var key in responseJson) { + presets.push(key); + } + console.log(presets); + const ts = selectElement.tomselect; + if (!ts) { + selectElement.innerHTML = ``; + presets.forEach(u => { + const opt = document.createElement('option'); + opt.value = u; + opt.textContent = u; + selectElement.appendChild(opt); + }); + return; + } + + ts.clearOptions(); + ts.addOption(presets.map(u => ({ value: u, text: u }))); + ts.refreshOptions(false); + + if (selectedValue) ts.setValue(selectedValue); + } catch (err) { + console.error('Error loading presets:', err); + showToast(appTranslations.errorLoadingPresets, 'danger'); + } } \ No newline at end of file