From 690712a7ca404b24294adb2dd34c1008f5bc1bd4 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt <22748698+fhdk@users.noreply.github.com> Date: Mon, 14 Mar 2022 17:59:22 +0100 Subject: [PATCH] more project files - working on cart functionality --- .gitignore | 52 +----- .idea/.idea.Wonky.Client/.idea/.gitignore | 2 +- README.md | 3 +- Wonky.Client.sln | 65 ++++---- Wonky.Client/App.razor | 39 ++--- Wonky.Client/AppId.cs | 3 +- .../AuthProviders/AuthStateProvider.cs | 4 + Wonky.Client/Components/AuthLinks.razor.css | 4 + .../Components/CompanySearchColumn.razor | 25 +++ ....razor.cs => CompanySearchColumn.razor.cs} | 7 +- .../Components/CompanySearchField.razor.css | 3 - Wonky.Client/Components/CompanySort.razor | 25 --- ...rchField.razor => CompanySortColumn.razor} | 14 +- ...rt.razor.cs => CompanySortColumn.razor.cs} | 7 +- Wonky.Client/Components/CompanyTable.razor | 2 + Wonky.Client/Components/CounterPrint.razor | 43 ----- Wonky.Client/Components/Home.razor | 7 +- Wonky.Client/Components/Home.razor.cs | 4 +- ...roupFilter.razor => ItemGroupFilter.razor} | 15 +- ...lter.razor.cs => ItemGroupFilter.razor.cs} | 11 +- ...archField.razor => ItemSearchColumn.razor} | 17 +- ...eld.razor.cs => ItemSearchColumn.razor.cs} | 14 +- ...lesItemSort.razor => ItemSortColumn.razor} | 12 +- ...mSort.razor.cs => ItemSortColumn.razor.cs} | 13 +- .../{SalesItemTable.razor => ItemTable.razor} | 4 +- ...sItemTable.razor.cs => ItemTable.razor.cs} | 2 +- ...temTable.razor.css => ItemTable.razor.css} | 0 Wonky.Client/Components/RegInfoCompany.razor | 8 +- .../Components/RegInfoCompany.razor.cs | 7 +- .../Components/RegLookupAddress.razor | 2 + .../Components/RegLookupAddress.razor.cs | 1 - .../Components/RegLookupVatNo.razor.cs | 1 - .../Components/RegStateVatNumber.razor.cs | 7 +- .../Components/SalesItemGroupFilter.razor.css | 3 - .../Components/SalesItemSearchField.razor.css | 3 - Wonky.Client/Components/SearchPhrase.razor | 9 +- Wonky.Client/Components/SearchPhrase.razor.cs | 7 +- .../Components/SearchPhrase.razor.css | 3 - Wonky.Client/Features/JwtParser.cs | 56 ------- Wonky.Client/Features/PagingResponse.cs | 1 + Wonky.Client/Helpers/Utils.cs | 2 + .../HttpInterceptorService.cs | 6 +- .../HttpInterceptors/HttpResponseException.cs | 1 + .../HttpRepository/CompanyHttpRepository.cs | 15 +- .../HttpRepository/ICompanyHttpRepository.cs | 1 + .../IKrvProductHttpRepository.cs | 29 ---- .../IKrvVariantHttpRepository.cs | 29 ---- .../ISalesItemHttpRepository.cs | 1 + .../KrvProductHttpRepository.cs | 108 ------------- .../KrvVariantHttpRepository.cs | 112 ------------- .../HttpRepository/SalesItemHttpRepository.cs | 14 +- Wonky.Client/Models/PurchaseOrder.cs | 1 + Wonky.Client/Models/Quote.cs | 2 + Wonky.Client/Pages/About.razor | 12 +- Wonky.Client/Pages/ActivityList.razor | 9 -- Wonky.Client/Pages/ActivityList.razor.cs | 10 -- Wonky.Client/Pages/ActivityList.razor.css | 0 Wonky.Client/Pages/CompanyCreate.razor | 1 - Wonky.Client/Pages/CompanyCreate.razor.cs | 9 +- Wonky.Client/Pages/CompanyList.razor | 11 +- Wonky.Client/Pages/CompanyList.razor.cs | 8 +- Wonky.Client/Pages/CompanyUpdate.razor | 1 + Wonky.Client/Pages/CompanyUpdate.razor.cs | 7 +- Wonky.Client/Pages/CompanyView.razor | 3 +- Wonky.Client/Pages/CompanyView.razor.cs | 4 +- Wonky.Client/Pages/Index.razor | 3 +- Wonky.Client/Pages/Login.razor | 8 +- Wonky.Client/Pages/Login.razor.cs | 8 +- Wonky.Client/Pages/Logout.razor.cs | 3 +- Wonky.Client/Pages/ProductCreate.razor | 54 ------- Wonky.Client/Pages/ProductCreate.razor.cs | 87 ---------- Wonky.Client/Pages/PurchaseOrderCreate.razor | 3 +- .../Pages/PurchaseOrderCreate.razor.cs | 7 +- Wonky.Client/Pages/Registration.razor | 66 -------- Wonky.Client/Pages/Registration.razor.cs | 54 ------- Wonky.Client/Pages/SalesItemCatalog.razor | 20 +-- Wonky.Client/Pages/SalesItemCatalog.razor.cs | 32 ++-- Wonky.Client/Pages/SalesItemView.razor | 6 +- Wonky.Client/Pages/SalesItemView.razor.cs | 4 +- Wonky.Client/Pages/ShoppingCart.razor | 153 ++++++++++++++++++ Wonky.Client/Pages/VirkDataLookup.razor | 38 ----- Wonky.Client/Program.cs | 5 +- Wonky.Client/Properties/launchSettings.json | 60 +++---- .../Services/AuthenticationService.cs | 2 +- .../Services/IAuthenticationService.cs | 1 + Wonky.Client/Services/RefreshTokenService.cs | 3 + Wonky.Client/Services/VirkRegistryService.cs | 75 +++++++++ ...Provider.razor => CartStateProvider.razor} | 4 +- ...er.razor.cs => CartStateProvider.razor.cs} | 32 ++-- Wonky.Client/Shared/MainLayout.razor | 1 + Wonky.Client/Shared/MainLayout.razor.css | 9 +- Wonky.Client/Shared/NavMenu.razor | 45 +----- .../Shared/ProductImageUpload.razor.cs | 62 ------- .../Shared/ProductImageUpload.razor.css | 8 - .../Shared/VariantImageUpload.razor.cs | 64 -------- .../Shared/VariantImageUpload.razor.css | 8 - Wonky.Client/Wonky.Client.csproj | 95 +++++++---- Wonky.Client/_Imports.razor | 4 +- Wonky.Client/wwwroot/appsettings.json | 34 ++-- Wonky.Client/wwwroot/css/app.css | 4 - Wonky.Client/wwwroot/index.html | 10 +- Wonky.Entity/Configuration/ApiConfig.cs | 29 ++++ Wonky.Entity/DTO/AuthResponseDto.cs | 39 +++++ Wonky.Entity/DTO/CompanyDto.cs | 41 +++++ .../DTO/CreateCompanyResponse.cs | 9 +- Wonky.Entity/DTO/CrmActivity.cs | 34 ++++ .../DTO/CrmActivityLine.cs | 26 ++- Wonky.Entity/DTO/KrvProductDto.cs | 30 ++++ Wonky.Entity/DTO/KrvVariantDto.cs | 38 +++++ Wonky.Entity/DTO/RefreshTokenDto.cs | 21 +++ Wonky.Entity/DTO/ResponseDto.cs | 24 +++ Wonky.Entity/DTO/SalesItemDto.cs | 29 ++++ .../DTO/SalesRateDto.cs | 12 +- Wonky.Entity/DTO/UpdateCompanyDto.cs | 33 ++++ .../DTO/UploadResponse.cs | 11 +- Wonky.Entity/DTO/UserAuthenticationDto.cs | 27 ++++ Wonky.Entity/DTO/UserInfoDto.cs | 35 ++++ Wonky.Entity/DTO/UserRegistrationDto.cs | 38 +++++ Wonky.Entity/Models/Cart.cs | 38 +++++ .../Models/TimeFrame.cs | 12 +- .../Models/VirkRegInfo.cs | 21 ++- Wonky.Entity/Models/VirkState.cs | 22 +++ Wonky.Entity/Requests/MetaData.cs | 25 +++ Wonky.Entity/Requests/PagingParams.cs | 32 ++++ Wonky.Entity/Requests/VirkParams.cs | 23 +++ Wonky.Entity/Wonky.Entity.csproj | 13 ++ global.json | 7 + 127 files changed, 1304 insertions(+), 1338 deletions(-) create mode 100644 Wonky.Client/Components/AuthLinks.razor.css create mode 100644 Wonky.Client/Components/CompanySearchColumn.razor rename Wonky.Client/Components/{CompanySearchField.razor.cs => CompanySearchColumn.razor.cs} (84%) delete mode 100644 Wonky.Client/Components/CompanySearchField.razor.css delete mode 100644 Wonky.Client/Components/CompanySort.razor rename Wonky.Client/Components/{CompanySearchField.razor => CompanySortColumn.razor} (71%) rename Wonky.Client/Components/{CompanySort.razor.cs => CompanySortColumn.razor.cs} (84%) delete mode 100644 Wonky.Client/Components/CounterPrint.razor rename Wonky.Client/Components/{SalesItemGroupFilter.razor => ItemGroupFilter.razor} (68%) rename Wonky.Client/Components/{SalesItemGroupFilter.razor.cs => ItemGroupFilter.razor.cs} (79%) rename Wonky.Client/Components/{SalesItemSearchField.razor => ItemSearchColumn.razor} (68%) rename Wonky.Client/Components/{SalesItemSearchField.razor.cs => ItemSearchColumn.razor.cs} (71%) rename Wonky.Client/Components/{SalesItemSort.razor => ItemSortColumn.razor} (73%) rename Wonky.Client/Components/{SalesItemSort.razor.cs => ItemSortColumn.razor.cs} (73%) rename Wonky.Client/Components/{SalesItemTable.razor => ItemTable.razor} (96%) rename Wonky.Client/Components/{SalesItemTable.razor.cs => ItemTable.razor.cs} (97%) rename Wonky.Client/Components/{SalesItemTable.razor.css => ItemTable.razor.css} (100%) delete mode 100644 Wonky.Client/Components/SalesItemGroupFilter.razor.css delete mode 100644 Wonky.Client/Components/SalesItemSearchField.razor.css delete mode 100644 Wonky.Client/Components/SearchPhrase.razor.css delete mode 100644 Wonky.Client/Features/JwtParser.cs delete mode 100644 Wonky.Client/HttpRepository/IKrvProductHttpRepository.cs delete mode 100644 Wonky.Client/HttpRepository/IKrvVariantHttpRepository.cs delete mode 100644 Wonky.Client/HttpRepository/KrvProductHttpRepository.cs delete mode 100644 Wonky.Client/HttpRepository/KrvVariantHttpRepository.cs delete mode 100644 Wonky.Client/Pages/ActivityList.razor delete mode 100644 Wonky.Client/Pages/ActivityList.razor.cs delete mode 100644 Wonky.Client/Pages/ActivityList.razor.css delete mode 100644 Wonky.Client/Pages/ProductCreate.razor delete mode 100644 Wonky.Client/Pages/ProductCreate.razor.cs delete mode 100644 Wonky.Client/Pages/Registration.razor delete mode 100644 Wonky.Client/Pages/Registration.razor.cs create mode 100644 Wonky.Client/Pages/ShoppingCart.razor delete mode 100644 Wonky.Client/Pages/VirkDataLookup.razor create mode 100644 Wonky.Client/Services/VirkRegistryService.cs rename Wonky.Client/Shared/{PoStateProvider.razor => CartStateProvider.razor} (95%) rename Wonky.Client/Shared/{PoStateProvider.razor.cs => CartStateProvider.razor.cs} (60%) delete mode 100644 Wonky.Client/Shared/ProductImageUpload.razor.cs delete mode 100644 Wonky.Client/Shared/ProductImageUpload.razor.css delete mode 100644 Wonky.Client/Shared/VariantImageUpload.razor.cs delete mode 100644 Wonky.Client/Shared/VariantImageUpload.razor.css create mode 100644 Wonky.Entity/Configuration/ApiConfig.cs create mode 100644 Wonky.Entity/DTO/AuthResponseDto.cs create mode 100644 Wonky.Entity/DTO/CompanyDto.cs rename Wonky.Client/Pages/CompanyInfo.razor => Wonky.Entity/DTO/CreateCompanyResponse.cs (92%) create mode 100644 Wonky.Entity/DTO/CrmActivity.cs rename Wonky.Client/Shared/VariantImageUpload.razor => Wonky.Entity/DTO/CrmActivityLine.cs (64%) create mode 100644 Wonky.Entity/DTO/KrvProductDto.cs create mode 100644 Wonky.Entity/DTO/KrvVariantDto.cs create mode 100644 Wonky.Entity/DTO/RefreshTokenDto.cs create mode 100644 Wonky.Entity/DTO/ResponseDto.cs create mode 100644 Wonky.Entity/DTO/SalesItemDto.cs rename Wonky.Client/Pages/CompanyActivity.razor => Wonky.Entity/DTO/SalesRateDto.cs (84%) create mode 100644 Wonky.Entity/DTO/UpdateCompanyDto.cs rename Wonky.Client/Pages/CompanyProducts.razor => Wonky.Entity/DTO/UploadResponse.cs (88%) create mode 100644 Wonky.Entity/DTO/UserAuthenticationDto.cs create mode 100644 Wonky.Entity/DTO/UserInfoDto.cs create mode 100644 Wonky.Entity/DTO/UserRegistrationDto.cs create mode 100644 Wonky.Entity/Models/Cart.cs rename Wonky.Client/Pages/CompanyKApv.razor => Wonky.Entity/Models/TimeFrame.cs (83%) rename Wonky.Client/Shared/ProductImageUpload.razor => Wonky.Entity/Models/VirkRegInfo.cs (64%) create mode 100644 Wonky.Entity/Models/VirkState.cs create mode 100644 Wonky.Entity/Requests/MetaData.cs create mode 100644 Wonky.Entity/Requests/PagingParams.cs create mode 100644 Wonky.Entity/Requests/VirkParams.cs create mode 100644 Wonky.Entity/Wonky.Entity.csproj create mode 100644 global.json diff --git a/.gitignore b/.gitignore index c567aa4b..68281069 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -*/**/appsettings.json +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 @@ -63,9 +63,6 @@ atlassian-ide-plugin.xml # Cursive Clojure plugin .idea/replstate.xml -# SonarLint plugin -.idea/sonarlint/ - # Crashlytics plugin (for Android Studio and IntelliJ) com_crashlytics_export_strings.xml crashlytics.properties @@ -82,7 +79,7 @@ fabric.properties ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. ## -## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore # User-specific files *.rsuser @@ -287,6 +284,9 @@ PublishScripts/ *.nuget.props *.nuget.targets +# Nuget personal access tokens and Credentials +nuget.config + # Microsoft Azure Build Output csx/ *.build.csdef @@ -375,17 +375,6 @@ node_modules/ # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) *.vbw -# Visual Studio 6 auto-generated project file (contains which files were open etc.) -*.vbp - -# Visual Studio 6 workspace and project file (working project files containing files to include in project) -*.dsw -*.dsp - -# Visual Studio 6 technical files -*.ncb -*.aps - # Visual Studio LightSwitch build output **/*.HTMLClient/GeneratedArtifacts **/*.DesktopClient/GeneratedArtifacts @@ -442,9 +431,6 @@ ASALocalRun/ # Local History for Visual Studio .localhistory/ -# Visual Studio History (VSHistory) files -.vshistory/ - # BeatPulse healthcheck temp database healthchecksdb @@ -476,32 +462,6 @@ FodyWeavers.xsd *.msp # JetBrains Rider +.idea/ *.sln.iml -# ---> VisualStudioCode -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -!.vscode/*.code-snippets - -# Local History for Visual Studio Code -.history/ - -# Built Visual Studio Code Extensions -*.vsix - -# ---> AL -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -*.code-workspace - -# Local History for Visual Studio Code -.history/ -*.app -.snapshots/* - diff --git a/.idea/.idea.Wonky.Client/.idea/.gitignore b/.idea/.idea.Wonky.Client/.idea/.gitignore index 00d2f20c..666a18a2 100644 --- a/.idea/.idea.Wonky.Client/.idea/.gitignore +++ b/.idea/.idea.Wonky.Client/.idea/.gitignore @@ -3,9 +3,9 @@ /workspace.xml # Rider ignored files /modules.xml +/contentModel.xml /projectSettingsUpdater.xml /.idea.Wonky.Client.iml -/contentModel.xml # Editor-based HTTP Client requests /httpRequests/ # Datasource local storage ignored files diff --git a/README.md b/README.md index 61ae4e05..6442ea03 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,2 @@ -# Wonky.Client +# Wonky Client -![](./Wonky.Client/wwwroot/wonky-logo.png) diff --git a/Wonky.Client.sln b/Wonky.Client.sln index e23480d7..d88202de 100644 --- a/Wonky.Client.sln +++ b/Wonky.Client.sln @@ -1,34 +1,31 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -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 - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A001767F-6CA1-428E-938A-EA491A778D3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {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 + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.32112.339 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wonky.Client", "Wonky.Client\Wonky.Client.csproj", "{6187227B-D451-4817-B535-743B14E3111D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wonky.Entity", "Wonky.Entity\Wonky.Entity.csproj", "{CF421FF4-0AE4-4B8A-997E-C2FD8DC9349F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {6187227B-D451-4817-B535-743B14E3111D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6187227B-D451-4817-B535-743B14E3111D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6187227B-D451-4817-B535-743B14E3111D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6187227B-D451-4817-B535-743B14E3111D}.Release|Any CPU.Build.0 = Release|Any CPU + {CF421FF4-0AE4-4B8A-997E-C2FD8DC9349F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CF421FF4-0AE4-4B8A-997E-C2FD8DC9349F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CF421FF4-0AE4-4B8A-997E-C2FD8DC9349F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CF421FF4-0AE4-4B8A-997E-C2FD8DC9349F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3FB8FD1A-6DA1-4063-816A-755FD5A93F8E} + EndGlobalSection +EndGlobal diff --git a/Wonky.Client/App.razor b/Wonky.Client/App.razor index 6e89a373..f0a0d3a0 100644 --- a/Wonky.Client/App.razor +++ b/Wonky.Client/App.razor @@ -1,5 +1,4 @@ -@using Wonky.Client.Shared -@* +@* // 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 Affero GNU General Public License as @@ -15,21 +14,23 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // *@ - - - - - - Checker autorisation ... - - - - - - - - - - - \ No newline at end of file + + + + + + Checker autorisation ... + + + + + + + + + + + + + diff --git a/Wonky.Client/AppId.cs b/Wonky.Client/AppId.cs index 0d73f44a..91b972b6 100644 --- a/Wonky.Client/AppId.cs +++ b/Wonky.Client/AppId.cs @@ -3,6 +3,7 @@ namespace Wonky.Client; public class AppId { public string Version { get; set; } = "0.2.1"; - public string Name { get; set; } = "Wonky Client"; + public string Name { get; set; } = "Inno Client"; + public bool IsBeta { get; set; } = false; } \ No newline at end of file diff --git a/Wonky.Client/AuthProviders/AuthStateProvider.cs b/Wonky.Client/AuthProviders/AuthStateProvider.cs index 68146fa7..485f8506 100644 --- a/Wonky.Client/AuthProviders/AuthStateProvider.cs +++ b/Wonky.Client/AuthProviders/AuthStateProvider.cs @@ -13,8 +13,12 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; using System.Net.Http.Headers; using System.Security.Claims; +using System.Threading.Tasks; using Blazored.LocalStorage; using Microsoft.AspNetCore.Components.Authorization; using Wonky.Entity.DTO; diff --git a/Wonky.Client/Components/AuthLinks.razor.css b/Wonky.Client/Components/AuthLinks.razor.css new file mode 100644 index 00000000..487b7ba3 --- /dev/null +++ b/Wonky.Client/Components/AuthLinks.razor.css @@ -0,0 +1,4 @@ + +a, a:link, a:hover, a:visited, a:active { + color: #ffaa00; +} \ No newline at end of file diff --git a/Wonky.Client/Components/CompanySearchColumn.razor b/Wonky.Client/Components/CompanySearchColumn.razor new file mode 100644 index 00000000..95a5c0b1 --- /dev/null +++ b/Wonky.Client/Components/CompanySearchColumn.razor @@ -0,0 +1,25 @@ +@* +// 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 Affero GNU 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 +// Affero GNU General Public License for more details. +// +// You should have received a copy of the Affero GNU General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + + + diff --git a/Wonky.Client/Components/CompanySearchField.razor.cs b/Wonky.Client/Components/CompanySearchColumn.razor.cs similarity index 84% rename from Wonky.Client/Components/CompanySearchField.razor.cs rename to Wonky.Client/Components/CompanySearchColumn.razor.cs index 5e364701..1e72b9fc 100644 --- a/Wonky.Client/Components/CompanySearchField.razor.cs +++ b/Wonky.Client/Components/CompanySearchColumn.razor.cs @@ -19,15 +19,14 @@ using Microsoft.AspNetCore.Components; namespace Wonky.Client.Components; -public partial class CompanySearchField +public partial class CompanySearchColumn { [Parameter] public EventCallback OnFilterChanged { get; set; } + private string SearchColumn { get; set; } = "name"; private async Task ApplyFilter(ChangeEventArgs eventArgs) { - if (eventArgs?.Value?.ToString() == "name") - return; - await OnFilterChanged.InvokeAsync(eventArgs?.Value?.ToString()); + await OnFilterChanged.InvokeAsync(SearchColumn); } } \ No newline at end of file diff --git a/Wonky.Client/Components/CompanySearchField.razor.css b/Wonky.Client/Components/CompanySearchField.razor.css deleted file mode 100644 index 4d7d555a..00000000 --- a/Wonky.Client/Components/CompanySearchField.razor.css +++ /dev/null @@ -1,3 +0,0 @@ -.search-field { - margin-bottom: 10px; -} \ No newline at end of file diff --git a/Wonky.Client/Components/CompanySort.razor b/Wonky.Client/Components/CompanySort.razor deleted file mode 100644 index 0f612d25..00000000 --- a/Wonky.Client/Components/CompanySort.razor +++ /dev/null @@ -1,25 +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 Affero GNU 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 -// Affero GNU General Public License for more details. -// -// You should have received a copy of the Affero GNU General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// -*@ - -
- -
\ No newline at end of file diff --git a/Wonky.Client/Components/CompanySearchField.razor b/Wonky.Client/Components/CompanySortColumn.razor similarity index 71% rename from Wonky.Client/Components/CompanySearchField.razor rename to Wonky.Client/Components/CompanySortColumn.razor index 8882835c..4ce52495 100644 --- a/Wonky.Client/Components/CompanySearchField.razor +++ b/Wonky.Client/Components/CompanySortColumn.razor @@ -15,11 +15,9 @@ // *@ -
- -
+ + diff --git a/Wonky.Client/Components/CompanySort.razor.cs b/Wonky.Client/Components/CompanySortColumn.razor.cs similarity index 84% rename from Wonky.Client/Components/CompanySort.razor.cs rename to Wonky.Client/Components/CompanySortColumn.razor.cs index 410179ef..a0c749ae 100644 --- a/Wonky.Client/Components/CompanySort.razor.cs +++ b/Wonky.Client/Components/CompanySortColumn.razor.cs @@ -19,16 +19,15 @@ using Microsoft.AspNetCore.Components; namespace Wonky.Client.Components { - public partial class CompanySort + public partial class CompanySortColumn { [Parameter] public EventCallback OnSortChanged { get; set; } + private string SortColumn { get; set; } = "name"; private async Task ApplySort(ChangeEventArgs eventArgs) { - if (eventArgs?.Value?.ToString() == "-1") - return; - await OnSortChanged.InvokeAsync(eventArgs?.Value?.ToString()); + await OnSortChanged.InvokeAsync(SortColumn); } } } diff --git a/Wonky.Client/Components/CompanyTable.razor b/Wonky.Client/Components/CompanyTable.razor index 61af00b0..c9b938f0 100644 --- a/Wonky.Client/Components/CompanyTable.razor +++ b/Wonky.Client/Components/CompanyTable.razor @@ -14,6 +14,8 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // *@ + +@using Wonky.Client.Components; @if (Companies.Any()) { diff --git a/Wonky.Client/Components/CounterPrint.razor b/Wonky.Client/Components/CounterPrint.razor deleted file mode 100644 index b1ce1f12..00000000 --- a/Wonky.Client/Components/CounterPrint.razor +++ /dev/null @@ -1,43 +0,0 @@ -@using Microsoft.Extensions.Logging -@implements IDisposable - -

@Title

- -

Current count: @CurrentCount

- -@code { - - [Parameter] public string Title { get; set; } - - [Parameter] public int CurrentCount { get; set; } - - [Inject] public ILogger Logger { get; set; } - - protected override void OnInitialized() - { - Logger.Log(LogLevel.Information,$"OnInitialized => Title: {Title}, CurrentCount: {CurrentCount}"); - } - - protected override void OnParametersSet() - { - Logger.Log(LogLevel.Information,$"OnParameterSet => Title: {Title}, CurrentCount: {CurrentCount}"); - } - - protected override void OnAfterRender(bool firstRender) - { - if (firstRender) - { - Logger.Log(LogLevel.Information,"This is the first render of the component"); - } - } - - protected override bool ShouldRender() - { - return true; - } - - public void Dispose() - { - Logger.Log(LogLevel.Information,"Component removed from the parnet's render tree."); - } -} diff --git a/Wonky.Client/Components/Home.razor b/Wonky.Client/Components/Home.razor index 95f432cc..8f5c980d 100644 --- a/Wonky.Client/Components/Home.razor +++ b/Wonky.Client/Components/Home.razor @@ -15,5 +15,8 @@ // *@ -Forside -

@Title

\ No newline at end of file +Innotec + +
+ Wonky Logo +
\ No newline at end of file diff --git a/Wonky.Client/Components/Home.razor.cs b/Wonky.Client/Components/Home.razor.cs index 1d9b936b..c54bcfbb 100644 --- a/Wonky.Client/Components/Home.razor.cs +++ b/Wonky.Client/Components/Home.razor.cs @@ -20,8 +20,6 @@ namespace Wonky.Client.Components { public partial class Home { - [Parameter] public string Title { get; set; } = "Hej"; - - [Parameter] public RenderFragment? LoginContent { get; set; } + [Parameter] public RenderFragment? LoginContent { get; set; } } } diff --git a/Wonky.Client/Components/SalesItemGroupFilter.razor b/Wonky.Client/Components/ItemGroupFilter.razor similarity index 68% rename from Wonky.Client/Components/SalesItemGroupFilter.razor rename to Wonky.Client/Components/ItemGroupFilter.razor index 035beb6e..c1cbf34f 100644 --- a/Wonky.Client/Components/SalesItemGroupFilter.razor +++ b/Wonky.Client/Components/ItemGroupFilter.razor @@ -15,14 +15,15 @@ // *@ -
- + + + - + -
\ No newline at end of file + \ No newline at end of file diff --git a/Wonky.Client/Components/SalesItemGroupFilter.razor.cs b/Wonky.Client/Components/ItemGroupFilter.razor.cs similarity index 79% rename from Wonky.Client/Components/SalesItemGroupFilter.razor.cs rename to Wonky.Client/Components/ItemGroupFilter.razor.cs index 9598a1e6..99392f5e 100644 --- a/Wonky.Client/Components/SalesItemGroupFilter.razor.cs +++ b/Wonky.Client/Components/ItemGroupFilter.razor.cs @@ -13,18 +13,19 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // +using System.Text.RegularExpressions; using Microsoft.AspNetCore.Components; namespace Wonky.Client.Components; -public partial class SalesItemGroupFilter +public partial class ItemGroupFilter { [Parameter] public EventCallback OnGroupFilterChanged { get; set; } - + private string GroupFilter { get; set; } = "all"; private async Task ApplyGroupFilter(ChangeEventArgs eventArgs) { - if (eventArgs?.Value?.ToString() == "-1") - return; - await OnGroupFilterChanged.InvokeAsync(eventArgs?.Value?.ToString()); + if (GroupFilter == "all") + GroupFilter = ""; + await OnGroupFilterChanged.InvokeAsync(GroupFilter); } } \ No newline at end of file diff --git a/Wonky.Client/Components/SalesItemSearchField.razor b/Wonky.Client/Components/ItemSearchColumn.razor similarity index 68% rename from Wonky.Client/Components/SalesItemSearchField.razor rename to Wonky.Client/Components/ItemSearchColumn.razor index 14315efc..b125fe20 100644 --- a/Wonky.Client/Components/SalesItemSearchField.razor +++ b/Wonky.Client/Components/ItemSearchColumn.razor @@ -15,11 +15,12 @@ // *@ -
- -
+ + diff --git a/Wonky.Client/Components/SalesItemSearchField.razor.cs b/Wonky.Client/Components/ItemSearchColumn.razor.cs similarity index 71% rename from Wonky.Client/Components/SalesItemSearchField.razor.cs rename to Wonky.Client/Components/ItemSearchColumn.razor.cs index 520f854d..3ec87ea5 100644 --- a/Wonky.Client/Components/SalesItemSearchField.razor.cs +++ b/Wonky.Client/Components/ItemSearchColumn.razor.cs @@ -17,14 +17,12 @@ using Microsoft.AspNetCore.Components; namespace Wonky.Client.Components; -public partial class SalesItemSearchField +public partial class ItemSearchColumn { - [Parameter] public EventCallback OnSearchFieldChanged { get; set; } - - private async Task ApplySearchField(ChangeEventArgs eventArgs) + [Parameter] public EventCallback OnSearchColumnChanged { get; set; } + private string SearchColumn { get; set; } = "name"; + private async Task ApplySearchColumn(ChangeEventArgs eventArgs) { - if (eventArgs?.Value?.ToString() == "-1") - return; - await OnSearchFieldChanged.InvokeAsync(eventArgs?.Value?.ToString()); - } + await OnSearchColumnChanged.InvokeAsync(SearchColumn); + } } \ No newline at end of file diff --git a/Wonky.Client/Components/SalesItemSort.razor b/Wonky.Client/Components/ItemSortColumn.razor similarity index 73% rename from Wonky.Client/Components/SalesItemSort.razor rename to Wonky.Client/Components/ItemSortColumn.razor index 6ef35701..de1274b2 100644 --- a/Wonky.Client/Components/SalesItemSort.razor +++ b/Wonky.Client/Components/ItemSortColumn.razor @@ -15,10 +15,8 @@ // *@ -
- -
\ No newline at end of file + + diff --git a/Wonky.Client/Components/SalesItemSort.razor.cs b/Wonky.Client/Components/ItemSortColumn.razor.cs similarity index 73% rename from Wonky.Client/Components/SalesItemSort.razor.cs rename to Wonky.Client/Components/ItemSortColumn.razor.cs index 0458386a..d548c4ed 100644 --- a/Wonky.Client/Components/SalesItemSort.razor.cs +++ b/Wonky.Client/Components/ItemSortColumn.razor.cs @@ -17,15 +17,14 @@ using Microsoft.AspNetCore.Components; namespace Wonky.Client.Components; -public partial class SalesItemSort +public partial class ItemSortColumn { [Parameter] - public EventCallback OnSortFieldChanged { get; set; } + public EventCallback OnSortColumnChanged { get; set; } - private async Task ApplySort(ChangeEventArgs eventArgs) + private string SortColumn { get; set; } = "name"; + private async Task ApplySortColumn(ChangeEventArgs eventArgs) { - if (eventArgs?.Value?.ToString() == "-1") - return; - await OnSortFieldChanged.InvokeAsync(eventArgs?.Value?.ToString()); - } + await OnSortColumnChanged.InvokeAsync(SortColumn); + } } \ No newline at end of file diff --git a/Wonky.Client/Components/SalesItemTable.razor b/Wonky.Client/Components/ItemTable.razor similarity index 96% rename from Wonky.Client/Components/SalesItemTable.razor rename to Wonky.Client/Components/ItemTable.razor index 0f200e35..5a11cc93 100644 --- a/Wonky.Client/Components/SalesItemTable.razor +++ b/Wonky.Client/Components/ItemTable.razor @@ -30,10 +30,10 @@ { - @salesItem.ItemName + @salesItem.Name - @salesItem.ItemNumber + @salesItem.Sku
    diff --git a/Wonky.Client/Components/SalesItemTable.razor.cs b/Wonky.Client/Components/ItemTable.razor.cs similarity index 97% rename from Wonky.Client/Components/SalesItemTable.razor.cs rename to Wonky.Client/Components/ItemTable.razor.cs index 5bd14f65..3df0822c 100644 --- a/Wonky.Client/Components/SalesItemTable.razor.cs +++ b/Wonky.Client/Components/ItemTable.razor.cs @@ -19,7 +19,7 @@ using Wonky.Entity.DTO; namespace Wonky.Client.Components; -public partial class SalesItemTable +public partial class ItemTable { [Parameter] public List SalesItems { get; set; } = new(); [Parameter] public string PoDraftAccount { get; set; } = ""; diff --git a/Wonky.Client/Components/SalesItemTable.razor.css b/Wonky.Client/Components/ItemTable.razor.css similarity index 100% rename from Wonky.Client/Components/SalesItemTable.razor.css rename to Wonky.Client/Components/ItemTable.razor.css diff --git a/Wonky.Client/Components/RegInfoCompany.razor b/Wonky.Client/Components/RegInfoCompany.razor index 4a4a82b3..fe0da788 100644 --- a/Wonky.Client/Components/RegInfoCompany.razor +++ b/Wonky.Client/Components/RegInfoCompany.razor @@ -27,10 +27,10 @@ CVR status @CurrentState
      -
    • @(string.IsNullOrEmpty(VirkRegInfo.Name) ? "" : VirkRegInfo.Name)
    • -
    • @(string.IsNullOrEmpty(VirkRegInfo.CoName) ? "" : VirkRegInfo.CoName)
    • -
    • @(string.IsNullOrEmpty(VirkRegInfo.Address) ? "" : VirkRegInfo.Address)
    • -
    • @(string.IsNullOrEmpty(VirkRegInfo.ZipCode) ? "" : VirkRegInfo.ZipCode) @(string.IsNullOrEmpty(VirkRegInfo.City) ? "" : VirkRegInfo.City)
    • +
    • @VirkRegInfo.Name
    • +
    • @VirkRegInfo.CoName
    • +
    • @VirkRegInfo.Address
    • +
    • @VirkRegInfo.ZipCode @VirkRegInfo.City
    diff --git a/Wonky.Client/Components/RegInfoCompany.razor.cs b/Wonky.Client/Components/RegInfoCompany.razor.cs index 3cbefd63..2dd288b9 100644 --- a/Wonky.Client/Components/RegInfoCompany.razor.cs +++ b/Wonky.Client/Components/RegInfoCompany.razor.cs @@ -17,7 +17,6 @@ using Microsoft.AspNetCore.Components; using Wonky.Client.Services; using Wonky.Entity.Models; using Wonky.Entity.Requests; -using Wonky.Virk.Services; namespace Wonky.Client.Components; @@ -30,14 +29,14 @@ public partial class RegInfoCompany private VirkRegInfo VirkRegInfo { get; set; } = new(); private bool HideMe = true; private bool CvrInvalid => string.IsNullOrEmpty(VatNumber); - private VirkParams _virkParams = new(); + private VirkParams _VirkParams = new(); private string CurrentState = "UKENDT"; private async Task GetCvrData() { - _virkParams.VatNumber = VatNumber; + _VirkParams.VatNumber = VatNumber; if (string.IsNullOrWhiteSpace(VirkRegInfo.VatNumber)) { - var result = await VirkRegistryService.QueryVirkRegistry(_virkParams); + var result = await VirkRegistryService.QueryVirkRegistry(_VirkParams); if (result.Any()) { CurrentState = VirkRegInfo.States[^1].State; diff --git a/Wonky.Client/Components/RegLookupAddress.razor b/Wonky.Client/Components/RegLookupAddress.razor index f8cc06f8..14f91af1 100644 --- a/Wonky.Client/Components/RegLookupAddress.razor +++ b/Wonky.Client/Components/RegLookupAddress.razor @@ -14,6 +14,8 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // *@ +@using Microsoft.VisualBasic +@using System.Diagnostics
    diff --git a/Wonky.Client/Components/RegLookupAddress.razor.cs b/Wonky.Client/Components/RegLookupAddress.razor.cs index 649f26e3..b25c3d56 100644 --- a/Wonky.Client/Components/RegLookupAddress.razor.cs +++ b/Wonky.Client/Components/RegLookupAddress.razor.cs @@ -20,7 +20,6 @@ using Wonky.Client.HttpInterceptors; using Wonky.Client.Services; using Wonky.Entity.Models; using Wonky.Entity.Requests; -using Wonky.Virk.Services; namespace Wonky.Client.Components; diff --git a/Wonky.Client/Components/RegLookupVatNo.razor.cs b/Wonky.Client/Components/RegLookupVatNo.razor.cs index 18926da8..4ca83bec 100644 --- a/Wonky.Client/Components/RegLookupVatNo.razor.cs +++ b/Wonky.Client/Components/RegLookupVatNo.razor.cs @@ -20,7 +20,6 @@ using Wonky.Client.HttpInterceptors; using Wonky.Client.Services; using Wonky.Entity.Models; using Wonky.Entity.Requests; -using Wonky.Virk.Services; namespace Wonky.Client.Components; diff --git a/Wonky.Client/Components/RegStateVatNumber.razor.cs b/Wonky.Client/Components/RegStateVatNumber.razor.cs index 106e690e..376dd792 100644 --- a/Wonky.Client/Components/RegStateVatNumber.razor.cs +++ b/Wonky.Client/Components/RegStateVatNumber.razor.cs @@ -18,7 +18,6 @@ using Microsoft.AspNetCore.Components; using Wonky.Client.Services; using Wonky.Entity.Models; using Wonky.Entity.Requests; -using Wonky.Virk.Services; namespace Wonky.Client.Components; @@ -29,15 +28,15 @@ public partial class RegStateVatNumber [Parameter] public string VatNumber { get; set; } = ""; private VirkRegInfo VirkRegInfo { get; set; } = new(); - private readonly VirkParams _virkParams = new(); + private readonly VirkParams _VirkParams = new(); private string CurrentRegState = "UKENDT"; protected override async Task OnParametersSetAsync() { - _virkParams.VatNumber = VatNumber; + _VirkParams.VatNumber = VatNumber; if (!string.IsNullOrEmpty(VatNumber)) { - var result = await VirkRegistryService.QueryVirkRegistry(_virkParams); + var result = await VirkRegistryService.QueryVirkRegistry(_VirkParams); VirkRegInfo = result.Any() ? result[0] : new VirkRegInfo(); if (VirkRegInfo.States.Any()) CurrentRegState = VirkRegInfo.States[^1].State; diff --git a/Wonky.Client/Components/SalesItemGroupFilter.razor.css b/Wonky.Client/Components/SalesItemGroupFilter.razor.css deleted file mode 100644 index e01c1fc6..00000000 --- a/Wonky.Client/Components/SalesItemGroupFilter.razor.css +++ /dev/null @@ -1,3 +0,0 @@ -.group-field { - margin-bottom: 10px; -} \ No newline at end of file diff --git a/Wonky.Client/Components/SalesItemSearchField.razor.css b/Wonky.Client/Components/SalesItemSearchField.razor.css deleted file mode 100644 index 4d7d555a..00000000 --- a/Wonky.Client/Components/SalesItemSearchField.razor.css +++ /dev/null @@ -1,3 +0,0 @@ -.search-field { - margin-bottom: 10px; -} \ No newline at end of file diff --git a/Wonky.Client/Components/SearchPhrase.razor b/Wonky.Client/Components/SearchPhrase.razor index ce57aae5..247f2854 100644 --- a/Wonky.Client/Components/SearchPhrase.razor +++ b/Wonky.Client/Components/SearchPhrase.razor @@ -15,8 +15,7 @@ // *@ -
    - -
    \ No newline at end of file + + diff --git a/Wonky.Client/Components/SearchPhrase.razor.cs b/Wonky.Client/Components/SearchPhrase.razor.cs index 0cb5cb54..bf7d0fde 100644 --- a/Wonky.Client/Components/SearchPhrase.razor.cs +++ b/Wonky.Client/Components/SearchPhrase.razor.cs @@ -22,9 +22,8 @@ namespace Wonky.Client.Components public partial class SearchPhrase { private Timer _timer = new(); - public string SearchTerm { get; set; } = ""; - - [Parameter] public EventCallback OnSearchChanged { get; set; } + private string SearchTerm { get; set; } = ""; + [Parameter] public EventCallback OnSearchPhraseChanged { get; set; } private void SearchChanged() { @@ -36,7 +35,7 @@ namespace Wonky.Client.Components private void OnTimerElapsed(object? sender, ElapsedEventArgs e) { - OnSearchChanged.InvokeAsync(SearchTerm); + OnSearchPhraseChanged.InvokeAsync(SearchTerm); _timer.Enabled = false; _timer.Dispose(); } diff --git a/Wonky.Client/Components/SearchPhrase.razor.css b/Wonky.Client/Components/SearchPhrase.razor.css deleted file mode 100644 index 32935266..00000000 --- a/Wonky.Client/Components/SearchPhrase.razor.css +++ /dev/null @@ -1,3 +0,0 @@ -.search-input { - margin-bottom: 10px; -} \ No newline at end of file diff --git a/Wonky.Client/Features/JwtParser.cs b/Wonky.Client/Features/JwtParser.cs deleted file mode 100644 index c6fdab6f..00000000 --- a/Wonky.Client/Features/JwtParser.cs +++ /dev/null @@ -1,56 +0,0 @@ -using System.Security.Claims; -using System.Text.Json; - -namespace Wonky.Client.Features; - -public class JwtParser -{ - public static IEnumerable ParseClaimsFromJwt(string jwt) - { - var claims = new List(); - var payload = jwt.Split('.')[1]; - - var jsonBytes = ParseBase64WithoutPadding(payload); - - var keyValuePairs = JsonSerializer - .Deserialize>(jsonBytes); - - ExtractRolesFromJwt(claims, keyValuePairs); - - claims.AddRange(keyValuePairs! - .Select(kvp => new Claim(kvp.Key, kvp.Value.ToString()))); - - return claims; - } - - private static void ExtractRolesFromJwt(List claims, - Dictionary? keyValuePairs) - { - keyValuePairs.TryGetValue(ClaimTypes.Role, out object roles); - if (roles == null) return; - var parsedRoles = roles.ToString().Trim() - .TrimStart('[').TrimEnd(']').Split(','); - if (parsedRoles.Length > 1) - { - claims.AddRange(parsedRoles - .Select(parsedRole => new Claim(ClaimTypes.Role, parsedRole.Trim('"')))); - } - else - { - claims.Add(new Claim(ClaimTypes.Role, parsedRoles[0])); - } - keyValuePairs.Remove(ClaimTypes.Role); - } - - - private static byte[] ParseBase64WithoutPadding(string base64) - { - switch (base64.Length % 4) - { - case 2: base64 += "=="; break; - case 3: base64 += "="; break; - } - - return Convert.FromBase64String(base64); - } -} \ No newline at end of file diff --git a/Wonky.Client/Features/PagingResponse.cs b/Wonky.Client/Features/PagingResponse.cs index 6bdb5700..42bfa151 100644 --- a/Wonky.Client/Features/PagingResponse.cs +++ b/Wonky.Client/Features/PagingResponse.cs @@ -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 Wonky.Entity.Requests; namespace Wonky.Client.Features; diff --git a/Wonky.Client/Helpers/Utils.cs b/Wonky.Client/Helpers/Utils.cs index 7331573a..f5e8e107 100644 --- a/Wonky.Client/Helpers/Utils.cs +++ b/Wonky.Client/Helpers/Utils.cs @@ -13,6 +13,8 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // +using System; + namespace Wonky.Client.Helpers; public static class Utils diff --git a/Wonky.Client/HttpInterceptors/HttpInterceptorService.cs b/Wonky.Client/HttpInterceptors/HttpInterceptorService.cs index c5cedfbe..593ebdb6 100644 --- a/Wonky.Client/HttpInterceptors/HttpInterceptorService.cs +++ b/Wonky.Client/HttpInterceptors/HttpInterceptorService.cs @@ -15,10 +15,12 @@ using System.Net; using System.Net.Http.Headers; +using System.Threading.Tasks; using Blazored.Toast.Services; -using Microsoft.AspNetCore.Components; -using Toolbelt.Blazor; using Wonky.Client.Services; +using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Logging; +using Toolbelt.Blazor; namespace Wonky.Client.HttpInterceptors { diff --git a/Wonky.Client/HttpInterceptors/HttpResponseException.cs b/Wonky.Client/HttpInterceptors/HttpResponseException.cs index cf52e847..61489b32 100644 --- a/Wonky.Client/HttpInterceptors/HttpResponseException.cs +++ b/Wonky.Client/HttpInterceptors/HttpResponseException.cs @@ -13,6 +13,7 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // +using System; using System.Runtime.Serialization; namespace Wonky.Client.HttpInterceptors diff --git a/Wonky.Client/HttpRepository/CompanyHttpRepository.cs b/Wonky.Client/HttpRepository/CompanyHttpRepository.cs index 60e0ce80..929cff96 100644 --- a/Wonky.Client/HttpRepository/CompanyHttpRepository.cs +++ b/Wonky.Client/HttpRepository/CompanyHttpRepository.cs @@ -13,12 +13,17 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; using System.Net.Http.Json; using System.Text.Json; +using System.Threading.Tasks; +using Wonky.Client.Features; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.WebUtilities; +using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using Wonky.Client.Features; using Wonky.Entity.Configuration; using Wonky.Entity.DTO; using Wonky.Entity.Requests; @@ -55,12 +60,12 @@ public class CompanyHttpRepository : ICompanyHttpRepository { ["pageNumber"] = pagingParameters.PageNumber.ToString(), ["pageSize"] = pagingParameters.PageSize.ToString(), - ["searchTerm"] = string.IsNullOrEmpty(pagingParameters.SearchTerm) ? "" : pagingParameters.SearchTerm, - ["orderBy"] = string.IsNullOrEmpty(pagingParameters.OrderBy) ? "" : pagingParameters.OrderBy, - ["searchColumn"] = string.IsNullOrEmpty(pagingParameters.SearchColumn) ? "" : pagingParameters.SearchColumn + ["searchTerm"] = pagingParameters.SearchTerm, + ["searchColumn"] = pagingParameters.SearchColumn, + ["orderBy"] = pagingParameters.OrderBy }; var response = await _client - .GetAsync(QueryHelpers.AddQueryString($"{_apiConfig.CrmCompanies}", queryString)); + .GetAsync(QueryHelpers.AddQueryString($"{_apiConfig.CrmCompanies}/page", queryString)); var content = await response.Content.ReadAsStringAsync(); diff --git a/Wonky.Client/HttpRepository/ICompanyHttpRepository.cs b/Wonky.Client/HttpRepository/ICompanyHttpRepository.cs index 65003abd..0292ae26 100644 --- a/Wonky.Client/HttpRepository/ICompanyHttpRepository.cs +++ b/Wonky.Client/HttpRepository/ICompanyHttpRepository.cs @@ -13,6 +13,7 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // +using System.Threading.Tasks; using Wonky.Client.Features; using Wonky.Entity.DTO; using Wonky.Entity.Requests; diff --git a/Wonky.Client/HttpRepository/IKrvProductHttpRepository.cs b/Wonky.Client/HttpRepository/IKrvProductHttpRepository.cs deleted file mode 100644 index 59fce7ff..00000000 --- a/Wonky.Client/HttpRepository/IKrvProductHttpRepository.cs +++ /dev/null @@ -1,29 +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 Affero GNU 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 -// Affero GNU General Public License for more details. -// -// You should have received a copy of the Affero GNU General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - -using Wonky.Client.Features; -using Wonky.Entity.DTO; -using Wonky.Entity.Requests; - -namespace Wonky.Client.HttpRepository; - -public interface IKrvProductHttpRepository -{ - Task> GetProducts(PagingParams pagingParameters); - Task GetProduct(string productId); - Task CreateProduct(KrvProductDto product); - Task UploadImage(MultipartFormDataContent content, string productId); - Task UpdateProduct(KrvProductDto product); -} \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/IKrvVariantHttpRepository.cs b/Wonky.Client/HttpRepository/IKrvVariantHttpRepository.cs deleted file mode 100644 index b67ce000..00000000 --- a/Wonky.Client/HttpRepository/IKrvVariantHttpRepository.cs +++ /dev/null @@ -1,29 +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 Affero GNU 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 -// Affero GNU General Public License for more details. -// -// You should have received a copy of the Affero GNU General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - -using Wonky.Client.Features; -using Wonky.Entity.DTO; -using Wonky.Entity.Requests; - -namespace Wonky.Client.HttpRepository; - -public interface IKrvVariantHttpRepository -{ - Task> GetVariants(PagingParams pagingParameters); - Task GetVariant(string variantId); - Task CreateVariant(KrvVariantDto variantDto); - Task UploadImage(MultipartFormDataContent content, string variantId); - Task UpdateVariant(KrvVariantDto variant); -} \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/ISalesItemHttpRepository.cs b/Wonky.Client/HttpRepository/ISalesItemHttpRepository.cs index d988b2a7..ab3bec04 100644 --- a/Wonky.Client/HttpRepository/ISalesItemHttpRepository.cs +++ b/Wonky.Client/HttpRepository/ISalesItemHttpRepository.cs @@ -13,6 +13,7 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // +using System.Threading.Tasks; using Wonky.Client.Features; using Wonky.Entity.DTO; using Wonky.Entity.Requests; diff --git a/Wonky.Client/HttpRepository/KrvProductHttpRepository.cs b/Wonky.Client/HttpRepository/KrvProductHttpRepository.cs deleted file mode 100644 index 05558ab7..00000000 --- a/Wonky.Client/HttpRepository/KrvProductHttpRepository.cs +++ /dev/null @@ -1,108 +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 Affero GNU 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 -// Affero GNU General Public License for more details. -// -// You should have received a copy of the Affero GNU General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - -using System.Net.Http.Json; -using System.Text.Json; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.WebUtilities; -using Microsoft.Extensions.Options; -using Wonky.Client.Features; -using Wonky.Entity.Configuration; -using Wonky.Entity.DTO; -using Wonky.Entity.Requests; - -namespace Wonky.Client.HttpRepository; - -public class KrvProductHttpRepository : IKrvProductHttpRepository -{ - private readonly JsonSerializerOptions? _options = new JsonSerializerOptions - { - PropertyNameCaseInsensitive = true - }; - - private readonly NavigationManager _navigation; - private ILogger _logger; - private readonly HttpClient _client; - private readonly ApiConfig _apiConfig; - - public KrvProductHttpRepository(HttpClient client, - ILogger logger, - NavigationManager navigation, IOptions configuration) - { - _client = client; - _logger = logger; - _navigation = navigation; - _apiConfig = configuration.Value; - } - - public async Task> GetProducts(PagingParams pagingParameters) - { - var queryString = new Dictionary - { - ["pageNumber"] = pagingParameters.PageNumber.ToString(), - ["pageSize"] = pagingParameters.PageSize.ToString(), - ["searchTerm"] = string.IsNullOrEmpty(pagingParameters.SearchTerm) ? "" : pagingParameters.SearchTerm, - ["orderBy"] = string.IsNullOrEmpty(pagingParameters.OrderBy) ? "" : pagingParameters.OrderBy - }; - var response = await _client - .GetAsync(QueryHelpers.AddQueryString($"{_apiConfig.KrvProducts}", queryString)) - ; - - var content = await response.Content - .ReadAsStringAsync() - ; - - var pagingResponse = new PagingResponse - { - Items = JsonSerializer.Deserialize>(content, _options), - MetaData = JsonSerializer.Deserialize( - response.Headers.GetValues("X-Pagination").First(), _options) - }; - return pagingResponse; - } - - public async Task GetProduct(string productId) - { - var product = await _client - .GetFromJsonAsync($"{_apiConfig.KrvProducts}/get/id({productId})") - ; - return product ?? new KrvProductDto(); - } - - public async Task CreateProduct(KrvProductDto productDto) - { - await _client - .PostAsJsonAsync($"{_apiConfig.KrvProducts}", productDto) - ; - } - - public async Task UploadImage(MultipartFormDataContent content, string productId) - { - var postResult = await _client - .PostAsync($"{_apiConfig.ImageUpload}/products/id({productId})/image", content) - ; - - var postContent = await postResult.Content.ReadAsStringAsync(); - - return postContent; - } - - public async Task UpdateProduct(KrvProductDto product) - { - Console.WriteLine(product.ProductId); - - await _client.PutAsJsonAsync($"{_apiConfig.KrvProducts}/put/id({product.ProductId})", product); - } -} \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/KrvVariantHttpRepository.cs b/Wonky.Client/HttpRepository/KrvVariantHttpRepository.cs deleted file mode 100644 index ea7b3e45..00000000 --- a/Wonky.Client/HttpRepository/KrvVariantHttpRepository.cs +++ /dev/null @@ -1,112 +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 Affero GNU 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 -// Affero GNU General Public License for more details. -// -// You should have received a copy of the Affero GNU General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - -using System.Net.Http.Json; -using System.Text.Json; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.WebUtilities; -using Microsoft.Extensions.Options; -using Wonky.Client.Features; -using Wonky.Entity.Configuration; -using Wonky.Entity.DTO; -using Wonky.Entity.Requests; - -namespace Wonky.Client.HttpRepository; - -public class KrvVariantHttpRepository : IKrvVariantHttpRepository -{ - private readonly JsonSerializerOptions _options = new JsonSerializerOptions - { - PropertyNameCaseInsensitive = true - }; - - private readonly NavigationManager _navigation; - private ILogger _logger; - private readonly HttpClient _client; - private readonly ApiConfig _apiConfig; - - public KrvVariantHttpRepository(HttpClient client, - ILogger logger, - NavigationManager navigation, IOptions configuration) - { - _client = client; - _logger = logger; - _navigation = navigation; - _apiConfig = configuration.Value; - } - - public async Task> GetVariants(PagingParams pagingParameters) - { - var queryString = new Dictionary - { - ["pageNumber"] = pagingParameters.PageNumber.ToString(), - ["pageSize"] = pagingParameters.PageSize.ToString(), - ["searchTerm"] = string.IsNullOrEmpty(pagingParameters.SearchTerm) ? "" : pagingParameters.SearchTerm, - ["orderBy"] = string.IsNullOrEmpty(pagingParameters.OrderBy) ? "" : pagingParameters.OrderBy - }; - var response = await _client - .GetAsync(QueryHelpers.AddQueryString($"{_apiConfig.KrvVariants}", queryString)) - ; - - var content = await response.Content - .ReadAsStringAsync() - ; - - var pagingResponse = new PagingResponse - { - Items = JsonSerializer.Deserialize>(content, _options), - MetaData = JsonSerializer.Deserialize( - response.Headers.GetValues("X-Pagination").First(), _options) - }; - return pagingResponse; - } - - public async Task GetVariant(string variantId) - { - var variant = await _client - .GetFromJsonAsync($"{_apiConfig.KrvVariants}/get/id({variantId})") - ; - return variant ?? new KrvVariantDto(); - } - - public async Task CreateVariant(KrvVariantDto variantDto) - { - await _client - .PostAsJsonAsync($"v2/", variantDto) - ; - } - - public async Task UploadImage(MultipartFormDataContent content, string variantId) - { - Console.WriteLine($" Repo -> UploadImage -> {variantId}"); - - var postResult = await _client - .PostAsync($"{_apiConfig.ImageUpload}/variants/id({variantId})/image", content) - ; - - var postContent = await postResult.Content.ReadAsStringAsync(); - - Console.WriteLine(postContent); - - return postContent; - } - - public async Task UpdateVariant(KrvVariantDto variant) - { - Console.WriteLine(variant.VariantId); - - await _client.PutAsJsonAsync($"{_apiConfig.KrvVariants}/put/id({variant.VariantId})", variant); - } -} \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/SalesItemHttpRepository.cs b/Wonky.Client/HttpRepository/SalesItemHttpRepository.cs index 47a1697b..3bd25ca8 100644 --- a/Wonky.Client/HttpRepository/SalesItemHttpRepository.cs +++ b/Wonky.Client/HttpRepository/SalesItemHttpRepository.cs @@ -13,12 +13,16 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; using System.Net.Http.Json; using System.Text.Json; +using System.Threading.Tasks; +using Wonky.Client.Features; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.WebUtilities; using Microsoft.Extensions.Options; -using Wonky.Client.Features; using Wonky.Entity.Configuration; using Wonky.Entity.DTO; using Wonky.Entity.Requests; @@ -53,11 +57,13 @@ public class SalesItemHttpRepository : ISalesItemHttpRepository { ["pageNumber"] = pagingParameters.PageNumber.ToString(), ["pageSize"] = pagingParameters.PageSize.ToString(), - ["searchTerm"] = string.IsNullOrEmpty(pagingParameters.SearchTerm) ? "" : pagingParameters.SearchTerm, - ["orderBy"] = string.IsNullOrEmpty(pagingParameters.OrderBy) ? "" : pagingParameters.OrderBy + ["searchTerm"] = pagingParameters.SearchTerm, + ["searchColumn"] = pagingParameters.SearchColumn, + ["orderBy"] = pagingParameters.OrderBy, + ["selectGroup"] = pagingParameters.SelectGroup }; var response = await _client - .GetAsync(QueryHelpers.AddQueryString($"{_apiConfig.PriceCatalog}", queryString)); + .GetAsync(QueryHelpers.AddQueryString($"{_apiConfig.PriceCatalog}/page", queryString)); var content = await response.Content.ReadAsStringAsync(); diff --git a/Wonky.Client/Models/PurchaseOrder.cs b/Wonky.Client/Models/PurchaseOrder.cs index b546367d..8a85eaa7 100644 --- a/Wonky.Client/Models/PurchaseOrder.cs +++ b/Wonky.Client/Models/PurchaseOrder.cs @@ -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; using Wonky.Entity.DTO; diff --git a/Wonky.Client/Models/Quote.cs b/Wonky.Client/Models/Quote.cs index 0c9cfca2..ff1a0d32 100644 --- a/Wonky.Client/Models/Quote.cs +++ b/Wonky.Client/Models/Quote.cs @@ -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.Client.Models { public class Quote diff --git a/Wonky.Client/Pages/About.razor b/Wonky.Client/Pages/About.razor index 96a1a1f3..77948602 100644 --- a/Wonky.Client/Pages/About.razor +++ b/Wonky.Client/Pages/About.razor @@ -1,6 +1,12 @@ +@using Wonky.Client.Components @page "/About" -

    Hvad er Wonky Online

    +
    + Wonky logo +
    -Wonky Online er Innotec Danmarks egen udviklede ordresystem. +
    +
    + +
    +
    - \ No newline at end of file diff --git a/Wonky.Client/Pages/ActivityList.razor b/Wonky.Client/Pages/ActivityList.razor deleted file mode 100644 index e79c5923..00000000 --- a/Wonky.Client/Pages/ActivityList.razor +++ /dev/null @@ -1,9 +0,0 @@ -@page "/activites" - -

    Salgs Aktivitet

    - -
    -
    - -
    -
    \ No newline at end of file diff --git a/Wonky.Client/Pages/ActivityList.razor.cs b/Wonky.Client/Pages/ActivityList.razor.cs deleted file mode 100644 index e519af77..00000000 --- a/Wonky.Client/Pages/ActivityList.razor.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System.Diagnostics; -using Microsoft.AspNetCore.Components; - -namespace Wonky.Client.Pages; - -public partial class ActivityList -{ - public List Activities { get; set; } = new(); - -} \ No newline at end of file diff --git a/Wonky.Client/Pages/ActivityList.razor.css b/Wonky.Client/Pages/ActivityList.razor.css deleted file mode 100644 index e69de29b..00000000 diff --git a/Wonky.Client/Pages/CompanyCreate.razor b/Wonky.Client/Pages/CompanyCreate.razor index d74dbc04..188b2c4f 100644 --- a/Wonky.Client/Pages/CompanyCreate.razor +++ b/Wonky.Client/Pages/CompanyCreate.razor @@ -17,7 +17,6 @@ @page "/create-company" @using Microsoft.AspNetCore.Authorization -@using Microsoft.AspNetCore.Components @attribute [Authorize(Roles = "Adviser")]

    Opret firma

    diff --git a/Wonky.Client/Pages/CompanyCreate.razor.cs b/Wonky.Client/Pages/CompanyCreate.razor.cs index 73aa7638..7b9d0045 100644 --- a/Wonky.Client/Pages/CompanyCreate.razor.cs +++ b/Wonky.Client/Pages/CompanyCreate.razor.cs @@ -13,18 +13,21 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // +using System; using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Threading.Tasks; using Blazored.LocalStorage; using Blazored.Toast.Services; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Forms; using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpRepository; using Wonky.Client.Services; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Forms; +using Microsoft.Extensions.Logging; using Wonky.Entity.DTO; using Wonky.Entity.Models; using Wonky.Entity.Requests; -using Wonky.Virk.Services; namespace Wonky.Client.Pages { diff --git a/Wonky.Client/Pages/CompanyList.razor b/Wonky.Client/Pages/CompanyList.razor index 3b8e5b18..e2034697 100644 --- a/Wonky.Client/Pages/CompanyList.razor +++ b/Wonky.Client/Pages/CompanyList.razor @@ -16,21 +16,20 @@ *@ @page "/companies" +@using Wonky.Client.Components @using Microsoft.AspNetCore.Authorization @attribute [Authorize(Roles = "Adviser")] -
    +
    - +
    - -
    -
    - +
    +
    Nyt firma diff --git a/Wonky.Client/Pages/CompanyList.razor.cs b/Wonky.Client/Pages/CompanyList.razor.cs index f10939e8..ce4eca25 100644 --- a/Wonky.Client/Pages/CompanyList.razor.cs +++ b/Wonky.Client/Pages/CompanyList.razor.cs @@ -13,9 +13,12 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // -using Microsoft.AspNetCore.Components; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpRepository; +using Microsoft.AspNetCore.Components; using Wonky.Entity.DTO; using Wonky.Entity.Requests; @@ -27,7 +30,7 @@ namespace Wonky.Client.Pages public MetaData? MetaData { get; set; } = new(); private PagingParams _paging = new(); - + [Inject] public ICompanyHttpRepository CompanyRepo { get; set; } @@ -56,6 +59,7 @@ namespace Wonky.Client.Pages private async Task FilterChanged(string? searchColumn) { + _paging.SearchTerm = ""; _paging.SearchColumn = searchColumn; _paging.PageNumber = 1; await GetCompanies(); diff --git a/Wonky.Client/Pages/CompanyUpdate.razor b/Wonky.Client/Pages/CompanyUpdate.razor index 9be2ebf6..4ecf3375 100644 --- a/Wonky.Client/Pages/CompanyUpdate.razor +++ b/Wonky.Client/Pages/CompanyUpdate.razor @@ -17,6 +17,7 @@ @page "/update-company/{account}" @using Microsoft.AspNetCore.Authorization +@using Wonky.Client.Components @using Microsoft.AspNetCore.Components @attribute [Authorize(Roles = "Adviser")] diff --git a/Wonky.Client/Pages/CompanyUpdate.razor.cs b/Wonky.Client/Pages/CompanyUpdate.razor.cs index e8913272..e08927f2 100644 --- a/Wonky.Client/Pages/CompanyUpdate.razor.cs +++ b/Wonky.Client/Pages/CompanyUpdate.razor.cs @@ -13,11 +13,14 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // +using System; +using System.Threading.Tasks; using Blazored.Toast.Services; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Forms; using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpRepository; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Forms; +using Microsoft.Extensions.Logging; using Wonky.Entity.DTO; namespace Wonky.Client.Pages; diff --git a/Wonky.Client/Pages/CompanyView.razor b/Wonky.Client/Pages/CompanyView.razor index e608c7fc..701eba5e 100644 --- a/Wonky.Client/Pages/CompanyView.razor +++ b/Wonky.Client/Pages/CompanyView.razor @@ -18,6 +18,7 @@ @page "/company/account/{account}" @page "/company/{companyId}" @using Microsoft.AspNetCore.Authorization +@using Wonky.Client.Components; @attribute [Authorize(Roles = "Adviser")]
    @@ -34,7 +35,7 @@
    - Tilbud + Tilbud Ordre Faktura Produkter diff --git a/Wonky.Client/Pages/CompanyView.razor.cs b/Wonky.Client/Pages/CompanyView.razor.cs index 176138ff..aa79f743 100644 --- a/Wonky.Client/Pages/CompanyView.razor.cs +++ b/Wonky.Client/Pages/CompanyView.razor.cs @@ -13,9 +13,11 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // -using Microsoft.AspNetCore.Components; +using System; +using System.Threading.Tasks; using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpRepository; +using Microsoft.AspNetCore.Components; using Wonky.Entity.DTO; namespace Wonky.Client.Pages; diff --git a/Wonky.Client/Pages/Index.razor b/Wonky.Client/Pages/Index.razor index 0586e4d2..dd13f3c3 100644 --- a/Wonky.Client/Pages/Index.razor +++ b/Wonky.Client/Pages/Index.razor @@ -18,8 +18,9 @@ @page "/" @page "/index" @inject IWebAssemblyHostEnvironment _hostEnvironment +@using Wonky.Client.Components; - + @code{ } diff --git a/Wonky.Client/Pages/Login.razor b/Wonky.Client/Pages/Login.razor index e19901e2..230bba62 100644 --- a/Wonky.Client/Pages/Login.razor +++ b/Wonky.Client/Pages/Login.razor @@ -31,15 +31,15 @@
    - +
    -
    - +
    @@ -48,7 +48,7 @@
    - +
    \ No newline at end of file diff --git a/Wonky.Client/Pages/Login.razor.cs b/Wonky.Client/Pages/Login.razor.cs index e5b2226c..a8d636bd 100644 --- a/Wonky.Client/Pages/Login.razor.cs +++ b/Wonky.Client/Pages/Login.razor.cs @@ -13,8 +13,9 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // -using Microsoft.AspNetCore.Components; +using System.Threading.Tasks; using Wonky.Client.Services; +using Microsoft.AspNetCore.Components; using Wonky.Entity.DTO; namespace Wonky.Client.Pages; @@ -31,20 +32,23 @@ public partial class Login [Parameter] public string ReturnUrl { get; set; } = ""; private bool ShowAuthError { get; set; } private string? Error { get; set; } + private bool execLogin; private async Task ExecuteLogin() { ShowAuthError = false; + execLogin = true; var result = await AuthenticationService.Login(_userAuthenticationDto); if (!result.IsSuccess) { Error = result.ErrorMessage; ShowAuthError = true; + execLogin = false; } else { - var returnUrl = string.IsNullOrEmpty(ReturnUrl) ? "/companies" : ReturnUrl; + var returnUrl = string.IsNullOrEmpty(ReturnUrl) ? "/Companies" : ReturnUrl; NavigationManager.NavigateTo(returnUrl); } } diff --git a/Wonky.Client/Pages/Logout.razor.cs b/Wonky.Client/Pages/Logout.razor.cs index 81eed805..91182c12 100644 --- a/Wonky.Client/Pages/Logout.razor.cs +++ b/Wonky.Client/Pages/Logout.razor.cs @@ -13,8 +13,9 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // -using Microsoft.AspNetCore.Components; +using System.Threading.Tasks; using Wonky.Client.Services; +using Microsoft.AspNetCore.Components; namespace Wonky.Client.Pages; diff --git a/Wonky.Client/Pages/ProductCreate.razor b/Wonky.Client/Pages/ProductCreate.razor deleted file mode 100644 index d212864c..00000000 --- a/Wonky.Client/Pages/ProductCreate.razor +++ /dev/null @@ -1,54 +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 Affero GNU 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 -// Affero GNU General Public License for more details. -// -// You should have received a copy of the Affero GNU General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// -*@ - -@page "/create-product" -@using Microsoft.AspNetCore.Authorization -@using Microsoft.AspNetCore.Components -@attribute [Authorize(Roles = "Admin")] -

    Opret KRV Produkt

    -@* *@ - - - @* *@ -
    - -
    - - -
    -
    -
    - -
    - -
    -
    - -
    - -
    - -
    -
    - -
    -
    - -
    -
    -
    - diff --git a/Wonky.Client/Pages/ProductCreate.razor.cs b/Wonky.Client/Pages/ProductCreate.razor.cs deleted file mode 100644 index 1f4ec1df..00000000 --- a/Wonky.Client/Pages/ProductCreate.razor.cs +++ /dev/null @@ -1,87 +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 Affero GNU 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 -// Affero GNU General Public License for more details. -// -// You should have received a copy of the Affero GNU General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - -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 -{ - public partial class ProductCreate : IDisposable - { - private KrvProductDto _productDto { get; set; } = new(); - - private EditContext _editContext; - private bool _formInvalid = true; - - [Inject] - public IKrvProductHttpRepository ProductRepo { get; set; } - - [Inject] - public HttpInterceptorService Interceptor { get; set; } - - [Inject] - public IToastService ToastService { get; set; } - - [Inject] - public ILogger Logger { get; set; } - - protected override void OnInitialized() - { - _editContext = new EditContext(_productDto); - _editContext.OnFieldChanged += HandleFieldChanged; - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); - } - - private async Task Create() - { - Logger.LogDebug($"{_productDto}"); - await ProductRepo.CreateProduct(_productDto); - ToastService.ShowSuccess($"Godt så. Produktet '{_productDto.TradingName}' er oprettet."); - _productDto = new KrvProductDto(); - _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(_productDto); - _editContext.OnFieldChanged += HandleFieldChanged; - _editContext.OnValidationStateChanged -= ValidationChanged; - } - - public void Dispose() - { - Interceptor.DisposeEvent(); - _editContext.OnFieldChanged -= HandleFieldChanged; - _editContext.OnValidationStateChanged -= ValidationChanged; - } - - private void AssignImageUrl(string imgUrl) => _productDto.PictureLink = imgUrl; - } -} - diff --git a/Wonky.Client/Pages/PurchaseOrderCreate.razor b/Wonky.Client/Pages/PurchaseOrderCreate.razor index 1309aac1..d9342c39 100644 --- a/Wonky.Client/Pages/PurchaseOrderCreate.razor +++ b/Wonky.Client/Pages/PurchaseOrderCreate.razor @@ -18,6 +18,7 @@ @page "/company/{account}/activity" @using Microsoft.AspNetCore.Authorization @attribute [Authorize(Roles = "Adviser")] +@using Wonky.Client.Components

    @_purchaseOrder.Name

    @@ -104,7 +105,7 @@
    - +
    diff --git a/Wonky.Client/Pages/PurchaseOrderCreate.razor.cs b/Wonky.Client/Pages/PurchaseOrderCreate.razor.cs index 3580ee27..0ba37de3 100644 --- a/Wonky.Client/Pages/PurchaseOrderCreate.razor.cs +++ b/Wonky.Client/Pages/PurchaseOrderCreate.razor.cs @@ -13,14 +13,17 @@ // 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.Threading.Tasks; using Blazored.LocalStorage; 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.Client.Models; +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Forms; using Wonky.Entity.DTO; using Wonky.Entity.Requests; diff --git a/Wonky.Client/Pages/Registration.razor b/Wonky.Client/Pages/Registration.razor deleted file mode 100644 index 5b504c96..00000000 --- a/Wonky.Client/Pages/Registration.razor +++ /dev/null @@ -1,66 +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 Affero GNU 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 -// Affero GNU General Public License for more details. -// -// You should have received a copy of the Affero GNU General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// -*@ - -@page "/register" -@using Microsoft.AspNetCore.Components -

    Registration

    - -@if - (ShowRegistrationErrors) -{ - -} - - -
    - -
    - - -
    -
    -
    - -
    - - -
    -
    -
    - -
    - - -
    -
    -
    -
    - -
    -
    -
    \ No newline at end of file diff --git a/Wonky.Client/Pages/Registration.razor.cs b/Wonky.Client/Pages/Registration.razor.cs deleted file mode 100644 index df6ea013..00000000 --- a/Wonky.Client/Pages/Registration.razor.cs +++ /dev/null @@ -1,54 +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 Affero GNU 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 -// Affero GNU General Public License for more details. -// -// You should have received a copy of the Affero GNU General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - -using Microsoft.AspNetCore.Components; -using Wonky.Client.Services; -using Wonky.Entity.DTO; - -namespace Wonky.Client.Pages -{ - public partial class Registration - { - private UserRegistrationDto _userRegistration = new (); - - [Inject] - public IAuthenticationService AuthenticationService { get; set; } - - [Inject] - public NavigationManager NavigationManager { get; set; } - - public bool ShowRegistrationErrors { get; set; } - public IEnumerable? Errors { get; set; } - - public async Task Register() - { - ShowRegistrationErrors = false; - - var result = await AuthenticationService.RegisterUser(_userRegistration); - if (!result.IsSuccess) - { - Errors = result.Errors; - ShowRegistrationErrors = true; - } - else - { - // todo: redirect to login page - // todo: store url - // var returnUrl = NavigationManager.Uri; - NavigationManager.NavigateTo("/login"); - } - } - } -} diff --git a/Wonky.Client/Pages/SalesItemCatalog.razor b/Wonky.Client/Pages/SalesItemCatalog.razor index 01d1b5bd..f4a0a08f 100644 --- a/Wonky.Client/Pages/SalesItemCatalog.razor +++ b/Wonky.Client/Pages/SalesItemCatalog.razor @@ -16,21 +16,23 @@ *@ @page "/price-catalog" +@using Wonky.Client.Components @using Microsoft.AspNetCore.Authorization @attribute [Authorize(Roles = "Adviser,Admin")] -
    -
    - +
    +
    +
    -
    - +
    +
    -
    +
    +
    -
    - @* Nyt firma *@ +
    +
    @@ -45,6 +47,6 @@
    - +
    \ No newline at end of file diff --git a/Wonky.Client/Pages/SalesItemCatalog.razor.cs b/Wonky.Client/Pages/SalesItemCatalog.razor.cs index 26ca6ecf..0fe0efaa 100644 --- a/Wonky.Client/Pages/SalesItemCatalog.razor.cs +++ b/Wonky.Client/Pages/SalesItemCatalog.razor.cs @@ -13,9 +13,12 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // -using Microsoft.AspNetCore.Components; +using System; +using System.Collections.Generic; +using System.Threading.Tasks; using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpRepository; +using Microsoft.AspNetCore.Components; using Wonky.Entity.DTO; using Wonky.Entity.Requests; @@ -26,7 +29,6 @@ public partial class SalesItemCatalog : IDisposable private List SalesItemList { get; set; } = new(); private MetaData? MetaData { get; set; } = new(); private PagingParams _paging = new(); - [Inject] public ISalesItemHttpRepository SalesItemRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } @@ -45,12 +47,9 @@ public partial class SalesItemCatalog : IDisposable private async Task GetSalesItems() { - if (SalesItemRepo != null) - { - var pagingResponse = await SalesItemRepo.GetSalesItems(_paging); - SalesItemList = pagingResponse.Items; - MetaData = pagingResponse.MetaData; - } + var pagingResponse = await SalesItemRepo.GetSalesItems(_paging); + SalesItemList = pagingResponse.Items!; + MetaData = pagingResponse.MetaData; } private async Task SetPageSize(int pageSize) @@ -60,14 +59,27 @@ public partial class SalesItemCatalog : IDisposable await GetSalesItems(); } - private async Task SearchChanged(string? searchTerm) + private async Task GroupFilterChanged(string groupFilter) + { + _paging.PageNumber = 1; + _paging.SelectGroup = groupFilter; + await GetSalesItems(); + } + private async Task SearchColumnChanged(string columnName) + { + _paging.PageNumber = 1; + _paging.SearchTerm = ""; + _paging.SearchColumn = columnName; + await GetSalesItems(); + } + private async Task SearchPhraseChanged(string searchTerm) { _paging.PageNumber = 1; _paging.SearchTerm = searchTerm; await GetSalesItems(); } - private async Task SortChanged(string? orderBy) + private async Task SortColumnChanged(string orderBy) { _paging.OrderBy = orderBy; await GetSalesItems(); diff --git a/Wonky.Client/Pages/SalesItemView.razor b/Wonky.Client/Pages/SalesItemView.razor index 57e348f9..637ea649 100644 --- a/Wonky.Client/Pages/SalesItemView.razor +++ b/Wonky.Client/Pages/SalesItemView.razor @@ -20,18 +20,18 @@ @attribute [Authorize(Roles = "Adviser,Admin")]
    -

    @Item.ItemName

    +

    @Item.Name

    - + - + diff --git a/Wonky.Client/Pages/SalesItemView.razor.cs b/Wonky.Client/Pages/SalesItemView.razor.cs index 6dcce758..6779b75d 100644 --- a/Wonky.Client/Pages/SalesItemView.razor.cs +++ b/Wonky.Client/Pages/SalesItemView.razor.cs @@ -13,9 +13,11 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // -using Microsoft.AspNetCore.Components; +using System; +using System.Threading.Tasks; using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpRepository; +using Microsoft.AspNetCore.Components; using Wonky.Entity.DTO; namespace Wonky.Client.Pages; diff --git a/Wonky.Client/Pages/ShoppingCart.razor b/Wonky.Client/Pages/ShoppingCart.razor new file mode 100644 index 00000000..49ad43d1 --- /dev/null +++ b/Wonky.Client/Pages/ShoppingCart.razor @@ -0,0 +1,153 @@ +@using Wonky.Entity.Models +@page "/cart" +

    ShoppingCart

    + +@if (AllItems != null) +{ +

    select item

    + +
    + @if (SelectedItem != null && ShowItem) + { +
    +
    Navn@Item.ItemName@Item.Name
    Varenr@Item.ItemNumber@Item.Sku
    + + + + + + + + + + + + + + + + +
    Name:@SelectedItem.Name
    Description:@SelectedItem.Description
    Price:$@SelectedItem.Price
    Add To Cart: + Quantity: + + +
    +
    + } + + // Show the cart contents if there are items in it. + @if (CartStateProvider != null && CartStateProvider.ShoppingCart.Items.Count > 0) + { +
    +

    Your Cart:

    +

    Total: $@CartStateProvider.ShoppingCart.Total

    + + @foreach (var item in CartStateProvider.ShoppingCart.Items) + { + + + + + + + + + + + + + + + + + + + + + + + + + + + } +
    +
    +
    Name:@item.Item.Name
    Description:@item.Item.Description
    Price:$@item.Item.Price
    Quantity:@item.Quantity
    Total:$@item.Total
    + @*Clicking this button passes the item so we can remove it*@ + +
    +
    +

    Total: $@CartStateProvider.ShoppingCart.Total

    + } +} +@code { + [CascadingParameter] CartStateProvider CartStateProvider { get; set; } + private bool ShowItem; + private string Quantity = "1"; + private List AllItems { get; set; } = new(); + private Item SelectedItem { get; set; } = new(); + + void ItemSelected(ChangeEventArgs args) + { + // Item has been selected + SelectedItem = (from x in AllItems where x.Id == Convert.ToInt32(args.Value) select x).First(); + Quantity = "1"; + ShowItem = true; + } + + async Task AddToCart() + { + // create a new cart item + var item = new CartItem + { + Item = SelectedItem, + Quantity = Convert.ToInt32(Quantity) + }; + + // add it to the cart + CartStateProvider.ShoppingCart.Items.Add(item); + + // save the item using the CartStateProvider's save method + await CartStateProvider.SaveChangesAsync(); + + // hide the selected item + ShowItem = false; + } + + async Task RemoveItem(CartItem item) + { + // click on remove + CartStateProvider.ShoppingCart.Items.Remove(item); + + // save the cart + await CartStateProvider.SaveChangesAsync(); + } + + protected override void OnInitialized() + { + // TODO load the items from server + // just create some for now + AllItems = new List(); + AllItems.Add(new Item() + { + Id = 1, + Name = "TEST 1", + Description = "Description 1", + Price = (decimal)10.99 + }); + AllItems.Add(new Item() + { + Id = 2, + Name = "TEST 2", + Description = "Description 2", + Price = (decimal)19.99 + }); + + } +} \ No newline at end of file diff --git a/Wonky.Client/Pages/VirkDataLookup.razor b/Wonky.Client/Pages/VirkDataLookup.razor deleted file mode 100644 index 1977e24b..00000000 --- a/Wonky.Client/Pages/VirkDataLookup.razor +++ /dev/null @@ -1,38 +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 Affero GNU 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 -// Affero GNU General Public License for more details. -// -// You should have received a copy of the Affero GNU General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// -*@ - -@page "/VirkData" -Innotec Danmark - -

    Virk CVR Database

    -
    -
    -

    CVR opslag

    -
    -
    - -
    -
    -
    -
    -

    Adresse opslag

    -
    -
    - -
    -
    - diff --git a/Wonky.Client/Program.cs b/Wonky.Client/Program.cs index 54d472a2..84af82c1 100644 --- a/Wonky.Client/Program.cs +++ b/Wonky.Client/Program.cs @@ -12,6 +12,7 @@ // You should have received a copy of the Affero GNU General Public License // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // + using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using Microsoft.AspNetCore.Components.Authorization; @@ -25,7 +26,6 @@ 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"); @@ -43,14 +43,11 @@ builder.Services.AddHttpClient("InnoAPI", (sp, cl) => }); builder.Services.AddBlazoredToast(); - builder.Services.AddHttpClientInterceptor(); builder.Services.Configure(builder.Configuration.GetSection("ApiConfig")); builder.Services.AddScoped(); -builder.Services.AddScoped(); -builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); diff --git a/Wonky.Client/Properties/launchSettings.json b/Wonky.Client/Properties/launchSettings.json index ac9f3170..e14599a8 100644 --- a/Wonky.Client/Properties/launchSettings.json +++ b/Wonky.Client/Properties/launchSettings.json @@ -1,30 +1,30 @@ -{ - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:33781", - "sslPort": 44330 - } - }, - "profiles": { - "Wonky.Client": { - "commandName": "Project", - "dotnetRunMessages": true, - "launchBrowser": true, - "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", - "applicationUrl": "https://localhost:7207;http://localhost:5101", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - } - } -} +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:61714", + "sslPort": 44308 + } + }, + "profiles": { + "Wonky.Client": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "applicationUrl": "https://localhost:7174;http://localhost:5280", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Wonky.Client/Services/AuthenticationService.cs b/Wonky.Client/Services/AuthenticationService.cs index 4e5b7dcd..2608ac2b 100644 --- a/Wonky.Client/Services/AuthenticationService.cs +++ b/Wonky.Client/Services/AuthenticationService.cs @@ -17,9 +17,9 @@ using System.Net.Http.Headers; using System.Net.Http.Json; using System.Text.Json; using Blazored.LocalStorage; +using Wonky.Client.AuthProviders; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.Extensions.Options; -using Wonky.Client.AuthProviders; using Wonky.Entity.Configuration; using Wonky.Entity.DTO; diff --git a/Wonky.Client/Services/IAuthenticationService.cs b/Wonky.Client/Services/IAuthenticationService.cs index 022012eb..4c63df81 100644 --- a/Wonky.Client/Services/IAuthenticationService.cs +++ b/Wonky.Client/Services/IAuthenticationService.cs @@ -13,6 +13,7 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // +using System.Threading.Tasks; using Wonky.Entity.DTO; namespace Wonky.Client.Services diff --git a/Wonky.Client/Services/RefreshTokenService.cs b/Wonky.Client/Services/RefreshTokenService.cs index 7a24a840..c8a3a4e0 100644 --- a/Wonky.Client/Services/RefreshTokenService.cs +++ b/Wonky.Client/Services/RefreshTokenService.cs @@ -13,7 +13,10 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // +using System; +using System.Threading.Tasks; using Microsoft.AspNetCore.Components.Authorization; +using Microsoft.Extensions.Logging; namespace Wonky.Client.Services; diff --git a/Wonky.Client/Services/VirkRegistryService.cs b/Wonky.Client/Services/VirkRegistryService.cs new file mode 100644 index 00000000..e9a34630 --- /dev/null +++ b/Wonky.Client/Services/VirkRegistryService.cs @@ -0,0 +1,75 @@ +// 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 Affero GNU 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 +// Affero GNU General Public License for more details. +// +// You should have received a copy of the Affero GNU 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; + private readonly List _noData = new() { new VirkRegInfo { Name = "INGEN DATA" } }; + + public VirkRegistryService(HttpClient client, IOptions apiConfig) + { + _client = client; + _apiConfig = apiConfig; + } + + public async Task> QueryVirkRegistry(VirkParams query) + { + if(!ValidateCvrQuery(query)) + { + throw new ArgumentException("CvrQuery does not validate"); + } + var queryString = new Dictionary + { + ["vatNumber"] = query.VatNumber, + ["streetName"] = query.StreetName, + ["houseNumber"] = query.HouseNumber, + ["zipCode"] = query.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>(content, _options); + + if (string.IsNullOrWhiteSpace(content) || !jsonResult.Any()) return _noData; + + if (!string.IsNullOrWhiteSpace(query.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 query) + { + if (!string.IsNullOrWhiteSpace(query.VatNumber)) + return true; + return !string.IsNullOrWhiteSpace(query.HouseNumber) && !string.IsNullOrWhiteSpace(query.StreetName) && + !string.IsNullOrWhiteSpace(query.ZipCode); + } +} \ No newline at end of file diff --git a/Wonky.Client/Shared/PoStateProvider.razor b/Wonky.Client/Shared/CartStateProvider.razor similarity index 95% rename from Wonky.Client/Shared/PoStateProvider.razor rename to Wonky.Client/Shared/CartStateProvider.razor index 9a6e7dd2..ef013766 100644 --- a/Wonky.Client/Shared/PoStateProvider.razor +++ b/Wonky.Client/Shared/CartStateProvider.razor @@ -15,7 +15,7 @@ // *@ -@if (hasLoaded) +@if (_hasLoaded) { @ChildContent @@ -23,5 +23,5 @@ } else { -

    Indlæser...

    +

    Indlæser ...

    } \ No newline at end of file diff --git a/Wonky.Client/Shared/PoStateProvider.razor.cs b/Wonky.Client/Shared/CartStateProvider.razor.cs similarity index 60% rename from Wonky.Client/Shared/PoStateProvider.razor.cs rename to Wonky.Client/Shared/CartStateProvider.razor.cs index cab00b6d..1ef4fbc1 100644 --- a/Wonky.Client/Shared/PoStateProvider.razor.cs +++ b/Wonky.Client/Shared/CartStateProvider.razor.cs @@ -13,33 +13,45 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // +using System.Threading.Tasks; using Blazored.LocalStorage; -using Microsoft.AspNetCore.Components; using Wonky.Client.Models; +using Microsoft.AspNetCore.Components; +using Wonky.Entity.Models; namespace Wonky.Client.Shared; -public partial class PoStateProvider +public partial class CartStateProvider { [Parameter] public RenderFragment ChildContent { get; set; } - public PurchaseOrder PurchaseOrder { get; set; } - [Parameter] public string Account { get; set; } = ""; + public Cart ShoppingCart { get; set; } + [Parameter] public string Account { get; set; } = "MyCart"; [Inject] public ILocalStorageService LocalStorageService { get; set; } - private bool hasLoaded; + private bool _hasLoaded; protected override async Task OnParametersSetAsync() { - PurchaseOrder = await LocalStorageService.GetItemAsync(Account); + ShoppingCart = await LocalStorageService.GetItemAsync(Account); - if (PurchaseOrder == null || PurchaseOrder.Lines.Count == 0) - PurchaseOrder = new PurchaseOrder(); + if (ShoppingCart == null || ShoppingCart.Items.Count == 0) + { + ShoppingCart = new Cart(); + } + else + { + if (DateTime.Now > ShoppingCart.LastAccessed.AddSeconds(ShoppingCart.TimeToLiveInSeconds)) + { + ShoppingCart = new Cart(); + } + } - hasLoaded = true; + ShoppingCart.LastAccessed = DateTime.Now; + _hasLoaded = true; } public async Task SaveChangesAsync() { - await LocalStorageService.SetItemAsync(Account, PurchaseOrder); + await LocalStorageService.SetItemAsync(Account, ShoppingCart); } } \ No newline at end of file diff --git a/Wonky.Client/Shared/MainLayout.razor b/Wonky.Client/Shared/MainLayout.razor index b9c05dd5..b68ccc79 100644 --- a/Wonky.Client/Shared/MainLayout.razor +++ b/Wonky.Client/Shared/MainLayout.razor @@ -15,6 +15,7 @@ // *@ @inherits LayoutComponentBase +@using Wonky.Client.Components