feat(configmanager): add LdapFormViewModel

Implement LdapFormViewModel for editing LDAP configuration section with
properties for ServerUrlsText, GroupDn, SearchBase, ConnectionTimeoutSeconds,
UseFakeAuth, and AdminBypassUsersText. Array properties use newline-separated
text with StringSplitOptions.RemoveEmptyEntries | TrimEntries for splitting.
This commit is contained in:
Joseph Doherty
2026-01-19 19:45:43 -05:00
parent cc555e4e34
commit 6e2decd21f
6 changed files with 597 additions and 0 deletions
@@ -0,0 +1,52 @@
using JdeScoping.ConfigManager.Models;
namespace JdeScoping.ConfigManager.ViewModels.Forms;
/// <summary>
/// ViewModel for editing Auth configuration section.
/// </summary>
public class AuthFormViewModel : ViewModelBase
{
private readonly AuthSection _model;
private readonly Action _onChanged;
public AuthFormViewModel(AuthSection model, Action onChanged)
{
_model = model ?? throw new ArgumentNullException(nameof(model));
_onChanged = onChanged ?? throw new ArgumentNullException(nameof(onChanged));
}
/// <summary>
/// Gets or sets the name of the authentication cookie.
/// </summary>
public string CookieName
{
get => _model.CookieName;
set
{
if (_model.CookieName != value)
{
_model.CookieName = value;
OnPropertyChanged();
_onChanged();
}
}
}
/// <summary>
/// Gets or sets the cookie expiration time in minutes.
/// </summary>
public int CookieExpirationMinutes
{
get => _model.CookieExpirationMinutes;
set
{
if (_model.CookieExpirationMinutes != value)
{
_model.CookieExpirationMinutes = value;
OnPropertyChanged();
_onChanged();
}
}
}
}
@@ -0,0 +1,154 @@
using JdeScoping.ConfigManager.Models;
namespace JdeScoping.ConfigManager.ViewModels.Forms;
/// <summary>
/// ViewModel for editing ExcelExport configuration section.
/// </summary>
public class ExcelExportFormViewModel : ViewModelBase
{
private readonly ExcelExportSection _model;
private readonly Action _onChanged;
public ExcelExportFormViewModel(ExcelExportSection model, Action onChanged)
{
_model = model ?? throw new ArgumentNullException(nameof(model));
_onChanged = onChanged ?? throw new ArgumentNullException(nameof(onChanged));
}
/// <summary>
/// Gets or sets the password for protecting the criteria worksheet.
/// </summary>
public string CriteriaSheetPassword
{
get => _model.CriteriaSheetPassword;
set
{
if (_model.CriteriaSheetPassword != value)
{
_model.CriteriaSheetPassword = value;
OnPropertyChanged();
_onChanged();
}
}
}
/// <summary>
/// Gets or sets the password for protecting the data worksheet.
/// </summary>
public string DataSheetPassword
{
get => _model.DataSheetPassword;
set
{
if (_model.DataSheetPassword != value)
{
_model.DataSheetPassword = value;
OnPropertyChanged();
_onChanged();
}
}
}
/// <summary>
/// Gets or sets the maximum number of rows per Excel worksheet.
/// </summary>
public int MaxRowsPerSheet
{
get => _model.MaxRowsPerSheet;
set
{
if (_model.MaxRowsPerSheet != value)
{
_model.MaxRowsPerSheet = value;
OnPropertyChanged();
_onChanged();
}
}
}
/// <summary>
/// Gets or sets the default date format for Excel exports.
/// </summary>
public string DefaultDateFormat
{
get => _model.DefaultDateFormat;
set
{
if (_model.DefaultDateFormat != value)
{
_model.DefaultDateFormat = value;
OnPropertyChanged();
_onChanged();
}
}
}
/// <summary>
/// Gets or sets whether to write debug output to files.
/// </summary>
public bool DebugWriteToFile
{
get => _model.DebugWriteToFile;
set
{
if (_model.DebugWriteToFile != value)
{
_model.DebugWriteToFile = value;
OnPropertyChanged();
_onChanged();
}
}
}
/// <summary>
/// Gets or sets the directory path for debug output files.
/// </summary>
public string DebugOutputDirectory
{
get => _model.DebugOutputDirectory;
set
{
if (_model.DebugOutputDirectory != value)
{
_model.DebugOutputDirectory = value;
OnPropertyChanged();
_onChanged();
}
}
}
/// <summary>
/// Gets or sets the time zone identifier for date/time conversions.
/// </summary>
public string TimezoneId
{
get => _model.TimezoneId;
set
{
if (_model.TimezoneId != value)
{
_model.TimezoneId = value;
OnPropertyChanged();
_onChanged();
}
}
}
/// <summary>
/// Gets or sets the time zone abbreviation for display purposes.
/// </summary>
public string TimezoneAbbreviation
{
get => _model.TimezoneAbbreviation;
set
{
if (_model.TimezoneAbbreviation != value)
{
_model.TimezoneAbbreviation = value;
OnPropertyChanged();
_onChanged();
}
}
}
}
@@ -0,0 +1,122 @@
using JdeScoping.ConfigManager.Models;
namespace JdeScoping.ConfigManager.ViewModels.Forms;
/// <summary>
/// ViewModel for editing LDAP configuration section.
/// </summary>
public class LdapFormViewModel : ViewModelBase
{
private readonly LdapSection _model;
private readonly Action _onChanged;
public LdapFormViewModel(LdapSection model, Action onChanged)
{
_model = model ?? throw new ArgumentNullException(nameof(model));
_onChanged = onChanged ?? throw new ArgumentNullException(nameof(onChanged));
}
/// <summary>
/// Gets or sets the server URLs as newline-separated text.
/// </summary>
public string ServerUrlsText
{
get => string.Join("\n", _model.ServerUrls);
set
{
var urls = value.Split('\n', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
if (!_model.ServerUrls.SequenceEqual(urls))
{
_model.ServerUrls = urls;
OnPropertyChanged();
_onChanged();
}
}
}
/// <summary>
/// Gets or sets the group distinguished name.
/// </summary>
public string GroupDn
{
get => _model.GroupDn;
set
{
if (_model.GroupDn != value)
{
_model.GroupDn = value;
OnPropertyChanged();
_onChanged();
}
}
}
/// <summary>
/// Gets or sets the search base distinguished name.
/// </summary>
public string SearchBase
{
get => _model.SearchBase;
set
{
if (_model.SearchBase != value)
{
_model.SearchBase = value;
OnPropertyChanged();
_onChanged();
}
}
}
/// <summary>
/// Gets or sets the connection timeout in seconds.
/// </summary>
public int ConnectionTimeoutSeconds
{
get => _model.ConnectionTimeoutSeconds;
set
{
if (_model.ConnectionTimeoutSeconds != value)
{
_model.ConnectionTimeoutSeconds = value;
OnPropertyChanged();
_onChanged();
}
}
}
/// <summary>
/// Gets or sets whether to use fake authentication.
/// </summary>
public bool UseFakeAuth
{
get => _model.UseFakeAuth;
set
{
if (_model.UseFakeAuth != value)
{
_model.UseFakeAuth = value;
OnPropertyChanged();
_onChanged();
}
}
}
/// <summary>
/// Gets or sets the admin bypass users as newline-separated text.
/// </summary>
public string AdminBypassUsersText
{
get => string.Join("\n", _model.AdminBypassUsers);
set
{
var users = value.Split('\n', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
if (!_model.AdminBypassUsers.SequenceEqual(users))
{
_model.AdminBypassUsers = users;
OnPropertyChanged();
_onChanged();
}
}
}
}