This commit is contained in:
Frede Hundewadt 2023-05-21 08:23:47 +02:00
parent 5c0ac0d728
commit 532cd08827
27 changed files with 39 additions and 272 deletions

View file

@ -1,149 +0,0 @@
@* 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">
<div class="mt-3 h3 card-title">
Sælger Vedligeholdelse
</div>
</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/>
}

View file

@ -1,116 +0,0 @@
// 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 UserAdminEditView UserInfo { get; set; } = new();
private EditContext UserEditContext { get; set; }
private ResetPasswordModel 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;
}
}

View file

@ -34,7 +34,6 @@
<Content Remove="wwwroot\icons\**" />
<Content Remove="Pages\AdvisorCustomerOrderViewPage.razor" />
<Content Remove="Pages\OfficeUserAdvisorViewEditPage.razor" />
<Content Remove="wwwroot\scripts\document-event-load.js" />
</ItemGroup>
<ItemGroup>

View file

@ -1,7 +1,7 @@
{
"appInfo": {
"name": "Wonky Online",
"version": "142.5",
"version": "145.1",
"rc": true,
"sandBox": true,
"image": "grumpy-coder.png"

View file

@ -1,3 +0,0 @@
document.addEventListener("load", function() {
window.print();
});

View file

@ -14,6 +14,7 @@
//
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Wonky.Entity.DTO;

View file

@ -13,6 +13,8 @@
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
//
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Wonky.Entity.DTO;

View file

@ -14,6 +14,8 @@
//
using System.Collections.Generic;
namespace Wonky.Entity.DTO;
public class EmailMessage

View file

@ -14,6 +14,7 @@
//
using System.Collections.Generic;
using Wonky.Entity.Views;
namespace Wonky.Entity.DTO;

View file

@ -14,6 +14,7 @@
//
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Wonky.Entity.DTO;

View file

@ -13,6 +13,7 @@
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
//
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Wonky.Entity.DTO;

View file

@ -1,3 +1,5 @@
using System.Collections.Generic;
namespace Wonky.Entity.DTO;
public class WorkplaceBopCreate

View file

@ -13,6 +13,8 @@
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
//
using System.Collections.Generic;
namespace Wonky.Entity.Models;
public class VirkRegInfo

View file

@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace Wonky.Entity.Views;

View file

@ -1,3 +1,5 @@
using System.Collections.Generic;
namespace Wonky.Entity.Views;
public class ExternalProductListView

View file

@ -14,6 +14,8 @@
//
using System.Collections.Generic;
namespace Wonky.Entity.Views;
public class InvoiceListView

View file

@ -14,6 +14,8 @@
//
using System.Collections.Generic;
namespace Wonky.Entity.Views;
public class InvoiceView

View file

@ -14,6 +14,8 @@
//
using System.Collections.Generic;
namespace Wonky.Entity.Views;
public class ReportActivityInfoView

View file

@ -13,6 +13,8 @@
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
//
using System.Collections.Generic;
namespace Wonky.Entity.Views;
public class ReportItemView

View file

@ -13,6 +13,8 @@
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
//
using System.Collections.Generic;
namespace Wonky.Entity.Views;
public class ReportStatusView

View file

@ -13,6 +13,8 @@
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
//
using System.Collections.Generic;
namespace Wonky.Entity.Views;
public class ReportView

View file

@ -13,6 +13,8 @@
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
//
using System.Collections.Generic;
namespace Wonky.Entity.Views;
public class SalesItemView

View file

@ -14,6 +14,8 @@
//
using System.Collections.Generic;
namespace Wonky.Entity.Views;
public class WarehouseOrderView

View file

@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.Diagnostics.Contracts;
namespace Wonky.Entity.Views;

View file

@ -1,3 +1,5 @@
using System.Collections.Generic;
namespace Wonky.Entity.Views;
public class WorkplaceProduct

View file

@ -1,3 +1,5 @@
using System.Collections.Generic;
namespace Wonky.Entity.Views;
public class WorkplaceProductVariant

View file

@ -1,7 +1,7 @@
{
"sdk": {
"version": "8.0.0",
"version": "6.0.0",
"rollForward": "latestMajor",
"allowPrerelease": true
"allowPrerelease": false
}
}