EmployeeView
This commit is contained in:
parent
6c652dc620
commit
8ca1fb91dd
3
.idea/.idea.ChronoFlow/.idea/avalonia.xml
generated
3
.idea/.idea.ChronoFlow/.idea/avalonia.xml
generated
@ -10,6 +10,9 @@
|
|||||||
<entry key="ChronoFlow.View/LoginView.axaml" value="ChronoFlow.View/ChronoFlow.View.csproj" />
|
<entry key="ChronoFlow.View/LoginView.axaml" value="ChronoFlow.View/ChronoFlow.View.csproj" />
|
||||||
<entry key="ChronoFlow.View/LoginWindow.axaml" value="ChronoFlow.View/ChronoFlow.View.csproj" />
|
<entry key="ChronoFlow.View/LoginWindow.axaml" value="ChronoFlow.View/ChronoFlow.View.csproj" />
|
||||||
<entry key="ChronoFlow.View/MainWindow.axaml" value="ChronoFlow.View/ChronoFlow.View.csproj" />
|
<entry key="ChronoFlow.View/MainWindow.axaml" value="ChronoFlow.View/ChronoFlow.View.csproj" />
|
||||||
|
<entry key="ChronoFlow.View/Mitarbeiter/EmployeeTasksView.axaml" value="ChronoFlow.View/ChronoFlow.View.csproj" />
|
||||||
|
<entry key="ChronoFlow.View/Mitarbeiter/EmployeeTasksViewModel.axaml" value="ChronoFlow.View/ChronoFlow.View.csproj" />
|
||||||
|
<entry key="ChronoFlow.View/Mitarbeiter/MitarbeiterMainView.axaml" value="ChronoFlow.View/ChronoFlow.View.csproj" />
|
||||||
<entry key="ChronoFlow.View/Mitarbeiter/MitarbeiterView.axaml" value="ChronoFlow.View/ChronoFlow.View.csproj" />
|
<entry key="ChronoFlow.View/Mitarbeiter/MitarbeiterView.axaml" value="ChronoFlow.View/ChronoFlow.View.csproj" />
|
||||||
<entry key="ChronoFlow.View/MitarbeiterHinzufuegenView.axaml" value="ChronoFlow.View/ChronoFlow.View.csproj" />
|
<entry key="ChronoFlow.View/MitarbeiterHinzufuegenView.axaml" value="ChronoFlow.View/ChronoFlow.View.csproj" />
|
||||||
<entry key="ChronoFlow.View/ZeiterfassungView.axaml" value="ChronoFlow.View/ChronoFlow.View.csproj" />
|
<entry key="ChronoFlow.View/ZeiterfassungView.axaml" value="ChronoFlow.View/ChronoFlow.View.csproj" />
|
||||||
|
|||||||
@ -23,5 +23,19 @@ namespace ChronoFlow.Model
|
|||||||
Erledigt = false;
|
Erledigt = false;
|
||||||
MitarbeiterKommentar = "";
|
MitarbeiterKommentar = "";
|
||||||
}
|
}
|
||||||
|
public string PrioritaetsFarbe
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var tageBisEnde = (Endzeit - DateTime.Now).TotalDays;
|
||||||
|
|
||||||
|
if (tageBisEnde <= 3)
|
||||||
|
return "Red";
|
||||||
|
else if (tageBisEnde <= 7)
|
||||||
|
return "DarkOrange";
|
||||||
|
else
|
||||||
|
return "Green";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
18
ChronoFlow.Persistence/ITimeEntryRepository.cs
Normal file
18
ChronoFlow.Persistence/ITimeEntryRepository.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using ChronoFlow.Model;
|
||||||
|
|
||||||
|
namespace ChronoFlow.Persistence
|
||||||
|
{
|
||||||
|
public interface ITimeEntryRepository
|
||||||
|
{
|
||||||
|
Task<List<Zeiteintrag>> GetEntriesForUserAsync(string username);
|
||||||
|
Task UpdateEntryStatusAndCommentAsync(int id, bool isCompleted, string? comment);
|
||||||
|
|
||||||
|
// (Optional) Weitere Methoden für Admin-Funktionen:
|
||||||
|
Task<List<Zeiteintrag>> GetAllEntriesAsync(); // Admin
|
||||||
|
Task AddEntryAsync(Zeiteintrag entry); // Admin
|
||||||
|
Task DeleteEntryAsync(int id); // Admin
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -7,7 +7,12 @@ using ChronoFlow.Security;
|
|||||||
|
|
||||||
namespace ChronoFlow.Persistence
|
namespace ChronoFlow.Persistence
|
||||||
{
|
{
|
||||||
public class SqliteZeiterfassungsService
|
public interface IZeiterfassungsRepository
|
||||||
|
{
|
||||||
|
Task<List<Zeiteintrag>> GetEintraegeFuerMitarbeiterAsync(string mitarbeiterName);
|
||||||
|
Task UpdateStatusUndKommentarAsync(int id, bool erledigt, string mitarbeiterKommentar);
|
||||||
|
}
|
||||||
|
public class SqliteZeiterfassungsService : IZeiterfassungsRepository
|
||||||
{
|
{
|
||||||
private readonly string _dbPath = "chrono_data.sb";
|
private readonly string _dbPath = "chrono_data.sb";
|
||||||
|
|
||||||
@ -458,5 +463,58 @@ namespace ChronoFlow.Persistence
|
|||||||
int rowsAffected = cmd.ExecuteNonQuery();
|
int rowsAffected = cmd.ExecuteNonQuery();
|
||||||
Console.WriteLine($"🔒 Passwort für Benutzer '{username}' zurückgesetzt (Rows affected: {rowsAffected})");
|
Console.WriteLine($"🔒 Passwort für Benutzer '{username}' zurückgesetzt (Rows affected: {rowsAffected})");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<List<Zeiteintrag>> GetEintraegeFuerMitarbeiterAsync(string mitarbeiterName)
|
||||||
|
{
|
||||||
|
var eintraege = new List<Zeiteintrag>();
|
||||||
|
using var connection = new SqliteConnection($"Data Source={_dbPath}");
|
||||||
|
await connection.OpenAsync();
|
||||||
|
|
||||||
|
var cmd = connection.CreateCommand();
|
||||||
|
cmd.CommandText = @"
|
||||||
|
SELECT * FROM Zeiteintraege
|
||||||
|
WHERE Mitarbeiter = $Mitarbeiter;
|
||||||
|
";
|
||||||
|
cmd.Parameters.AddWithValue("$Mitarbeiter", mitarbeiterName);
|
||||||
|
|
||||||
|
using var reader = await cmd.ExecuteReaderAsync();
|
||||||
|
while (await reader.ReadAsync())
|
||||||
|
{
|
||||||
|
eintraege.Add(new Zeiteintrag
|
||||||
|
{
|
||||||
|
Id = reader.GetInt32(0),
|
||||||
|
Mitarbeiter = reader.GetString(1),
|
||||||
|
Startzeit = DateTime.Parse(reader.GetString(2)),
|
||||||
|
Endzeit = DateTime.Parse(reader.GetString(3)),
|
||||||
|
Projekt = reader.GetString(4),
|
||||||
|
Kommentar = reader.GetString(5),
|
||||||
|
Erledigt = Convert.ToInt32(reader["Erledigt"]) == 1,
|
||||||
|
MitarbeiterKommentar = reader.GetString(7)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return eintraege;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task UpdateStatusUndKommentarAsync(int id, bool erledigt, string mitarbeiterKommentar)
|
||||||
|
{
|
||||||
|
using var connection = new SqliteConnection($"Data Source={_dbPath}");
|
||||||
|
await connection.OpenAsync();
|
||||||
|
|
||||||
|
var cmd = connection.CreateCommand();
|
||||||
|
cmd.CommandText = @"
|
||||||
|
UPDATE Zeiteintraege
|
||||||
|
SET Erledigt = $Erledigt,
|
||||||
|
MitarbeiterKommentar = $Kommentar
|
||||||
|
WHERE Id = $Id;
|
||||||
|
";
|
||||||
|
|
||||||
|
cmd.Parameters.AddWithValue("$Erledigt", erledigt ? 1 : 0);
|
||||||
|
cmd.Parameters.AddWithValue("$Kommentar", mitarbeiterKommentar ?? "");
|
||||||
|
cmd.Parameters.AddWithValue("$Id", id);
|
||||||
|
|
||||||
|
int rowsAffected = await cmd.ExecuteNonQueryAsync();
|
||||||
|
Console.WriteLine($"✏ Zeiteintrag (Id={id}) aktualisiert: erledigt={erledigt}, kommentar gesetzt.");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ namespace ChronoFlow.View.Admin
|
|||||||
MitarbeiterDropdown.SelectedItem = null;
|
MitarbeiterDropdown.SelectedItem = null;
|
||||||
|
|
||||||
// 🔄 Dashboard aktualisieren, wenn zurück
|
// 🔄 Dashboard aktualisieren, wenn zurück
|
||||||
if (_viewManager.TryGetView<AdminMainView>("AdminMain", out var adminView))
|
if (_viewManager.TryGetView<AdminMainView>("AdminMain", out var adminView) && adminView != null)
|
||||||
{
|
{
|
||||||
adminView.AktualisiereLetzteProjekte();
|
adminView.AktualisiereLetzteProjekte();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia" Version="11.0.6" />
|
<PackageReference Include="Avalonia" Version="11.0.6" />
|
||||||
<PackageReference Include="Avalonia.Desktop" Version="11.0.6" />
|
<PackageReference Include="Avalonia.Desktop" Version="11.0.6" />
|
||||||
|
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||||
<PackageReference Include="MessageBox.Avalonia" Version="0.10.4" />
|
<PackageReference Include="MessageBox.Avalonia" Version="0.10.4" />
|
||||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.6" />
|
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.6" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@ -26,6 +27,9 @@
|
|||||||
<DependentUpon>MitarbeiterHinzufuegenView.axaml</DependentUpon>
|
<DependentUpon>MitarbeiterHinzufuegenView.axaml</DependentUpon>
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Update="Mitarbeiter\EmployeeTasksViewModel.axaml.cs">
|
||||||
|
<DependentUpon>EmployeeTasksViewModel.axaml.axaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@ -3,6 +3,7 @@ using Avalonia.Controls;
|
|||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using ChronoFlow.Model;
|
using ChronoFlow.Model;
|
||||||
using ChronoFlow.View.Admin;
|
using ChronoFlow.View.Admin;
|
||||||
|
using ChronoFlow.View.Mitarbeiter;
|
||||||
|
|
||||||
namespace ChronoFlow.View
|
namespace ChronoFlow.View
|
||||||
{
|
{
|
||||||
@ -26,7 +27,7 @@ namespace ChronoFlow.View
|
|||||||
_viewManager.Register("AlleProjekte", () => new AlleProjekteView(_viewManager));
|
_viewManager.Register("AlleProjekte", () => new AlleProjekteView(_viewManager));
|
||||||
_viewManager.Register("MitarbeiterListe", () => new MitarbeiterListeView(_viewManager));
|
_viewManager.Register("MitarbeiterListe", () => new MitarbeiterListeView(_viewManager));
|
||||||
_viewManager.Register("AbgeschlosseneProjekte", () => new AbgeschlosseneProjekteView(_viewManager));
|
_viewManager.Register("AbgeschlosseneProjekte", () => new AbgeschlosseneProjekteView(_viewManager));
|
||||||
// ⏳ später: _viewManager.Register("MitarbeiterMain", () => new MitarbeiterMainView(_viewManager));
|
_viewManager.Register("Zeiterfassung", () => new EmployeeTasksView(_loggedInUser.Username));
|
||||||
|
|
||||||
if (_loggedInUser.Role == "Admin")
|
if (_loggedInUser.Role == "Admin")
|
||||||
{
|
{
|
||||||
|
|||||||
28
ChronoFlow.View/Mitarbeiter/EmployeeTasksView.axaml
Normal file
28
ChronoFlow.View/Mitarbeiter/EmployeeTasksView.axaml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:vm="clr-namespace:ChronoFlow.ViewModels.Mitarbeiter"
|
||||||
|
x:Class="ChronoFlow.View.Mitarbeiter.EmployeeTasksView">
|
||||||
|
<StackPanel Margin="20" Spacing="10">
|
||||||
|
<TextBlock Text="Meine Aufgaben" FontSize="24" FontWeight="Bold"/>
|
||||||
|
|
||||||
|
<ItemsControl ItemsSource="{Binding Eintraege}">
|
||||||
|
<ItemsControl.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Border BorderThickness="1" BorderBrush="Gray" CornerRadius="4" Padding="10" Margin="5">
|
||||||
|
<StackPanel Spacing="5">
|
||||||
|
<TextBlock Text="{Binding Projekt}" FontWeight="Bold"/>
|
||||||
|
<CheckBox Content="Erledigt" IsChecked="{Binding Erledigt}"/>
|
||||||
|
<TextBox Text="{Binding MitarbeiterKommentar}" Watermark="Kommentar hinzufügen..."/>
|
||||||
|
<TextBlock Text="{Binding Endzeit, StringFormat='Deadline: {0:dd.MM.yyyy}'}"
|
||||||
|
Foreground="{Binding PrioritaetsFarbe}"
|
||||||
|
FontWeight="Bold" FontSize="14"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsControl.ItemTemplate>
|
||||||
|
</ItemsControl>
|
||||||
|
|
||||||
|
<Button Content="Änderungen speichern" Command="{Binding SpeichereEintraegeCommand}"/>
|
||||||
|
<TextBlock Text="{Binding StatusText}" Foreground="Green" FontStyle="Italic"/>
|
||||||
|
</StackPanel>
|
||||||
|
</UserControl>
|
||||||
20
ChronoFlow.View/Mitarbeiter/EmployeeTasksView.axaml.cs
Normal file
20
ChronoFlow.View/Mitarbeiter/EmployeeTasksView.axaml.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using ChronoFlow.ViewModels.Mitarbeiter;
|
||||||
|
using ChronoFlow.Persistence;
|
||||||
|
|
||||||
|
namespace ChronoFlow.View.Mitarbeiter
|
||||||
|
{
|
||||||
|
public partial class EmployeeTasksView : UserControl
|
||||||
|
{
|
||||||
|
public EmployeeTasksView(string benutzername)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
// Benutzername dynamisch übergeben
|
||||||
|
DataContext = new EmployeeTasksViewModel(
|
||||||
|
new SqliteZeiterfassungsService(),
|
||||||
|
benutzername
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
33
ChronoFlow.View/Mitarbeiter/EmployeeTasksViewModel.axaml
Normal file
33
ChronoFlow.View/Mitarbeiter/EmployeeTasksViewModel.axaml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:viewmodels="clr-namespace:ChronoFlow.ViewModels"
|
||||||
|
mc:Ignorable="d">
|
||||||
|
<StackPanel Margin="20" Spacing="10">
|
||||||
|
<TextBlock Text="Meine Aufgaben" FontSize="24" FontWeight="Bold"/>
|
||||||
|
|
||||||
|
<ItemsControl ItemsSource="{Binding Eintraege}">
|
||||||
|
<ItemsControl.ItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<Border BorderThickness="1" BorderBrush="Gray" Padding="10" Margin="5">
|
||||||
|
<StackPanel Spacing="5">
|
||||||
|
<TextBlock Text="{Binding TaskDescription}" FontWeight="Bold"/>
|
||||||
|
<TextBlock Text="{Binding Date}" FontStyle="Italic"/>
|
||||||
|
<TextBlock Text="Priorität: {Binding Priority}" Foreground="DarkRed"/>
|
||||||
|
<CheckBox Content="Erledigt" IsChecked="{Binding IsCompleted}"/>
|
||||||
|
<TextBox Text="{Binding Comment}" Watermark="Kommentar eingeben..."/>
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsControl.ItemTemplate>
|
||||||
|
</ItemsControl>
|
||||||
|
|
||||||
|
<Button Content="Änderungen speichern" Command="{Binding SaveChangesCommand}" HorizontalAlignment="Right"/>
|
||||||
|
<TextBlock Text="{Binding StatusText}"
|
||||||
|
Foreground="Green"
|
||||||
|
FontStyle="Italic"
|
||||||
|
FontWeight="SemiBold"
|
||||||
|
Margin="5"/>
|
||||||
|
</StackPanel>
|
||||||
|
</UserControl>
|
||||||
54
ChronoFlow.View/Mitarbeiter/EmployeeTasksViewModel.axaml.cs
Normal file
54
ChronoFlow.View/Mitarbeiter/EmployeeTasksViewModel.axaml.cs
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using ChronoFlow.Model;
|
||||||
|
using ChronoFlow.Persistence;
|
||||||
|
|
||||||
|
namespace ChronoFlow.ViewModels.Mitarbeiter
|
||||||
|
{
|
||||||
|
public partial class EmployeeTasksViewModel : ObservableObject
|
||||||
|
{
|
||||||
|
// Liste aller Zeiteinträge für den aktuell eingeloggten Mitarbeiter
|
||||||
|
[ObservableProperty]
|
||||||
|
private ObservableCollection<Zeiteintrag> eintraege = new();
|
||||||
|
|
||||||
|
// Ausgabe für Erfolg/Nachricht
|
||||||
|
[ObservableProperty]
|
||||||
|
private string? statusText;
|
||||||
|
|
||||||
|
private readonly IZeiterfassungsRepository repository;
|
||||||
|
private readonly string aktuellerBenutzername;
|
||||||
|
|
||||||
|
// Konstruktor erhält Repository (z. B. SqliteZeiterfassungsService) + aktuellen Benutzernamen
|
||||||
|
public EmployeeTasksViewModel(IZeiterfassungsRepository repository, string aktuellerBenutzername)
|
||||||
|
{
|
||||||
|
this.repository = repository;
|
||||||
|
this.aktuellerBenutzername = aktuellerBenutzername;
|
||||||
|
|
||||||
|
// Direkt beim Start laden
|
||||||
|
_ = LadeEintraegeAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lädt alle Einträge für den Benutzer aus der Datenbank
|
||||||
|
[RelayCommand]
|
||||||
|
public async Task LadeEintraegeAsync()
|
||||||
|
{
|
||||||
|
var eintraegeAusDb = await repository.GetEintraegeFuerMitarbeiterAsync(aktuellerBenutzername);
|
||||||
|
Eintraege = new ObservableCollection<Zeiteintrag>(eintraegeAusDb);
|
||||||
|
StatusText = $"🔄 {Eintraege.Count} Einträge geladen.";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Speichert Änderungen (Status + Kommentar) für alle sichtbaren Einträge
|
||||||
|
[RelayCommand]
|
||||||
|
public async Task SpeichereEintraegeAsync()
|
||||||
|
{
|
||||||
|
foreach (var eintrag in Eintraege)
|
||||||
|
{
|
||||||
|
await repository.UpdateStatusUndKommentarAsync(eintrag.Id, eintrag.Erledigt, eintrag.MitarbeiterKommentar);
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusText = "✅ Änderungen gespeichert.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -5,14 +5,16 @@
|
|||||||
<TextBlock Text="👋 Willkommen im Mitarbeiter-Dashboard" FontSize="24" Margin="0,0,0,20"/>
|
<TextBlock Text="👋 Willkommen im Mitarbeiter-Dashboard" FontSize="24" Margin="0,0,0,20"/>
|
||||||
|
|
||||||
<Border Background="#FFEFEFEF" CornerRadius="8" Padding="10" Margin="0,0,0,20">
|
<Border Background="#FFEFEFEF" CornerRadius="8" Padding="10" Margin="0,0,0,20">
|
||||||
<TextBlock Text="📢 Letzte Benachrichtigungen:" FontWeight="Bold" Margin="0,0,0,10"/>
|
<StackPanel>
|
||||||
<ItemsControl Name="NotificationList">
|
<TextBlock Text="📢 Letzte Benachrichtigungen:" FontWeight="Bold" Margin="0,0,0,10"/>
|
||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl Name="NotificationList">
|
||||||
<DataTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
<TextBlock Text="{Binding}" Foreground="DarkBlue"/>
|
<DataTemplate>
|
||||||
</DataTemplate>
|
<TextBlock Text="{Binding}" Foreground="DarkBlue"/>
|
||||||
</ItemsControl.ItemTemplate>
|
</DataTemplate>
|
||||||
</ItemsControl>
|
</ItemsControl.ItemTemplate>
|
||||||
|
</ItemsControl>
|
||||||
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<TextBlock Text="🕒 Letzte eigene Projekte:" FontWeight="Bold" Margin="0,0,0,10"/>
|
<TextBlock Text="🕒 Letzte eigene Projekte:" FontWeight="Bold" Margin="0,0,0,10"/>
|
||||||
|
|||||||
@ -0,0 +1,50 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using ChronoFlow.Model;
|
||||||
|
using ChronoFlow.Persistence;
|
||||||
|
|
||||||
|
namespace ChronoFlow.View.Mitarbeiter
|
||||||
|
{
|
||||||
|
public partial class MitarbeiterMainView : UserControl
|
||||||
|
{
|
||||||
|
private readonly ViewManager _viewManager;
|
||||||
|
private readonly User _currentUser;
|
||||||
|
private readonly ObservableCollection<Zeiteintrag> _letzteProjekte = new();
|
||||||
|
private readonly ObservableCollection<string> _notifications = new();
|
||||||
|
|
||||||
|
public MitarbeiterMainView(ViewManager viewManager, User user)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_viewManager = viewManager;
|
||||||
|
_currentUser = user;
|
||||||
|
|
||||||
|
LetzteProjekteListe.ItemsSource = _letzteProjekte;
|
||||||
|
NotificationList.ItemsSource = _notifications;
|
||||||
|
|
||||||
|
LadeLetzteProjekte();
|
||||||
|
LadeBenachrichtigungen();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LadeLetzteProjekte()
|
||||||
|
{
|
||||||
|
var dbService = new SqliteZeiterfassungsService();
|
||||||
|
var projekte = dbService.LadeLetzteProjekte(3);
|
||||||
|
_letzteProjekte.Clear();
|
||||||
|
|
||||||
|
foreach (var p in projekte)
|
||||||
|
{
|
||||||
|
if (p.Mitarbeiter == _currentUser.Username)
|
||||||
|
_letzteProjekte.Add(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LadeBenachrichtigungen()
|
||||||
|
{
|
||||||
|
// 🛈 Platzhalter → hier später echte DB-Infos laden!
|
||||||
|
_notifications.Clear();
|
||||||
|
_notifications.Add("Projekt Alpha wurde aktualisiert.");
|
||||||
|
_notifications.Add("Deadline für Projekt Beta wurde verschoben.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user