diff --git a/Jugenddienst Stunden/App.xaml.cs b/Jugenddienst Stunden/App.xaml.cs index 92a98c0..2dd72ac 100644 --- a/Jugenddienst Stunden/App.xaml.cs +++ b/Jugenddienst Stunden/App.xaml.cs @@ -1,5 +1,4 @@ -//using AndroidX.Browser.Trusted; - + namespace Jugenddienst_Stunden { public partial class App : Application { public App() { @@ -7,11 +6,42 @@ namespace Jugenddienst_Stunden { MainPage = new AppShell(); - //Models.Auth.Main(new string[] { "http://hours.dauni.mine.nu:81/appapi", "OTI6Y1JVUS9RTG1jMTZUbnN2c2JZRm5yRDNiUTZz" }); //Angelika - //Models.Auth.Main(new string[] { "http://hours.dauni.mine.nu:81/appapi", "Njc6cjltcVJ1SmtITUtFZ3llUVpJcWJzc2NDejVZ" }); //Dario - - //Models.Auth.Main(new string[] { "http://hours.dauni.mine.nu:81/appapi?hours", "MTQzfEFlMVRjQXdZMnI4RmpxZ0FSY3A0VEN2bVZYVXxodHRwOi8vaG91cnMuZGF1bmkubWluZS5udTo4MS9hcHBhcGk=" }); //Christine - } + + + //protected override Window CreateWindow(IActivationState activationState) => + //new Window(new AppShell()) { + // Width = 500, + // Height = 900 + //}; + + + // protected override Window CreateWindow(IActivationState activationState) { + // Window window = base.CreateWindow(activationState); + // window.Activated += Window_Activated; + // return window; + // } + + // private async void Window_Activated(object sender, EventArgs e) { + //#if WINDOWS + // const int DefaultWidth = 500; + // const int DefaultHeight = 900; + + // var window = sender as Window; + + // // change window size. + // window.Width = DefaultWidth; + // window.Height = DefaultHeight; + + // // give it some time to complete window resizing task. + // await window.Dispatcher.DispatchAsync(() => { }); + + // var disp = DeviceDisplay.Current.MainDisplayInfo; + + // // move to screen center + // //window.X = (disp.Width / disp.Density - window.Width) / 2; + // //window.Y = (disp.Height / disp.Density - window.Height) / 2; + //#endif + // } } } diff --git a/Jugenddienst Stunden/AppShell.xaml b/Jugenddienst Stunden/AppShell.xaml index bf1a733..ed27028 100644 --- a/Jugenddienst Stunden/AppShell.xaml +++ b/Jugenddienst Stunden/AppShell.xaml @@ -7,20 +7,20 @@ Shell.FlyoutBehavior="Disabled"> + + - - + Icon="{OnPlatform 'icon_security.png', iOS='icon_security_ios.png', MacCatalyst='icon_security_ios.png'}" /> \ No newline at end of file diff --git a/Jugenddienst Stunden/Jugenddienst Stunden.csproj b/Jugenddienst Stunden/Jugenddienst Stunden.csproj index fb0a0de..60fa632 100644 --- a/Jugenddienst Stunden/Jugenddienst Stunden.csproj +++ b/Jugenddienst Stunden/Jugenddienst Stunden.csproj @@ -1,7 +1,7 @@  - net8.0-ios;net8.0-maccatalyst;net8.0-android34.0 + net8.0-maccatalyst;net8.0-android34.0 @@ -31,20 +31,32 @@ 11.0 13.1 - 29.0 + 27.0 10.0.17763.0 10.0.17763.0 6.5 + True + paket_icon.png + de + + + + + True + + + + True + + + + True $(TargetFrameworks);net8.0-windows10.0.26100.0 - - False - - @@ -63,6 +75,13 @@ + + + True + \ + + + @@ -79,6 +98,9 @@ LoginPage.xaml + + StundePage.xaml + @@ -88,6 +110,9 @@ MSBuild:Compile + + MSBuild:Compile + MSBuild:Compile diff --git a/Jugenddienst Stunden/MauiProgram.cs b/Jugenddienst Stunden/MauiProgram.cs index 64d4da6..fab291b 100644 --- a/Jugenddienst Stunden/MauiProgram.cs +++ b/Jugenddienst Stunden/MauiProgram.cs @@ -1,5 +1,6 @@ //using BarcodeScanning; using Microsoft.Extensions.Logging; +using Microsoft.Maui.LifecycleEvents; using ZXing.Net.Maui.Controls; @@ -15,11 +16,15 @@ namespace Jugenddienst_Stunden { }) .UseBarcodeReader(); + + #if DEBUG builder.Logging.AddDebug(); #endif return builder.Build(); } + + } } diff --git a/Jugenddienst Stunden/Models/Stunde.cs b/Jugenddienst Stunden/Models/Stunde.cs index 3b785a1..a18fa81 100644 --- a/Jugenddienst Stunden/Models/Stunde.cs +++ b/Jugenddienst Stunden/Models/Stunde.cs @@ -11,6 +11,8 @@ namespace Jugenddienst_Stunden.Models { internal class Stunde : ObservableObject { + + //Default-Werte zum Testen //Katharina @@ -29,6 +31,7 @@ namespace Jugenddienst_Stunden.Models //private static readonly string requestUrl = $"{BaseAddress}/appapi?hours"; public DateTime Date { get; set; } + private static Hours Hours { get; set; } @@ -38,9 +41,11 @@ namespace Jugenddienst_Stunden.Models //apiKey = "MTAyfEJZZnB1L3VwcnhoVms0dDlLZENPZWtUVy85b3xodHRwOi8vaG91cnMuZGF1bmkubWluZS5udTo4MS9hcHBhcGk="; //name = "Kathi"; //surname = "Wegi"; + //apiKey = "MTQzfEFlMVRjQXdZMnI4RmpxZ0FSY3A0VEN2bVZYVXxodHRwOi8vaG91cnMuZGF1bmkubWluZS5udTo4MS9hcHBhcGk="; //name = "Chri"; //surname = "Fe"; + //apiKey = "MTI3fDEyYURVdHVZVWRaZk91eDlNcjZDUFlTdmdkNHxodHRwOi8vaG91cnMuZGF1bmkubWluZS5udTo4MS9hcHBhcGk="; //name = "Ju"; //surname = "Ze"; @@ -49,6 +54,10 @@ namespace Jugenddienst_Stunden.Models //name = "Le"; //surname = "Ma"; + //apiKey = "OXxpM0lQcXcySUp0S3hHbzFSb3VqdStwRXlDQmd8aHR0cHM6Ly9ob3Vycy5waWRhLmluZm8vYXBwYXBp"; + //name = "Eli"; + //surname = "Gap"; + //Preferences.Default.Set("apiKey", apiKey); //Preferences.Default.Set("name", name); @@ -65,7 +74,7 @@ namespace Jugenddienst_Stunden.Models var tokendata = new TokenData(apiKey); //string data = await Auth.GetApiDataWithAuthAsync(requestUrl, apiKey); - string data = await Auth.GetApiDataWithAuthAsync(tokendata.url + "?hours&month=8", tokendata.apiKey); + string data = await Auth.GetApiDataWithAuthAsync(tokendata.url + "?hours&month="+DateTime.Today.Month, tokendata.apiKey); if (data == null) { throw new Exception("Keine Daten erhalten"); @@ -112,10 +121,31 @@ namespace Jugenddienst_Stunden.Models } + Hours = hours; + return hours; + } + + public static DayTime LoadEntry(int id) { + + DayTime hours = Hours.daytime.Find(x => x.id == id); + return hours; } + public static Stunde Load(string filename) { + filename = System.IO.Path.Combine(FileSystem.AppDataDirectory, filename); + + if (!File.Exists(filename)) + throw new FileNotFoundException("Unable to find file on local storage.", filename); + + return + new() { + //Filename = Path.GetFileName(filename), + //Text = File.ReadAllText(filename), + Date = File.GetLastWriteTime(filename) + }; + } } } diff --git a/Jugenddienst Stunden/Platforms/Windows/App.xaml.cs b/Jugenddienst Stunden/Platforms/Windows/App.xaml.cs index a7e1346..441d1a0 100644 --- a/Jugenddienst Stunden/Platforms/Windows/App.xaml.cs +++ b/Jugenddienst Stunden/Platforms/Windows/App.xaml.cs @@ -1,4 +1,6 @@ -using Microsoft.UI.Xaml; +using Microsoft.Maui.LifecycleEvents; +using Microsoft.UI.Xaml; + // To learn more about WinUI, the WinUI project structure, // and more about our project templates, see: http://aka.ms/winui-project-info. @@ -17,6 +19,9 @@ namespace Jugenddienst_Stunden.WinUI { } protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); + + } + } diff --git a/Jugenddienst Stunden/Resources/Images/icon_security.png b/Jugenddienst Stunden/Resources/Images/icon_security.png new file mode 100644 index 0000000..f9a8616 Binary files /dev/null and b/Jugenddienst Stunden/Resources/Images/icon_security.png differ diff --git a/Jugenddienst Stunden/Resources/Images/icon_security_ios.png b/Jugenddienst Stunden/Resources/Images/icon_security_ios.png new file mode 100644 index 0000000..830f0a2 Binary files /dev/null and b/Jugenddienst Stunden/Resources/Images/icon_security_ios.png differ diff --git a/Jugenddienst Stunden/Types/DayTime.cs b/Jugenddienst Stunden/Types/DayTime.cs new file mode 100644 index 0000000..25757f5 --- /dev/null +++ b/Jugenddienst Stunden/Types/DayTime.cs @@ -0,0 +1,19 @@ +namespace Jugenddienst_Stunden.Types { + public class DayTime { + public int? id; + public int EmployeeId; + public DateTime day; + public int wday; + public TimeOnly begin { get; set; } + public TimeOnly end { get; set; } + public string description { get; set; } + public string? free; + public bool? approved; + public int? type; + public int? project; + public int? gemeinde; + public TimeOnly night; + public Dictionary total; + public TimeOnly end_print; + } +} diff --git a/Jugenddienst Stunden/Types/Hours.cs b/Jugenddienst Stunden/Types/Hours.cs index 4a4759c..87d0d4a 100644 --- a/Jugenddienst Stunden/Types/Hours.cs +++ b/Jugenddienst Stunden/Types/Hours.cs @@ -21,6 +21,7 @@ namespace Jugenddienst_Stunden.Types //[JsonConverter(typeof(JsonSingleOrEmptyArrayConverter))] //public Dictionary zeit_total_daily; public List zeit_total_daily_api; + public List daytime; //public List wochensumme; public string overtime_month; public string overtime; @@ -37,5 +38,6 @@ namespace Jugenddienst_Stunden.Types public DateTime Date; public DateTime MinDate; public DateTime MaxDate; + } } diff --git a/Jugenddienst Stunden/ViewModels/StundeViewModel.cs b/Jugenddienst Stunden/ViewModels/StundeViewModel.cs new file mode 100644 index 0000000..6d06d3d --- /dev/null +++ b/Jugenddienst Stunden/ViewModels/StundeViewModel.cs @@ -0,0 +1,52 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; + +namespace Jugenddienst_Stunden.ViewModels { + internal class StundeViewModel : ObservableObject, IQueryAttributable { + + public int id { get; set; } + + private Types.DayTime _stunde; + public string Description { + get => _stunde.description; + set { + if (_stunde.description != value) { + _stunde.description = value; + OnPropertyChanged(); + } + } + } + + public int Identifier => (int)_stunde.id; + + public ICommand SaveCommand { get; private set; } + public ICommand DeleteCommand { get; private set; } + + + + //private async Task Save() { + // _stunde.Date = DateTime.Now; + // _stunde.Save(); + // await Shell.Current.GoToAsync($"..?saved={_stunde.Filename}"); + //} + + //private async Task Delete() { + // _stunde.Delete(); + // await Shell.Current.GoToAsync($"..?deleted={_stunde.Filename}"); + //} + + async void IQueryAttributable.ApplyQueryAttributes(IDictionary query) { + if (query.ContainsKey("load")) { + DateTime heute = DateTime.Now; + //_stunde = await Models.Stunde.LoadDay(heute); + //_stunde = await Models.Stunde.LoadData(); + //RefreshProperties(); + } + } + } +} diff --git a/Jugenddienst Stunden/ViewModels/StundenViewModel.cs b/Jugenddienst Stunden/ViewModels/StundenViewModel.cs index 745ee17..7771331 100644 --- a/Jugenddienst Stunden/ViewModels/StundenViewModel.cs +++ b/Jugenddienst Stunden/ViewModels/StundenViewModel.cs @@ -15,23 +15,18 @@ namespace Jugenddienst_Stunden.ViewModels { public string Surname => AppInfo.VersionString; public string MoreInfoUrl => "https://aka.ms/maui"; public string Message => "Hier werden deine geleisteten Arbeitsstunden aufgelistet"; + public string LoadOverview => "Lade Summen für " + DateTime.Today.ToString("MMMM"); + public static DateTime GetDay = DateTime.Today; + public string ShowDay => "Zeit an Tag " + GetDay.ToString("ddd d. MMM") + ": "; + + public int id { get; set; } + public ICommand SelectEntryCommand { get; } + public ICommand LoadDataCommand { get; private set; } public object Stunden { get; } - public static int GetDay = DateTime.Today.Day; - public string ShowDay => "Zeit an Tag " + GetDay + ": "; + - - /* Nicht gemergte Änderung aus Projekt "Jugenddienst Stunden (net8.0-ios)" - Vor: - private Models.Hours _hour; - public Models.Hours Hours { - get => _hour; - Nach: - private Hours _hour; - public Hours Hours { - get => _hour; - */ private Types.Hours _hour; public Types.Hours Hours { get => _hour; @@ -52,6 +47,10 @@ namespace Jugenddienst_Stunden.ViewModels { get => _hour.overtime_month; } + public List DayTimes { + get => _hour.daytime; + } + public DateTime MinimumDate { //get => _hour.MinDate; //get => DateTime.Today.AddDays(-21); @@ -69,12 +68,13 @@ namespace Jugenddienst_Stunden.ViewModels { set { if (dateToday != value) { dateToday = value; - GetDay = dateToday.Day; + GetDay = value; OnPropertyChanged(); _ = LoadDay(value); // Use discard operator to explicitly ignore the returned Task - //RefreshProperties(); + //RefreshProperties(); OnPropertyChanged(nameof(TimeDay)); OnPropertyChanged(nameof(ShowDay)); + OnPropertyChanged(nameof(DayTimes)); } } } @@ -83,9 +83,6 @@ namespace Jugenddienst_Stunden.ViewModels { get => _hour.Date; } - //public Dictionary ZeitTotalDaily { - // get => _hour.zeit_total_daily; - //} public List ZeitTotalDaily { get => _hour.zeit_total_daily_api; @@ -133,20 +130,24 @@ namespace Jugenddienst_Stunden.ViewModels { _hour = new Types.Hours(); LoadDataCommand = new AsyncRelayCommand(LoadData); + SelectEntryCommand = new AsyncRelayCommand(SelectEntryAsync); + } - //protected void OnPropertyChanged(string propertyName) { - // PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - //} + private async Task SelectEntryAsync(ViewModels.StundeViewModel entry) { + if (entry != null) + await Shell.Current.GoToAsync($"{nameof(Views.StundePage)}?load={entry.id}"); + } + + - //public async Task LoadData() => - // await Models.Stunde.LoadData(); public event EventHandler AlertEvent; public async Task LoadData() { try { _hour = await Models.Stunde.LoadData(); + RefreshProperties(); } catch (Exception e) { AlertEvent?.Invoke(this, e.Message); } @@ -156,8 +157,11 @@ namespace Jugenddienst_Stunden.ViewModels { try { _hour = await Models.Stunde.LoadDay(date); if (_hour.zeit_total_daily_api != null) { - TimeDay = _hour.zeit_total_daily_api.Where(static p => p.Day == GetDay).ToList() ?? new List { new TimeDay { Day = GetDay, Hours = 0 } }; - RefreshProperties(); + TimeDay = _hour.zeit_total_daily_api.Where(static p => p.Day == GetDay.Day).ToList() ?? new List { new TimeDay { Day = GetDay.Day, Hours = 0 } }; + //RefreshProperties(); + OnPropertyChanged(nameof(ShowDay)); + OnPropertyChanged(nameof(TimeDay)); + OnPropertyChanged(nameof(DayTimes)); } } catch (Exception e) { AlertEvent?.Invoke(this, e.Message); diff --git a/Jugenddienst Stunden/Views/StundePage.xaml b/Jugenddienst Stunden/Views/StundePage.xaml new file mode 100644 index 0000000..afcfbbc --- /dev/null +++ b/Jugenddienst Stunden/Views/StundePage.xaml @@ -0,0 +1,18 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Jugenddienst Stunden/Views/StundePage.xaml.cs b/Jugenddienst Stunden/Views/StundePage.xaml.cs new file mode 100644 index 0000000..047715e --- /dev/null +++ b/Jugenddienst Stunden/Views/StundePage.xaml.cs @@ -0,0 +1,9 @@ +namespace Jugenddienst_Stunden.Views; + +public partial class StundePage : ContentPage +{ + public StundePage() + { + InitializeComponent(); + } +} \ No newline at end of file diff --git a/Jugenddienst Stunden/Views/StundenPage.xaml b/Jugenddienst Stunden/Views/StundenPage.xaml index 8f9d519..0df6ee0 100644 --- a/Jugenddienst Stunden/Views/StundenPage.xaml +++ b/Jugenddienst Stunden/Views/StundenPage.xaml @@ -8,73 +8,97 @@ + + + - +