Skip to content

Commit

Permalink
Fix one more wrong vehicle bug
Browse files Browse the repository at this point in the history
  • Loading branch information
TDroogers committed Sep 23, 2024
1 parent 9b71c25 commit 31f1679
Show file tree
Hide file tree
Showing 22 changed files with 294 additions and 59 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
image: kanman/drogecode.knrm.oefenrooster:latest
restart: always
environment:
- ConnectionStrings__postgresDB=host=host.docker.internal;port=5432;database=BackupProd2;username=postgresUser;password=postgresPW
- ConnectionStrings__postgresDB=host=host.docker.internal;port=5432;database=BackupProd;username=postgresUser;password=postgresPW
build:
context: .
dockerfile: src/Server/Dockerfile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
if (_defaults.DefaultSchedules?.Any() == true)
{<MudDataGrid Items="@_defaults.DefaultSchedules" Striped="true" Hover="true">
<Columns>
<HierarchyColumn T="DefaultSchedule"/>
<HierarchyColumn T="DefaultConfig"/>
<PropertyColumn Property="x => x.Name" Title="@L["Name"]" CellClassFunc="@(x => $"trainingType-{x.RoosterTrainingTypeId}")"/>
<PropertyColumn Property="x => x.WeekDay" Title="@L["Weekday"]">
<CellTemplate>
Expand All @@ -30,6 +30,12 @@
}
</CellTemplate>
</TemplateColumn>
<TemplateColumn>
<CellTemplate>
<MudIconButton Icon="@Icons.Material.Filled.Delete" OnClick="@(async () => { await Delete(context.Item); })"/>
<MudIconButton Icon="@Icons.Material.Filled.Edit" OnClick="@(() => { OpenMonthItemDialog(context.Item, false); })"/>
</CellTemplate>
</TemplateColumn>
</Columns>
</MudDataGrid>
}
Expand Down
63 changes: 63 additions & 0 deletions src/Client/Pages/Configuration/DefaultConfig.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using Drogecode.Knrm.Oefenrooster.Client.Repositories;
using Drogecode.Knrm.Oefenrooster.Shared.Models.DefaultSchedule;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Localization;

namespace Drogecode.Knrm.Oefenrooster.Client.Pages.Configuration;

public sealed partial class DefaultConfig : IDisposable
{
[Inject] private IStringLocalizer<DefaultConfig> L { get; set; } = default!;
[Inject] private IStringLocalizer<App> LApp { get; set; } = default!;
[Inject] private DefaultScheduleRepository _defaultScheduleRepository { get; set; } = default!;
private CancellationTokenSource _cls = new();
private GetAllDefaultScheduleResponse? _defaults;
private bool _bussy;

protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
_defaults = await _defaultScheduleRepository.GetAllDefaultSchedule(_cls.Token);
StateHasChanged();
}
}

private async Task Delete(DefaultSchedule? defaultSchedule)
{
if (defaultSchedule is null)
return;
/*var deleteResult = await _defaultScheduleRepository.Delete(defaultSchedule.Id, _cls.Token);
if (deleteResult is true)
{
_defaults!.DefaultSchedules!.Remove(defaultSchedule);
}*/
}

private void OpenMonthItemDialog(DefaultSchedule? defaultSchedule, bool isNew)
{
//DayItemDialog
/*var parameters = new DialogParameters<MonthItemDialog> {
{ x=> x.MonthItem, monthItem},
{ x=> x.IsNew, isNew},
{ x=> x.Refresh, _refreshModel },
};
DialogOptions options = new DialogOptions() { MaxWidth = MaxWidth.Medium, FullWidth = true };
DialogProvider.Show<MonthItemDialog>(isNew ? L["Patch month item"] : L["Edit month item"], parameters, options);*/
}

private async Task RefreshMeAsync()
{
if (_bussy) return;
_bussy = true;
StateHasChanged();
_defaults = await _defaultScheduleRepository.GetAllDefaultSchedule(_cls.Token);
_bussy = false;
StateHasChanged();
}

public void Dispose()
{
_cls.Cancel();
}
}
29 changes: 0 additions & 29 deletions src/Client/Pages/Configuration/DefaultSchedule.razor.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/Client/Repositories/HolidayRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public HolidayRepository(IHolidayClient holidayClient, IOfflineService offlineSe
return result;
}

public async Task<DeleteResonse> Delete(Guid id, CancellationToken clt)
public async Task<DeleteResponse> Delete(Guid id, CancellationToken clt)
{
var result = await _holidayClient.DeleteAsync(id, clt);
return result;
Expand Down
95 changes: 95 additions & 0 deletions src/ClientGenerator/Clients/DefaultScheduleClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
//----------------------

using Drogecode.Knrm.Oefenrooster.Shared.Models.DefaultSchedule;
using Drogecode.Knrm.Oefenrooster.Shared.Models;
using Drogecode.Knrm.Oefenrooster.Shared.Models;

#pragma warning disable 108 // Disable "CS0108 '{derivedDto}.ToJson()' hides inherited member '{dtoBase}.ToJson()'. Use the new keyword if hiding was intended."
#pragma warning disable 114 // Disable "CS0114 '{derivedDto}.RaisePropertyChanged(String)' hides inherited member 'dtoBase.RaisePropertyChanged(String)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword."
Expand All @@ -27,6 +29,15 @@ namespace Drogecode.Knrm.Oefenrooster.ClientGenerator.Client
[System.CodeDom.Compiler.GeneratedCode("NSwag", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")]
public partial interface IDefaultScheduleClient
{
/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
System.Threading.Tasks.Task<DeleteResponse> DeleteDefaultScheduleAsync(System.Guid? id);

/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
System.Threading.Tasks.Task<DeleteResponse> DeleteDefaultScheduleAsync(System.Guid? id, System.Threading.CancellationToken cancellationToken);

/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
System.Threading.Tasks.Task<GetAllDefaultGroupsResponse> GetAllGroupsAsync();
Expand Down Expand Up @@ -115,6 +126,90 @@ private static Newtonsoft.Json.JsonSerializerSettings CreateSerializerSettings()
partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, System.Text.StringBuilder urlBuilder);
partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response);

/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual System.Threading.Tasks.Task<DeleteResponse> DeleteDefaultScheduleAsync(System.Guid? id)
{
return DeleteDefaultScheduleAsync(id, System.Threading.CancellationToken.None);
}

/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual async System.Threading.Tasks.Task<DeleteResponse> DeleteDefaultScheduleAsync(System.Guid? id, System.Threading.CancellationToken cancellationToken)
{
var client_ = _httpClient;
var disposeClient_ = false;
try
{
using (var request_ = new System.Net.Http.HttpRequestMessage())
{
request_.Method = new System.Net.Http.HttpMethod("DELETE");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain"));

var urlBuilder_ = new System.Text.StringBuilder();

// Operation Path: "api/DefaultSchedule/config"
urlBuilder_.Append("api/DefaultSchedule/config");
urlBuilder_.Append('?');
if (id != null)
{
urlBuilder_.Append(System.Uri.EscapeDataString("id")).Append('=').Append(System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture))).Append('&');
}
urlBuilder_.Length--;

PrepareRequest(client_, request_, urlBuilder_);

var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);

PrepareRequest(client_, request_, url_);

var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
var disposeResponse_ = true;
try
{
var headers_ = new System.Collections.Generic.Dictionary<string, System.Collections.Generic.IEnumerable<string>>();
foreach (var item_ in response_.Headers)
headers_[item_.Key] = item_.Value;
if (response_.Content != null && response_.Content.Headers != null)
{
foreach (var item_ in response_.Content.Headers)
headers_[item_.Key] = item_.Value;
}

ProcessResponse(client_, response_);

var status_ = (int)response_.StatusCode;
if (status_ == 200)
{
var objectResponse_ = await ReadObjectResponseAsync<DeleteResponse>(response_, headers_, cancellationToken).ConfigureAwait(false);
if (objectResponse_.Object == null)
{
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
}
return objectResponse_.Object;
}
else
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
}
}
finally
{
if (disposeResponse_)
response_.Dispose();
}
}
}
finally
{
if (disposeClient_)
client_.Dispose();
}
}

/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual System.Threading.Tasks.Task<GetAllDefaultGroupsResponse> GetAllGroupsAsync()
Expand Down
12 changes: 7 additions & 5 deletions src/ClientGenerator/Clients/HolidayClient.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
//----------------------

using Drogecode.Knrm.Oefenrooster.Shared.Models.Holiday;
using Drogecode.Knrm.Oefenrooster.Shared.Models;
using Drogecode.Knrm.Oefenrooster.Shared.Models;

#pragma warning disable 108 // Disable "CS0108 '{derivedDto}.ToJson()' hides inherited member '{dtoBase}.ToJson()'. Use the new keyword if hiding was intended."
#pragma warning disable 114 // Disable "CS0114 '{derivedDto}.RaisePropertyChanged(String)' hides inherited member 'dtoBase.RaisePropertyChanged(String)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword."
Expand Down Expand Up @@ -83,12 +85,12 @@ public partial interface IHolidayClient

/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
System.Threading.Tasks.Task<DeleteResonse> DeleteAsync(System.Guid id);
System.Threading.Tasks.Task<DeleteResponse> DeleteAsync(System.Guid id);

/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
System.Threading.Tasks.Task<DeleteResonse> DeleteAsync(System.Guid id, System.Threading.CancellationToken cancellationToken);
System.Threading.Tasks.Task<DeleteResponse> DeleteAsync(System.Guid id, System.Threading.CancellationToken cancellationToken);

}

Expand Down Expand Up @@ -616,15 +618,15 @@ public virtual async System.Threading.Tasks.Task<GetResponse> GetAsync(System.Gu

/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual System.Threading.Tasks.Task<DeleteResonse> DeleteAsync(System.Guid id)
public virtual System.Threading.Tasks.Task<DeleteResponse> DeleteAsync(System.Guid id)
{
return DeleteAsync(id, System.Threading.CancellationToken.None);
}

/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <returns>OK</returns>
/// <exception cref="ApiException">A server side error occurred.</exception>
public virtual async System.Threading.Tasks.Task<DeleteResonse> DeleteAsync(System.Guid id, System.Threading.CancellationToken cancellationToken)
public virtual async System.Threading.Tasks.Task<DeleteResponse> DeleteAsync(System.Guid id, System.Threading.CancellationToken cancellationToken)
{
if (id == null)
throw new System.ArgumentNullException("id");
Expand Down Expand Up @@ -669,7 +671,7 @@ public virtual async System.Threading.Tasks.Task<DeleteResonse> DeleteAsync(Syst
var status_ = (int)response_.StatusCode;
if (status_ == 200)
{
var objectResponse_ = await ReadObjectResponseAsync<DeleteResonse>(response_, headers_, cancellationToken).ConfigureAwait(false);
var objectResponse_ = await ReadObjectResponseAsync<DeleteResponse>(response_, headers_, cancellationToken).ConfigureAwait(false);
if (objectResponse_.Object == null)
{
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
</OpenApiReference>
<OpenApiReference Include="OpenAPIs\DefaultSchedule.json" CodeGenerator="NSwagCSharp" Namespace="Drogecode.Knrm.Oefenrooster.ClientGenerator.Client" ClassName="DefaultScheduleClient">
<OutputPath>../Clients/DefaultScheduleClient.g.cs</OutputPath>
<Options>/GenerateClientInterfaces:true /GenerateDtoTypes:false /UseBaseUrl:false /AdditionalNamespaceUsages:Drogecode.Knrm.Oefenrooster.Shared.Models.DefaultSchedule</Options>
<Options>/GenerateClientInterfaces:true /GenerateDtoTypes:false /UseBaseUrl:false /AdditionalNamespaceUsages:Drogecode.Knrm.Oefenrooster.Shared.Models.DefaultSchedule,Drogecode.Knrm.Oefenrooster.Shared.Models,Drogecode.Knrm.Oefenrooster.Shared.Models</Options>
</OpenApiReference>
<OpenApiReference Include="OpenAPIs\Function.json" CodeGenerator="NSwagCSharp" Namespace="Drogecode.Knrm.Oefenrooster.ClientGenerator.Client" ClassName="FunctionClient">
<OutputPath>../Clients/FunctionClient.g.cs</OutputPath>
<Options>/GenerateClientInterfaces:true /GenerateDtoTypes:false /UseBaseUrl:false /AdditionalNamespaceUsages:Drogecode.Knrm.Oefenrooster.Shared.Models.Function</Options>
</OpenApiReference>
<OpenApiReference Include="OpenAPIs\Holiday.json" CodeGenerator="NSwagCSharp" Namespace="Drogecode.Knrm.Oefenrooster.ClientGenerator.Client" ClassName="HolidayClient">
<OutputPath>../Clients/HolidayClient.g.cs</OutputPath>
<Options>/GenerateClientInterfaces:true /GenerateDtoTypes:false /UseBaseUrl:false /AdditionalNamespaceUsages:Drogecode.Knrm.Oefenrooster.Shared.Models.Holiday</Options>
<Options>/GenerateClientInterfaces:true /GenerateDtoTypes:false /UseBaseUrl:false /AdditionalNamespaceUsages:Drogecode.Knrm.Oefenrooster.Shared.Models.Holiday,Drogecode.Knrm.Oefenrooster.Shared.Models,Drogecode.Knrm.Oefenrooster.Shared.Models</Options>
</OpenApiReference>
<OpenApiReference Include="OpenAPIs\PreCom.json" CodeGenerator="NSwagCSharp" Namespace="Drogecode.Knrm.Oefenrooster.ClientGenerator.Client" ClassName="PreComClient">
<OutputPath>../Clients/PreComClient.g.cs</OutputPath>
Expand Down
56 changes: 56 additions & 0 deletions src/ClientGenerator/OpenAPIs/DefaultSchedule.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,46 @@
"version": "v1"
},
"paths": {
"/api/DefaultSchedule/config": {
"delete": {
"tags": [
"DefaultSchedule"
],
"operationId": "DeleteDefaultSchedule",
"parameters": [
{
"name": "id",
"in": "query",
"schema": {
"type": "string",
"format": "uuid"
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"text/plain": {
"schema": {
"$ref": "#/components/schemas/DeleteResponse"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/DeleteResponse"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/DeleteResponse"
}
}
}
}
}
}
},
"/api/DefaultSchedule/groups": {
"get": {
"tags": [
Expand Down Expand Up @@ -418,6 +458,22 @@
},
"additionalProperties": false
},
"DeleteResponse": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"offline": {
"type": "boolean"
},
"elapsedMilliseconds": {
"type": "integer",
"format": "int64"
}
},
"additionalProperties": false
},
"GetAllDefaultGroupsResponse": {
"type": "object",
"properties": {
Expand Down
Loading

0 comments on commit 31f1679

Please sign in to comment.