project files
This commit is contained in:
parent
424dabe3ae
commit
53ecf22538
42 changed files with 48 additions and 1215 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
*/**/appsettings.json
|
||||
# ---> JetBrains
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
|
|
@ -5,6 +5,10 @@ VisualStudioVersion = 16.0.30114.105
|
|||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wonky.Client", "Wonky.Client\Wonky.Client.csproj", "{A001767F-6CA1-428E-938A-EA491A778D3E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wonky.Entity", "..\Wonky.Entity\Wonky.Entity\Wonky.Entity.csproj", "{39D1D838-9D6C-41AB-8A77-ABF4ECC35402}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wonky.Virk", "..\Wonky.Virk\Wonky.Virk\Wonky.Virk.csproj", "{69A68DBC-1CAF-496D-B8FE-7FB82E7FE0E9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -18,5 +22,13 @@ Global
|
|||
{A001767F-6CA1-428E-938A-EA491A778D3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A001767F-6CA1-428E-938A-EA491A778D3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A001767F-6CA1-428E-938A-EA491A778D3E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{39D1D838-9D6C-41AB-8A77-ABF4ECC35402}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{39D1D838-9D6C-41AB-8A77-ABF4ECC35402}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{39D1D838-9D6C-41AB-8A77-ABF4ECC35402}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{39D1D838-9D6C-41AB-8A77-ABF4ECC35402}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{69A68DBC-1CAF-496D-B8FE-7FB82E7FE0E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{69A68DBC-1CAF-496D-B8FE-7FB82E7FE0E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{69A68DBC-1CAF-496D-B8FE-7FB82E7FE0E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{69A68DBC-1CAF-496D-B8FE-7FB82E7FE0E9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -3,7 +3,7 @@ namespace Wonky.Client;
|
|||
public class AppId
|
||||
{
|
||||
public string Version { get; set; } = "0.2.1";
|
||||
public string Name { get; set; } = "Inno Client";
|
||||
public string Name { get; set; } = "Wonky Client";
|
||||
|
||||
public bool IsBeta { get; set; } = false;
|
||||
}
|
|
@ -17,6 +17,7 @@ using Microsoft.AspNetCore.Components;
|
|||
using Wonky.Client.Services;
|
||||
using Wonky.Entity.Models;
|
||||
using Wonky.Entity.Requests;
|
||||
using Wonky.Virk.Services;
|
||||
|
||||
namespace Wonky.Client.Components;
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ using Wonky.Client.HttpInterceptors;
|
|||
using Wonky.Client.Services;
|
||||
using Wonky.Entity.Models;
|
||||
using Wonky.Entity.Requests;
|
||||
using Wonky.Virk.Services;
|
||||
|
||||
namespace Wonky.Client.Components;
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ using Wonky.Client.HttpInterceptors;
|
|||
using Wonky.Client.Services;
|
||||
using Wonky.Entity.Models;
|
||||
using Wonky.Entity.Requests;
|
||||
using Wonky.Virk.Services;
|
||||
|
||||
namespace Wonky.Client.Components;
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ using Microsoft.AspNetCore.Components;
|
|||
using Wonky.Client.Services;
|
||||
using Wonky.Entity.Models;
|
||||
using Wonky.Entity.Requests;
|
||||
using Wonky.Virk.Services;
|
||||
|
||||
namespace Wonky.Client.Components;
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
@page "/activites"
|
||||
@using Client.V1.Components;
|
||||
|
||||
<h3>Salgs Aktivitet</h3>
|
||||
|
||||
|
|
|
@ -7,10 +7,4 @@ public partial class ActivityList
|
|||
{
|
||||
public List<Activity> Activities { get; set; } = new();
|
||||
|
||||
[Inject] public ActivityDbContext DbContext { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Activities = await DbContext.GetAllActivities();
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@ using Wonky.Client.Services;
|
|||
using Wonky.Entity.DTO;
|
||||
using Wonky.Entity.Models;
|
||||
using Wonky.Entity.Requests;
|
||||
using Wonky.Virk.Services;
|
||||
|
||||
namespace Wonky.Client.Pages
|
||||
{
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
@page "/krv-product/{productId}"
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h1>@Product.TradingName</h1>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<img class="image-preview" src="@Product.PictureLink" alt="@Product.TradingName"/>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<a href="/krvProducts" class="btn btn-success">Tilbage</a>
|
||||
</div>
|
||||
</div>
|
|
@ -1,36 +0,0 @@
|
|||
using Microsoft.AspNetCore.Components;
|
||||
using Wonky.Client.HttpInterceptors;
|
||||
using Wonky.Client.HttpRepository;
|
||||
using Wonky.Entity.DTO;
|
||||
|
||||
namespace Wonky.Client.Pages.KrvAdmin;
|
||||
|
||||
public partial class KrvProduct : IDisposable
|
||||
{
|
||||
private KrvProductDto Product { get; set; } = new ();
|
||||
|
||||
[Inject]
|
||||
public IKrvProductHttpRepository ProductRepo { get; set; }
|
||||
|
||||
[Inject]
|
||||
public HttpInterceptorService Interceptor { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string ProductId { get; set; } = "";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Interceptor.RegisterEvent();
|
||||
Interceptor.RegisterBeforeSendEvent();
|
||||
Product = await ProductRepo.GetProduct(ProductId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Interceptor.DisposeEvent();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
/* product image preview */
|
||||
.image-name {
|
||||
margin-left: 10px;
|
||||
}
|
||||
.image-preview {
|
||||
width: auto;
|
||||
max-width: 200px;
|
||||
height: 100px;
|
||||
margin-top: 15px;
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
@page "/krv-products"
|
||||
@using Client.V1.Components
|
||||
@using Inno.Entities.RequestFeatures
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<Search OnSearchChanged="SearchChanged"></Search>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<SortKrvProducts OnSortChanged="SortChanged" />
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
@* <a class="btn btn-success mb-1" href="/createCompany">Nyt firma</a> *@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<Pagination MetaData="MetaData" Spread="2" SelectedPage="SelectedPage"></Pagination>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<PageSizeDropDown SelectedPageSize="SetPageSize" />
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<KrvProductTable KrvProducts="KrvProducts"></KrvProductTable>
|
||||
</div>
|
||||
</div>
|
|
@ -1,64 +0,0 @@
|
|||
using Microsoft.AspNetCore.Components;
|
||||
using Wonky.Client.HttpInterceptors;
|
||||
using Wonky.Client.HttpRepository;
|
||||
using Wonky.Entity.DTO;
|
||||
using Wonky.Entity.Requests;
|
||||
|
||||
namespace Wonky.Client.Pages.KrvAdmin;
|
||||
|
||||
public partial class KrvProductList : IDisposable
|
||||
{
|
||||
public List<KrvProductDto> KrvProducts { get; set; } = new();
|
||||
public MetaData? MetaData { get; set; } = new();
|
||||
|
||||
private PagingParams _paging = new();
|
||||
|
||||
[Inject]
|
||||
public IKrvProductHttpRepository ProductRepo { get; set; }
|
||||
|
||||
[Inject]
|
||||
public HttpInterceptorService Interceptor { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Interceptor.RegisterEvent();
|
||||
Interceptor.RegisterBeforeSendEvent();
|
||||
await GetKrvProducts();
|
||||
}
|
||||
|
||||
private async Task SelectedPage(int page)
|
||||
{
|
||||
_paging.PageNumber = page;
|
||||
await GetKrvProducts();
|
||||
}
|
||||
|
||||
private async Task GetKrvProducts()
|
||||
{
|
||||
var pagingResponse = await ProductRepo.GetProducts(_paging);
|
||||
KrvProducts = pagingResponse.Items;
|
||||
MetaData = pagingResponse.MetaData;
|
||||
}
|
||||
|
||||
private async Task SetPageSize(int pageSize)
|
||||
{
|
||||
_paging.PageSize = pageSize;
|
||||
_paging.PageNumber = 1;
|
||||
await GetKrvProducts();
|
||||
}
|
||||
|
||||
private async Task SearchChanged(string? searchTerm)
|
||||
{
|
||||
_paging.PageNumber = 1;
|
||||
_paging.SearchTerm = searchTerm;
|
||||
await GetKrvProducts();
|
||||
}
|
||||
|
||||
private async Task SortChanged(string? orderBy)
|
||||
{
|
||||
_paging.OrderBy = orderBy;
|
||||
await GetKrvProducts();
|
||||
}
|
||||
|
||||
public void Dispose() => Interceptor.DisposeEvent();
|
||||
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
@page "/krv-product-update/{productId}"
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@using Microsoft.AspNetCore.Components
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
@if (_productDto != null)
|
||||
{
|
||||
<div class="card bg-light mt-5">
|
||||
<div class="card-header">
|
||||
<h1>Opdater KRV Variant</h1>
|
||||
</div>
|
||||
@* <EditForm Model="_company" OnValidSubmit="Create" class="card-body bg-light mt-5"> *@
|
||||
<EditForm EditContext="_editContext" OnValidSubmit="Update" class="card-body">
|
||||
<DataAnnotationsValidator/>
|
||||
@* <ValidationSummary /> *@
|
||||
<div class="form-group row mb-2">
|
||||
<label for="name" class="col-md-2 col-form-label">Handelsnavn</label>
|
||||
<div class="col-md-10">
|
||||
<InputText id="name" class="form-control" @bind-Value="_productDto.TradingName"/>
|
||||
<ValidationMessage For="@(() => _productDto.TradingName)" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-2">
|
||||
<label for="pictureLink" class="col-md-2 col-form-label">Billede URL</label>
|
||||
<div class="col-md-10">
|
||||
<InputText id="pictureLink" class="form-control" @bind-Value="@_productDto.PictureLink" />
|
||||
@* <VariantImageUpload OnChange="AssignKrvVariantPicture" *@
|
||||
@* PictureLink="@_productDto.PictureLink" *@
|
||||
@* VariantId="@_productDto.VariantId" *@
|
||||
@* ImageFilename="@_productDto.ErpSku"/> *@
|
||||
<ValidationMessage For="@(() => _productDto.PictureLink)"/>
|
||||
@if(!string.IsNullOrWhiteSpace(_productDto.PictureLink))
|
||||
{
|
||||
<div>
|
||||
<img src="@_productDto.PictureLink" id="image" class="image-preview" alt="@_productDto.TradingName" />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="submit" class="btn btn-success" >Opdater</button>
|
||||
</div>
|
||||
</div>
|
||||
</EditForm>
|
||||
<div class="card-footer">
|
||||
<a href="/krvVariants" class="btn btn-success">Tilbage</a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>Vent venligst ...</p>
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
using Blazored.Toast.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Wonky.Client.HttpInterceptors;
|
||||
using Wonky.Client.HttpRepository;
|
||||
using Wonky.Entity.DTO;
|
||||
|
||||
namespace Wonky.Client.Pages.KrvAdmin;
|
||||
|
||||
public partial class KrvProductUpdate : IDisposable
|
||||
{
|
||||
private KrvProductDto _productDto;
|
||||
private EditContext _editContext;
|
||||
private bool _formInvalid = true;
|
||||
|
||||
[Parameter]
|
||||
public string ProductId { get; set; }
|
||||
|
||||
[Inject]
|
||||
public IKrvProductHttpRepository ProductRepo { get; set; }
|
||||
|
||||
[Inject]
|
||||
public HttpInterceptorService Interceptor { get; set; }
|
||||
|
||||
[Inject]
|
||||
public IToastService ToastService { get; set; }
|
||||
|
||||
[Inject]
|
||||
public ILogger<KrvVariantCreate> Logger { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_productDto = await ProductRepo.GetProduct(ProductId);
|
||||
_editContext = new EditContext(_productDto);
|
||||
_editContext.OnFieldChanged += HandleFieldChanged;
|
||||
Interceptor.RegisterEvent();
|
||||
Interceptor.RegisterBeforeSendEvent();
|
||||
}
|
||||
|
||||
private void HandleFieldChanged(object sender, FieldChangedEventArgs e)
|
||||
{
|
||||
_formInvalid = !_editContext.Validate();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task Update()
|
||||
{
|
||||
await ProductRepo.UpdateProduct(_productDto);
|
||||
ToastService.ShowSuccess($"Godt så. Produktet '{_productDto.TradingName}' er opdateret.");
|
||||
}
|
||||
|
||||
private void AssignKrvVariantPicture(string imgUrl)
|
||||
=> _productDto.PictureLink = imgUrl;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Interceptor.DisposeEvent();
|
||||
_editContext.OnFieldChanged -= HandleFieldChanged;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
/* product image preview */
|
||||
.image-name {
|
||||
margin-left: 10px;
|
||||
}
|
||||
.image-preview {
|
||||
width: 200px;
|
||||
margin-top: 15px;
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
@page "/create-variant"
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@using Microsoft.AspNetCore.Components
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
<h2>Opret KRV Variant</h2>
|
||||
@* <EditForm Model="_company" OnValidSubmit="Create" class="card card-body bg-light mt-5"> *@
|
||||
<EditForm EditContext="_editContext" OnValidSubmit="Create" class="card card-body bg-light mt-5">
|
||||
<DataAnnotationsValidator />
|
||||
@* <ValidationSummary /> *@
|
||||
<div class="form-group row mb-2">
|
||||
<label for="name" class="col-md-2 col-form-label">Belgisk Navn</label>
|
||||
<div class="col-md-10">
|
||||
<InputText id="name" class="form-control" @bind-Value="_variantDto.Name"/>
|
||||
<ValidationMessage For="@(() => _variantDto.Name)"></ValidationMessage>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-2">
|
||||
<label for="sku" class="col-md-2 col-form-label">Belgisk Varenummer</label>
|
||||
<div class="col-md-10">
|
||||
<InputText id="sku" class="form-control" @bind-Value="_variantDto.Sku"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row mb-2">
|
||||
<label for="erpName" class="col-md-2 col-form-label">Erp Navn</label>
|
||||
<div class="col-md-10">
|
||||
<InputText id="erpName" class="form-control" @bind-Value="_variantDto.ErpName"/>
|
||||
<ValidationMessage For="@(() => _variantDto.Name)"></ValidationMessage>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-2">
|
||||
<label for="erpSku" class="col-md-2 col-form-label">Erp Varenummer</label>
|
||||
<div class="col-md-10">
|
||||
<InputText id="erpSku" class="form-control" @bind-Value="_variantDto.ErpSku"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-2">
|
||||
<label for="shortName" class="col-md-2 col-form-label">Forkortelse</label>
|
||||
<div class="col-md-10">
|
||||
<InputText id="shortName" class="form-control" @bind-Value="_variantDto.ShortName"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-2">
|
||||
<label for="sdsLink" class="col-md-2 col-form-label">Link til Sikkerhedsdatablad</label>
|
||||
<div class="col-md-10">
|
||||
<InputText id="sdsLink" class="form-control" @bind-Value="_variantDto.SdsLink"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row mb-2">
|
||||
<label for="file-upload" class="col-md-2 col-form-label">Produkt billede</label>
|
||||
<div class="col-md-10">
|
||||
<ProductImageUpload OnChange="AssignImageUrl" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="submit" class="btn btn-success" disabled="@_formInvalid">Opret</button>
|
||||
</div>
|
||||
</div>
|
||||
</EditForm>
|
|
@ -1,70 +0,0 @@
|
|||
using Blazored.Toast.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Wonky.Client.HttpInterceptors;
|
||||
using Wonky.Client.HttpRepository;
|
||||
using Wonky.Entity.DTO;
|
||||
|
||||
namespace Wonky.Client.Pages.KrvAdmin;
|
||||
|
||||
public partial class KrvVariantCreate : IDisposable
|
||||
{
|
||||
private KrvVariantDto _variantDto { get; set; } = new();
|
||||
|
||||
private EditContext _editContext;
|
||||
private bool _formInvalid = true;
|
||||
|
||||
[Inject]
|
||||
public IKrvVariantHttpRepository VariantRepo { get; set; }
|
||||
|
||||
[Inject]
|
||||
public HttpInterceptorService Interceptor { get; set; }
|
||||
|
||||
[Inject]
|
||||
public IToastService ToastService { get; set; }
|
||||
|
||||
[Inject]
|
||||
public ILogger<KrvVariantCreate> Logger { get; set; }
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
_editContext = new EditContext(_variantDto);
|
||||
_editContext.OnFieldChanged += HandleFieldChanged;
|
||||
Interceptor.RegisterEvent();
|
||||
Interceptor.RegisterBeforeSendEvent();
|
||||
}
|
||||
|
||||
private async Task Create()
|
||||
{
|
||||
Logger.LogDebug($"{_variantDto}");
|
||||
await VariantRepo.CreateVariant(_variantDto);
|
||||
ToastService.ShowSuccess($"Godt så. Produktet '{_variantDto.ErpName}' er oprettet.");
|
||||
_variantDto = new KrvVariantDto();
|
||||
_editContext.OnValidationStateChanged += ValidationChanged;
|
||||
_editContext.NotifyValidationStateChanged();
|
||||
}
|
||||
private void HandleFieldChanged(object sender, FieldChangedEventArgs e)
|
||||
{
|
||||
_formInvalid = !_editContext.Validate();
|
||||
StateHasChanged();
|
||||
}
|
||||
private void ValidationChanged(object sender, ValidationStateChangedEventArgs e)
|
||||
{
|
||||
_formInvalid = true;
|
||||
_editContext.OnFieldChanged -= HandleFieldChanged;
|
||||
_editContext = new EditContext(_variantDto);
|
||||
_editContext.OnFieldChanged += HandleFieldChanged;
|
||||
_editContext.OnValidationStateChanged -= ValidationChanged;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Interceptor.DisposeEvent();
|
||||
_editContext.OnFieldChanged -= HandleFieldChanged;
|
||||
_editContext.OnValidationStateChanged -= ValidationChanged;
|
||||
}
|
||||
|
||||
private void AssignImageUrl(string imgUrl) => _variantDto.PictureLink = imgUrl;
|
||||
}
|
||||
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
@page "/krv-variants"
|
||||
@using Client.V1.Components
|
||||
@using Inno.Entities.RequestFeatures
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<Search OnSearchChanged="SearchChanged"></Search>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<SortKrvVariants OnSortChanged="SortChanged" />
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
@* <a class="btn btn-success mb-1" href="/createCompany">Nyt firma</a> *@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<Pagination MetaData="MetaData" Spread="2" SelectedPage="SelectedPage"></Pagination>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<PageSizeDropDown SelectedPageSize="SetPageSize" />
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<KrvVariantTable KrvVariants="KrvVariants"></KrvVariantTable>
|
||||
</div>
|
||||
</div>
|
|
@ -1,60 +0,0 @@
|
|||
using Microsoft.AspNetCore.Components;
|
||||
using Wonky.Client.HttpInterceptors;
|
||||
using Wonky.Client.HttpRepository;
|
||||
using Wonky.Entity.DTO;
|
||||
using Wonky.Entity.Requests;
|
||||
|
||||
namespace Wonky.Client.Pages.KrvAdmin;
|
||||
|
||||
public partial class KrvVariantList : IDisposable
|
||||
{
|
||||
private List<KrvVariantDto> KrvVariants { get; set; } = new();
|
||||
private MetaData MetaData { get; set; } = new();
|
||||
|
||||
private PagingParams _paging = new();
|
||||
|
||||
[Inject] public IKrvVariantHttpRepository VariantRepo { get; set; }
|
||||
[Inject] public HttpInterceptorService Interceptor { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Interceptor.RegisterEvent();
|
||||
Interceptor.RegisterBeforeSendEvent();
|
||||
await GetKrvVariants();
|
||||
}
|
||||
|
||||
private async Task SelectedPage(int page)
|
||||
{
|
||||
_paging.PageNumber = page;
|
||||
await GetKrvVariants();
|
||||
}
|
||||
|
||||
private async Task GetKrvVariants()
|
||||
{
|
||||
var pagingResponse = await VariantRepo.GetVariants(_paging);
|
||||
KrvVariants = pagingResponse.Items;
|
||||
MetaData = pagingResponse.MetaData;
|
||||
}
|
||||
|
||||
private async Task SetPageSize(int pageSize)
|
||||
{
|
||||
_paging.PageSize = pageSize;
|
||||
_paging.PageNumber = 1;
|
||||
await GetKrvVariants();
|
||||
}
|
||||
|
||||
private async Task SearchChanged(string? searchTerm)
|
||||
{
|
||||
_paging.PageNumber = 1;
|
||||
_paging.SearchTerm = searchTerm;
|
||||
await GetKrvVariants();
|
||||
}
|
||||
|
||||
private async Task SortChanged(string? orderBy)
|
||||
{
|
||||
_paging.OrderBy = orderBy;
|
||||
await GetKrvVariants();
|
||||
}
|
||||
|
||||
public void Dispose() => Interceptor.DisposeEvent();
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
@page "/krv-variant-update/{variantId}"
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
@if (_variantDto != null)
|
||||
{
|
||||
<div class="card bg-light mt-5">
|
||||
<div class="card-header">
|
||||
<h1>Opdater KRV Variant</h1>
|
||||
</div>
|
||||
@* <EditForm Model="_company" OnValidSubmit="Create" class="card-body bg-light mt-5"> *@
|
||||
<EditForm EditContext="_editContext" OnValidSubmit="Update" class="card-body">
|
||||
<DataAnnotationsValidator/>
|
||||
@* <ValidationSummary /> *@
|
||||
<div class="form-group row mb-2">
|
||||
<label for="name" class="col-md-2 col-form-label">BE Navn</label>
|
||||
<div class="col-md-10">
|
||||
<InputText id="name" class="form-control" @bind-Value="_variantDto.Name"/>
|
||||
<ValidationMessage For="@(() => _variantDto.Name)" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-2">
|
||||
<label for="sku" class="col-md-2 col-form-label">BE Varenr</label>
|
||||
<div class="col-md-10">
|
||||
<InputText id="sku" class="form-control" @bind-Value="_variantDto.Sku"/>
|
||||
<ValidationMessage For="@(() => _variantDto.Sku)" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row mb-2">
|
||||
<label for="erpName" class="col-md-2 col-form-label">DK Navn</label>
|
||||
<div class="col-md-10">
|
||||
<InputText id="erpName" class="form-control" @bind-Value="_variantDto.ErpName"/>
|
||||
<ValidationMessage For="@(() => _variantDto.ErpName)" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-2">
|
||||
<label for="erpSku" class="col-md-2 col-form-label">DK Varenr</label>
|
||||
<div class="col-md-10">
|
||||
<InputText id="erpSku" class="form-control" @bind-Value="_variantDto.ErpSku"/>
|
||||
<ValidationMessage For="@(() => _variantDto.ErpSku)" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-2">
|
||||
<label for="shortName" class="col-md-2 col-form-label">Kort Navn</label>
|
||||
<div class="col-md-10">
|
||||
<InputText id="shortName" class="form-control" @bind-Value="_variantDto.ShortName"/>
|
||||
<ValidationMessage For="@(() => _variantDto.ShortName)" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row mb-2">
|
||||
<label for="sdsLink" class="col-md-2 col-form-label">SDS URL</label>
|
||||
<div class="col-md-10">
|
||||
<InputText id="sdsLink" class="form-control" @bind-Value="@_variantDto.SdsLink"/>
|
||||
<ValidationMessage For="@(() => _variantDto.SdsLink)" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row mb-2">
|
||||
<label for="pictureLink" class="col-md-2 col-form-label">Billede URL</label>
|
||||
<div class="col-md-10">
|
||||
<InputText id="pictureLink" class="form-control" @bind-Value="@_variantDto.PictureLink" />
|
||||
@* <VariantImageUpload OnChange="AssignKrvVariantPicture" *@
|
||||
@* PictureLink="@_variantDto.PictureLink" *@
|
||||
@* VariantId="@_variantDto.VariantId" *@
|
||||
@* ImageFilename="@_variantDto.ErpSku"/> *@
|
||||
<ValidationMessage For="@(() => _variantDto.PictureLink)"/>
|
||||
@if(!string.IsNullOrWhiteSpace(_variantDto.PictureLink))
|
||||
{
|
||||
<div>
|
||||
<img src="@_variantDto.PictureLink" id="image" class="image-preview" alt="@_variantDto.Name" />
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="submit" class="btn btn-success" >Opdater</button>
|
||||
</div>
|
||||
</div>
|
||||
</EditForm>
|
||||
<div class="card-footer">
|
||||
<a href="/krvVariants" class="btn btn-success">Tilbage</a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>Vent venligst ...</p>
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
using Blazored.Toast.Services;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Forms;
|
||||
using Wonky.Client.HttpInterceptors;
|
||||
using Wonky.Client.HttpRepository;
|
||||
using Wonky.Entity.DTO;
|
||||
|
||||
namespace Wonky.Client.Pages.KrvAdmin;
|
||||
|
||||
public partial class KrvVariantUpdate : IDisposable
|
||||
{
|
||||
private KrvVariantDto _variantDto;
|
||||
private EditContext _editContext;
|
||||
private bool _formInvalid = true;
|
||||
|
||||
[Parameter]
|
||||
public string VariantId { get; set; }
|
||||
|
||||
[Inject]
|
||||
public IKrvVariantHttpRepository VariantRepo { get; set; }
|
||||
|
||||
[Inject]
|
||||
public HttpInterceptorService Interceptor { get; set; }
|
||||
|
||||
[Inject]
|
||||
public IToastService ToastService { get; set; }
|
||||
|
||||
[Inject]
|
||||
public ILogger<KrvVariantCreate> Logger { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_variantDto = await VariantRepo.GetVariant(VariantId);
|
||||
_editContext = new EditContext(_variantDto);
|
||||
_editContext.OnFieldChanged += HandleFieldChanged;
|
||||
Interceptor.RegisterEvent();
|
||||
Interceptor.RegisterBeforeSendEvent();
|
||||
}
|
||||
|
||||
private void HandleFieldChanged(object sender, FieldChangedEventArgs e)
|
||||
{
|
||||
_formInvalid = !_editContext.Validate();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task Update()
|
||||
{
|
||||
await VariantRepo.UpdateVariant(_variantDto);
|
||||
ToastService.ShowSuccess($"Godt så. Produktet '{_variantDto.ErpName}' er opdateret.");
|
||||
}
|
||||
|
||||
private void AssignKrvVariantPicture(string imgUrl)
|
||||
=> _variantDto.PictureLink = imgUrl;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Interceptor.DisposeEvent();
|
||||
_editContext.OnFieldChanged -= HandleFieldChanged;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
/* variant image preview */
|
||||
.image-name {
|
||||
margin-left: 10px;
|
||||
}
|
||||
.image-preview {
|
||||
width: 200px;
|
||||
margin-top: 15px;
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
@page "/krv-variant/{variantId}"
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@attribute [Authorize(Roles = "Admin")]
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h1>@Variant.Name</h1>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<table class="table table-striped table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">BE Navn</th>
|
||||
<td>@Variant.Name</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">BE Varenr</th>
|
||||
<td>@Variant.Sku</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">DK Navn</th>
|
||||
<td>@Variant.ErpName</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">DK Varenr</th>
|
||||
<td>@Variant.ErpSku</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Kort navn</th>
|
||||
<td>@Variant.ShortName</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">SDS URL</th>
|
||||
<td><a href="@Variant.SdsLink">@Variant.SdsLink</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">Billede URL</th>
|
||||
<td>@Variant.PictureLink</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"></th>
|
||||
<td><img src="@Variant.PictureLink" class="image-preview" alt="@Variant.Name"/></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<a href="/krvVariants" class="btn btn-success">Tilbage</a>
|
||||
</div>
|
||||
</div>
|
|
@ -1,35 +0,0 @@
|
|||
using Microsoft.AspNetCore.Components;
|
||||
using Wonky.Client.HttpInterceptors;
|
||||
using Wonky.Client.HttpRepository;
|
||||
using Wonky.Entity.DTO;
|
||||
|
||||
namespace Wonky.Client.Pages.KrvAdmin;
|
||||
|
||||
public partial class KrvVariantView : IDisposable
|
||||
{
|
||||
private KrvVariantDto Variant { get; set; } = new ();
|
||||
|
||||
[Inject]
|
||||
public IKrvVariantHttpRepository VariantRepo { get; set; }
|
||||
|
||||
[Inject]
|
||||
public HttpInterceptorService Interceptor { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string VariantId { get; set; } = "";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Interceptor.RegisterEvent();
|
||||
Interceptor.RegisterBeforeSendEvent();
|
||||
Variant = await VariantRepo.GetVariant(VariantId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Interceptor.DisposeEvent();
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
/* variant image preview */
|
||||
.image-name {
|
||||
margin-left: 10px;
|
||||
}
|
||||
.image-preview {
|
||||
width: auto;
|
||||
max-width: 200px;
|
||||
height: 100px;
|
||||
margin-top: 15px;
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
@page "/counter"
|
||||
@using Client.V1.Components
|
||||
@using System.Security.Claims
|
||||
|
||||
<AuthorizeView>
|
||||
<Authorized>
|
||||
Bruger @context.User.FindFirst(ClaimTypes.Name).Value har tilladelse
|
||||
</Authorized>
|
||||
<NotAuthorized>
|
||||
Bruger har <strong>IKKE</strong> tilladelse
|
||||
</NotAuthorized>
|
||||
</AuthorizeView>
|
||||
<CounterPrint CurrentCount="currentCount" Title="Counter" />
|
||||
|
||||
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
|
||||
|
||||
@code {
|
||||
private int currentCount = 0;
|
||||
|
||||
[CascadingParameter]
|
||||
public Task<AuthenticationState> AuthState { get; set; }
|
||||
|
||||
private async void IncrementCount()
|
||||
{
|
||||
var authState = await AuthState;
|
||||
var user = authState.User;
|
||||
if(user.Identity.IsAuthenticated)
|
||||
{
|
||||
currentCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentCount--;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
@page "/js-interop"
|
||||
<h3>JsInterop in Blazor</h3>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
Calling JS returning void
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<button type="button" class="btn btn-info" @onclick="ShowAlertWindow">Show Alert Window</button>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
Calling JS returning void (with object)
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<button type="button" class="btn btn-info" @onclick="ShowAlertObject">Show Alert Object</button>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
Calling JS returning a result
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button type="button" class="btn btn-info" @onclick="RegisterEmail">Registrer Email</button>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
@_registrationResult
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
Calling JS returning an object
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button type="button" class="btn btn-info" @onclick="ExtractEmailDetails">Email Details</button>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
@_messageDetails
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
Passing HTML Reference to JS Function
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<input type="text" @ref="_elRef" class="form-control"/>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<button type="button" class="btn btn-info" @onclick="FocusAndStyleElement">Focus</button>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
Passing Input Component to JS Function
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<EditForm Model="_emailDetails">
|
||||
<input id="dummyInputComponent" class="form-control"
|
||||
@bind-value="_emailDetails.Name"/>
|
||||
</EditForm>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<button type="button" class="btn btn-info" @onclick="FocusAndStyleInputComponent">Focus</button>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<div class="col alert alert-danger">
|
||||
@_errorMessage
|
||||
</div>
|
||||
</div>
|
|
@ -1,85 +0,0 @@
|
|||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
|
||||
namespace Wonky.Client.Pages.Testing;
|
||||
|
||||
public partial class JsInterop
|
||||
{
|
||||
[Inject] public IJSRuntime JsRuntime { get; set; }
|
||||
private IJSObjectReference _jsModule;
|
||||
private string _registrationResult;
|
||||
private string _messageDetails;
|
||||
private ElementReference _elRef;
|
||||
private EmailDetails _emailDetails = new EmailDetails();
|
||||
private string _errorMessage = "";
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
_jsModule = await JsRuntime
|
||||
.InvokeAsync<IJSObjectReference>("import", "./scripts/jsExample.js");
|
||||
await FocusAndStyleElement();
|
||||
await ThrowError();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private async Task ShowAlertWindow()
|
||||
{
|
||||
// global namespace
|
||||
await _jsModule.InvokeVoidAsync("showAlert", "JS function call called from .NET");
|
||||
}
|
||||
|
||||
private async Task ShowAlertObject()
|
||||
{
|
||||
// global namespace
|
||||
await _jsModule
|
||||
.InvokeVoidAsync("showAlertObject", new { Name = "Frede", Age = "61"});
|
||||
}
|
||||
|
||||
private async Task RegisterEmail()
|
||||
{
|
||||
_registrationResult = await _jsModule
|
||||
.InvokeAsync<string>("emailRegistration", "Angiv email adresse");
|
||||
}
|
||||
|
||||
private async Task ExtractEmailDetails()
|
||||
{
|
||||
var emailDetails = await _jsModule.InvokeAsync<EmailDetails>("splitEmail", "Angiv email");
|
||||
_messageDetails = emailDetails != null
|
||||
? $"Navn: {emailDetails.Name}, Domain: {emailDetails.Domain}, TLD: {emailDetails.Tld}"
|
||||
: "Email ikke angivet";
|
||||
}
|
||||
|
||||
private async Task FocusAndStyleElement()
|
||||
{
|
||||
await _jsModule.InvokeVoidAsync("focusAndStyleElement", _elRef);
|
||||
}
|
||||
private async Task FocusAndStyleInputComponent()
|
||||
{
|
||||
await _jsModule.InvokeVoidAsync("focusAndStyleInputComponent", "dummyInputComponent");
|
||||
}
|
||||
|
||||
private async Task ThrowError()
|
||||
{
|
||||
try
|
||||
{
|
||||
await _jsModule.InvokeVoidAsync("throwError");
|
||||
}
|
||||
catch (JSException ex)
|
||||
{
|
||||
_errorMessage = ex.Message;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class EmailDetails
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Domain { get; set; }
|
||||
public string Tld { get; set; }
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
@page "/js-interop-2"
|
||||
<h3>JsInterop2</h3>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
Calling C# static method from JS
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button type="button" class="btn btn-info"
|
||||
onclick="jsFunctions.calculateSquareRoot()">Kvadrat rod</button>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<span id="string-result" class="form-text"></span>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
Calling C# static method from JS
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button type="button" class="btn btn-info"
|
||||
onclick="jsFunctions.calculateSquareRootJustResult()">Kvadrat rod custom identifier</button>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<span id="result" class="form-text"></span>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
Calling instance method from JS
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button type="button" class="btn btn-info"
|
||||
@onclick="SendDotNetInstanceToJS">Show Mouse Coordinates</button>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div id="coords" class="coords">
|
||||
@_coordinates.X - @_coordinates.Y
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -1,43 +0,0 @@
|
|||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
|
||||
namespace Wonky.Client.Pages.Testing;
|
||||
|
||||
public partial class JsInterop2
|
||||
{
|
||||
private MouseCoordinates _coordinates = new MouseCoordinates();
|
||||
|
||||
[Inject] public IJSRuntime JsRuntime { get; set; }
|
||||
|
||||
[JSInvokable]
|
||||
public static string CalculateSquareRoot(int number)
|
||||
{
|
||||
var result = Math.Sqrt(number);
|
||||
return $"result from {number} is {result}";
|
||||
}
|
||||
|
||||
[JSInvokable("CalculateSquareRootJustResult")]
|
||||
public static string CalculateSquareRoot(int number, bool justResult)
|
||||
{
|
||||
var result = Math.Sqrt(number);
|
||||
return !justResult ? $"result from {number} is {result}" : result.ToString();
|
||||
}
|
||||
|
||||
private async Task SendDotNetInstanceToJS()
|
||||
{
|
||||
var dotNetObjRef = DotNetObjectReference.Create(this);
|
||||
await JsRuntime.InvokeVoidAsync("jsFunctions.registerMouseCoordinatesHandler", dotNetObjRef);
|
||||
}
|
||||
|
||||
[JSInvokable]
|
||||
public void ShowCoordinates(MouseCoordinates coordinates)
|
||||
{
|
||||
_coordinates = coordinates;
|
||||
StateHasChanged();
|
||||
}
|
||||
public class MouseCoordinates
|
||||
{
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
.coords {
|
||||
height: 200px;
|
||||
width: 400px;
|
||||
background-color: #d6d8d6;
|
||||
text-align: center;
|
||||
font-size: 20px;
|
||||
}
|
|
@ -25,6 +25,7 @@ using Wonky.Client.HttpInterceptors;
|
|||
using Wonky.Client.HttpRepository;
|
||||
using Wonky.Client.Services;
|
||||
using Wonky.Entity.Configuration;
|
||||
using Wonky.Virk.Services;
|
||||
|
||||
var builder = WebAssemblyHostBuilder.CreateDefault(args);
|
||||
builder.RootComponents.Add<App>("#app");
|
||||
|
|
|
@ -1,75 +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 Microsoft.AspNetCore.WebUtilities;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Wonky.Entity.Configuration;
|
||||
using Wonky.Entity.Models;
|
||||
using Wonky.Entity.Requests;
|
||||
|
||||
namespace Wonky.Client.Services;
|
||||
|
||||
public class VirkRegistryService
|
||||
{
|
||||
private readonly JsonSerializerOptions _options = new() { PropertyNameCaseInsensitive = true };
|
||||
private readonly HttpClient _client;
|
||||
private readonly IOptions<ApiConfig> _apiConfig;
|
||||
private readonly List<VirkRegInfo> _noData = new() { new VirkRegInfo { Name = "INGEN DATA" } };
|
||||
|
||||
public VirkRegistryService(HttpClient client, IOptions<ApiConfig> apiConfig)
|
||||
{
|
||||
_client = client;
|
||||
_apiConfig = apiConfig;
|
||||
}
|
||||
|
||||
public async Task<List<VirkRegInfo>> QueryVirkRegistry(VirkParams @params)
|
||||
{
|
||||
if(!ValidateCvrQuery(@params))
|
||||
{
|
||||
throw new ArgumentException("CvrQuery does not validate");
|
||||
}
|
||||
var queryString = new Dictionary<string, string>
|
||||
{
|
||||
["vatNumber"] = @params.VatNumber,
|
||||
["streetName"] = @params.StreetName,
|
||||
["houseNumber"] = @params.HouseNumber,
|
||||
["zipCode"] = @params.ZipCode
|
||||
};
|
||||
var endpoint = QueryHelpers.AddQueryString(_apiConfig.Value.CvrLookup , queryString);
|
||||
var response = await _client.GetAsync(endpoint);
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
|
||||
var jsonResult = JsonSerializer.Deserialize<List<VirkRegInfo>>(content, _options);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(content) || !jsonResult.Any()) return _noData;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(@params.VatNumber)) return jsonResult;
|
||||
|
||||
var result = jsonResult
|
||||
.Where(x => x.States[^1].State == "NORMAL")
|
||||
.OrderBy(x => x.Name).ToList();
|
||||
|
||||
return result.Count == 0 ? _noData : result;
|
||||
}
|
||||
|
||||
private static bool ValidateCvrQuery(VirkParams @params)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(@params.VatNumber))
|
||||
return true;
|
||||
return !string.IsNullOrWhiteSpace(@params.HouseNumber) && !string.IsNullOrWhiteSpace(@params.StreetName) &&
|
||||
!string.IsNullOrWhiteSpace(@params.ZipCode);
|
||||
}
|
||||
}
|
|
@ -24,5 +24,23 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Wonky.Entity\Wonky.Entity\Wonky.Entity.csproj" />
|
||||
<ProjectReference Include="..\..\Wonky.Virk\Wonky.Virk\Wonky.Virk.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<_ContentIncludedByDefault Remove="Pages\KrvAdmin\KrvProduct.razor" />
|
||||
<_ContentIncludedByDefault Remove="Pages\KrvAdmin\KrvProductList.razor" />
|
||||
<_ContentIncludedByDefault Remove="Pages\KrvAdmin\KrvProductUpdate.razor" />
|
||||
<_ContentIncludedByDefault Remove="Pages\KrvAdmin\KrvVariantCreate.razor" />
|
||||
<_ContentIncludedByDefault Remove="Pages\KrvAdmin\KrvVariantList.razor" />
|
||||
<_ContentIncludedByDefault Remove="Pages\KrvAdmin\KrvVariantUpdate.razor" />
|
||||
<_ContentIncludedByDefault Remove="Pages\KrvAdmin\KrvVariantView.razor" />
|
||||
<_ContentIncludedByDefault Remove="Pages\Testing\Counter.razor" />
|
||||
<_ContentIncludedByDefault Remove="Pages\Testing\JsInterop.razor" />
|
||||
<_ContentIncludedByDefault Remove="Pages\Testing\JsInterop2.razor" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="wwwroot\scripts" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -12,4 +12,6 @@
|
|||
@using Microsoft.AspNetCore.Components.WebAssembly.Hosting
|
||||
@using Microsoft.AspNetCore.Components.Authorization
|
||||
@using DnetIndexedDb
|
||||
@using Wonky.Entity
|
||||
@using Wonky.Virk
|
||||
|
||||
|
|
3
Wonky.Client/wwwroot/appsettings.json
Normal file
3
Wonky.Client/wwwroot/appsettings.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
|
||||
}
|
|
@ -22,6 +22,10 @@ a, .btn-link {
|
|||
border-color: #1861ac;
|
||||
}
|
||||
|
||||
.card {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding-top: 1.1rem;
|
||||
}
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
export function showAlert(message) {
|
||||
alert(message);
|
||||
}
|
||||
|
||||
export function showAlertObject(person) {
|
||||
const message = 'Navn: ' + person.name + " Alder: " + person.age;
|
||||
alert(message)
|
||||
}
|
||||
|
||||
export function emailRegistration(message) {
|
||||
const result = prompt(message)
|
||||
if (!result)
|
||||
return 'Angiv en email';
|
||||
|
||||
return 'Tak! Din email: ' + result + ' er registreret.';
|
||||
}
|
||||
|
||||
export function splitEmail(message) {
|
||||
const email = prompt(message);
|
||||
if (!email)
|
||||
return null;
|
||||
|
||||
const firstPart = email.substring(0, email.indexOf("@"));
|
||||
const lastPart = email.substring(email.indexOf("@") + 1);
|
||||
return {
|
||||
'name': firstPart,
|
||||
'domain': lastPart.split(".")[0],
|
||||
'tld': lastPart.split(".")[1]
|
||||
}
|
||||
}
|
||||
|
||||
export function focusAndStyleElement(element) {
|
||||
element.style.color = "red";
|
||||
element.focus();
|
||||
}
|
||||
|
||||
export function focusAndStyleInputComponent(id) {
|
||||
const element = document.getElementById(id);
|
||||
|
||||
element.style.color = "red";
|
||||
element.focus();
|
||||
}
|
||||
|
||||
export function throwError() {
|
||||
throw Error("Testing error message from JS file.")
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
var jsFunctions = {};
|
||||
|
||||
jsFunctions.calculateSquareRoot = function () {
|
||||
const number = prompt("Giv mig et tal");
|
||||
|
||||
DotNet.invokeMethodAsync("Client.V1", "CalculateSquareRoot", parseInt(number))
|
||||
.then(result => {
|
||||
var el = document.getElementById("string-result");
|
||||
el.innerHTML = result;
|
||||
})
|
||||
}
|
||||
|
||||
jsFunctions.calculateSquareRootJustResult = function () {
|
||||
const number = prompt("Giv mig et tal");
|
||||
|
||||
DotNet.invokeMethodAsync("Client.V1", "CalculateSquareRootJustResult", parseInt(number), true)
|
||||
.then(result => {
|
||||
var el = document.getElementById("result");
|
||||
el.innerHTML = result;
|
||||
})
|
||||
}
|
||||
|
||||
jsFunctions.registerMouseCoordinatesHandler = function (dotNetObjRef) {
|
||||
function mouseCoordinatesHandler() {
|
||||
dotNetObjRef.invokeMethodAsync("ShowCoordinates", {
|
||||
x: window.event.screenX,
|
||||
y: window.event.screenY,
|
||||
});
|
||||
}
|
||||
mouseCoordinatesHandler();
|
||||
document.getElementById("coords").onmousemove = mouseCoordinatesHandler();
|
||||
}
|
Loading…
Reference in a new issue