FÉLKÉSZ

This commit is contained in:
2025-04-05 18:11:42 +02:00
parent 4951fc0c7a
commit 33232bae75
15 changed files with 404 additions and 72 deletions
@@ -7,26 +7,33 @@
<Frame BorderColor="Gray" Padding="5" Margin="1" HasShadow="True">
<VerticalStackLayout Margin="10,10,10,0">
<Button
x:Name="ButtonGetCheckPoints"
Margin="0,0,0,10"
Text="Ellenőrzési pontok"
SemanticProperties.Hint="Ellenőrzési pontok"
Clicked="OnButtonGetCheckPoints"
HorizontalOptions="Fill" />
x:Name="ButtonGetCheckPoints"
Margin="0,0,0,10"
Text="Ellenőrzési pontok"
SemanticProperties.Hint="Ellenőrzési pontok"
Clicked="OnButtonGetCheckPoints"
HorizontalOptions="Fill" />
<Button
x:Name="ButtonGetEquipments"
Margin="0,0,0,10"
Text="Berendezések"
SemanticProperties.Hint="Berendezések"
Clicked="OnButtonGetCheckPoints"
HorizontalOptions="Fill" />
x:Name="ButtonGetEquipments"
Margin="0,0,0,10"
Text="Berendezések"
SemanticProperties.Hint="Berendezések"
Clicked="OnButtonGetEquipments"
HorizontalOptions="Fill" />
<Button
x:Name="ButtonGetLocations"
Margin="0,0,0,10"
Text="Lokációk"
SemanticProperties.Hint="Lokációk"
Clicked="OnButtonGetCheckPoints"
HorizontalOptions="Fill" />
x:Name="ButtonGetLocations"
Margin="0,0,0,10"
Text="Lokációk"
SemanticProperties.Hint="Lokációk"
Clicked="OnButtonGetLocations"
HorizontalOptions="Fill" />
<Button
x:Name="ButtonGetUsers"
Margin="0,0,0,10"
Text="Felhasználók"
SemanticProperties.Hint="Felhasználók"
Clicked="OnButtonGetUsers"
HorizontalOptions="Fill" />
</VerticalStackLayout>
</Frame>
</VerticalStackLayout>
@@ -1,4 +1,5 @@
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.MAUI.Pages.Security;
namespace WorkFlowCheck.MAUI.Pages.BaseStock;
@@ -16,11 +17,18 @@ public partial class BaseStockPage : ContentPage
}
private async void OnButtonGetEquipments(object sender, EventArgs e)
{
await Shell.Current.GoToAsync("//EquipmentsPage");
//await Shell.Current.GoToAsync("//EquipmentsPage");
await Navigation.PushAsync(new EquipmentsPage());
}
private async void OnButtonGetLocations(object sender, EventArgs e)
{
await Shell.Current.GoToAsync("//LocationsPage");
//await Shell.Current.GoToAsync("//LocationsPage");
await Navigation.PushAsync(new LocationsPage());
}
private async void OnButtonGetUsers(object sender, EventArgs e)
{
//await Shell.Current.GoToAsync("//LocationsPage");
await Navigation.PushAsync(new UsersPage());
}
protected override bool OnBackButtonPressed()
@@ -3,36 +3,46 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="WorkFlowCheck.MAUI.Pages.BaseStock.CheckPointsPage"
Title="Ellenőrzési pontok">
<StackLayout>
<Label x:Name="progressLabel" Text="Folyamatjelző" FontSize="Medium" HorizontalOptions="Center" />
<ProgressBar x:Name="progressBar" WidthRequest="300" HeightRequest="40" />
<Button
x:Name="ButtonSync" Margin="5"
Text="Adatok szinkronizálása"
SemanticProperties.Hint="Adatok szinkronizálása"
Clicked="OnButtonSync"
HorizontalOptions="Fill" />
<RefreshView x:Name="refreshView" Command="{Binding RefreshCommand}" IsRefreshing="{Binding IsRefreshing}">
<CollectionView x:Name="CheckPointsList">
<CollectionView.ItemTemplate>
<DataTemplate>
<Frame BorderColor="Gray" Padding="10" Margin="5" HasShadow="True" BackgroundColor="WhiteSmoke">
<StackLayout>
<Label Text="{Binding ShortName}" FontSize="16" FontAttributes="Bold" />
<Label Text="{Binding Code}" FontSize="14" />
<HorizontalStackLayout HorizontalOptions="End">
<Button Text="Edit" Margin="5,0,0,0"
Command="{Binding BindingContext.EditCommand, Source={x:Reference CheckPointsList}}"
CommandParameter="{Binding .}" />
<Button Text="Pair" Margin="5,0,0,0"
Command="{Binding BindingContext.PairCommand, Source={x:Reference CheckPointsList}}"
CommandParameter="{Binding .}" />
</HorizontalStackLayout>
</StackLayout>
</Frame>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</RefreshView>
</StackLayout>
</ContentPage>
<Grid>
<!-- Fő tartalom -->
<StackLayout>
<Label x:Name="progressLabel" Text="Folyamatjelző" FontSize="Medium" HorizontalOptions="Center" />
<ProgressBar x:Name="progressBar" WidthRequest="300" HeightRequest="40" />
<Button
x:Name="ButtonSync" Margin="5"
Text="Adatok szinkronizálása"
SemanticProperties.Hint="Adatok szinkronizálása"
Clicked="OnButtonSync"
HorizontalOptions="Fill" />
<RefreshView x:Name="refreshView" Command="{Binding RefreshCommand}" IsRefreshing="{Binding IsRefreshing}">
<CollectionView x:Name="CheckPointsList">
<CollectionView.ItemTemplate>
<DataTemplate>
<Frame BorderColor="Gray" Padding="10" Margin="5" HasShadow="True" BackgroundColor="WhiteSmoke">
<StackLayout>
<Label Text="{Binding ShortName}" FontSize="16" FontAttributes="Bold" />
<Label Text="{Binding Code}" FontSize="14" />
<HorizontalStackLayout HorizontalOptions="End">
<Button Text="Edit" Margin="5,0,0,0"
Command="{Binding BindingContext.EditCommand, Source={x:Reference CheckPointsList}}"
CommandParameter="{Binding .}" />
<Button Text="Pair" Margin="5,0,0,0"
Command="{Binding BindingContext.PairCommand, Source={x:Reference CheckPointsList}}"
CommandParameter="{Binding .}" />
</HorizontalStackLayout>
</StackLayout>
</Frame>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</RefreshView>
</StackLayout>
<!-- Betöltés közbeni ActivityIndicator -->
<Grid x:Name="loadingOverlay" BackgroundColor="#80000000" IsVisible="{Binding IsLoading}" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0, 0, 1, 1">
<ActivityIndicator IsRunning="{Binding IsLoading}" Color="White"
VerticalOptions="Center" HorizontalOptions="Center"
WidthRequest="50" HeightRequest="50"/>
</Grid>
</Grid>
</ContentPage>
@@ -20,11 +20,20 @@ public partial class CheckPointsPage : ContentPage
_baseStockService = MauiProgram.ServiceProvider.GetRequiredService<IBaseStockService>();
_syncService = MauiProgram.ServiceProvider.GetRequiredService<ISyncService>();
}
private bool _isLoading;
public bool IsLoading
{
get => _isLoading;
set
{
_isLoading = value;
OnPropertyChanged();
}
}
public ICommand RefreshCommand { get; set; }
public ICommand EditCommand { get; set; }
public ICommand PairCommand { get; set; }
public bool IsRefreshing { get; set; }
protected override async void OnAppearing()
{
@@ -39,15 +48,12 @@ public partial class CheckPointsPage : ContentPage
}
private async Task LoadCheckPoints()
{
IsRefreshing = true;
//await _syncService.SyncDatas();
IsLoading = true;
CheckPointsList.ItemsSource = await _baseStockService.GetAllCheckPoints();
IsRefreshing = false;
OnPropertyChanged(nameof(IsRefreshing));
IsLoading = false;
}
private async void OnEditItem(CheckPointDTO checkPointDTO)
{
// Navigálás a CheckPointEdit.xaml-ra, és átadjuk az editálni kívánt elemet
await Navigation.PushAsync(new CheckPointEditPage(checkPointDTO));
}
private async void OnPairItem(CheckPointDTO checkPointDTO)
@@ -74,7 +80,7 @@ public partial class CheckPointsPage : ContentPage
}
private async void OnButtonSync(object sender, EventArgs e)
{
IsRefreshing = true;
IsLoading = true;
ButtonSync.IsEnabled = false;
progressLabel.Text = "Szinkronizálás indítása...";
@@ -103,7 +109,7 @@ public partial class CheckPointsPage : ContentPage
finally
{
ButtonSync.IsEnabled = true;
IsRefreshing = false;
IsLoading = false;
}
}
}
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="WorkFlowCheck.MAUI.Pages.Security.UsersPage"
Title="Felhasználók">
<StackLayout>
<Label x:Name="progressLabel" Text="Folyamatjelző" FontSize="Medium" HorizontalOptions="Center" />
<ProgressBar x:Name="progressBar" WidthRequest="300" HeightRequest="40" />
<Button
x:Name="ButtonSync" Margin="5"
Text="Adatok szinkronizálása"
SemanticProperties.Hint="Adatok szinkronizálása"
Clicked="OnButtonSync"
HorizontalOptions="Fill" />
<RefreshView x:Name="refreshView" Command="{Binding RefreshCommand}" IsRefreshing="{Binding IsRefreshing}">
<CollectionView x:Name="UsersList">
<CollectionView.ItemTemplate>
<DataTemplate>
<Frame BorderColor="Gray" Padding="10" Margin="5" HasShadow="True" BackgroundColor="WhiteSmoke">
<StackLayout>
<Label Text="{Binding ShortName}" FontSize="16" FontAttributes="Bold" />
<Label Text="{Binding Code}" FontSize="14" />
<HorizontalStackLayout HorizontalOptions="End">
<Button Text="Edit" Margin="5,0,0,0"
Command="{Binding BindingContext.EditCommand, Source={x:Reference UsersList}}"
CommandParameter="{Binding .}" />
<Button Text="Pair" Margin="5,0,0,0"
Command="{Binding BindingContext.PairCommand, Source={x:Reference UsersList}}"
CommandParameter="{Binding .}" />
</HorizontalStackLayout>
</StackLayout>
</Frame>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</RefreshView>
</StackLayout>
</ContentPage>
@@ -0,0 +1,99 @@
using System.Windows.Input;
using WorkFlowCheck.Common.DTO;
using WorkFlowCheck.MAUI.Services.Interfaces;
using WorkFlowCheck.MAUI.Pages.NFC;
namespace WorkFlowCheck.MAUI.Pages.Security;
public partial class UsersPage : ContentPage
{
private readonly IUserService _userService;
public UsersPage()
{
InitializeComponent();
_userService = MauiProgram.ServiceProvider.GetRequiredService<IUserService>();
}
public ICommand RefreshCommand { get; set; }
public ICommand PairCommand { get; set; }
public bool IsRefreshing { get; set; }
protected override async void OnAppearing()
{
base.OnAppearing();
RefreshCommand = new Command(async () => await LoadUsers());
PairCommand = new Command<UserDTO>(OnPairItem);
BindingContext = this;
await LoadUsers();
}
private async Task LoadUsers()
{
IsRefreshing = true;
//await _syncService.SyncDatas();
UsersList.ItemsSource = await _userService.GetAllUsers();
IsRefreshing = false;
OnPropertyChanged(nameof(IsRefreshing));
}
private async void OnPairItem(UserDTO UserDTO)
{
var UserCode = await NFCWaiter.ShowModalAsync();
if (!string.IsNullOrEmpty(UserCode))
{
if (Navigation.ModalStack.Count > 0)
{
await Navigation.PopModalAsync();
}
if (UserDTO != null)
{
UserDTO.Code = UserCode;
await _baseStockService.UpdateUser(UserDTO);
await LoadUsers();
}
}
}
protected override bool OnBackButtonPressed()
{
Shell.Current.GoToAsync("//BaseStockPage");
return true;
}
private async void OnButtonSync(object sender, EventArgs e)
{
IsRefreshing = true;
ButtonSync.IsEnabled = false;
progressLabel.Text = "Szinkronizálás indítása...";
progressBar.Progress = 0;
try
{
await Task.Run(async () =>
{
await _userService.SyncUsers_Up((percentage, infostring) =>
{
MainThread.BeginInvokeOnMainThread(() =>
{
progressBar.Progress = percentage / 100;
progressLabel.Text = $"{infostring}: {percentage:0.00}%";
});
});
});
progressLabel.Text = "Szinkronizálás befejezve!";
}
catch (Exception ex)
{
progressLabel.Text = $"Hiba történt: {ex.Message}";
}
finally
{
ButtonSync.IsEnabled = true;
IsRefreshing = false;
}
}
}