From 55be2f1e889cbbae683f8754a5044a1046331fb1 Mon Sep 17 00:00:00 2001 From: Leon Hoppe Date: Fri, 28 Feb 2025 16:56:48 +0100 Subject: [PATCH] Started working on backend --- WorkTime.sln | 7 +++++ src/WorkTime.Api/Models/TimeEntry.cs | 15 ++++++++++ src/WorkTime.Host/Program.cs | 3 ++ .../Properties/launchSettings.json | 29 +++++++++++++++++++ src/WorkTime.Host/WorkTime.Host.csproj | 18 ++++++++++++ .../appsettings.Development.json | 8 +++++ src/WorkTime.Host/appsettings.json | 9 ++++++ src/WorkTime.Mobile/src/app/time/time.page.ts | 9 +++++- src/WorkTime.Mobile/src/models/timeEntry.ts | 4 +++ 9 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 src/WorkTime.Api/Models/TimeEntry.cs create mode 100644 src/WorkTime.Host/Program.cs create mode 100644 src/WorkTime.Host/Properties/launchSettings.json create mode 100644 src/WorkTime.Host/WorkTime.Host.csproj create mode 100644 src/WorkTime.Host/appsettings.Development.json create mode 100644 src/WorkTime.Host/appsettings.json diff --git a/WorkTime.sln b/WorkTime.sln index bb03b9a..26d83d5 100644 --- a/WorkTime.sln +++ b/WorkTime.sln @@ -4,6 +4,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Source", "Source", "{25C5A6 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkTime.Api", "src\WorkTime.Api\WorkTime.Api.csproj", "{63F71A39-70D8-4F22-8006-C345E0CD4A5C}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkTime.Host", "src\WorkTime.Host\WorkTime.Host.csproj", "{6F5D4D47-1484-44EA-A5DD-D00AAD2F2F68}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -11,11 +13,16 @@ Global EndGlobalSection GlobalSection(NestedProjects) = preSolution {63F71A39-70D8-4F22-8006-C345E0CD4A5C} = {25C5A6B2-A1F9-4244-9538-18E3FE76D382} + {6F5D4D47-1484-44EA-A5DD-D00AAD2F2F68} = {25C5A6B2-A1F9-4244-9538-18E3FE76D382} EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {63F71A39-70D8-4F22-8006-C345E0CD4A5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {63F71A39-70D8-4F22-8006-C345E0CD4A5C}.Debug|Any CPU.Build.0 = Debug|Any CPU {63F71A39-70D8-4F22-8006-C345E0CD4A5C}.Release|Any CPU.ActiveCfg = Release|Any CPU {63F71A39-70D8-4F22-8006-C345E0CD4A5C}.Release|Any CPU.Build.0 = Release|Any CPU + {6F5D4D47-1484-44EA-A5DD-D00AAD2F2F68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6F5D4D47-1484-44EA-A5DD-D00AAD2F2F68}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6F5D4D47-1484-44EA-A5DD-D00AAD2F2F68}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6F5D4D47-1484-44EA-A5DD-D00AAD2F2F68}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/src/WorkTime.Api/Models/TimeEntry.cs b/src/WorkTime.Api/Models/TimeEntry.cs new file mode 100644 index 0000000..d99b1be --- /dev/null +++ b/src/WorkTime.Api/Models/TimeEntry.cs @@ -0,0 +1,15 @@ +namespace WorkTime.Api.Models; + +public class TimeEntry { + public Guid Owner { get; set; } + public DateTime RegisteredAt { get; set; } + public EntryType Type { get; set; } + public bool IsMoba { get; set; } +} + +public enum EntryType { + Login = 0, + Logout = 1, + StartDrive = 2, + EndDrive = 3 +} diff --git a/src/WorkTime.Host/Program.cs b/src/WorkTime.Host/Program.cs new file mode 100644 index 0000000..b077ec2 --- /dev/null +++ b/src/WorkTime.Host/Program.cs @@ -0,0 +1,3 @@ +var builder = DistributedApplication.CreateBuilder(args); + +builder.Build().Run(); \ No newline at end of file diff --git a/src/WorkTime.Host/Properties/launchSettings.json b/src/WorkTime.Host/Properties/launchSettings.json new file mode 100644 index 0000000..cb941bd --- /dev/null +++ b/src/WorkTime.Host/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "profiles": { + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:17121;http://localhost:15199", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "DOTNET_ENVIRONMENT": "Development", + "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21125", + "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22099" + } + }, + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:15199", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development", + "DOTNET_ENVIRONMENT": "Development", + "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19218", + "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20104" + } + } + } +} diff --git a/src/WorkTime.Host/WorkTime.Host.csproj b/src/WorkTime.Host/WorkTime.Host.csproj new file mode 100644 index 0000000..c969fb7 --- /dev/null +++ b/src/WorkTime.Host/WorkTime.Host.csproj @@ -0,0 +1,18 @@ + + + + + + Exe + net9.0 + enable + enable + true + ba72af6f-0952-417d-bef6-ab77ed6fa624 + + + + + + + diff --git a/src/WorkTime.Host/appsettings.Development.json b/src/WorkTime.Host/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/src/WorkTime.Host/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/src/WorkTime.Host/appsettings.json b/src/WorkTime.Host/appsettings.json new file mode 100644 index 0000000..31c092a --- /dev/null +++ b/src/WorkTime.Host/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Aspire.Hosting.Dcp": "Warning" + } + } +} diff --git a/src/WorkTime.Mobile/src/app/time/time.page.ts b/src/WorkTime.Mobile/src/app/time/time.page.ts index b8edd3c..d324466 100644 --- a/src/WorkTime.Mobile/src/app/time/time.page.ts +++ b/src/WorkTime.Mobile/src/app/time/time.page.ts @@ -154,10 +154,17 @@ export class TimePage implements ViewDidEnter { } private updateCurrentAction(): void { + console.log(this.data); if (this.data.length == 0) { this.currentAction = 'login'; }else { - const lastEntry = this.data[this.data.length - 1] + const lastEntry = this.data[this.data.length - 1]; + + if (!this.timeService.isToday(lastEntry.registeredAt)) { + this.currentAction = 'login'; + this.currentlyMoba = false; + return; + } switch (lastEntry.type) { case "start-drive": diff --git a/src/WorkTime.Mobile/src/models/timeEntry.ts b/src/WorkTime.Mobile/src/models/timeEntry.ts index 5a19670..87b8feb 100644 --- a/src/WorkTime.Mobile/src/models/timeEntry.ts +++ b/src/WorkTime.Mobile/src/models/timeEntry.ts @@ -4,4 +4,8 @@ export interface TimeEntry { isMoba: boolean; } +export interface BackendTimeEntry extends TimeEntry { + owner: string; +} + export type TimeType = 'login' | 'logout' | 'start-drive' | 'end-drive';