diff --git a/Wonky.Client/HttpRepository/IWorkplaceHttpRepository.cs b/Wonky.Client/HttpRepository/IWorkplaceHttpRepository.cs new file mode 100644 index 00000000..7c8c3e76 --- /dev/null +++ b/Wonky.Client/HttpRepository/IWorkplaceHttpRepository.cs @@ -0,0 +1,28 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using Wonky.Entity.DTO; +using Wonky.Entity.Views; + +namespace Wonky.Client.HttpRepository; + +public interface IWorkplaceHttpRepository +{ + Task> GetWorkplaces(string companyId); + Task GetWorkplace(string companyId, string workplaceId); + Task CreateWorkplace(string companyId, WorkplaceDto workplace); + Task UpdateWorkplace(string companyId, WorkplaceDto workplace); + Task DeleteWorkplace(string companyId, string workplaceId); +} \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/WorkplaceHttpRepository.cs b/Wonky.Client/HttpRepository/WorkplaceHttpRepository.cs new file mode 100644 index 00000000..7c0a9cfa --- /dev/null +++ b/Wonky.Client/HttpRepository/WorkplaceHttpRepository.cs @@ -0,0 +1,80 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using System.Net.Http.Json; +using System.Text.Json; +using Microsoft.AspNetCore.Components; +using Microsoft.Extensions.Options; +using Wonky.Entity.Configuration; +using Wonky.Entity.DTO; +using Wonky.Entity.Views; + +namespace Wonky.Client.HttpRepository; + +public class WorkplaceHttpRepository : IWorkplaceHttpRepository +{ + private readonly JsonSerializerOptions? _options = new JsonSerializerOptions + { + PropertyNameCaseInsensitive = true + }; + + private readonly NavigationManager _navigation; + private ILogger _logger; + private readonly HttpClient _client; + private readonly ApiConfig _api; + + public WorkplaceHttpRepository(HttpClient client, + ILogger logger, + NavigationManager navigation, + IOptions configuration) + { + _client = client; + _logger = logger; + _navigation = navigation; + _api = configuration.Value; + } + + public async Task> GetWorkplaces(string companyId) + { + var result = await _client.GetFromJsonAsync>( + $"{_api.CrmCustomers}/{companyId}/{_api.CrmWorkplaceExt}", _options); + return result ?? new List(); + } + + public async Task GetWorkplace(string companyId, string workplaceId) + { + var result = await _client.GetFromJsonAsync( + $"{_api.CrmCustomers}/{companyId}/{_api.CrmWorkplaceExt}/{workplaceId}", _options); + return result ?? new WorkplaceDto(); + } + + public async Task CreateWorkplace(string companyId, WorkplaceDto workplace) + { + await _client.PostAsJsonAsync( + $"{_api.CrmCustomers}/{companyId}/{_api.CrmWorkplaceExt}", workplace, _options); + } + + public async Task UpdateWorkplace(string companyId, WorkplaceDto workplace) + { + await _client.PutAsJsonAsync( + $"{_api.CrmCustomers}/{companyId}/{_api.CrmWorkplaceExt}/{workplace.WorkplaceId}", workplace, _options); + } + + public async Task DeleteWorkplace(string companyId, string workplaceId) + { + await _client.DeleteAsync( + $"{_api.CrmCustomers}/{companyId}/{_api.CrmWorkplaceExt}/{workplaceId}"); + } +} \ No newline at end of file diff --git a/Wonky.Client/Pages/KrvItemViewPage.razor b/Wonky.Client/Pages/KrvItemViewPage.razor new file mode 100644 index 00000000..89f03ffa --- /dev/null +++ b/Wonky.Client/Pages/KrvItemViewPage.razor @@ -0,0 +1,68 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + +@page "/krv/{CountryCode}/items/{salesItemId}" +@using Microsoft.AspNetCore.Authorization +@attribute [Authorize(Roles = "Advisor,Advisor")] + + +
+
+

@_item.Name

+
+
+ + + + + + + + + + + + + + + + + + + +
Navn@_item.Name
Varenr@_item.Sku
@_item.ProductGroup
Kort Navn@_item.ShortName
+ + + + + + + + @foreach (var rate in _item.Rates) + { + + + + + } + +
Priser
@rate.Quantity@rate.Rate
+
+ +
\ No newline at end of file diff --git a/Wonky.Client/Pages/KrvItemViewPage.razor.cs b/Wonky.Client/Pages/KrvItemViewPage.razor.cs new file mode 100644 index 00000000..c73cdc69 --- /dev/null +++ b/Wonky.Client/Pages/KrvItemViewPage.razor.cs @@ -0,0 +1,53 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using Wonky.Client.HttpInterceptors; +using Wonky.Client.HttpRepository; +using Microsoft.AspNetCore.Components; +using Wonky.Entity.Views; + +#pragma warning disable CS8618 +namespace Wonky.Client.Pages; + +public partial class KrvItemViewPage : IDisposable +{ + // ################################################################## + [Inject] private ICountryCatalogRepository _itemRepo { get; set; } + [Inject] private HttpInterceptorService _interceptor { get; set; } + + // ################################################################## + [Parameter] public string SalesItemId { get; set; } = ""; + [Parameter] public string CountryCode { get; set; } = ""; + + // ################################################################## + private SalesItemView _item { get; set; } = new (); + + + protected override async Task OnInitializedAsync() + { + _interceptor.RegisterEvent(); + _interceptor.RegisterBeforeSendEvent(); + _item = await _itemRepo.GetSalesItemId(CountryCode, SalesItemId); + } + + + /// + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. + /// + public void Dispose() + { + _interceptor!.DisposeEvent(); + } +} \ No newline at end of file diff --git a/Wonky.Client/Pages/KrvItemViewPage.razor.css b/Wonky.Client/Pages/KrvItemViewPage.razor.css new file mode 100644 index 00000000..50839936 --- /dev/null +++ b/Wonky.Client/Pages/KrvItemViewPage.razor.css @@ -0,0 +1,10 @@ +/* item image preview */ +.image-name { + margin-left: 10px; +} +.image-preview { + width: auto; + max-width: 200px; + height: 100px; + margin-top: 15px; +} \ No newline at end of file diff --git a/Wonky.Client/Pages/WorkplaceDocumentListPage.razor b/Wonky.Client/Pages/WorkplaceDocumentListPage.razor new file mode 100644 index 00000000..ff79843b --- /dev/null +++ b/Wonky.Client/Pages/WorkplaceDocumentListPage.razor @@ -0,0 +1,6 @@ +@using Microsoft.AspNetCore.Authorization +@using Wonky.Client.Components +@attribute [Authorize(Roles = "Advisor")] +@page "/advisor/customers//{CompanyId}/workplaces/{WorkplaceId}/documents" + +

Dokumenter

\ No newline at end of file diff --git a/Wonky.Client/Pages/WorkplaceDocumentListPage.razor.cs b/Wonky.Client/Pages/WorkplaceDocumentListPage.razor.cs new file mode 100644 index 00000000..16c5c26f --- /dev/null +++ b/Wonky.Client/Pages/WorkplaceDocumentListPage.razor.cs @@ -0,0 +1,35 @@ +using Microsoft.AspNetCore.Components; +using Wonky.Client.HttpInterceptors; +using Wonky.Client.HttpRepository; +using Wonky.Entity.DTO; + +#pragma warning disable CS8618 + +namespace Wonky.Client.Pages; + +public partial class WorkplaceDocumentListPage : IDisposable +{ + // ############################################################## + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private IWorkplaceHttpRepository WorkplaceRepo { get; set; } + + // ############################################################## + [Parameter] public string CompanyId { get; set; } = ""; + [Parameter] public string WorkplaceId { get; set; } = ""; + + // ############################################################## + private WorkplaceDto Workplace { get; set; } = new(); + + + protected override async Task OnParametersSetAsync() + { + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); + + } + + public void Dispose() + { + Interceptor.DisposeEvent(); + } +} \ No newline at end of file diff --git a/Wonky.Client/Pages/WorkplaceListPage.razor b/Wonky.Client/Pages/WorkplaceListPage.razor new file mode 100644 index 00000000..17849fb8 --- /dev/null +++ b/Wonky.Client/Pages/WorkplaceListPage.razor @@ -0,0 +1,30 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + +@using Microsoft.AspNetCore.Authorization +@using Wonky.Client.Components +@attribute [Authorize(Roles = "Advisor")] +@page "/advisor/customers/{CompanyId}/workplaces" + +
+
+

@Customer.Name

+
+
+
+ +
\ No newline at end of file diff --git a/Wonky.Client/Pages/WorkplaceListPage.razor.cs b/Wonky.Client/Pages/WorkplaceListPage.razor.cs new file mode 100644 index 00000000..0088fe6d --- /dev/null +++ b/Wonky.Client/Pages/WorkplaceListPage.razor.cs @@ -0,0 +1,60 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + + +using Microsoft.AspNetCore.Components; +using Wonky.Client.HttpInterceptors; +using Wonky.Client.HttpRepository; +using Wonky.Entity.DTO; +using Wonky.Entity.Views; + +#pragma warning disable CS8618 +namespace Wonky.Client.Pages; + +public partial class WorkplaceListPage : IDisposable +{ + // ############################################################## + [Inject] private IWorkplaceHttpRepository WorkplaceRepo { get; set; } + [Inject] private IAdvisorCustomerRepository CustomerRepo { get; set; } + [Inject] private HttpInterceptorService Interceptor { get; set; } + + + // ############################################################## + [Parameter] public string CompanyId { get; set; } = ""; + + // ############################################################## + private List Workplaces { get; set; } = new(); + private CompanyDto Customer { get; set; } = new(); + + + protected override async Task OnParametersSetAsync() + { + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); + Customer = await CustomerRepo.GetCompanyById(CompanyId); + } + + + protected override async Task OnInitializedAsync() + { + Workplaces = await WorkplaceRepo.GetWorkplaces(CompanyId); + } + + + public void Dispose() + { + Interceptor.DisposeEvent(); + } +} \ No newline at end of file diff --git a/Wonky.Client/Pages/WorkplaceViewPage.razor b/Wonky.Client/Pages/WorkplaceViewPage.razor new file mode 100644 index 00000000..f0175d74 --- /dev/null +++ b/Wonky.Client/Pages/WorkplaceViewPage.razor @@ -0,0 +1,121 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + + +@using Microsoft.AspNetCore.Authorization +@attribute [Authorize(Roles = "Advisor")] +@page "/advisor/customers/{CompanyId}/workplaces/{WorkplaceId}" + +
+
+
+

@Workplace.CompanyName

+

@Workplace.Name @(!string.IsNullOrWhiteSpace(Workplace.Description) ? $"- {Workplace.Description}" : "")

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Stamdata +
Navn + + + Beskrivelse + + +
Placering og Opbevaring
Produkter + + +
Masker + + + Øjenskylleflaske + + +
Handsker + + + Førstehjælp + + +
Sikkerhedsbriller + + +
Affald + + +
+
+
+ +
+
+ +
+ +
+
+
+
\ No newline at end of file diff --git a/Wonky.Client/Pages/WorkplaceViewPage.razor.cs b/Wonky.Client/Pages/WorkplaceViewPage.razor.cs new file mode 100644 index 00000000..2c4a3b13 --- /dev/null +++ b/Wonky.Client/Pages/WorkplaceViewPage.razor.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 GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + + +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Forms; +using Wonky.Client.HttpInterceptors; +using Wonky.Client.HttpRepository; +using Wonky.Entity.DTO; + +#pragma warning disable CS8618 + +namespace Wonky.Client.Pages; + +public partial class WorkplaceViewPage : IDisposable +{ + // ##############################################################33333 + [Inject] private IWorkplaceHttpRepository WorkplaceRepo { get; set; } + [Inject] private IAdvisorCustomerRepository CustomerRepo { get; set; } + [Inject] private HttpInterceptorService Interceptor { get; set; } + [Inject] private NavigationManager Navigator { get; set; } + + // ##############################################################33333 + [Parameter] public string CompanyId { get; set; } = ""; + [Parameter] public string WorkplaceId { get; set; } = ""; + + // ##############################################################33333 + private WorkplaceDto Workplace { get; set; } = new(); + private EditContext WorkplaceContext { get; set; } + + + protected override async Task OnParametersSetAsync() + { + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); + Workplace = await WorkplaceRepo.GetWorkplace(CompanyId, WorkplaceId); + } + + + protected override void OnInitialized() + { + WorkplaceContext = new EditContext(Workplace); + } + + + private async Task SubmitUpdate() + { + await WorkplaceRepo.UpdateWorkplace(CompanyId, Workplace); + } + + + private async Task DeleteWorkplace() + { + await WorkplaceRepo.DeleteWorkplace(CompanyId, Workplace.WorkplaceId); + Navigator.NavigateTo($"/companies/{CompanyId}/workplaces"); + } + + + public void Dispose() + { + Interceptor.DisposeEvent(); + } +} \ No newline at end of file