UI BUGFIX

This commit is contained in:
2025-04-09 15:37:30 +02:00
parent d383ccccbd
commit e3ee93c74c
5 changed files with 74 additions and 15 deletions
@@ -1,3 +1,5 @@
using CommunityToolkit.Maui.Alerts;
using CommunityToolkit.Maui.Core;
using System.Diagnostics;
using System.Globalization;
using System.Threading.Tasks;
@@ -13,6 +15,7 @@ public partial class CheckListPage : ContentPage
{
private readonly ICheckListService _checkListService;
private readonly IUserService _userService;
private readonly ISyncService _syncService;
private bool _isLoading;
private UserDTO _currentUser;
@@ -36,6 +39,7 @@ public partial class CheckListPage : ContentPage
InitializeComponent();
_checkListService = MauiProgram.ServiceProvider.GetRequiredService<ICheckListService>();
_userService = MauiProgram.ServiceProvider.GetRequiredService<IUserService>();
_syncService = MauiProgram.ServiceProvider.GetRequiredService<ISyncService>();
NewCommand = new Command<CheckListTemplateHeaderDTO>(OnNewItem);
ContinueCommand = new Command<CheckListHeaderDTO>(OnContinueItem);
UnblockCommand = new Command<CheckListHeaderDTO>(OnUnblockItem);
@@ -64,13 +68,48 @@ public partial class CheckListPage : ContentPage
private async void OnNewItem(CheckListTemplateHeaderDTO checkListTemplateHeaderDTO)
{
IsLoading = true;
await _checkListService.StartNew(
var response = await _checkListService.StartNew(
new CheckListHeaderNewDTO()
{
UserId = _userService.GetCurrentUser().Id,
CheckListTemplateHeaderId = checkListTemplateHeaderDTO.Id
});
IsLoading = false;
if (response != null && response.IsSuccess)
{
await Task.Run(async () =>
{
await _syncService.SyncCheckListHeader_Down((percentage, infostring) =>
{
// Direkt UI frissítés
MainThread.BeginInvokeOnMainThread(() =>
{
//progressBar.Progress = percentage / 100;
//progressLabel.Text = $"{infostring}: {percentage:0.00}%";
});
});
});
await LoadCheckList();
var visualOptions = new SnackbarOptions
{
ActionButtonTextColor = Colors.White,
CornerRadius = new CornerRadius(10),
Font = Microsoft.Maui.Font.SystemFontOfSize(16),
BackgroundColor = Microsoft.Maui.Graphics.Color.Parse("Green"),
TextColor = Colors.White
};
var snackbar = Snackbar.Make(
$"Új ellenõrzés indult! {response.Data.DocumentNumber}",
duration: TimeSpan.FromSeconds(10),
action: () => Console.WriteLine("Snackbar dismissed"),
actionButtonText: "OK",
visualOptions: visualOptions
);
await snackbar.Show();
}
}
private async void OnContinueItem(CheckListHeaderDTO checkListHeaderDTO)
{
@@ -96,15 +135,34 @@ public partial class CheckListPage : ContentPage
private async Task LoadCheckListTemplate()
{
IsLoading = true;
CheckListTemplate.ItemsSource = await _checkListService.GetCheckListTemplates(_currentUser.Id);
IsLoading = false;
}
private async Task LoadCheckList()
{
IsLoading = true;
CheckList.ItemsSource = await _checkListService.GetCheckLists(_currentUser.Id);
var checkListHeaderDTOs = await _checkListService.GetCheckLists(_currentUser.Id);
var isAdmin = false;
var userDTO = _userService.GetCurrentUser();
foreach (var roleDTO in userDTO.RoleDTO)
{
if (roleDTO.IsAdmin)
{
isAdmin = true;
CheckList.ItemsSource = checkListHeaderDTOs;
break;
}
}
if (!isAdmin)
{
var result = checkListHeaderDTOs
.Where(w => w.UserId == userDTO.Id && w.CheckStatus != CheckStatus.Blocked).ToList();
CheckList.ItemsSource = result;
}
IsLoading = false;
}
@@ -3,7 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="WorkFlowCheck.MAUI.Pages.Security.LoginPage"
xmlns:local="clr-namespace:WorkFlowCheck.MAUI.Pages"
Title="Bejelentkezés"
Title="Workflow Check Application (v0.988)"
BackgroundColor="#f0f0f0">
<ContentView x:Name="LoginContent">
@@ -45,7 +45,7 @@
<Entry x:Name="PasswordEntry"
Placeholder="PIN kód"
IsPassword="True"
Keyboard="Numeric"
FontSize="18"
BackgroundColor="#f9f9f9"
HeightRequest="50"
@@ -5,6 +5,7 @@ using Newtonsoft.Json;
using System.Net.Http.Json;
using System.Runtime.CompilerServices;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.Common.Enums;
using WorkFlowCheck.MAUI.DataLayer;
using WorkFlowCheck.MAUI.Services.Interfaces;
@@ -94,7 +95,11 @@ namespace WorkFlowCheck.MAUI.Services
var retVal = new List<CheckListHeaderDTO>();
try
{
var res = await _dbContext.CheckListHeaders.ToListAsync();
var res = await _dbContext.CheckListHeaders
.Where(w => w.CheckStatus == CheckStatus.Open ||
w.CheckStatus == CheckStatus.InProgress ||
w.CheckStatus == CheckStatus.Blocked)
.ToListAsync();
retVal = _mapper.Map<List<CheckListHeaderDTO>>(res);
}
catch (Exception ex)
@@ -151,7 +151,7 @@ namespace WorkFlowCheck.MAUI.Services
var checkPointListDTO = _mapper.Map<List<CheckPointDTO>>(checkPointList);
var endpoint = $"{_httpClient.BaseAddress}api/Sync/UpdateAllCheckPoint";
var json = JsonConvert.SerializeObject(checkPointListDTO);
var json = JsonConvert.SerializeObject(checkPointListDTO, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
var jsonBytes = Encoding.UTF8.GetBytes(json);
var jsonStream = new MemoryStream(jsonBytes);
@@ -314,11 +314,7 @@ namespace WorkFlowCheck.MAUI.Services
var checkListHeaderDTO = _mapper.Map<CheckListHeaderDTO>(checkListHeader);
var endpoint = $"{_httpClient.BaseAddress}api/Sync/SendCheckListHeader";
var json = JsonConvert.SerializeObject(checkListHeaderDTO,
new JsonSerializerSettings
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
});
var json = JsonConvert.SerializeObject(checkListHeaderDTO, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
var jsonBytes = Encoding.UTF8.GetBytes(json);
var jsonStream = new MemoryStream(jsonBytes);
@@ -160,7 +160,7 @@ namespace WorkFlowCheck.MAUI.Services
var userListDTO = _mapper.Map<List<UserDTO>>(userList);
var endpoint = $"{_httpClient.BaseAddress}api/Sync/UpdateAllUser";
var json = JsonConvert.SerializeObject(userListDTO);
var json = JsonConvert.SerializeObject(userListDTO, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
var jsonBytes = Encoding.UTF8.GetBytes(json);
var jsonStream = new MemoryStream(jsonBytes);
@@ -187,7 +187,7 @@ namespace WorkFlowCheck.MAUI.Services
}
return retVal;
}
public void SetCurrentUser(UserDTO user)
{
CurrentUser = user;