310 lines
14 KiB
Plaintext
310 lines
14 KiB
Plaintext
@page "/hr-kpi"
|
|
@using Microsoft.Extensions.Options
|
|
@using TrafagSalesExporter.Components.HrKpi
|
|
@using TrafagSalesExporter.Services
|
|
@inject IHrKpiService HrKpiService
|
|
@inject IOptions<HrKpiDataSourceOptions> DataSourceOptions
|
|
@inject IHrKpiAccessService HrKpiAccess
|
|
@inject ISnackbar Snackbar
|
|
@inject IUiTextService UiText
|
|
@inject IJSRuntime JsRuntime
|
|
|
|
<PageTitle>@T("HR KPI", "HR KPI")</PageTitle>
|
|
|
|
<MudText Typo="Typo.h4" Class="mb-4">@T("HR KPI", "HR KPI")</MudText>
|
|
|
|
@if (!CanShowHrKpi)
|
|
{
|
|
<MudPaper Class="pa-4 mb-4" Elevation="1" Style="max-width:520px;">
|
|
<MudStack Spacing="3">
|
|
<MudAlert Severity="Severity.Warning" Variant="Variant.Outlined">
|
|
@T("HR KPI enthaelt sensible Personaldaten. Bitte separat anmelden.", "HR KPI contains sensitive HR data. Please sign in separately.")
|
|
</MudAlert>
|
|
@if (!HrKpiAccess.IsConfigured)
|
|
{
|
|
<MudAlert Severity="Severity.Error" Variant="Variant.Filled">
|
|
@T("HR-KPI-Zugang ist noch nicht konfiguriert. Bitte Username und PasswordHash in HrKpiAccess konfigurieren.", "HR KPI access is not configured yet. Please configure Username and PasswordHash in HrKpiAccess.")
|
|
</MudAlert>
|
|
}
|
|
<MudTextField @bind-Value="_hrUsername" Label="@T("Name", "Name")" Disabled="@(!HrKpiAccess.IsConfigured)" />
|
|
<MudTextField @bind-Value="_hrPassword" Label="@T("Passwort", "Password")" InputType="InputType.Password" Disabled="@(!HrKpiAccess.IsConfigured)" />
|
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="UnlockHrKpiAsync"
|
|
StartIcon="@Icons.Material.Filled.LockOpen" Disabled="@(!HrKpiAccess.IsConfigured)">
|
|
@T("HR KPI entsperren", "Unlock HR KPI")
|
|
</MudButton>
|
|
<MudDivider />
|
|
<MudExpansionPanels Elevation="0">
|
|
<MudExpansionPanel Text="@T("Passwort ändern", "Change password")" Icon="@Icons.Material.Filled.Password">
|
|
<MudStack Spacing="3" Class="pt-2">
|
|
<MudTextField @bind-Value="_changeUsername" Label="@T("Name", "Name")" Disabled="@(!HrKpiAccess.IsConfigured)" />
|
|
<MudTextField @bind-Value="_currentPassword" Label="@T("Aktuelles Passwort", "Current password")" InputType="InputType.Password" Disabled="@(!HrKpiAccess.IsConfigured)" />
|
|
<MudTextField @bind-Value="_newPassword" Label="@T("Neues Passwort", "New password")" InputType="InputType.Password" HelperText="@T("Mindestens 8 Zeichen.", "At least 8 characters.")" Disabled="@(!HrKpiAccess.IsConfigured)" />
|
|
<MudTextField @bind-Value="_newPasswordRepeat" Label="@T("Neues Passwort wiederholen", "Repeat new password")" InputType="InputType.Password" Disabled="@(!HrKpiAccess.IsConfigured)" />
|
|
<MudButton Variant="Variant.Outlined" Color="Color.Primary" OnClick="ChangeHrPasswordAsync"
|
|
StartIcon="@Icons.Material.Filled.Save" Disabled="@(!HrKpiAccess.IsConfigured)">
|
|
@T("Passwort speichern", "Save password")
|
|
</MudButton>
|
|
</MudStack>
|
|
</MudExpansionPanel>
|
|
</MudExpansionPanels>
|
|
</MudStack>
|
|
</MudPaper>
|
|
}
|
|
else
|
|
{
|
|
<MudPaper Class="pa-4 mb-4" Elevation="1">
|
|
<MudGrid>
|
|
<MudItem xs="12" md="5">
|
|
<MudTextField @bind-Value="_dataFolder"
|
|
Label="@T("Datenordner fuer Rexx/SAP-Dateien", "Data folder for Rexx/SAP files")"
|
|
HelperText="@T("Standard ist C:\\temp. Der Ordner kann hier fuer den aktuellen Lauf angepasst oder dauerhaft in appsettings.json unter HrKpi:DataFolder geaendert werden.", "Default is C:\\temp. The folder can be changed here for the current run or permanently in appsettings.json under HrKpi:DataFolder.")" />
|
|
</MudItem>
|
|
<MudItem xs="6" md="2">
|
|
<MudSelect T="int?" @bind-Value="_year" Label="@T("Austrittsjahr", "Leaver year")" Dense Clearable>
|
|
@foreach (var option in _result?.ExitYearOptions ?? [])
|
|
{
|
|
<MudSelectItem Value="@((int?)option)">@option</MudSelectItem>
|
|
}
|
|
</MudSelect>
|
|
</MudItem>
|
|
<MudItem xs="12" md="3">
|
|
<MudSelect T="string" @bind-Value="_organisation" Label="@T("Organisation", "Organisation")" Dense Clearable>
|
|
@foreach (var option in _result?.OrganisationOptions ?? [])
|
|
{
|
|
<MudSelectItem Value="@option">@option</MudSelectItem>
|
|
}
|
|
</MudSelect>
|
|
</MudItem>
|
|
<MudItem xs="12" md="2">
|
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="LoadAsync"
|
|
StartIcon="@Icons.Material.Filled.Refresh" Disabled="_loading" FullWidth>
|
|
@(_loading ? T("Lade...", "Loading...") : T("Laden", "Load"))
|
|
</MudButton>
|
|
</MudItem>
|
|
<MudItem xs="12" md="2">
|
|
<MudSwitch T="bool" @bind-Value="_managementView" Color="Color.Primary"
|
|
Label="@T("Managementsicht", "Management view")" />
|
|
</MudItem>
|
|
<MudItem xs="12" md="3">
|
|
<MudDatePicker @bind-Date="_fromDate" Label="@T("Von Austritt", "Exit from")" Clearable DateFormat="dd.MM.yyyy" />
|
|
</MudItem>
|
|
<MudItem xs="12" md="3">
|
|
<MudDatePicker @bind-Date="_toDate" Label="@T("Bis Austritt", "Exit to")" Clearable DateFormat="dd.MM.yyyy" />
|
|
</MudItem>
|
|
<MudItem xs="12" md="2">
|
|
<MudSelect T="int?" @bind-Value="_entryYear" Label="@T("Eintrittsjahr", "Entry year")" Dense Clearable>
|
|
@foreach (var option in _result?.EntryYearOptions ?? [])
|
|
{
|
|
<MudSelectItem Value="@((int?)option)">@option</MudSelectItem>
|
|
}
|
|
</MudSelect>
|
|
</MudItem>
|
|
<MudItem xs="12" md="4">
|
|
<MudTextField @bind-Value="_searchText" Label="@T("Suche Name / Personalnr.", "Search name / personnel no.")" />
|
|
</MudItem>
|
|
<MudItem xs="12" md="3">
|
|
<MudSelect T="string" @bind-Value="_kostenstelle" Label="@T("Kostenstelle", "Cost center")" Dense Clearable>
|
|
@foreach (var option in _result?.KostenstelleOptions ?? [])
|
|
{
|
|
<MudSelectItem Value="@option">@option</MudSelectItem>
|
|
}
|
|
</MudSelect>
|
|
</MudItem>
|
|
<MudItem xs="12" md="3">
|
|
<MudSelect T="string" @bind-Value="_mitarbeitertyp" Label="@T("Mitarbeitertyp", "Employee type")" Dense Clearable>
|
|
@foreach (var option in _result?.MitarbeitertypOptions ?? [])
|
|
{
|
|
<MudSelectItem Value="@option">@option</MudSelectItem>
|
|
}
|
|
</MudSelect>
|
|
</MudItem>
|
|
<MudItem xs="12" md="2">
|
|
<MudSelect T="string" @bind-Value="_fluktuationFilter" Label="@T("Fluktuation", "Turnover")" Dense>
|
|
@foreach (var option in _fluktuationOptions)
|
|
{
|
|
<MudSelectItem Value="@option.Key">@option.Label</MudSelectItem>
|
|
}
|
|
</MudSelect>
|
|
</MudItem>
|
|
<MudItem xs="6" md="2">
|
|
<MudSelect T="string" @bind-Value="_glzAmpel" Label="@T("GLZ", "Time")" Dense Clearable>
|
|
@foreach (var option in _ampelOptions)
|
|
{
|
|
<MudSelectItem Value="@option">@option</MudSelectItem>
|
|
}
|
|
</MudSelect>
|
|
</MudItem>
|
|
<MudItem xs="6" md="2">
|
|
<MudSelect T="string" @bind-Value="_restferienAmpel" Label="@T("Restferien", "Vacation")" Dense Clearable>
|
|
@foreach (var option in _restferienOptions)
|
|
{
|
|
<MudSelectItem Value="@option">@option</MudSelectItem>
|
|
}
|
|
</MudSelect>
|
|
</MudItem>
|
|
<MudItem xs="12" md="2">
|
|
<MudButton Variant="Variant.Outlined" Color="Color.Secondary" OnClick="LockHrKpi"
|
|
StartIcon="@Icons.Material.Filled.Lock" FullWidth>
|
|
@T("Sperren", "Lock")
|
|
</MudButton>
|
|
</MudItem>
|
|
<MudItem xs="12" md="2">
|
|
<MudButton Variant="Variant.Outlined" Color="Color.Primary" OnClick="PrintAsync"
|
|
StartIcon="@Icons.Material.Filled.Print" FullWidth>
|
|
@T("Drucken/PDF", "Print/PDF")
|
|
</MudButton>
|
|
</MudItem>
|
|
</MudGrid>
|
|
</MudPaper>
|
|
}
|
|
|
|
@if (CanShowHrKpi && _result is not null)
|
|
{
|
|
@if (_result.Notices.Count > 0)
|
|
{
|
|
<MudPaper Class="pa-4 mb-4" Elevation="1">
|
|
@foreach (var notice in _result.Notices)
|
|
{
|
|
<MudAlert Severity="Severity.Warning" Dense Variant="Variant.Outlined" Class="mb-2">@notice</MudAlert>
|
|
}
|
|
</MudPaper>
|
|
}
|
|
|
|
<HrKpiDashboardTabs Result="_result" />
|
|
|
|
}
|
|
|
|
@code {
|
|
private string _dataFolder = HrKpiDataSourceOptions.DefaultFolder;
|
|
private int? _year;
|
|
private DateTime? _fromDate;
|
|
private DateTime? _toDate;
|
|
private int? _entryYear;
|
|
private string? _organisation;
|
|
private string? _kostenstelle;
|
|
private string? _mitarbeitertyp;
|
|
private string _fluktuationFilter = "Alle";
|
|
private string? _glzAmpel;
|
|
private string? _restferienAmpel;
|
|
private string? _searchText;
|
|
private bool _managementView;
|
|
private string? _hrUsername;
|
|
private string? _hrPassword;
|
|
private string? _changeUsername;
|
|
private string? _currentPassword;
|
|
private string? _newPassword;
|
|
private string? _newPasswordRepeat;
|
|
private bool _loading;
|
|
private HrKpiResult? _result;
|
|
private readonly List<(string Key, string Label)> _fluktuationOptions =
|
|
[
|
|
("Alle", "Alle"),
|
|
("Fluktuationsrelevant", "Relevant"),
|
|
("Arbeitnehmerkuendigung", "Arbeitnehmerkuendigung"),
|
|
("Ausgeschlossen", "Ausgeschlossen")
|
|
];
|
|
private readonly List<string> _ampelOptions = ["Gruen", "Gelb", "Rot"];
|
|
private readonly List<string> _restferienOptions = ["Gruen", "Rot"];
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
_dataFolder = DataSourceOptions.Value.Normalize().DataFolder;
|
|
if (CanShowHrKpi)
|
|
{
|
|
await LoadAsync();
|
|
}
|
|
}
|
|
|
|
private async Task LoadAsync()
|
|
{
|
|
if (!CanShowHrKpi)
|
|
{
|
|
return;
|
|
}
|
|
|
|
_loading = true;
|
|
try
|
|
{
|
|
_result = await HrKpiService.BuildAsync(new HrKpiOptions
|
|
{
|
|
DataFolder = _dataFolder,
|
|
Year = _year,
|
|
FromDate = _fromDate,
|
|
ToDate = _toDate,
|
|
EntryYear = _entryYear,
|
|
Organisationseinheit = _organisation,
|
|
KostenstelleText = _kostenstelle,
|
|
Mitarbeitertyp = _mitarbeitertyp,
|
|
FluktuationFilter = _fluktuationFilter,
|
|
GlzAmpel = _glzAmpel,
|
|
RestferienAmpel = _restferienAmpel,
|
|
SearchText = _searchText,
|
|
ManagementView = _managementView
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Snackbar.Add(ex.Message, Severity.Error);
|
|
}
|
|
finally
|
|
{
|
|
_loading = false;
|
|
}
|
|
}
|
|
|
|
private async Task UnlockHrKpiAsync()
|
|
{
|
|
if (!HrKpiAccess.TryUnlock(_hrUsername ?? string.Empty, _hrPassword ?? string.Empty))
|
|
{
|
|
Snackbar.Add(T("HR-KPI-Anmeldung fehlgeschlagen.", "HR KPI sign-in failed."), Severity.Error);
|
|
return;
|
|
}
|
|
|
|
_hrPassword = string.Empty;
|
|
await LoadAsync();
|
|
}
|
|
|
|
private Task ChangeHrPasswordAsync()
|
|
{
|
|
if (string.IsNullOrWhiteSpace(_newPassword) || _newPassword.Length < 8)
|
|
{
|
|
Snackbar.Add(T("Das neue Passwort muss mindestens 8 Zeichen lang sein.", "The new password must be at least 8 characters long."), Severity.Warning);
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
if (_newPassword != _newPasswordRepeat)
|
|
{
|
|
Snackbar.Add(T("Die neuen Passwörter stimmen nicht überein.", "The new passwords do not match."), Severity.Warning);
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
if (!HrKpiAccess.TryChangePassword(_changeUsername ?? string.Empty, _currentPassword ?? string.Empty, _newPassword))
|
|
{
|
|
Snackbar.Add(T("Passwort konnte nicht geändert werden. Name oder aktuelles Passwort prüfen.", "Password could not be changed. Check the name or current password."), Severity.Error);
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
_currentPassword = string.Empty;
|
|
_newPassword = string.Empty;
|
|
_newPasswordRepeat = string.Empty;
|
|
Snackbar.Add(T("Passwort wurde geändert.", "Password has been changed."), Severity.Success);
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
private void LockHrKpi()
|
|
{
|
|
HrKpiAccess.Lock();
|
|
_result = null;
|
|
_hrPassword = string.Empty;
|
|
}
|
|
|
|
private async Task PrintAsync()
|
|
{
|
|
await JsRuntime.InvokeVoidAsync("print");
|
|
}
|
|
|
|
private bool CanShowHrKpi => !HrKpiAccess.IsEnabled || HrKpiAccess.IsUnlocked;
|
|
|
|
private string T(string german, string english) => UiText.Text(german, english);
|
|
}
|