2026-05-14 12:31:35 +02:00
|
|
|
@page "/settings"
|
2026-05-21 11:04:42 +02:00
|
|
|
@attribute [Authorize]
|
2026-05-16 16:13:35 +02:00
|
|
|
@inject ISettingsService SettingsService
|
|
|
|
|
@inject IThemeService ThemeService
|
2026-05-14 12:31:35 +02:00
|
|
|
@inject IOllamaService OllamaService
|
|
|
|
|
@inject NavigationManager Navigation
|
|
|
|
|
@inject IJSRuntime JSRuntime
|
|
|
|
|
@inject IProjectService ProjectService
|
2026-05-25 06:38:16 +02:00
|
|
|
@inject ILocalizationService Loc
|
2026-05-14 12:31:35 +02:00
|
|
|
|
2026-05-25 06:38:16 +02:00
|
|
|
<PageTitle>@Loc["page.title.settings"] - Author Buddy</PageTitle>
|
2026-05-14 12:31:35 +02:00
|
|
|
|
|
|
|
|
<div class="settings-page">
|
|
|
|
|
|
2026-05-17 07:27:18 +02:00
|
|
|
<div class="settings-section">
|
2026-05-25 06:38:16 +02:00
|
|
|
<h3 class="settings-section-title">@Loc["settings.section.user"]</h3>
|
2026-05-17 07:27:18 +02:00
|
|
|
<div class="form-group">
|
2026-05-25 06:38:16 +02:00
|
|
|
<label for="userSelect">@Loc["settings.user.label.active"]</label>
|
2026-05-17 07:27:18 +02:00
|
|
|
<select id="userSelect" value="@selectedUserId" @onchange="SwitchUser">
|
|
|
|
|
@foreach (var u in users)
|
|
|
|
|
{
|
2026-05-25 06:38:16 +02:00
|
|
|
<option value="@u.Id">@u.Name (@(u.Role == AuthorBuddy.Web.Data.UserRole.Administrator ? Loc["settings.user.role.admin"] : Loc["settings.user.role.author"]))</option>
|
2026-05-17 07:27:18 +02:00
|
|
|
}
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="form-group">
|
2026-05-25 06:38:16 +02:00
|
|
|
<label for="newUserName">@Loc["settings.user.label.new"]</label>
|
2026-05-17 07:27:18 +02:00
|
|
|
<div style="display: flex; gap: 8px;">
|
2026-05-25 06:38:16 +02:00
|
|
|
<input id="newUserName" @bind="newUserName" placeholder="@Loc["settings.user.placeholder.name"]" style="flex: 1;" />
|
|
|
|
|
<button class="btn btn-secondary" @onclick="AddUser">@Loc["settings.user.button.add"]</button>
|
2026-05-17 07:27:18 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-05-21 11:04:42 +02:00
|
|
|
<div class="settings-section" style="margin-bottom:16px;">
|
2026-05-25 06:38:16 +02:00
|
|
|
<button class="btn btn-secondary" @onclick='() => Navigation.NavigateTo("/setup-2fa")'>@Loc["settings.user.link.2fa"]</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="settings-context">
|
|
|
|
|
@if (currentProjectName != null)
|
|
|
|
|
{
|
|
|
|
|
<span class="settings-badge settings-badge-project">@Loc["settings.context.project"]: @currentProjectName</span>
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
<span class="settings-badge settings-badge-user">@Loc["settings.context.user"]</span>
|
|
|
|
|
}
|
2026-05-21 11:04:42 +02:00
|
|
|
</div>
|
|
|
|
|
|
2026-05-16 16:13:35 +02:00
|
|
|
<div class="settings-layout">
|
|
|
|
|
|
2026-05-20 07:27:41 +02:00
|
|
|
<div class="settings-column" >
|
2026-05-16 16:13:35 +02:00
|
|
|
<div class="settings-section">
|
2026-05-25 06:38:16 +02:00
|
|
|
<h3 class="settings-section-title">@Loc["settings.section.models"]</h3>
|
2026-05-16 16:13:35 +02:00
|
|
|
<div class="form-group">
|
2026-05-25 06:38:16 +02:00
|
|
|
<label for="ragModel">@Loc["settings.models.label.rag"]</label>
|
2026-05-16 16:13:35 +02:00
|
|
|
<select id="ragModel" @bind="ragModel">
|
|
|
|
|
@if (availableModels.Count == 0)
|
|
|
|
|
{
|
2026-05-25 06:38:16 +02:00
|
|
|
<option value="">@Loc["settings.models.empty"]</option>
|
2026-05-16 16:13:35 +02:00
|
|
|
}
|
|
|
|
|
@foreach (var m in availableModels)
|
|
|
|
|
{
|
|
|
|
|
<option value="@m.Name">@m.Name</option>
|
|
|
|
|
}
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="form-group">
|
2026-05-25 06:38:16 +02:00
|
|
|
<label for="styleModel">@Loc["settings.models.label.style"]</label>
|
2026-05-16 16:13:35 +02:00
|
|
|
<select id="styleModel" @bind="styleModel">
|
|
|
|
|
@if (availableModels.Count == 0)
|
|
|
|
|
{
|
2026-05-25 06:38:16 +02:00
|
|
|
<option value="">@Loc["settings.models.empty"]</option>
|
2026-05-16 16:13:35 +02:00
|
|
|
}
|
|
|
|
|
@foreach (var m in availableModels)
|
|
|
|
|
{
|
|
|
|
|
<option value="@m.Name">@m.Name</option>
|
|
|
|
|
}
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="form-group">
|
2026-05-25 06:38:16 +02:00
|
|
|
<label for="spellingModel">@Loc["settings.models.label.spellcheck"]</label>
|
2026-05-16 16:13:35 +02:00
|
|
|
<select id="spellingModel" @bind="spellingModel">
|
|
|
|
|
@if (availableModels.Count == 0)
|
|
|
|
|
{
|
2026-05-25 06:38:16 +02:00
|
|
|
<option value="">@Loc["settings.models.empty"]</option>
|
2026-05-16 16:13:35 +02:00
|
|
|
}
|
|
|
|
|
@foreach (var m in availableModels)
|
|
|
|
|
{
|
|
|
|
|
<option value="@m.Name">@m.Name</option>
|
|
|
|
|
}
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="settings-section">
|
2026-05-25 06:38:16 +02:00
|
|
|
<h3 class="settings-section-title">@Loc["settings.section.ollama_server"]</h3>
|
2026-05-16 16:13:35 +02:00
|
|
|
<div class="form-group">
|
2026-05-25 06:38:16 +02:00
|
|
|
<label for="ollamaUrl">@Loc["settings.ollama.label.url"]</label>
|
2026-05-16 16:13:35 +02:00
|
|
|
<input id="ollamaUrl" @bind="ollamaUrl" placeholder="http://localhost:11434" />
|
2026-05-25 06:38:16 +02:00
|
|
|
<div class="form-hint">@Loc["settings.ollama.hint.url"]</div>
|
2026-05-16 16:13:35 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="settings-section">
|
2026-05-25 06:38:16 +02:00
|
|
|
<h3 class="settings-section-title">@Loc["settings.section.appearance"]</h3>
|
2026-05-16 16:13:35 +02:00
|
|
|
<div class="form-group">
|
2026-05-25 06:38:16 +02:00
|
|
|
<label for="themeSelect">@Loc["settings.appearance.label.theme"]</label>
|
2026-05-16 16:13:35 +02:00
|
|
|
<select id="themeSelect" @bind="selectedTheme">
|
2026-05-25 06:38:16 +02:00
|
|
|
<option value="light">@Loc["settings.appearance.theme.light"]</option>
|
|
|
|
|
<option value="dark">@Loc["settings.appearance.theme.dark"]</option>
|
|
|
|
|
<option value="w95">W95 @Loc["settings.appearance.theme.retro"]</option>
|
2026-05-20 07:27:41 +02:00
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="settings-section">
|
2026-05-25 06:38:16 +02:00
|
|
|
<h3 class="settings-section-title">@Loc["settings.section.language"]</h3>
|
2026-05-20 07:27:41 +02:00
|
|
|
<div class="form-group">
|
2026-05-25 06:38:16 +02:00
|
|
|
<label for="languageSelect">@Loc["settings.language.label"]</label>
|
2026-05-20 07:27:41 +02:00
|
|
|
<select id="languageSelect" @bind="selectedLanguage">
|
|
|
|
|
<option value="de">Deutsch</option>
|
|
|
|
|
<option value="en">English</option>
|
2026-05-16 16:13:35 +02:00
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-05-14 12:31:35 +02:00
|
|
|
</div>
|
|
|
|
|
|
2026-05-20 07:27:41 +02:00
|
|
|
<div class="settings-column" >
|
2026-05-16 16:13:35 +02:00
|
|
|
<div class="settings-section">
|
2026-05-25 06:38:16 +02:00
|
|
|
<h3 class="settings-section-title">@Loc["settings.section.editor_prompt"]</h3>
|
2026-05-16 16:13:35 +02:00
|
|
|
<div class="form-group">
|
|
|
|
|
<textarea id="lektorPrompt" @bind="lektorPrompt" rows="6"></textarea>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="settings-section">
|
2026-05-25 06:38:16 +02:00
|
|
|
<h3 class="settings-section-title">@Loc["settings.section.factcheck_template"]</h3>
|
2026-05-16 16:13:35 +02:00
|
|
|
<div class="form-group">
|
|
|
|
|
<textarea id="factCheckTemplate" @bind="factCheckTemplate" rows="6"></textarea>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="settings-section">
|
2026-05-25 06:38:16 +02:00
|
|
|
<h3 class="settings-section-title">@Loc["settings.section.spellcheck_prompt"]</h3>
|
2026-05-16 16:13:35 +02:00
|
|
|
<div class="form-group">
|
|
|
|
|
<textarea id="spellingPrompt" @bind="spellingPrompt" rows="6"></textarea>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-05-14 12:31:35 +02:00
|
|
|
</div>
|
|
|
|
|
|
2026-05-20 07:27:41 +02:00
|
|
|
<div class="settings-column" >
|
2026-05-20 06:12:54 +02:00
|
|
|
<div class="settings-section">
|
2026-05-25 06:38:16 +02:00
|
|
|
<h3 class="settings-section-title">@Loc["settings.section.advocatus_diaboli"]</h3>
|
2026-05-20 06:12:54 +02:00
|
|
|
<div class="form-group">
|
|
|
|
|
<textarea id="advocatusDiaboliPrompt" @bind="advocatusDiaboliPrompt" rows="6"></textarea>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="settings-section">
|
2026-05-25 06:38:16 +02:00
|
|
|
<h3 class="settings-section-title">@Loc["settings.section.hook_finder"]</h3>
|
2026-05-20 06:12:54 +02:00
|
|
|
<div class="form-group">
|
|
|
|
|
<textarea id="hookFinderPrompt" @bind="hookFinderPrompt" rows="6"></textarea>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="settings-section">
|
2026-05-25 06:38:16 +02:00
|
|
|
<h3 class="settings-section-title">@Loc["settings.section.eli5"]</h3>
|
2026-05-20 06:12:54 +02:00
|
|
|
<div class="form-group">
|
|
|
|
|
<textarea id="eli5Prompt" @bind="eli5Prompt" rows="6"></textarea>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-05-14 12:31:35 +02:00
|
|
|
</div>
|
|
|
|
|
|
2026-05-16 16:13:35 +02:00
|
|
|
<div class="settings-actions">
|
2026-05-25 06:38:16 +02:00
|
|
|
<button class="btn btn-primary" @onclick="SaveSettings">@Loc["settings.button.save"]</button>
|
2026-05-16 16:13:35 +02:00
|
|
|
@if (!string.IsNullOrEmpty(statusMessage))
|
|
|
|
|
{
|
|
|
|
|
<span class="settings-status">@statusMessage</span>
|
|
|
|
|
}
|
2026-05-14 12:31:35 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
@code {
|
|
|
|
|
private string ragModel = "llama3.2";
|
|
|
|
|
private string styleModel = "llama3.2";
|
|
|
|
|
private string spellingModel = "phi3:mini";
|
|
|
|
|
private string selectedTheme = "light";
|
|
|
|
|
private string ollamaUrl = "http://localhost:11434";
|
2026-05-16 16:13:35 +02:00
|
|
|
private string lektorPrompt = string.Empty;
|
|
|
|
|
private string factCheckTemplate = string.Empty;
|
|
|
|
|
private string spellingPrompt = string.Empty;
|
2026-05-20 06:12:54 +02:00
|
|
|
private string advocatusDiaboliPrompt = string.Empty;
|
|
|
|
|
private string hookFinderPrompt = string.Empty;
|
|
|
|
|
private string eli5Prompt = string.Empty;
|
2026-05-20 07:27:41 +02:00
|
|
|
private string selectedLanguage = "de";
|
2026-05-14 12:31:35 +02:00
|
|
|
private string newProjectName = string.Empty;
|
2026-05-17 07:27:18 +02:00
|
|
|
private string newUserName = string.Empty;
|
2026-05-14 12:31:35 +02:00
|
|
|
private string statusMessage = string.Empty;
|
2026-05-16 16:13:35 +02:00
|
|
|
private List<LLM_Model> availableModels = new();
|
2026-05-17 07:27:18 +02:00
|
|
|
private List<UserEntity> users = new();
|
|
|
|
|
private int selectedUserId;
|
2026-05-25 06:38:16 +02:00
|
|
|
private string? currentProjectName;
|
2026-05-20 07:27:41 +02:00
|
|
|
|
2026-05-14 12:31:35 +02:00
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
{
|
2026-05-17 07:27:18 +02:00
|
|
|
users = await SettingsService.GetUsersAsync();
|
|
|
|
|
var current = await SettingsService.GetCurrentUserAsync();
|
|
|
|
|
selectedUserId = current.Id;
|
|
|
|
|
|
2026-05-25 06:38:16 +02:00
|
|
|
var pid = SettingsService.CurrentProjectId;
|
|
|
|
|
if (pid != null)
|
|
|
|
|
{
|
|
|
|
|
var project = await ProjectService.GetProjectAsync(pid.Value);
|
|
|
|
|
currentProjectName = project?.Name;
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-20 06:12:54 +02:00
|
|
|
await LoadUserSettings();
|
2026-05-14 12:31:35 +02:00
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var models = await OllamaService.GetLocalModelsAsync();
|
|
|
|
|
availableModels = models.ToList();
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
availableModels = new();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-05-20 06:12:54 +02:00
|
|
|
private async Task LoadUserSettings()
|
2026-05-17 07:27:18 +02:00
|
|
|
{
|
2026-05-20 06:12:54 +02:00
|
|
|
ragModel = await SettingsService.GetRagModelAsync() ?? "llama3.2";
|
|
|
|
|
styleModel = await SettingsService.GetStyleModelAsync() ?? "llama3.2";
|
|
|
|
|
spellingModel = await SettingsService.GetSpellingModelAsync() ?? "phi3:mini";
|
|
|
|
|
selectedTheme = await SettingsService.GetThemeAsync() ?? "light";
|
|
|
|
|
ollamaUrl = await SettingsService.GetOllamaUrlAsync() ?? "http://localhost:11434";
|
|
|
|
|
lektorPrompt = await SettingsService.GetLektorSystemPromptAsync() ?? string.Empty;
|
|
|
|
|
factCheckTemplate = await SettingsService.GetFactCheckTemplateAsync() ?? string.Empty;
|
|
|
|
|
spellingPrompt = await SettingsService.GetSpellingPromptAsync() ?? string.Empty;
|
|
|
|
|
advocatusDiaboliPrompt = await SettingsService.GetAdvocatusDiaboliPromptAsync() ?? string.Empty;
|
|
|
|
|
hookFinderPrompt = await SettingsService.GetHookFinderPromptAsync() ?? string.Empty;
|
|
|
|
|
eli5Prompt = await SettingsService.GetEli5PromptAsync() ?? string.Empty;
|
2026-05-20 07:27:41 +02:00
|
|
|
selectedLanguage = await SettingsService.GetLanguageAsync() ?? "de";
|
2026-05-17 07:27:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task SwitchUser(ChangeEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var userId = int.Parse(e.Value?.ToString() ?? "0");
|
|
|
|
|
selectedUserId = userId;
|
2026-05-25 06:38:16 +02:00
|
|
|
SettingsService.SetCurrentUser(userId);
|
|
|
|
|
await SettingsService.InitializeAsync();
|
2026-05-20 06:12:54 +02:00
|
|
|
await LoadUserSettings();
|
2026-05-17 07:27:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task AddUser()
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(newUserName)) return;
|
|
|
|
|
|
|
|
|
|
var user = await SettingsService.CreateUserAsync(newUserName);
|
|
|
|
|
users.Add(user);
|
|
|
|
|
newUserName = string.Empty;
|
2026-05-25 06:38:16 +02:00
|
|
|
statusMessage = string.Format(Loc["settings.status.user_created"], user.Name);
|
2026-05-17 07:27:18 +02:00
|
|
|
}
|
|
|
|
|
|
2026-05-14 12:31:35 +02:00
|
|
|
private async Task SaveSettings()
|
|
|
|
|
{
|
2026-05-16 16:13:35 +02:00
|
|
|
await SettingsService.SaveOllamaUrlAsync(ollamaUrl);
|
2026-05-20 06:12:54 +02:00
|
|
|
OllamaService.Reconfigure(ollamaUrl);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(ragModel))
|
|
|
|
|
{
|
|
|
|
|
var ok = await OllamaService.TestEmbeddingAsync(ragModel);
|
|
|
|
|
if (!ok)
|
|
|
|
|
{
|
2026-05-20 07:27:41 +02:00
|
|
|
statusMessage = selectedLanguage == "en"
|
|
|
|
|
? $"Model '{ragModel}' does not support embeddings. RAG model not saved."
|
|
|
|
|
: $"Modell '{ragModel}' unterstützt keine Embeddings. RAG-Modell nicht gespeichert.";
|
2026-05-20 06:12:54 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-05-16 16:13:35 +02:00
|
|
|
await SettingsService.SaveRagModelAsync(ragModel);
|
|
|
|
|
await SettingsService.SaveStyleModelAsync(styleModel);
|
|
|
|
|
await SettingsService.SaveSpellingModelAsync(spellingModel);
|
|
|
|
|
await SettingsService.SaveThemeAsync(selectedTheme);
|
|
|
|
|
await SettingsService.SaveLektorSystemPromptAsync(lektorPrompt);
|
|
|
|
|
await SettingsService.SaveFactCheckTemplateAsync(factCheckTemplate);
|
|
|
|
|
await SettingsService.SaveSpellingPromptAsync(spellingPrompt);
|
2026-05-20 06:12:54 +02:00
|
|
|
await SettingsService.SaveAdvocatusDiaboliPromptAsync(advocatusDiaboliPrompt);
|
|
|
|
|
await SettingsService.SaveHookFinderPromptAsync(hookFinderPrompt);
|
|
|
|
|
await SettingsService.SaveEli5PromptAsync(eli5Prompt);
|
2026-05-20 07:27:41 +02:00
|
|
|
await SettingsService.SaveLanguageAsync(selectedLanguage);
|
2026-05-14 12:31:35 +02:00
|
|
|
|
2026-05-25 06:38:16 +02:00
|
|
|
if (selectedLanguage != Loc.CurrentLanguage)
|
|
|
|
|
await Loc.SetLanguageAsync(selectedLanguage);
|
|
|
|
|
|
|
|
|
|
statusMessage = Loc["settings.status.saved"];
|
2026-05-16 16:13:35 +02:00
|
|
|
await ThemeService.ApplyTheme(selectedTheme);
|
2026-05-14 12:31:35 +02:00
|
|
|
}
|
|
|
|
|
}
|