Zeigt die Fälligkeit der vier bestehenden, manuell ausgelösten WebUntis-Abgleiche (Fehlzeiten je Lerngruppe, offene Stunden, Klassenbuch-, Hausaufgabenabgleich) in einem neuen Hub-Fenster, ohne selbst WebUntis anzufragen - nur gespeicherte Zeitstempel werden ausgewertet. Konsolidiert die bisher verstreuten Einstiegspunkte (Sidebar-Button, Dashboard-Buttons) in ein neues WebUntis-Menü plus einen kompakten Gesundheits-Indikator auf dem Dashboard. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:vm="clr-namespace:LehrerApp.Desktop.ViewModels.UntisHub"
|
||||
x:Class="LehrerApp.Desktop.Views.UntisHub.UntisHubDialog"
|
||||
x:DataType="vm:UntisHubViewModel"
|
||||
Title="Untis-Hub"
|
||||
Width="900" Height="600" MinWidth="640" MinHeight="400"
|
||||
WindowStartupLocation="CenterOwner">
|
||||
|
||||
<Window.Styles>
|
||||
<Style Selector="TextBlock.duestatus">
|
||||
<Setter Property="Foreground" Value="{DynamicResource AppStatusOkBrush}"/>
|
||||
</Style>
|
||||
<Style Selector="TextBlock.duestatus.warning">
|
||||
<Setter Property="Foreground" Value="{DynamicResource AppStatusWarningBrush}"/>
|
||||
</Style>
|
||||
<Style Selector="TextBlock.duestatus.danger">
|
||||
<Setter Property="Foreground" Value="{DynamicResource AppStatusDangerBrush}"/>
|
||||
</Style>
|
||||
</Window.Styles>
|
||||
|
||||
<DockPanel Margin="20">
|
||||
<StackPanel DockPanel.Dock="Top" Spacing="10" Margin="0,0,0,14">
|
||||
<Grid ColumnDefinitions="*,Auto">
|
||||
<TextBlock Text="Untis-Hub" FontSize="22" FontWeight="SemiBold"/>
|
||||
<Button Grid.Column="1" Content="Aktualisieren" Click="OnRefreshClick"/>
|
||||
</Grid>
|
||||
<TextBlock Text="{Binding Status}" FontSize="12" Opacity="0.7" TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
|
||||
<DataGrid ItemsSource="{Binding Rows}" AutoGenerateColumns="False" IsReadOnly="True"
|
||||
GridLinesVisibility="Horizontal" BorderBrush="{DynamicResource AppCardBorderBrush}"
|
||||
BorderThickness="1" CanUserResizeColumns="True" CanUserSortColumns="True" RowHeight="46"
|
||||
IsVisible="{Binding IsAvailable}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Bereich" Binding="{Binding GroupName}" Width="1.3*"/>
|
||||
<DataGridTextColumn Header="Prüfung" Binding="{Binding JobLabel}" Width="1.3*"/>
|
||||
<DataGridTemplateColumn Header="Status" Width="1.1*">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate x:DataType="vm:UntisHubRowViewModel">
|
||||
<TextBlock Text="{Binding DueLabel}" Classes="duestatus"
|
||||
Classes.warning="{Binding IsWarning}" Classes.danger="{Binding IsDanger}"
|
||||
VerticalAlignment="Center"/>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn Header="Letztes Ergebnis" Binding="{Binding LastResultSummary}" Width="2*"/>
|
||||
<DataGridTemplateColumn Header="" Width="130">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate x:DataType="vm:UntisHubRowViewModel">
|
||||
<Button Content="Jetzt prüfen" Click="OnCheckClick" DataContext="{Binding}"/>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<TextBlock IsVisible="{Binding !IsAvailable}" Text="WebUntis ist nicht konfiguriert. Bitte zuerst in den Einstellungen hinterlegen."
|
||||
FontSize="14" Opacity="0.7" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</DockPanel>
|
||||
</Window>
|
||||
@@ -0,0 +1,58 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using LehrerApp.Core.Interfaces;
|
||||
using LehrerApp.Core.Models;
|
||||
using LehrerApp.Core.Services;
|
||||
using LehrerApp.Desktop.Services;
|
||||
using LehrerApp.Desktop.ViewModels.UntisHub;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace LehrerApp.Desktop.Views.UntisHub;
|
||||
|
||||
public partial class UntisHubDialog : Window
|
||||
{
|
||||
public UntisHubDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = new UntisHubViewModel(
|
||||
App.Services.GetRequiredService<UntisHubService>(),
|
||||
App.Services.GetRequiredService<IGroupRepository>(),
|
||||
App.Services.GetRequiredService<WebUntisIntegrationService>());
|
||||
}
|
||||
|
||||
private void OnRefreshClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is UntisHubViewModel vm) vm.Load();
|
||||
}
|
||||
|
||||
private async void OnCheckClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is not UntisHubViewModel vm || sender is not Button { DataContext: UntisHubRowViewModel row })
|
||||
return;
|
||||
var hub = App.Services.GetRequiredService<UntisHubService>();
|
||||
var today = DateOnly.FromDateTime(DateTime.Today);
|
||||
|
||||
switch (row.Kind)
|
||||
{
|
||||
case UntisHubJobKind.FehlzeitenKurz or UntisHubJobKind.FehlzeitenLang:
|
||||
var group = row.GroupId is { } id ? vm.FindGroup(id) : null;
|
||||
if (group is null) return;
|
||||
var schoolYears = App.Services.GetRequiredService<SchoolYearService>();
|
||||
var start = row.Kind == UntisHubJobKind.FehlzeitenKurz
|
||||
? today.AddDays(-30)
|
||||
: schoolYears.SchoolYearStart(schoolYears.CurrentSchoolYear());
|
||||
await UntisHubActions.RunFehlzeitenAsync(this, group, row.Kind, start, today, hub);
|
||||
break;
|
||||
case UntisHubJobKind.OffenePeriods:
|
||||
await UntisHubActions.RunOffenePeriodsAsync(this, hub);
|
||||
break;
|
||||
case UntisHubJobKind.Klassenbuchabgleich:
|
||||
await UntisHubActions.RunKlassenbuchAsync(this, hub);
|
||||
break;
|
||||
case UntisHubJobKind.Hausaufgabenabgleich:
|
||||
await UntisHubActions.RunHausaufgabenAsync(this, hub);
|
||||
break;
|
||||
}
|
||||
vm.Load();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user