added - show closed companies

This commit is contained in:
Frede Hundewadt 2022-08-06 07:35:35 +02:00
parent 2c68d27c2f
commit e41bbd32db
8 changed files with 38 additions and 25 deletions

View file

@ -38,10 +38,16 @@
</div>
</div>
<div class="row mb-2">
<div class="col-md-9">
<PaginationComponent MetaData="_metaData" Spread="2" SelectedPage="SelectedPage" />
<div class="col-3">
<div class="form-check">
<input type="checkbox" id="folded" class="form-check-input" checked="@_includeFolded" @onclick="OnFoldedClick" >
<label for="folded" class="form-check-label">Ophørte</label>
</div>
</div>
<div class="col-md-3 justify-content-end">
<div class="col-6">
<PaginationComponent MetaData="_metaData" Spread="2" SelectedPage="SelectedPage"/>
</div>
<div class="col-3 justify-content-end">
<a class="btn btn-success text-nowrap" href="/companies/new">Opret kunde</a>
</div>
</div>

View file

@ -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<CompanyDto>();
_paging.PageNumber = 1;
_paging.HasFolded = _includeFolded ? 1 : 0;
await GetCompanies();
}
private async Task SelectedPage(int page)
{
_companyList = new List<CompanyDto>();

View file

@ -37,22 +37,22 @@
</div>
<div class="col-lg-8">
<div class="card-body py-5 px-md-5">
<EditForm Model="_userAuthenticationDto" OnValidSubmit="ExecuteLogin" class="form">
<EditForm Model="_credentialDto" OnValidSubmit="ExecuteLogin" class="form">
<DataAnnotationsValidator/>
<div class="input-group mb-4">
<span class="input-group-text" id="email-addon"><i class="oi oi-person"></i></span>
<InputText type="email" id="email" class="form-control" aria-described-by="email-addon"
placeholder="Email adresse"
@bind-Value="_userAuthenticationDto.Email" autocomplete="username"/>
<ValidationMessage For="@(() => _userAuthenticationDto.Email)"/>
@bind-Value="_credentialDto.Email" autocomplete="username"/>
<ValidationMessage For="@(() => _credentialDto.Email)"/>
</div>
<div class="input-group mb-4">
<span class="input-group-text" id="passwd-addon"><i class="oi oi-key"></i></span>
<InputText type="password" id="password" class="form-control" aria-described-by="passwd-addon"
placeholder="Adgangskode"
@bind-Value="_userAuthenticationDto.Password" autocomplete="current-password"/>
<ValidationMessage For="@(() => _userAuthenticationDto.Password)"/>
@bind-Value="_credentialDto.Password" autocomplete="current-password"/>
<ValidationMessage For="@(() => _credentialDto.Password)"/>
</div>
<div class="d-grid">

View file

@ -26,7 +26,7 @@ public partial class Login
[Inject] public IAuthenticationService AuthenticationService { get; set; }
[Inject] public ILogger<Login> 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;

View file

@ -44,17 +44,17 @@ namespace Wonky.Client.Services
_apiConfig = apiConfig;
}
public async Task<AuthResponseView> Login(UserAuthenticationDto userAuthenticationDtoUserAuth)
public async Task<AuthResponseView> Login(CredentialDto credentials)
{
var credentials = new Dictionary<string, string>
var credForm = new Dictionary<string, string>
{
["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<UserInfoView> UserInfo(bool write = false)

View file

@ -21,7 +21,7 @@ namespace Wonky.Client.Services
{
public interface IAuthenticationService
{
Task<AuthResponseView> Login(UserAuthenticationDto userAuthenticationDtoUserAuth);
Task<AuthResponseView> Login(CredentialDto credentials);
Task Logout();
Task<string> RefreshToken();
Task<UserInfoView> UserInfo(bool write = false);

View file

@ -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",

View file

@ -17,7 +17,7 @@ using System.ComponentModel.DataAnnotations;
namespace Wonky.Entity.DTO;
public class UserAuthenticationDto
public class CredentialDto
{
/// <summary>
/// User identification