Parcourir la source

- data hndling on back navigation

- rest call for "Fundmeldung"
master
Flo Smilari il y a 4 ans
Parent
révision
312a39b81d

+ 12
- 8
Pages/AccountPage.razor Voir le fichier

@@ -15,9 +15,9 @@
<div class="row no-gutters align-items-start w-100">
<div class="row no-gutters align-items-center w-100" style="padding-top:2em">
<div class="col-12">
<MatSelect Class="w-100" Label="@i18n["Salutation"]" Outlined="true" @bind-Value="@Account.Salutation" Style="margin-bottom: 0.5rem" Required="true">
<MatOptionString Value="sir">@i18n["Man"]</MatOptionString>
<MatOptionString Value="madam">@i18n["Woman"]</MatOptionString>
<MatSelect Class="w-100 required" Label="@i18n["Salutation"]" Outlined="true" @bind-Value="@Account.Salutation" Style="margin-bottom: 0.5rem" Required="true">
<MatOptionString Value="M">@i18n["Male"]</MatOptionString>
<MatOptionString Value="F">@i18n["Female"]</MatOptionString>
</MatSelect>
</div>
</div>
@@ -73,22 +73,26 @@
@code {
[Parameter]
public string FromRoute { get; set; }
[Parameter]
public string FromRoute { get; set; }
private UserData Account = new();
protected async override void OnInitialized() {
base.OnInitialized();
PageHistoryManager.OnBeforeNavigateBack = new EventCallback(this, (Action)OnBeforeNavigateBack);
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
Account = await GetUserData();
UserDataProvider.mapUserData(Account, ReportDataProvider.Report);
base.OnInitialized();
if (ReportDataProvider.Report != null) {
UserDataProvider.mapUserData(Account, ReportDataProvider.Report);
}
StateHasChanged();
}
private void OnBeforeNavigateBack() {
UserDataProvider.mapReport(ReportDataProvider.Report, Account);
if (ReportDataProvider.Report != null) {
UserDataProvider.mapReport(ReportDataProvider.Report, Account);
}
}
private async void SaveUserData() {

+ 7
- 2
Pages/CaritasServiceFundVeloAlternatePickupContactPage.razor Voir le fichier

@@ -22,7 +22,7 @@
<div class="row no-gutters align-items-start w-100">
<div class="row no-gutters w-100">
<div class="col-12">
<MatSelect Class="w-100" Label="@i18n["Salutation"]" Outlined="true" @bind-Value="pucSalutation" Required="true" Style="margin-bottom: 0.5rem">
<MatSelect Class="w-100 required" Label="@i18n["Salutation"]" Outlined="true" @bind-Value="pucSalutation" Required="true" Style="margin-bottom: 0.5rem">
<MatOptionString Value="sir">@i18n["Man"]</MatOptionString>
<MatOptionString Value="madam">@i18n["Woman"]</MatOptionString>
</MatSelect>
@@ -90,12 +90,17 @@
private string pucEmail;
protected async override void OnInitialized() {
base.OnInitialized();
PageHistoryManager.OnBeforeNavigateBack = new EventCallback(this, (Action)OnBeforeNavigateBack);
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
refreshGUIFromDto();
base.OnInitialized();
StateHasChanged();
}
private void OnBeforeNavigateBack() {
updateDtoFromGUI();
}
private void Next() {
updateDtoFromGUI();
NavigationManager.NavigateTo("fundvelo/account/Found");

+ 33
- 14
Pages/CaritasServiceFundVeloFoundConclusion.razor Voir le fichier

@@ -1,11 +1,14 @@
@page "/fundvelo/conclusion_found"
@using cwebplusApp.Shared.Services;
@using cwebplusApp.Shared.Models;
@inject NavigationManager NavigationManager
@inject IStringLocalizer<Resources> i18n
@inject PageHistoryManager PageHistoryManager
@inject ReportDataProvider ReportDataProvider
@inject NavigationManager NavigationManager;
@inject IStringLocalizer<Resources> i18n;
@inject PageHistoryManager PageHistoryManager;
@inject ReportDataProvider ReportDataProvider;
@inject ILFBicycleRest ILFBicycleRest;
@inject Toaster Toaster;
<div class="row px-3 h-100">
<div class="row no-gutters align-items-start justify-content-center w-100">
@@ -15,11 +18,17 @@
<MatHeadline6 Style="font-family:Ubuntu">@i18n["FinishedTextFound"]</MatHeadline6>
</div>
<div class="row no-gutters align-items-start justify-content-center w-100">
<Animate Animation="Animations.ZoomIn" Delay="TimeSpan.FromSeconds(0.5)" Duration="TimeSpan.FromSeconds(2.5)">
<Animate Animation="Animations.FadeIn" Delay="TimeSpan.FromSeconds(0.5)" Duration="TimeSpan.FromSeconds(2.5)">
<DoneImage></DoneImage>
</Animate>
</Animate>
@if (!running) {
if (responseOk) {
<Animate Animation="Animations.ZoomIn" Duration="TimeSpan.FromSeconds(2.5)">
<DoneImage></DoneImage>
</Animate>
} else {
<Animate Animation="Animations.ZoomIn" Duration="TimeSpan.FromSeconds(2.5)">
<FailureImage></FailureImage>
</Animate>
}
}
</div>
<div class="row no-gutters align-items-end justify-content-center w-100" style="padding-bottom:2em;padding-top:2em">
<div class="col w-100 text-center">
@@ -31,14 +40,24 @@
@code {
protected override void OnInitialized() {
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
private Animate doneAnimZoom;
private bool responseOk = false;
private bool running = true;
protected async override void OnInitialized() {
base.OnInitialized();
}
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
ReportResponse response = await ILFBicycleRest.SendFoundReport(ReportDataProvider.GetFoundReport());
responseOk = System.Net.HttpStatusCode.OK == response.StatusCode ? true : false;
running = false;
StateHasChanged();
if(responseOk) {
Toaster.ShowSuccess(i18n.GetString("FoundBike"), response.Message);
} else {
Toaster.ShowError(response.Message, response.GetDataAsFormattedList());
}
}
private void Finished() {
NavigationManager.NavigateTo("caritas_services");

+ 4
- 4
Pages/CaritasServiceFundVeloFoundKeyDataPage.razor Voir le fichier

@@ -105,7 +105,7 @@
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-8-tablet mat-layout-grid-cell-span-12-desktop">
<div class="mat-layout-grid-inner">
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-4-tablet mat-layout-grid-cell-span-4-desktop">
<MatSelectValue FullWidth="true" Outlined="true" Label="@i18n["Color"]" Required="true" @bind-Value="selectedColor" Items="@Colors" ValueSelector="@(i=>i)">
<MatSelectValue Class="required" FullWidth="true" Outlined="true" Label="@i18n["Color"]" @bind-Value="selectedColor" Items="@Colors" ValueSelector="@(i=>i)">
<ItemTemplate>
<div>
<span class="btn-sm" style="background-color:@context.Code;
@@ -129,7 +129,7 @@
</div>
</div>
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-4-tablet mat-layout-grid-cell-span-4-desktop">
<MatSelectValue FullWidth="true" Outlined="true" Label="@i18n["Type"]" Required="true" @bind-Value="selectedBcType" Items="@BicycleTypes" ValueSelector="@(i=>i)">
<MatSelectValue Class="required" FullWidth="true" Outlined="true" Label="@i18n["Type"]" @bind-Value="selectedBcType" Items="@BicycleTypes" ValueSelector="@(i=>i)">
<ItemTemplate>
<div>
<span>@context?.Bezeichnung</span>
@@ -311,8 +311,8 @@
report.GeographicInfo.Latitude = bicycleGeoPosition.Latitude;
report.GeographicInfo.Longitude = bicycleGeoPosition.Longitude;
report.FotoString = imgUrl;
report.FarbeId = selectedColor != null ? selectedColor.Id : 0;
report.TypId = selectedBcType != null ? selectedBcType.Id : 0;
report.FarbeId = selectedColor != null ? selectedColor.Id : -1;
report.TypId = selectedBcType != null ? selectedBcType.Id : -1;
if (SelectedBrand != null) {
if (SelectedBrand.Id == -999) {
report.NeueMarke = SelectedBrand.Bezeichnung;

+ 8
- 2
Pages/CaritasServiceFundVeloFoundKeyDataPage.razor.cs Voir le fichier

@@ -112,13 +112,19 @@ namespace cwebplusApp.Pages {
await this.mapRef.SetView(geoPosition);
}
}
private static string GetFormattedAddressZipAndTown(NominatimReverseAddress addressDto) {
string country_code = addressDto.address.country_code;
string zip = addressDto.address.postcode.Split("-", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)[0];
string zip = SplitAndGetFirstPostcode(addressDto.address.postcode);
string town = addressDto.address.village ?? addressDto.address.town ?? addressDto.address.city;
return !String.IsNullOrEmpty(country_code) ? country_code.ToUpper() + "-" + zip + " " + town : zip + " " + town;
}
private static string SplitAndGetFirstPostcode(string postcode) {
return postcode.Split("-", StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)[0];
}
private async Task OnMouseMapClicked(MouseEvent mouseEvent) {
await AddBicycleMarkerOnClickPosition(mouseEvent);
@@ -129,7 +135,7 @@ namespace cwebplusApp.Pages {
if (addressDto != null) {
this.bicycleGeoPosition.Address = GetFormattedAddressStreet(addressDto);
this.bicycleGeoPosition.City = addressDto.address.village ?? addressDto.address.town ?? addressDto.address.city;
this.bicycleGeoPosition.Zip = addressDto.address.postcode;
this.bicycleGeoPosition.Zip = SplitAndGetFirstPostcode(addressDto.address.postcode);
this.bicycleGeoPosition.DisplayCity = GetFormattedAddressZipAndTown(addressDto);
} else {
Toaster.ShowWarning(I18n.GetString("Warning.Nominatim.Title"), I18n.GetString("Warning.Nominatim.Msg"));

+ 7
- 4
Pages/CaritasServiceFundVeloMissingConclusion.razor Voir le fichier

@@ -2,9 +2,11 @@
@using cwebplusApp.Shared.Services;
@inject NavigationManager NavigationManager
@inject IStringLocalizer<Resources> i18n
@inject PageHistoryManager PageHistoryManager
@inject NavigationManager NavigationManager;
@inject IStringLocalizer<Resources> i18n;
@inject PageHistoryManager PageHistoryManager;
@inject ReportDataProvider ReportDataProvider;
@inject ILFBicycleRest ILFBicycleRest;
<div class="row px-3 h-100">
<div class="row no-gutters align-items-start justify-content-center w-100">
@@ -24,8 +26,9 @@
@code {
protected override void OnInitialized() {
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
base.OnInitialized();
PageHistoryManager.AddPageToHistory(NavigationManager.Uri);
ILFBicycleRest.SendMissingReport(ReportDataProvider.GetMissingReport());
}
private void Finished() {

+ 2
- 2
Pages/CaritasServiceFundVeloMissingKeyDataPage.razor Voir le fichier

@@ -70,7 +70,7 @@
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-4-tablet mat-layout-grid-cell-span-4-desktop">
<div class="mat-layout-grid-inner">
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-8-tablet mat-layout-grid-cell-span-12-desktop">
<MatSelectValue FullWidth="true" Outlined="true" Label="@i18n["Color"]" @bind-Value="selectedColor" Items="@Colors" ValueSelector="@(i=>i)" Required="true">
<MatSelectValue Class="required" FullWidth="true" Outlined="true" Label="@i18n["Color"]" @bind-Value="selectedColor" Items="@Colors" ValueSelector="@(i=>i)">
<ItemTemplate>
<div>
<span class="btn-sm" style="background-color:@context.Code;
@@ -94,7 +94,7 @@
</div>
</div>
<div class="mat-layout-grid-cell mat-layout-grid-cell-span-4-phone mat-layout-grid-cell-span-8-tablet mat-layout-grid-cell-span-12-desktop">
<MatSelectValue FullWidth="true" Outlined="true" Label="@i18n["Type"]" @bind-Value="selectedBcType" Items="@BicycleTypes" ValueSelector="@(i=>i)" Required="true">
<MatSelectValue Class="required" FullWidth="true" Outlined="true" Label="@i18n["Type"]" @bind-Value="selectedBcType" Items="@BicycleTypes" ValueSelector="@(i=>i)">
<ItemTemplate>
<div>
<span>@context?.Bezeichnung</span>

+ 9
- 0
Pages/FailureImage.razor Voir le fichier

@@ -0,0 +1,9 @@
@page "/failureimage"
<div class="text-center">
<img src="./images/failure.png" class="w-50" alt="Failure!" />
</div>
@code {
}

+ 1
- 1
Pages/InfoPage.razor Voir le fichier

@@ -25,7 +25,7 @@
</tr>
<tr>
<td class="text-center">
<MatCaption Style="font-family:Ubuntu">Version: 0.0.1</MatCaption>
<MatCaption Style="font-family:Ubuntu">Version: 0.1.0</MatCaption>
</td>
</tr>
</table>

+ 22
- 0
Shared/Models/ReportResponse.cs Voir le fichier

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
namespace cwebplusApp.Shared.Models {
public class ReportResponse {
public HttpStatusCode StatusCode { get; set; }
public string Message { get; set; }
public string[] Data { get; set; }
public string GetDataAsFormattedList() {
string result = "";
foreach(string s in Data) {
result += s + "\r\n";
}
return result;
}
}
}

+ 4
- 4
Shared/ResourceFiles/Resources.de.resx Voir le fichier

@@ -282,6 +282,9 @@
<data name="Error.PhotoOrPictureToBig.Title" xml:space="preserve">
<value>Bilddatei zu gross!</value>
</data>
<data name="Female" xml:space="preserve">
<value>Frau</value>
</data>
<data name="Finished" xml:space="preserve">
<value>Fertig</value>
</data>
@@ -351,7 +354,7 @@
<data name="Mail" xml:space="preserve">
<value>E-Mail</value>
</data>
<data name="Man" xml:space="preserve">
<data name="Male" xml:space="preserve">
<value>Herr</value>
</data>
<data name="MissingBike" xml:space="preserve">
@@ -414,9 +417,6 @@
<data name="Welcome" xml:space="preserve">
<value>Willkommen bei Caritas!</value>
</data>
<data name="Woman" xml:space="preserve">
<value>Frau</value>
</data>
<data name="Zip" xml:space="preserve">
<value>PLZ</value>
</data>

+ 4
- 4
Shared/ResourceFiles/Resources.fr.resx Voir le fichier

@@ -282,6 +282,9 @@
<data name="Error.PhotoOrPictureToBig.Title" xml:space="preserve">
<value>La taille de la photo est trop grande!</value>
</data>
<data name="Female" xml:space="preserve">
<value>Madame</value>
</data>
<data name="Finished" xml:space="preserve">
<value>Terminé</value>
</data>
@@ -351,7 +354,7 @@
<data name="Mail" xml:space="preserve">
<value>Courrier</value>
</data>
<data name="Man" xml:space="preserve">
<data name="Male" xml:space="preserve">
<value>Monsieur</value>
</data>
<data name="MissingBike" xml:space="preserve">
@@ -414,9 +417,6 @@
<data name="Welcome" xml:space="preserve">
<value>Bienvenue chez Caritas!</value>
</data>
<data name="Woman" xml:space="preserve">
<value>Madame</value>
</data>
<data name="Zip" xml:space="preserve">
<value>Code postal</value>
</data>

+ 4
- 4
Shared/ResourceFiles/Resources.it.resx Voir le fichier

@@ -282,6 +282,9 @@
<data name="Error.PhotoOrPictureToBig.Title" xml:space="preserve">
<value>Dimensione dell'immagine troppo grande!</value>
</data>
<data name="Female" xml:space="preserve">
<value>Signora</value>
</data>
<data name="Finished" xml:space="preserve">
<value>Termina</value>
</data>
@@ -351,7 +354,7 @@
<data name="Mail" xml:space="preserve">
<value>E-Mail</value>
</data>
<data name="Man" xml:space="preserve">
<data name="Male" xml:space="preserve">
<value>Signore</value>
</data>
<data name="MissingBike" xml:space="preserve">
@@ -414,9 +417,6 @@
<data name="Welcome" xml:space="preserve">
<value>Benvenuti alla Caritas!</value>
</data>
<data name="Woman" xml:space="preserve">
<value>Signora</value>
</data>
<data name="Zip" xml:space="preserve">
<value>CAP</value>
</data>

+ 4
- 4
Shared/ResourceFiles/Resources.resx Voir le fichier

@@ -282,6 +282,9 @@
<data name="Error.PhotoOrPictureToBig.Title" xml:space="preserve">
<value>Size of picture to big!</value>
</data>
<data name="Female" xml:space="preserve">
<value>Madam</value>
</data>
<data name="Finished" xml:space="preserve">
<value>Finished</value>
</data>
@@ -351,7 +354,7 @@
<data name="Mail" xml:space="preserve">
<value>E-Mail</value>
</data>
<data name="Man" xml:space="preserve">
<data name="Male" xml:space="preserve">
<value>Sir</value>
</data>
<data name="MissingBike" xml:space="preserve">
@@ -414,9 +417,6 @@
<data name="Welcome" xml:space="preserve">
<value>Welcome to Caritas!</value>
</data>
<data name="Woman" xml:space="preserve">
<value>Madam</value>
</data>
<data name="Zip" xml:space="preserve">
<value>Zip</value>
</data>

+ 4
- 0
Shared/Services/ILFBicycleRest.cs Voir le fichier

@@ -13,5 +13,9 @@ namespace cwebplusApp.Shared.Services {
Task<List<BicycleType>> GetBicycleTypes();
Task<List<Brand>> GetBrands();
Task<ReportResponse> SendFoundReport(FoundReport report);
Task<ReportResponse> SendMissingReport(MissingReport report);
}
}

+ 39
- 0
Shared/Services/LFBicycleRest.cs Voir le fichier

@@ -6,6 +6,8 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace cwebplusApp.Shared.Services {
@@ -75,5 +77,42 @@ namespace cwebplusApp.Shared.Services {
throw new HttpRequestException("HTTP client not initialized!");
}
public async Task<ReportResponse> SendFoundReport(FoundReport report) {
if (httpClient != null) {
string subResourceUrl = Configuration.GetValue<string>("subresource_url_foundreport");
if (!String.IsNullOrEmpty(subResourceUrl)) {
string reportJson = JsonNet.Serialize(report);
HttpContent content = new StringContent(reportJson, Encoding.UTF8, "application/json");
HttpResponseMessage httpResult = await httpClient.PostAsync(string.Format(subResourceUrl, VERSION, CultureInfo.CurrentCulture.TwoLetterISOLanguageName), content);
string msg = await httpResult.Content.ReadAsStringAsync();
ReportResponse response = JsonNet.Deserialize<ReportResponse>(msg);
response.StatusCode = httpResult.StatusCode;
//ReportResponse response = new();
//response.StatusCode = System.Net.HttpStatusCode.OK;
//Thread.Sleep(2000);
return response;
}
}
throw new HttpRequestException("HTTP client not initialized!");
}
public async Task<ReportResponse> SendMissingReport(MissingReport report) {
if (httpClient != null) {
string subResourceUrl = Configuration.GetValue<string>("subresource_url_missingreport");
if (!String.IsNullOrEmpty(subResourceUrl)) {
string reportJson = JsonNet.Serialize(report);
HttpContent content = new StringContent(reportJson, Encoding.UTF8, "application/json");
HttpResponseMessage httpResult = await httpClient.PostAsync(string.Format(subResourceUrl, VERSION, CultureInfo.CurrentCulture.TwoLetterISOLanguageName), content);
if (httpResult.StatusCode == System.Net.HttpStatusCode.OK) {
ReportResponse reponse = JsonNet.Deserialize<ReportResponse>(await httpResult.Content.ReadAsStringAsync());
return reponse;
}
throw new HttpRequestException("HTTP error " + httpResult.StatusCode);
}
}
throw new HttpRequestException("HTTP client not initialized!");
}
}
}

+ 4
- 2
Shared/Services/Toaster.cs Voir le fichier

@@ -9,6 +9,10 @@ namespace cwebplusApp.Shared.Services {
this.matToaster = toaster;
}
public void ShowSuccess(string title, string message, string icon = "") {
matToaster.Add(message, MatBlazor.MatToastType.Success, title, icon);
}
public void ShowInfo(string title, string message, string icon = "") {
matToaster.Add(message, MatBlazor.MatToastType.Info, title, icon);
}
@@ -16,12 +20,10 @@ namespace cwebplusApp.Shared.Services {
public void ShowWarning(string title, string message, string icon = "") {
matToaster.Add(message, MatBlazor.MatToastType.Warning, title, icon);
}
public void ShowError(string title, string message, string icon = "") {
matToaster.Add(message, MatBlazor.MatToastType.Danger, title, icon);
}
}

+ 8
- 1
Shared/Services/UserDataProvider.cs Voir le fichier

@@ -57,7 +57,7 @@ namespace cwebplusApp.Shared.Services {
public static void mapUserData(UserData userData, Report report) {
userData.Salutation = report.Anrede;
userData.Firstname = report.Vorname;
userData.Lastname = report.Nachname; ;
userData.Lastname = report.Nachname;
userData.Phone = report.Telefon;
}
@@ -67,5 +67,12 @@ namespace cwebplusApp.Shared.Services {
report.Nachname = userData.Lastname;
report.Telefon = userData.Phone;
}
public static void mapReport(Report report, char Salutation, string Firstname, string Lastname, string Phone) {
report.Anrede = new string(Salutation, 1);
report.Vorname = Firstname;
report.Nachname = Lastname;
report.Telefon = Phone;
}
}
}

+ 2
- 0
cwebplusApp.csproj Voir le fichier

@@ -30,4 +30,6 @@
<ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties wwwroot_4appsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>
</Project>

+ 3
- 1
wwwroot/appsettings.json Voir le fichier

@@ -2,5 +2,7 @@
"host_base_url": "https://integrate.dynalias.net:9443/Fundvelo/",
"subresource_url_colors": "api/{0}/{1}/fundvelo/colors",
"subresource_url_brands": "api/{0}/{1}/fundvelo/brands",
"subresource_url_types": "api/{0}/{1}/fundvelo/types"
"subresource_url_types": "api/{0}/{1}/fundvelo/types",
"subresource_url_foundreport": "api/{0}/{1}/fundvelo/fundmeldung",
"subresource_url_missingreport": "api/{0}/{1}/fundvelo/suchauftrag"
}

+ 8
- 0
wwwroot/css/app.css Voir le fichier

@@ -227,4 +227,12 @@ label.italic input.mat-text-field-input {
div.mdc-checkbox {
margin-left: -11px;
}
div.mat-select.required span#outlined-select-label.mdc-floating-label::after {
content: "*";
}
.mat-toast-container.mat-toast-bottom-center > div {
width: 95%;
}

BIN
wwwroot/images/failure.png Voir le fichier


+ 1
- 0
wwwroot/service-worker.js Voir le fichier

@@ -19,6 +19,7 @@ const assets = [
'/conclusion_found',
'/conclusion_missing',
'/doneimage',
'/failureimage',
'favicon.ico',
'images/batch_found.png',
'images/batch_fundvelo.png',

Chargement…
Annuler
Enregistrer