WIP: system user management
This commit is contained in:
parent
5b42d8c995
commit
3d4f463927
20 changed files with 442 additions and 66 deletions
|
@ -22,7 +22,7 @@
|
||||||
{
|
{
|
||||||
<div class="list-group-item list-group-item-action" style="cursor: pointer;">
|
<div class="list-group-item list-group-item-action" style="cursor: pointer;">
|
||||||
<div class="row align-items-center">
|
<div class="row align-items-center">
|
||||||
<div class="col-sm-1">@user.SalesRep</div>
|
<div class="col-sm-1">@user.CountryCode @user.SalesRep</div>
|
||||||
<div class="col-sm-3">@user.FullName</div>
|
<div class="col-sm-3">@user.FullName</div>
|
||||||
<div class="col-sm-2">@user.PhoneNumber</div>
|
<div class="col-sm-2">@user.PhoneNumber</div>
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
|
@ -31,13 +31,6 @@
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
<a class="btn btn-success d-block" href="/office/users/advisors/@user.CountryCode.ToLower()/@user.UserId/customers">Kunder</a>
|
<a class="btn btn-success d-block" href="/office/users/advisors/@user.CountryCode.ToLower()/@user.UserId/customers">Kunder</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-2">
|
|
||||||
<AuthorizeView Roles="Admin,Office">
|
|
||||||
<Authorized>
|
|
||||||
<a class="btn btn-info d-block" href="/office/users/advisors/@user.CountryCode.ToLower()/@user.UserId/view">Rediger</a>
|
|
||||||
</Authorized>
|
|
||||||
</AuthorizeView>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ using Wonky.Entity.Views;
|
||||||
|
|
||||||
namespace Wonky.Client.Pages;
|
namespace Wonky.Client.Pages;
|
||||||
|
|
||||||
public partial class ReportPrintOrderPage
|
public partial class CommonReportPrintOrderPage
|
||||||
{
|
{
|
||||||
[Parameter] public string CountryCode { get; set; } = "";
|
[Parameter] public string CountryCode { get; set; } = "";
|
||||||
[Parameter] public string UserId { get; set; } = "";
|
[Parameter] public string UserId { get; set; } = "";
|
||||||
|
@ -36,7 +36,7 @@ public partial class ReportPrintOrderPage
|
||||||
[Inject] public NavigationManager Navigator { get; set; }
|
[Inject] public NavigationManager Navigator { get; set; }
|
||||||
[Inject] public IOrderProcessRepository ProcessRepo { get; set; }
|
[Inject] public IOrderProcessRepository ProcessRepo { get; set; }
|
||||||
[Inject] public IJSRuntime JsRuntime { get; set; }
|
[Inject] public IJSRuntime JsRuntime { get; set; }
|
||||||
[Inject] public ILogger<ReportPrintOrderPage> Logger { get; set; }
|
[Inject] public ILogger<CommonReportPrintOrderPage> Logger { get; set; }
|
||||||
[Inject] public IToastService Toaster { get; set; }
|
[Inject] public IToastService Toaster { get; set; }
|
||||||
private ReportView Report { get; set; } = new();
|
private ReportView Report { get; set; } = new();
|
||||||
private List<ReportItemView> Items { get; set; } = new();
|
private List<ReportItemView> Items { get; set; } = new();
|
|
@ -23,7 +23,7 @@ using Wonky.Entity.Views;
|
||||||
|
|
||||||
namespace Wonky.Client.Pages;
|
namespace Wonky.Client.Pages;
|
||||||
|
|
||||||
public partial class ReportPrintSummaryPage
|
public partial class CommonReportPrintSummaryPage
|
||||||
{
|
{
|
||||||
[Parameter] public string CountryCode { get; set; } = "";
|
[Parameter] public string CountryCode { get; set; } = "";
|
||||||
[Parameter] public string UserId { get; set; } = "";
|
[Parameter] public string UserId { get; set; } = "";
|
||||||
|
@ -31,7 +31,7 @@ public partial class ReportPrintSummaryPage
|
||||||
[Inject] public ILocalStorageService Storage { get; set; }
|
[Inject] public ILocalStorageService Storage { get; set; }
|
||||||
[Inject] public NavigationManager Navigator { get; set; }
|
[Inject] public NavigationManager Navigator { get; set; }
|
||||||
[Inject] public IJSRuntime JsRuntime { get; set; }
|
[Inject] public IJSRuntime JsRuntime { get; set; }
|
||||||
[Inject] public ILogger<ReportPrintSummaryPage> Logger { get; set; }
|
[Inject] public ILogger<CommonReportPrintSummaryPage> Logger { get; set; }
|
||||||
private ReportView Report { get; set; } = new();
|
private ReportView Report { get; set; } = new();
|
||||||
private IJSObjectReference JsModule { get; set; }
|
private IJSObjectReference JsModule { get; set; }
|
||||||
private string ReturnUrl { get; set; } = "";
|
private string ReturnUrl { get; set; } = "";
|
148
Wonky.Client/Pages/OfficeUserAdvisorViewEditPage.razor
Normal file
148
Wonky.Client/Pages/OfficeUserAdvisorViewEditPage.razor
Normal file
|
@ -0,0 +1,148 @@
|
||||||
|
@*
|
||||||
|
// Copyright (C) 2022 FCS Frede's Computer Services.
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||||
|
//
|
||||||
|
*@
|
||||||
|
|
||||||
|
@using Microsoft.AspNetCore.Authorization
|
||||||
|
@using Wonky.Client.Components
|
||||||
|
@attribute [Authorize(Roles = "Admin")]
|
||||||
|
@page "/office/users/advisors/{CountryCode}/{UserId}/view"
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header bg-dark text-white">
|
||||||
|
<h3>Bruger info</h3>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
@if (!string.IsNullOrWhiteSpace(UserInfo.UserId))
|
||||||
|
{
|
||||||
|
<EditForm EditContext="UserEditContext" OnValidSubmit="UpdateAdvisor">
|
||||||
|
<DataAnnotationsValidator/>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<table class="table">
|
||||||
|
<tbody>
|
||||||
|
<tr class="align-middle">
|
||||||
|
<th scope="col">
|
||||||
|
Fornavn
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
<InputText id="firstName" class="form-control" @bind-Value="UserInfo.FirstName" readonly="@ReadOnly" />
|
||||||
|
<ValidationMessage For="@(() => UserInfo.FirstName)"></ValidationMessage>
|
||||||
|
</td>
|
||||||
|
<th scope="col">
|
||||||
|
Efternavn
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
<InputText id="lastName" class="form-control" @bind-Value="UserInfo.LastName" readonly="@ReadOnly" />
|
||||||
|
<ValidationMessage For="@(() => UserInfo.LastName)"></ValidationMessage>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="align-middle">
|
||||||
|
<th scope="col">
|
||||||
|
Email
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
<InputText id="email" class="form-control" @bind-Value="UserInfo.Email" readonly="@ReadOnly" />
|
||||||
|
<ValidationMessage For="@(() => UserInfo.Email)"></ValidationMessage>
|
||||||
|
</td>
|
||||||
|
<th scope="col">
|
||||||
|
Mobilnummer
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
<InputText id="phoneNumber" class="form-control" @bind-Value="UserInfo.PhoneNumber" readonly="@ReadOnly" />
|
||||||
|
<ValidationMessage For="@(() => UserInfo.PhoneNumber)"></ValidationMessage>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="align-middle">
|
||||||
|
<th scope="col">
|
||||||
|
Sælgernr.
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
<InputText id="salesRep" class="form-control" @bind-Value="UserInfo.SalesRep" readonly="@ReadOnly" />
|
||||||
|
<ValidationMessage For="@(() => UserInfo.SalesRep)"></ValidationMessage>
|
||||||
|
</td>
|
||||||
|
<th scope="col">
|
||||||
|
Landekode
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
<InputText id="countryCode" class="form-control" @bind-Value="UserInfo.CountryCode" readonly="@ReadOnly" />
|
||||||
|
<ValidationMessage For="@(() => UserInfo.CountryCode)"></ValidationMessage>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="align-middle">
|
||||||
|
<th scope="col">
|
||||||
|
Spærret
|
||||||
|
</th>
|
||||||
|
<td colspan="3">
|
||||||
|
<InputCheckbox id="lockoutEnabled" class="form-check" @bind-Value="UserInfo.LockoutEnabled"/>
|
||||||
|
<ValidationMessage For="@(() => UserInfo.LockoutEnabled)"></ValidationMessage>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<button type="button" class="btn btn-danger" @onclick="() => ReadOnly = !ReadOnly">Rediger</button>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<button type="submit" class="btn btn-primary">Gem</button>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<a class="btn btn-primary" href="/office/users/advisors/@CountryCode">Tilbage</a>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<a class="btn btn-primary" href="/office/users/advisors/@CountryCode/@UserId/reports">Salg</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</EditForm>
|
||||||
|
<EditForm EditContext="PasswdContext" class="mt-5" >
|
||||||
|
<DataAnnotationsValidator />
|
||||||
|
<h3>NULSTIL ADGANGSKODE</h3>
|
||||||
|
<div class="alert-info">
|
||||||
|
<h4>Password politik</h4>
|
||||||
|
<p>Mindst 10 tegn bestående af store og små bogstaver samt tal.</p>
|
||||||
|
<p>Du kan teste pasword og danne stærke password på <a href="https://pw.nix.dk">pw.nix.dk</a></p>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-3">
|
||||||
|
<label for="newPasswd" class="col-md-2 col-form-label">Ny</label>
|
||||||
|
<div class="col-md-10">
|
||||||
|
<InputText id="newPasswd" class="form-control" @bind-Value="@Passwords.NewPassword"/>
|
||||||
|
<ValidationMessage For="@(() => Passwords.NewPassword)"></ValidationMessage>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-3">
|
||||||
|
<label for="verifyPasswd" class="col-md-2 col-form-label">Bekræft</label>
|
||||||
|
<div class="col-md-10">
|
||||||
|
<InputText id="verifyPasswd" class="form-control" @bind-Value="@Passwords.ConfirmPassword"/>
|
||||||
|
<ValidationMessage For="@(() => Passwords.ConfirmPassword)"></ValidationMessage>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col align-content-end">
|
||||||
|
<button class="btn btn-warning" @onclick="SetPassword" disabled="@PwInvalid">NULSTIL</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</EditForm>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
@if (Working)
|
||||||
|
{
|
||||||
|
<WorkingThreeDots/>
|
||||||
|
}
|
116
Wonky.Client/Pages/OfficeUserAdvisorViewEditPage.razor.cs
Normal file
116
Wonky.Client/Pages/OfficeUserAdvisorViewEditPage.razor.cs
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
|
||||||
|
// Copyright (C) 2022 FCS Frede's Computer Services.
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||||
|
//
|
||||||
|
|
||||||
|
using System.Text.Json;
|
||||||
|
using Blazored.Toast.Services;
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using Microsoft.AspNetCore.Components.Forms;
|
||||||
|
using Wonky.Client.Helpers;
|
||||||
|
using Wonky.Client.HttpInterceptors;
|
||||||
|
using Wonky.Client.HttpRepository;
|
||||||
|
using Wonky.Entity.DTO;
|
||||||
|
using Wonky.Entity.Views;
|
||||||
|
#pragma warning disable CS8618
|
||||||
|
|
||||||
|
namespace Wonky.Client.Pages;
|
||||||
|
|
||||||
|
public partial class OfficeUserAdvisorViewEditPage : IDisposable
|
||||||
|
{
|
||||||
|
[Parameter] public string UserId { get; set; } = "";
|
||||||
|
[Parameter] public string CountryCode { get; set; } = "";
|
||||||
|
[Inject] public HttpInterceptorService Interceptor { get; set; }
|
||||||
|
[Inject] public ISystemUserRepository UserRepo { get; set; }
|
||||||
|
[Inject] public ILogger<OfficeUserAdvisorViewEditPage> Logger { get; set; }
|
||||||
|
[Inject] public IToastService Toaster { get; set; }
|
||||||
|
private UserManagerEditView UserInfo { get; set; } = new();
|
||||||
|
private EditContext UserEditContext { get; set; }
|
||||||
|
private ResetPasswordDto Passwords { get; set; } = new();
|
||||||
|
private EditContext PasswdContext { get; set; }
|
||||||
|
private bool PwInvalid { get; set; } = true;
|
||||||
|
private bool Working { get; set; } = true;
|
||||||
|
private bool ReadOnly { get; set; } = true;
|
||||||
|
private const int MinPwLength = 10;
|
||||||
|
|
||||||
|
private readonly JsonSerializerOptions _options = new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
PropertyNameCaseInsensitive = true
|
||||||
|
};
|
||||||
|
|
||||||
|
protected override async Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
Interceptor.RegisterEvent();
|
||||||
|
Interceptor.RegisterBeforeSendEvent();
|
||||||
|
UserInfo = await UserRepo.GetUserInfo(UserId);
|
||||||
|
|
||||||
|
UserEditContext = new EditContext(UserInfo);
|
||||||
|
PasswdContext = new EditContext(Passwords);
|
||||||
|
|
||||||
|
PasswdContext.OnFieldChanged += PwHandleFieldChanged;
|
||||||
|
PasswdContext.OnValidationStateChanged += PwValidationChanged;
|
||||||
|
Working = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task UpdateAdvisor()
|
||||||
|
{
|
||||||
|
ReadOnly = true;
|
||||||
|
Working = true;
|
||||||
|
Toaster.ShowInfo("Sender data til server ...");
|
||||||
|
await UserRepo.UpdateUserInfo(UserId, UserInfo);
|
||||||
|
Working = false;
|
||||||
|
Toaster.ShowInfo("Sælger er opdateret ...");
|
||||||
|
// _navigator.NavigateTo($"/office/users/advisors/{CountryCode}/{UserId}");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PwHandleFieldChanged(object sender, FieldChangedEventArgs e)
|
||||||
|
{
|
||||||
|
PwInvalid = !PasswdContext.Validate();
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
private void PwValidationChanged(object sender, ValidationStateChangedEventArgs e)
|
||||||
|
{
|
||||||
|
PwInvalid = true;
|
||||||
|
if (!Utils.IsValidPasswd(Passwords.NewPassword, MinPwLength))
|
||||||
|
return;
|
||||||
|
|
||||||
|
PasswdContext.OnFieldChanged -= PwHandleFieldChanged;
|
||||||
|
PasswdContext.OnValidationStateChanged -= PwValidationChanged;
|
||||||
|
|
||||||
|
PasswdContext = new EditContext(Passwords);
|
||||||
|
|
||||||
|
PasswdContext.OnFieldChanged += PwHandleFieldChanged;
|
||||||
|
PasswdContext.OnValidationStateChanged += PwValidationChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SetPassword()
|
||||||
|
{
|
||||||
|
if (Working)
|
||||||
|
return;
|
||||||
|
Working = true;
|
||||||
|
Toaster.ShowInfo("Nulstiller adgangskode.");
|
||||||
|
await UserRepo.ResetUserPassword(UserId, Passwords.NewPassword, Passwords.ConfirmPassword);
|
||||||
|
Passwords.NewPassword = "";
|
||||||
|
Passwords.ConfirmPassword = "";
|
||||||
|
Working = false;
|
||||||
|
Toaster.ShowInfo("Adgangskode er nulstillet.");
|
||||||
|
// _navigator.NavigateTo($"/office/users/advisors/{CountryCode}/{UserId}");
|
||||||
|
}
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Interceptor.DisposeEvent();
|
||||||
|
PasswdContext.OnFieldChanged -= PwHandleFieldChanged;
|
||||||
|
PasswdContext.OnValidationStateChanged -= PwValidationChanged;
|
||||||
|
}
|
||||||
|
}
|
6
Wonky.Client/Pages/SystemKrvProductsAdminPage.razor
Normal file
6
Wonky.Client/Pages/SystemKrvProductsAdminPage.razor
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
@page "/system/krv/products"
|
||||||
|
<h3>SystemKrvProductsAdminPage</h3>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
}
|
6
Wonky.Client/Pages/SystemKrvProtectionsAdminPage.razor
Normal file
6
Wonky.Client/Pages/SystemKrvProtectionsAdminPage.razor
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
@page "/system/krv/protections"
|
||||||
|
<h3>SystemKrvProtectionsAdminPage</h3>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
}
|
6
Wonky.Client/Pages/SystemKrvTextsAdminPage.razor
Normal file
6
Wonky.Client/Pages/SystemKrvTextsAdminPage.razor
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
@page "/system/krv/texts"
|
||||||
|
<h3>SystemKrvTextsAdminPage</h3>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
}
|
29
Wonky.Client/Pages/SystemManagerLandingPage.razor
Normal file
29
Wonky.Client/Pages/SystemManagerLandingPage.razor
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
@*
|
||||||
|
// Copyright (C) 2022 FCS Frede's Computer Services.
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||||
|
//
|
||||||
|
*@
|
||||||
|
|
||||||
|
@using Microsoft.AspNetCore.Authorization
|
||||||
|
@attribute [Authorize(Roles = "Admin")]
|
||||||
|
@page "/system"
|
||||||
|
<PageTitle>System Mmanager</PageTitle>
|
||||||
|
|
||||||
|
<div class="list-group">
|
||||||
|
<a class="list-group-item list-group-item-action" href="/system/users">Bruger Admin</a>
|
||||||
|
<a class="list-group-item list-group-item-action" href="/system/supervisors">Supervisor Admin</a>
|
||||||
|
<a class="list-group-item list-group-item-action" href="/system/krv/products">Kemi Produkt Admin</a>
|
||||||
|
<a class="list-group-item list-group-item-action" href="/system/krv/protections">Kemi Værnemiddel Admin</a>
|
||||||
|
<a class="list-group-item list-group-item-action" href="/system/krv/texts">Kemi Tekster Admin</a>
|
||||||
|
</div>
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
// Copyright (C) 2022 FCS Frede's Computer Services.
|
// Copyright (C) 2022 FCS Frede's Computer Services.
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU Affero General Public License as
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
@ -14,11 +15,10 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using Wonky.Entity.DTO;
|
|
||||||
|
|
||||||
namespace Wonky.Client.Components;
|
namespace Wonky.Client.Pages;
|
||||||
|
|
||||||
public partial class OfficeCountryUserListComponent
|
public partial class SystemManagerLandingPage
|
||||||
{
|
{
|
||||||
[Parameter] public List<UserManagerListView> UserList { get; set; } = new();
|
[Parameter] public string CountryCode { get; set; } = "";
|
||||||
}
|
}
|
28
Wonky.Client/Pages/SystemSupervisorListPage.razor
Normal file
28
Wonky.Client/Pages/SystemSupervisorListPage.razor
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
@*
|
||||||
|
// Copyright (C) 2022 FCS Frede's Computer Services.
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Affero General Public License as
|
||||||
|
// published by the Free Software Foundation, either version 3 of the
|
||||||
|
// License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Affero General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
|
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||||
|
//
|
||||||
|
*@
|
||||||
|
|
||||||
|
@using Microsoft.AspNetCore.Authorization
|
||||||
|
@attribute [Authorize(Roles = "Admin")]
|
||||||
|
@page "/system/supervisors"
|
||||||
|
|
||||||
|
<PageTitle>SupervisorUserListPage</PageTitle>
|
||||||
|
|
||||||
|
<h3>Supervisor User List Page</h3>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
}
|
|
@ -15,41 +15,51 @@
|
||||||
//
|
//
|
||||||
*@
|
*@
|
||||||
|
|
||||||
@if (UserList.Any())
|
@using Microsoft.AspNetCore.Authorization
|
||||||
{
|
@attribute [Authorize(Roles = "Admin")]
|
||||||
<div class="list-group list-group-flush">
|
@page "/system/users"
|
||||||
<div class="list-group-item">
|
|
||||||
<div class="row">
|
<PageTitle>Admin User List Page</PageTitle>
|
||||||
<div class="col fw-bold">
|
|
||||||
Navn
|
<h3>Admin User List Page</h3>
|
||||||
</div>
|
|
||||||
<div class="col fw-bold">
|
<div class="list-group">
|
||||||
Telefon
|
<div class="list-group-item">
|
||||||
</div>
|
<div class="row">
|
||||||
<div class="col fw-bold">
|
<div class="col-sm-1">
|
||||||
Email
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="col-sm-5">
|
||||||
@foreach (var user in UserList)
|
<div class="h4">Navn</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-4">
|
||||||
|
<div class="h4">Email</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<div class="h4">Telefon</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (UserList.Any())
|
||||||
|
{
|
||||||
|
foreach (var user in UserList)
|
||||||
{
|
{
|
||||||
<a class="list-group-item list-group-item-action" href="/office/users/office/@user.CountryCode.ToLower()/@user.UserId/view">
|
<a class="list-group-item list-group-item-action" href="/system/users/@user.UserId">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col-sm-1">
|
||||||
|
@user.CountryCode @user.SalesRep
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-5">
|
||||||
@user.FullName
|
@user.FullName
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col-sm-4">
|
||||||
@user.PhoneNumber
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
@user.Email
|
@user.Email
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-sm-2">
|
||||||
|
@user.PhoneNumber
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
}
|
}
|
||||||
</div>
|
}
|
||||||
}
|
</div>
|
||||||
else
|
|
||||||
{
|
|
||||||
<div>Ingen data</div>
|
|
||||||
}
|
|
27
Wonky.Client/Pages/SystemUserListPage.razor.cs
Normal file
27
Wonky.Client/Pages/SystemUserListPage.razor.cs
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
using Wonky.Client.HttpInterceptors;
|
||||||
|
using Wonky.Client.HttpRepository;
|
||||||
|
using Wonky.Entity.DTO;
|
||||||
|
|
||||||
|
namespace Wonky.Client.Pages;
|
||||||
|
|
||||||
|
public partial class SystemUserListPage : IDisposable
|
||||||
|
{
|
||||||
|
[Inject] public HttpInterceptorService Interceptor { get; set; }
|
||||||
|
[Inject] public ISystemUserRepository UserRepo { get; set; }
|
||||||
|
|
||||||
|
private List<UserManagerListView> UserList { get; set; } = new();
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
Interceptor.RegisterEvent();
|
||||||
|
Interceptor.RegisterBeforeSendEvent();
|
||||||
|
|
||||||
|
UserList = await UserRepo.GetUsers();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Interceptor.DisposeEvent();
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,7 +18,7 @@
|
||||||
@using Microsoft.AspNetCore.Authorization
|
@using Microsoft.AspNetCore.Authorization
|
||||||
@using Wonky.Client.Components
|
@using Wonky.Client.Components
|
||||||
@attribute [Authorize(Roles = "Admin")]
|
@attribute [Authorize(Roles = "Admin")]
|
||||||
@page "/office/users/advisors/{CountryCode}/{UserId}/view"
|
@page "/system/users/{UserId}"
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header bg-dark text-white">
|
<div class="card-header bg-dark text-white">
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@if (!string.IsNullOrWhiteSpace(UserInfo.UserId))
|
@if (!string.IsNullOrWhiteSpace(UserInfo.UserId))
|
||||||
{
|
{
|
||||||
<EditForm EditContext="UserEditContext" OnValidSubmit="UpdateAdvisor">
|
<EditForm EditContext="UserEditContext" OnValidSubmit="UpdateUser">
|
||||||
<DataAnnotationsValidator/>
|
<DataAnnotationsValidator/>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
|
@ -102,10 +102,7 @@
|
||||||
<button type="submit" class="btn btn-primary">Gem</button>
|
<button type="submit" class="btn btn-primary">Gem</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<a class="btn btn-primary" href="/office/users/advisors/@CountryCode">Tilbage</a>
|
<a class="btn btn-primary" href="/system/users">Tilbage</a>
|
||||||
</div>
|
|
||||||
<div class="col">
|
|
||||||
<a class="btn btn-primary" href="/office/users/advisors/@CountryCode/@UserId/reports">Salg</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</EditForm>
|
</EditForm>
|
||||||
|
|
|
@ -22,7 +22,7 @@ using Wonky.Client.Helpers;
|
||||||
using Wonky.Client.HttpInterceptors;
|
using Wonky.Client.HttpInterceptors;
|
||||||
using Wonky.Client.HttpRepository;
|
using Wonky.Client.HttpRepository;
|
||||||
using Wonky.Entity.DTO;
|
using Wonky.Entity.DTO;
|
||||||
using Wonky.Entity.Views;
|
|
||||||
#pragma warning disable CS8618
|
#pragma warning disable CS8618
|
||||||
|
|
||||||
namespace Wonky.Client.Pages;
|
namespace Wonky.Client.Pages;
|
||||||
|
@ -33,8 +33,7 @@ public partial class SystemUserViewEditPage : IDisposable
|
||||||
[Parameter] public string CountryCode { get; set; } = "";
|
[Parameter] public string CountryCode { get; set; } = "";
|
||||||
[Inject] public HttpInterceptorService Interceptor { get; set; }
|
[Inject] public HttpInterceptorService Interceptor { get; set; }
|
||||||
[Inject] public ISystemUserRepository UserRepo { get; set; }
|
[Inject] public ISystemUserRepository UserRepo { get; set; }
|
||||||
// [Inject] public ILogger<SystemUserViewEditPage> Logger { get; set; }
|
[Inject] public ILogger<SystemUserViewEditPage> Logger { get; set; }
|
||||||
// [Inject] public NavigationManager Navigator { get; set; }
|
|
||||||
[Inject] public IToastService Toaster { get; set; }
|
[Inject] public IToastService Toaster { get; set; }
|
||||||
private UserManagerEditView UserInfo { get; set; } = new();
|
private UserManagerEditView UserInfo { get; set; } = new();
|
||||||
private EditContext UserEditContext { get; set; }
|
private EditContext UserEditContext { get; set; }
|
||||||
|
@ -43,7 +42,6 @@ public partial class SystemUserViewEditPage : IDisposable
|
||||||
private bool PwInvalid { get; set; } = true;
|
private bool PwInvalid { get; set; } = true;
|
||||||
private bool Working { get; set; } = true;
|
private bool Working { get; set; } = true;
|
||||||
private bool ReadOnly { get; set; } = true;
|
private bool ReadOnly { get; set; } = true;
|
||||||
private const int MinPwLength = 10;
|
|
||||||
|
|
||||||
private readonly JsonSerializerOptions _options = new JsonSerializerOptions
|
private readonly JsonSerializerOptions _options = new JsonSerializerOptions
|
||||||
{
|
{
|
||||||
|
@ -54,25 +52,25 @@ public partial class SystemUserViewEditPage : IDisposable
|
||||||
{
|
{
|
||||||
Interceptor.RegisterEvent();
|
Interceptor.RegisterEvent();
|
||||||
Interceptor.RegisterBeforeSendEvent();
|
Interceptor.RegisterBeforeSendEvent();
|
||||||
|
|
||||||
UserInfo = await UserRepo.GetUserInfo(UserId);
|
UserInfo = await UserRepo.GetUserInfo(UserId);
|
||||||
|
|
||||||
UserEditContext = new EditContext(UserInfo);
|
UserEditContext = new EditContext(UserInfo);
|
||||||
PasswdContext = new EditContext(Passwords);
|
PasswdContext = new EditContext(Passwords);
|
||||||
|
|
||||||
PasswdContext.OnFieldChanged += PwHandleFieldChanged;
|
PasswdContext.OnFieldChanged += PwHandleFieldChanged!;
|
||||||
PasswdContext.OnValidationStateChanged += PwValidationChanged;
|
PasswdContext.OnValidationStateChanged += PwValidationChanged;
|
||||||
Working = false;
|
Working = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task UpdateAdvisor()
|
private async Task UpdateUser()
|
||||||
{
|
{
|
||||||
ReadOnly = true;
|
ReadOnly = true;
|
||||||
Working = true;
|
Working = true;
|
||||||
Toaster.ShowInfo("Sender data til server ...");
|
Toaster.ShowInfo("Sender data til server ...");
|
||||||
await UserRepo.UpdateUserInfo(UserId, UserInfo);
|
await UserRepo.UpdateUserInfo(UserId, UserInfo);
|
||||||
Working = false;
|
Working = false;
|
||||||
Toaster.ShowInfo("Sælger er opdateret ...");
|
Toaster.ShowInfo("Bruger er opdateret ...");
|
||||||
// _navigator.NavigateTo($"/office/users/advisors/{CountryCode}/{UserId}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PwHandleFieldChanged(object sender, FieldChangedEventArgs e)
|
private void PwHandleFieldChanged(object sender, FieldChangedEventArgs e)
|
||||||
|
@ -80,18 +78,18 @@ public partial class SystemUserViewEditPage : IDisposable
|
||||||
PwInvalid = !PasswdContext.Validate();
|
PwInvalid = !PasswdContext.Validate();
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
private void PwValidationChanged(object sender, ValidationStateChangedEventArgs e)
|
private void PwValidationChanged(object? sender, ValidationStateChangedEventArgs e)
|
||||||
{
|
{
|
||||||
PwInvalid = true;
|
PwInvalid = true;
|
||||||
if (!Utils.IsValidPasswd(Passwords.NewPassword, MinPwLength))
|
if (!Utils.IsValidPasswd(Passwords.NewPassword))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PasswdContext.OnFieldChanged -= PwHandleFieldChanged;
|
PasswdContext.OnFieldChanged -= PwHandleFieldChanged!;
|
||||||
PasswdContext.OnValidationStateChanged -= PwValidationChanged;
|
PasswdContext.OnValidationStateChanged -= PwValidationChanged;
|
||||||
|
|
||||||
PasswdContext = new EditContext(Passwords);
|
PasswdContext = new EditContext(Passwords);
|
||||||
|
|
||||||
PasswdContext.OnFieldChanged += PwHandleFieldChanged;
|
PasswdContext.OnFieldChanged += PwHandleFieldChanged!;
|
||||||
PasswdContext.OnValidationStateChanged += PwValidationChanged;
|
PasswdContext.OnValidationStateChanged += PwValidationChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,12 +104,11 @@ public partial class SystemUserViewEditPage : IDisposable
|
||||||
Passwords.ConfirmPassword = "";
|
Passwords.ConfirmPassword = "";
|
||||||
Working = false;
|
Working = false;
|
||||||
Toaster.ShowInfo("Adgangskode er nulstillet.");
|
Toaster.ShowInfo("Adgangskode er nulstillet.");
|
||||||
// _navigator.NavigateTo($"/office/users/advisors/{CountryCode}/{UserId}");
|
|
||||||
}
|
}
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Interceptor.DisposeEvent();
|
Interceptor.DisposeEvent();
|
||||||
PasswdContext.OnFieldChanged -= PwHandleFieldChanged;
|
PasswdContext.OnFieldChanged -= PwHandleFieldChanged!;
|
||||||
PasswdContext.OnValidationStateChanged -= PwValidationChanged;
|
PasswdContext.OnValidationStateChanged -= PwValidationChanged;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -109,6 +109,14 @@
|
||||||
</div>
|
</div>
|
||||||
</Authorized>
|
</Authorized>
|
||||||
</AuthorizeView>
|
</AuthorizeView>
|
||||||
|
|
||||||
|
<AuthorizeView Roles="Admin">
|
||||||
|
<div class="nav-item px-3">
|
||||||
|
<NavLink class="nav-link ps-2" href="/system">
|
||||||
|
<i class="bi-gear-wide-connected pe-2" style="font-size:1.3em;" aria-hidden="true"></i> System
|
||||||
|
</NavLink>
|
||||||
|
</div>
|
||||||
|
</AuthorizeView>
|
||||||
|
|
||||||
<AuthorizeView Roles="Admin,Advisor,Office,Supervisor,Warehouse">
|
<AuthorizeView Roles="Admin,Advisor,Office,Supervisor,Warehouse">
|
||||||
<div class="nav-item px-3">
|
<div class="nav-item px-3">
|
||||||
|
@ -116,6 +124,11 @@
|
||||||
<i class="bi-question pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Hjælp
|
<i class="bi-question pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Hjælp
|
||||||
</NavLink>
|
</NavLink>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="nav-item px-3">
|
||||||
|
<NavLink class="nav-link ps-2" href="/logout">
|
||||||
|
<i class="bi-lock pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Log af
|
||||||
|
</NavLink>
|
||||||
|
</div>
|
||||||
</AuthorizeView>
|
</AuthorizeView>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"appInfo": {
|
"appInfo": {
|
||||||
"name": "Wonky Online",
|
"name": "Wonky Online",
|
||||||
"version": "0.118.5",
|
"version": "0.119.0",
|
||||||
"rc": true,
|
"rc": true,
|
||||||
"sandBox": false,
|
"sandBox": false,
|
||||||
"image": "grumpy-coder.png"
|
"image": "grumpy-coder.png"
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"apiConfig": {
|
"apiConfig": {
|
||||||
"baseUrl": "https://zeta.innotec.dk",
|
"baseUrl": "https://dev.innotec.dk",
|
||||||
"catalog": "api/v2/catalog/country",
|
"catalog": "api/v2/catalog/country",
|
||||||
"crmCustomers": "api/v2/crm/companies",
|
"crmCustomers": "api/v2/crm/companies",
|
||||||
"crmInventoryExt": "history/inventory",
|
"crmInventoryExt": "history/inventory",
|
||||||
|
|
Loading…
Reference in a new issue