wip - krv
This commit is contained in:
parent
331a9fbcf7
commit
b741e2bb07
13 changed files with 220 additions and 5 deletions
|
@ -26,6 +26,7 @@
|
|||
<th scope="col"></th>
|
||||
<th scope="col"></th>
|
||||
<th scope="col"></th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -60,6 +61,11 @@
|
|||
<a class="btn btn-light border-dark pe-3 me-2" href="/companies/@task.ReferenceId">
|
||||
<i class="oi oi-pencil"></i>
|
||||
</a>
|
||||
}
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
@if (task.TaskTypeEnum is "Recall")
|
||||
{
|
||||
<button type="button" class="btn btn-primary" @onclick="() => CompleteTask(task.TaskItemId)">
|
||||
<i class="oi oi-map-marker"></i>
|
||||
</button>
|
||||
|
|
12
Wonky.Client/HttpRepository/IWorkplaceHttpRepository.cs
Normal file
12
Wonky.Client/HttpRepository/IWorkplaceHttpRepository.cs
Normal file
|
@ -0,0 +1,12 @@
|
|||
using Wonky.Entity.DTO;
|
||||
|
||||
namespace Wonky.Client.HttpRepository;
|
||||
|
||||
public interface IWorkplaceHttpRepository
|
||||
{
|
||||
Task<List<WorkplaceDto>> GetWorkplaces(string companyId);
|
||||
Task<WorkplaceDto> GetWorkplace(string companyId, string workplaceId);
|
||||
Task CreateWorkplace(string companyId, WorkplaceDto workplace);
|
||||
Task UpdateWorkplace(string companyId, WorkplaceDto workplace);
|
||||
Task DeleteWorkplace(string companyId, string workplaceId);
|
||||
}
|
64
Wonky.Client/HttpRepository/WorkplaceHttpRepository.cs
Normal file
64
Wonky.Client/HttpRepository/WorkplaceHttpRepository.cs
Normal file
|
@ -0,0 +1,64 @@
|
|||
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;
|
||||
|
||||
namespace Wonky.Client.HttpRepository;
|
||||
|
||||
public class WorkplaceHttpRepository : IWorkplaceHttpRepository
|
||||
{
|
||||
private readonly JsonSerializerOptions? _options = new JsonSerializerOptions
|
||||
{
|
||||
PropertyNameCaseInsensitive = true
|
||||
};
|
||||
|
||||
private readonly NavigationManager _navigation;
|
||||
private ILogger<WorkplaceHttpRepository> _logger;
|
||||
private readonly HttpClient _client;
|
||||
private readonly ApiConfig _api;
|
||||
|
||||
public WorkplaceHttpRepository(HttpClient client,
|
||||
ILogger<WorkplaceHttpRepository> logger,
|
||||
NavigationManager navigation,
|
||||
IOptions<ApiConfig> configuration)
|
||||
{
|
||||
_client = client;
|
||||
_logger = logger;
|
||||
_navigation = navigation;
|
||||
_api = configuration.Value;
|
||||
}
|
||||
|
||||
public async Task<List<WorkplaceDto>> GetWorkplaces(string companyId)
|
||||
{
|
||||
var result = await _client.GetFromJsonAsync<List<WorkplaceDto>>(
|
||||
$"{_api.CrmCustomer}/{companyId}/{_api.CrmWorkplace}", _options);
|
||||
return result ?? new List<WorkplaceDto>();
|
||||
}
|
||||
|
||||
public async Task<WorkplaceDto> GetWorkplace(string companyId, string workplaceId)
|
||||
{
|
||||
var result = await _client.GetFromJsonAsync<WorkplaceDto>(
|
||||
$"{_api.CrmCustomer}/{companyId}/{_api.CrmWorkplace}/{workplaceId}", _options);
|
||||
return result ?? new WorkplaceDto();
|
||||
}
|
||||
|
||||
public async Task CreateWorkplace(string companyId, WorkplaceDto workplace)
|
||||
{
|
||||
await _client.PostAsJsonAsync(
|
||||
$"{_api.CrmCustomer}/{companyId}/{_api.CrmWorkplace}", workplace, _options);
|
||||
}
|
||||
|
||||
public async Task UpdateWorkplace(string companyId, WorkplaceDto workplace)
|
||||
{
|
||||
await _client.PutAsJsonAsync(
|
||||
$"{_api.CrmCustomer}/{companyId}/{_api.CrmWorkplace}/{workplace.WorkplaceId}", workplace, _options);
|
||||
}
|
||||
|
||||
public async Task DeleteWorkplace(string companyId, string workplaceId)
|
||||
{
|
||||
await _client.DeleteAsync(
|
||||
$"{_api.CrmCustomer}/{companyId}/{_api.CrmWorkplace}/{workplaceId}");
|
||||
}
|
||||
}
|
|
@ -18,7 +18,6 @@
|
|||
@using Microsoft.AspNetCore.Authorization
|
||||
@using Microsoft.AspNetCore.Components
|
||||
@using Wonky.Client.Components
|
||||
@using Wonky.Client.Helpers
|
||||
@attribute [Authorize(Roles = "Advisor")]
|
||||
@page "/companies/{CompanyId}"
|
||||
|
||||
|
@ -202,6 +201,9 @@
|
|||
<div class="col">
|
||||
<a class="btn btn-light border-dark" href="/companies">Til Oversigt</a>
|
||||
</div>
|
||||
<div class="col">
|
||||
<a class="btn btn-light border-dark" href="/companies/@_company.CompanyId/workplaces">Kemi</a>
|
||||
</div>
|
||||
<div class="col">
|
||||
<a class="btn btn-light border-dark" href="/companies/@_company.CompanyId/h/i">Produktkøb</a>
|
||||
</div>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<TaskItemTableComponent TaskItemList="_taskItems" />
|
||||
<div class="card-body">
|
||||
<TaskItemTableComponent TaskItemList="_taskItems" />
|
||||
</div>
|
||||
</div>
|
24
Wonky.Client/Pages/WorkplaceListPage.razor
Normal file
24
Wonky.Client/Pages/WorkplaceListPage.razor
Normal file
|
@ -0,0 +1,24 @@
|
|||
@using Microsoft.AspNetCore.Authorization
|
||||
@attribute [Authorize(Roles = "Advisor")]
|
||||
@page "/companies/{CompanyId}/workplaces"
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="card-title">
|
||||
<h2>@_company.Name</h2>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@if (_workplaces.Any())
|
||||
{
|
||||
<ul class="list-group">
|
||||
@foreach (var workplace in _workplaces)
|
||||
{
|
||||
<a class="list-group-item list-group-item-action" href="/companies/@CompanyId/workplaces/@workplace.WorkplaceId">
|
||||
@workplace.Name @(!string.IsNullOrWhiteSpace(workplace.Description) ? $"- {workplace.Description}" : "")
|
||||
</a>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
</div>
|
||||
</div>
|
32
Wonky.Client/Pages/WorkplaceListPage.razor.cs
Normal file
32
Wonky.Client/Pages/WorkplaceListPage.razor.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using System.Text.Json;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Wonky.Client.HttpInterceptors;
|
||||
using Wonky.Client.HttpRepository;
|
||||
using Wonky.Entity.DTO;
|
||||
|
||||
namespace Wonky.Client.Pages;
|
||||
|
||||
public partial class WorkplaceListPage : IDisposable
|
||||
{
|
||||
[Parameter] public string CompanyId { get; set; } = "";
|
||||
[Inject] private IWorkplaceHttpRepository _workplaceRepo { get; set; }
|
||||
[Inject] private ICompanyHttpRepository _companyRepo { get; set; }
|
||||
[Inject] private HttpInterceptorService _interceptor { get; set; }
|
||||
private List<WorkplaceDto> _workplaces { get; set; } = new();
|
||||
private CompanyDto _company { get; set; } = new();
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
_interceptor.RegisterEvent();
|
||||
_interceptor.RegisterBeforeSendEvent();
|
||||
_company = await _companyRepo.GetCompanyById(CompanyId);
|
||||
_workplaces = await _workplaceRepo.GetWorkplaces(CompanyId);
|
||||
|
||||
Console.WriteLine(JsonSerializer.Serialize(_workplaces));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_interceptor.DisposeEvent();
|
||||
}
|
||||
}
|
26
Wonky.Client/Pages/WorkplaceViewPage.razor
Normal file
26
Wonky.Client/Pages/WorkplaceViewPage.razor
Normal file
|
@ -0,0 +1,26 @@
|
|||
@using Microsoft.AspNetCore.Authorization
|
||||
@attribute [Authorize(Roles = "Advisor")]
|
||||
@page "/companies/{CompanyId}/workplaces/{WorkplaceId}"
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<div class="card-title">
|
||||
<h2>@_company.Name</h2>
|
||||
<h3>@_workplace.Name @(!string.IsNullOrWhiteSpace(_workplace.Description) ? $"- {_workplace.Description}" : "" )</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div>
|
||||
@_workplace.WorkplaceId
|
||||
</div>
|
||||
<div>
|
||||
@_workplace.Name
|
||||
</div>
|
||||
<div>
|
||||
@_workplace.Description
|
||||
</div>
|
||||
<div>
|
||||
@_workplace.ShortUrl
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
33
Wonky.Client/Pages/WorkplaceViewPage.razor.cs
Normal file
33
Wonky.Client/Pages/WorkplaceViewPage.razor.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using System.Text.Json;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Wonky.Client.HttpInterceptors;
|
||||
using Wonky.Client.HttpRepository;
|
||||
using Wonky.Entity.DTO;
|
||||
|
||||
namespace Wonky.Client.Pages;
|
||||
|
||||
public partial class WorkplaceViewPage : IDisposable
|
||||
{
|
||||
[Parameter] public string CompanyId { get; set; } = "";
|
||||
[Parameter] public string WorkplaceId { get; set; } = "";
|
||||
[Inject] private IWorkplaceHttpRepository _workplaceRepo { get; set; }
|
||||
[Inject] private ICompanyHttpRepository _companyRepo { get; set; }
|
||||
[Inject] private HttpInterceptorService _interceptor { get; set; }
|
||||
private WorkplaceDto _workplace { get; set; } = new();
|
||||
private CompanyDto _company { get; set; } = new();
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
_interceptor.RegisterEvent();
|
||||
_interceptor.RegisterBeforeSendEvent();
|
||||
_company = await _companyRepo.GetCompanyById(CompanyId);
|
||||
_workplace = await _workplaceRepo.GetWorkplace(CompanyId, WorkplaceId);
|
||||
|
||||
Console.WriteLine(JsonSerializer.Serialize(_workplace));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_interceptor.DisposeEvent();
|
||||
}
|
||||
}
|
|
@ -58,6 +58,7 @@ builder.Services.AddScoped<IHistoryHttpRepository, HistoryHttpRepository>();
|
|||
builder.Services.AddScoped<IUserHttpRepository, UserHttpRepository>();
|
||||
builder.Services.AddScoped<IAdminReportHttpRepository, AdminReportHttpRepository>();
|
||||
builder.Services.AddScoped<IWarehouseHttpRepository, WarehouseHttpRepository>();
|
||||
builder.Services.AddScoped<IWorkplaceHttpRepository, WorkplaceHttpRepository>();
|
||||
|
||||
builder.Services.AddScoped<HttpInterceptorService>();
|
||||
builder.Services.AddBlazoredLocalStorage();
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
"image": "grumpy-coder.png"
|
||||
},
|
||||
"apiConfig": {
|
||||
"innoBaseUrl": "https://staging.innotec.dk",
|
||||
"innoBaseUrl": "https://dev.innotec.dk",
|
||||
"glsTrackUrl": "https://www.gls-group.eu/276-I-PORTAL-WEB/content/GLS/DK01/DA/5004.htm?txtAction=71000&txtRefNo=",
|
||||
"glsId": "",
|
||||
"serviceVirk": "api/v2/services/virk",
|
||||
|
@ -23,6 +23,7 @@
|
|||
"crmInventory": "history/inventory",
|
||||
"crmProduct": "history/products",
|
||||
"crmSync": "history/sync",
|
||||
"crmWorkplace": "workplaces",
|
||||
"adminUser": "api/v2/admin/users/advisors",
|
||||
"adminOffice": "api/v2/admin/users/office",
|
||||
"adminPasswd": "api/v2/admin/users/passwd",
|
||||
|
|
|
@ -96,6 +96,11 @@ public class ApiConfig
|
|||
/// </summary>
|
||||
public string CrmSync { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Application uri for getting workplace(s)
|
||||
/// </summary>
|
||||
public string CrmWorkplace { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Application uri for administration of sales representatives
|
||||
/// </summary>
|
||||
|
|
9
Wonky.Entity/DTO/WorkplaceDto.cs
Normal file
9
Wonky.Entity/DTO/WorkplaceDto.cs
Normal file
|
@ -0,0 +1,9 @@
|
|||
namespace Wonky.Entity.DTO;
|
||||
|
||||
public class WorkplaceDto
|
||||
{
|
||||
public string WorkplaceId { get; set; } = "";
|
||||
public string Name { get; set; } = "";
|
||||
public string Description { get; set; } = "";
|
||||
public string ShortUrl { get; set; } = "";
|
||||
}
|
Loading…
Reference in a new issue