From e41bbd32db0a358b2cbe96d05b52371be5dca7c6 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt <22748698+fhdk@users.noreply.github.com> Date: Sat, 6 Aug 2022 07:35:35 +0200 Subject: [PATCH] added - show closed companies --- Wonky.Client/Pages/CustomerListPage.razor | 12 +++++++++--- Wonky.Client/Pages/CustomerListPage.razor.cs | 10 ++++++++++ Wonky.Client/Pages/Login.razor | 10 +++++----- Wonky.Client/Pages/Login.razor.cs | 4 ++-- Wonky.Client/Services/AuthenticationService.cs | 15 ++++++--------- Wonky.Client/Services/IAuthenticationService.cs | 2 +- Wonky.Client/wwwroot/appsettings.json | 8 ++++---- ...{UserAuthenticationDto.cs => CredentialDto.cs} | 2 +- 8 files changed, 38 insertions(+), 25 deletions(-) rename Wonky.Entity/DTO/{UserAuthenticationDto.cs => CredentialDto.cs} (97%) diff --git a/Wonky.Client/Pages/CustomerListPage.razor b/Wonky.Client/Pages/CustomerListPage.razor index 72915966..6440d14b 100644 --- a/Wonky.Client/Pages/CustomerListPage.razor +++ b/Wonky.Client/Pages/CustomerListPage.razor @@ -38,10 +38,16 @@
-
- +
+
+ + +
-
+
+ +
+
diff --git a/Wonky.Client/Pages/CustomerListPage.razor.cs b/Wonky.Client/Pages/CustomerListPage.razor.cs index 507400ee..cfed320c 100644 --- a/Wonky.Client/Pages/CustomerListPage.razor.cs +++ b/Wonky.Client/Pages/CustomerListPage.razor.cs @@ -38,6 +38,7 @@ namespace Wonky.Client.Pages private CompanyPagingParams _paging = new(); private Preferences _preferences { get; set; } = new(); private string _savedSearch { get; set; } = ""; + private bool _includeFolded { get; set; } protected override async Task OnInitializedAsync() { @@ -46,6 +47,7 @@ namespace Wonky.Client.Pages _paging.OrderBy = _preferences.CompanySort; _paging.SearchColumn = _preferences.CompanySearch; _paging.PageSize = Convert.ToInt32(_preferences.PageSize); + _paging.HasFolded = _includeFolded ? 1 : 0; // load saved search _savedSearch = _preferences.CompanyFilterPhrase; @@ -58,6 +60,14 @@ namespace Wonky.Client.Pages await GetCompanies(); } + private async Task OnFoldedClick() + { + _includeFolded = !_includeFolded; + _companyList = new List(); + _paging.PageNumber = 1; + _paging.HasFolded = _includeFolded ? 1 : 0; + await GetCompanies(); + } private async Task SelectedPage(int page) { _companyList = new List(); diff --git a/Wonky.Client/Pages/Login.razor b/Wonky.Client/Pages/Login.razor index 292c1d70..7081635a 100644 --- a/Wonky.Client/Pages/Login.razor +++ b/Wonky.Client/Pages/Login.razor @@ -37,22 +37,22 @@
- +
- + @bind-Value="_credentialDto.Email" autocomplete="username"/> +
- + @bind-Value="_credentialDto.Password" autocomplete="current-password"/> +
diff --git a/Wonky.Client/Pages/Login.razor.cs b/Wonky.Client/Pages/Login.razor.cs index ca2831f6..3b08dffd 100644 --- a/Wonky.Client/Pages/Login.razor.cs +++ b/Wonky.Client/Pages/Login.razor.cs @@ -26,7 +26,7 @@ public partial class Login [Inject] public IAuthenticationService AuthenticationService { get; set; } [Inject] public ILogger Logger { get; set; } [Parameter] public string ReturnUrl { get; set; } - private UserAuthenticationDto _userAuthenticationDto = new (); + private CredentialDto _credentialDto = new (); private bool ShowAuthError { get; set; } private string? Error { get; set; } private bool execLogin = false; @@ -36,7 +36,7 @@ public partial class Login ShowAuthError = false; execLogin = true; - var result = await AuthenticationService.Login(_userAuthenticationDto); + var result = await AuthenticationService.Login(_credentialDto); if (!result.IsSuccess) { Error = result.ErrorMessage; diff --git a/Wonky.Client/Services/AuthenticationService.cs b/Wonky.Client/Services/AuthenticationService.cs index 101b728c..230b8037 100644 --- a/Wonky.Client/Services/AuthenticationService.cs +++ b/Wonky.Client/Services/AuthenticationService.cs @@ -44,17 +44,17 @@ namespace Wonky.Client.Services _apiConfig = apiConfig; } - public async Task Login(UserAuthenticationDto userAuthenticationDtoUserAuth) + public async Task Login(CredentialDto credentials) { - var credentials = new Dictionary + var credForm = new Dictionary { ["grant_type"] = "password", - ["username"] = userAuthenticationDtoUserAuth.Email, - ["password"] = userAuthenticationDtoUserAuth.Password + ["username"] = credentials.Email, + ["password"] = credentials.Password }; var response = await _client - .PostAsync(_apiConfig.Value.CrmAuth, new FormUrlEncodedContent(credentials)); + .PostAsync(_apiConfig.Value.CrmAuth, new FormUrlEncodedContent(credForm)); var resContent = await response.Content.ReadAsStringAsync(); @@ -111,10 +111,7 @@ namespace Wonky.Client.Services { ((AuthStateProvider)_authStateProvider).NotifyUserLogout(); _client.DefaultRequestHeaders.Authorization = null; - await _localStorage.RemoveItemAsync("_xa"); - await _localStorage.RemoveItemAsync("_xr"); - await _localStorage.RemoveItemAsync("_xe"); - await _localStorage.RemoveItemAsync("_xu"); + await _localStorage.ClearAsync(); } public async Task UserInfo(bool write = false) diff --git a/Wonky.Client/Services/IAuthenticationService.cs b/Wonky.Client/Services/IAuthenticationService.cs index 034af31c..8fa8ca2e 100644 --- a/Wonky.Client/Services/IAuthenticationService.cs +++ b/Wonky.Client/Services/IAuthenticationService.cs @@ -21,7 +21,7 @@ namespace Wonky.Client.Services { public interface IAuthenticationService { - Task Login(UserAuthenticationDto userAuthenticationDtoUserAuth); + Task Login(CredentialDto credentials); Task Logout(); Task RefreshToken(); Task UserInfo(bool write = false); diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index c3e72996..7e20e184 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -1,13 +1,13 @@ { "appInfo": { "name": "Wonky Client", - "version": "0.10.54", - "rc": true, - "sandBox": false, + "version": "0.10.61", + "rc": false, + "sandBox": true, "image": "grumpy-coder.png" }, "apiConfig": { - "innoBaseUrl": "https://app.innotec.dk", + "innoBaseUrl": "https://dev.innotec.dk", "glsTrackUrl": "https://www.gls-group.eu/276-I-PORTAL-WEB/content/GLS/DK01/DA/5004.htm?txtAction=71000&txtRefNo=", "glsId": "", "serviceVirk": "api/v2/services/virk", diff --git a/Wonky.Entity/DTO/UserAuthenticationDto.cs b/Wonky.Entity/DTO/CredentialDto.cs similarity index 97% rename from Wonky.Entity/DTO/UserAuthenticationDto.cs rename to Wonky.Entity/DTO/CredentialDto.cs index 7c22135f..39ea6b60 100644 --- a/Wonky.Entity/DTO/UserAuthenticationDto.cs +++ b/Wonky.Entity/DTO/CredentialDto.cs @@ -17,7 +17,7 @@ using System.ComponentModel.DataAnnotations; namespace Wonky.Entity.DTO; -public class UserAuthenticationDto +public class CredentialDto { /// /// User identification