Loading angepasst
This commit is contained in:
@@ -155,6 +155,33 @@ else
|
||||
@code {
|
||||
private static readonly System.Globalization.CultureInfo _deCulture = new("de-DE");
|
||||
|
||||
[PersistentState(AllowUpdates = true)]
|
||||
public AppSettings? PersistentSettings { get; set; }
|
||||
|
||||
[PersistentState(AllowUpdates = true)]
|
||||
public List<MonthDayVm>? PersistentDays { get; set; }
|
||||
|
||||
[PersistentState(AllowUpdates = true)]
|
||||
public string? PersistentSubLabel { get; set; }
|
||||
|
||||
[PersistentState(AllowUpdates = true)]
|
||||
public TimeSpan? PersistentMonthNet { get; set; }
|
||||
|
||||
[PersistentState(AllowUpdates = true)]
|
||||
public TimeSpan? PersistentMonthOvertime { get; set; }
|
||||
|
||||
[PersistentState(AllowUpdates = true)]
|
||||
public int? PersistentRecordedWorkDays { get; set; }
|
||||
|
||||
[PersistentState(AllowUpdates = true)]
|
||||
public int? PersistentTotalWorkDays { get; set; }
|
||||
|
||||
[PersistentState(AllowUpdates = true)]
|
||||
public int? PersistentVacationCount { get; set; }
|
||||
|
||||
[PersistentState(AllowUpdates = true)]
|
||||
public int? PersistentHolidayCount { get; set; }
|
||||
|
||||
private bool _loading = true;
|
||||
private int _userId;
|
||||
private int _year = DateTime.Today.Year;
|
||||
@@ -174,13 +201,41 @@ else
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (PersistentSettings != null && PersistentDays != null)
|
||||
{
|
||||
_settings = PersistentSettings;
|
||||
_days = PersistentDays;
|
||||
_subLabel = PersistentSubLabel ?? "";
|
||||
_monthNet = PersistentMonthNet ?? TimeSpan.Zero;
|
||||
_monthOvertime = PersistentMonthOvertime ?? TimeSpan.Zero;
|
||||
_recordedWorkDays = PersistentRecordedWorkDays ?? 0;
|
||||
_totalWorkDays = PersistentTotalWorkDays ?? 0;
|
||||
_vacationCount = PersistentVacationCount ?? 0;
|
||||
_holidayCount = PersistentHolidayCount ?? 0;
|
||||
_loading = false;
|
||||
}
|
||||
|
||||
var authState = await AuthStateProvider.GetAuthenticationStateAsync();
|
||||
var claim = authState.User.FindFirst(ClaimTypes.NameIdentifier);
|
||||
if (claim == null) return;
|
||||
_userId = int.Parse(claim.Value);
|
||||
_settings = await TrackerService.GetSettingsAsync(_userId);
|
||||
await LoadMonth();
|
||||
_loading = false;
|
||||
|
||||
if (PersistentSettings == null || PersistentDays == null)
|
||||
{
|
||||
_settings = await TrackerService.GetSettingsAsync(_userId);
|
||||
await LoadMonth();
|
||||
|
||||
PersistentSettings = _settings;
|
||||
PersistentDays = _days;
|
||||
PersistentSubLabel = _subLabel;
|
||||
PersistentMonthNet = _monthNet;
|
||||
PersistentMonthOvertime = _monthOvertime;
|
||||
PersistentRecordedWorkDays = _recordedWorkDays;
|
||||
PersistentTotalWorkDays = _totalWorkDays;
|
||||
PersistentVacationCount = _vacationCount;
|
||||
PersistentHolidayCount = _holidayCount;
|
||||
_loading = false;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadMonth()
|
||||
@@ -317,7 +372,7 @@ else
|
||||
else Chip("Ausstehend", "#CFD8DC");
|
||||
};
|
||||
|
||||
private sealed class MonthDayVm
|
||||
public sealed class MonthDayVm
|
||||
{
|
||||
public DateOnly Date { get; set; }
|
||||
public TimeOnly? StartTime { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user