This commit is contained in:
Frede Hundewadt 2022-07-09 17:43:52 +02:00
parent 56bd2d25a7
commit e6e0c2b326
16 changed files with 160 additions and 92 deletions

View file

@ -16,21 +16,21 @@
*@ *@
@using Microsoft.AspNetCore.Authorization @using Microsoft.AspNetCore.Authorization
<PageTitle>Inno Web CRM</PageTitle> @using Wonky.Client.Components
<PageTitle>Inno Web CRM</PageTitle>
<AuthorizeView Roles="Adviser"> <AuthorizeView Roles="Adviser">
<div class="card"> <div class="alert bg-light border-dark">
<div class="card-header"> <div class="row">
<div class="row"> <div class="col">
<div class="col"> <h2 class="workDate">@(DateTime.Parse(_workDate).ToLongDateString())</h2>
<h2 class="workDate">@(DateTime.Parse(_workDate).ToLongDateString())</h2> </div>
</div> <div class="col">
<div class="col"> <WorkDateComponent OnChanged="GetTaskItems"></WorkDateComponent>
<WorkDateComponent OnChanged="GetCalender"></WorkDateComponent>
</div>
</div> </div>
</div> </div>
</div> </div>
<TaskItemTableComponent TaskItemList="_taskItems" OnDelete="OnDeleteConfirmed" OnDone="OnDoneClicked"></TaskItemTableComponent>
</AuthorizeView> </AuthorizeView>
<AuthorizeView Roles="Admin"> <AuthorizeView Roles="Admin">
<h2>Administrator</h2> <h2>Administrator</h2>

View file

@ -14,6 +14,7 @@
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
// //
using System.Text.Json;
using Blazored.LocalStorage; using Blazored.LocalStorage;
using Blazored.Toast.Services; using Blazored.Toast.Services;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
@ -30,34 +31,59 @@ using Wonky.Entity.Views;
namespace Wonky.Client.Components; namespace Wonky.Client.Components;
public partial class Home : IDisposable public partial class Home : IDisposable
{ {
// [Inject] public ILocalStorageService Storage { get; set; } [Inject] private UserPreferenceService _preferenceService { get; set; }
[Inject] public UserPreferenceService UserPrefs { get; set; } [Inject] private ILogger<Home> _logger { get; set; }
[Inject] public ILogger<Home> Logger { get; set; } [Inject] private HttpInterceptorService _interceptor { get; set; }
[Inject] private HttpInterceptorService Interceptor { get; set; }
[Inject] private IToastService _toast { get; set; } [Inject] private IToastService _toast { get; set; }
[Inject] private ITaskItemHttpRepository _taskItemRepo { get; set; }
private readonly JsonSerializerOptions _options = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
private Preferences _prefs { get; set; } = new(); private Preferences _prefs { get; set; } = new();
private string _workDate { get; set; } = $"{DateTime.Now:yyyy-MM-dd}"; private string _workDate { get; set; } = $"{DateTime.Now:yyyy-MM-dd}";
private List<TaskItemDto>? _taskItems { get; set; } = new();
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
_prefs = await UserPrefs.GetPreferences(); _prefs = await _preferenceService.GetPreferences();
if(!string.IsNullOrWhiteSpace(_prefs.WorkDate)) if(!string.IsNullOrWhiteSpace(_prefs.WorkDate))
_workDate = _prefs.WorkDate; _workDate = _prefs.WorkDate;
Interceptor.RegisterEvent(); _interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent(); _interceptor.RegisterBeforeSendEvent();
await GetCalender(_workDate); await GetTaskItems(_workDate);
} }
private async Task GetCalender(string workDate) private async Task GetTaskItems(string workDate)
{ {
_workDate = workDate; _workDate = workDate;
_taskItems = await _taskItemRepo.GetTaskList(workDate);
}
private async Task OnDoneClicked(string taskItemId)
{
// var item = _taskItems.Find(x => x.TaskItemId == taskItemId);
// item.IsCompleted = true;
_logger.LogDebug("MarkAsDone TaskItemId => {}", taskItemId);
//await _taskItemRepo.UpdateTaskItem(taskItemId, item);
}
private async Task OnDeleteConfirmed(string taskItemId)
{
_logger.LogDebug("Delete TaskItemId => {}", taskItemId);
//await _taskItemRepo.DeleteTaskItem(taskItemId);
} }
public void Dispose() public void Dispose()
{ {
Interceptor.DisposeEvent(); _interceptor.DisposeEvent();
} }
} }

View file

@ -15,47 +15,31 @@
// //
*@ *@
@if (TaskItemList.Any()) @if (TaskItemList != null)
{ {
<div class="list-group list-group-flush"> <table class="table table-striped">
<div class="list-group-item bg-black opacity-75 text-white"> <thead>
<div class="row align-content-center"> <tr>
<div class="col"> <th scope="col"></th>
<th scope="col"></th>
</div> <th scope="col"></th>
<div class="col"> <th scope="col"></th>
<th scope="col"></th>
</div> </tr>
<div class="col"> </thead>
<tbody>
</div>
<div class="col">
</div>
</div>
</div>
@foreach (var task in TaskItemList) @foreach (var task in TaskItemList)
{ {
<a class="list-group-item list-group-item-action" href="/task-items/@task.TaskItemId">
<div class="row align-items-center"> <tr @onclick="() => ModifyTaskItem(task.TaskItemId)">
<div class="col"> <td class="align-middle">@task.Description</td>
@task.Name <td class="align-middle">@task.Name</td>
</div> <td class="align-middle">@task.DueTimestamp</td>
<div class="col"> <td class="align-middle"><button type="button" class="btn btn-primary" @onclick="() => ShowConfirmationModal(task.TaskItemId)">Slet</button></td>
@task.DueTimestamp <td class="align-middle"><button type="button" class="btn btn-danger" @onclick="() => TaskItemDone(task.TaskItemId)">Udført</button></td>
</div> </tr>
<div class="col">
@(task.Text[..50]) ...
</div>
<div class="col">
<button class="btn btn-primary" @onclick="() => CallConfirmationModal(task.TaskItemId)">Afslut</button>
</div>
<div class="col">
<button class="btn btn-danger" @onclick="() => CloseTaskItem(task.TaskItemId)">Slet</button>
</div>
</div>
</a>
} }
</div>
</tbody>
</table>
} }

View file

@ -25,27 +25,30 @@ namespace Wonky.Client.Components
{ {
public partial class TaskItemTableComponent public partial class TaskItemTableComponent
{ {
[Parameter] public List<TaskItemDto> TaskItemList { get; set; } = new(); [Parameter] public List<TaskItemDto>? TaskItemList { get; set; }
[Parameter] public EventCallback<string> OnDelete { get; set; } [Parameter] public EventCallback<string> OnDelete { get; set; }
[Parameter] public EventCallback<string> OnSelect { get; set; }
[Parameter] public EventCallback<string> OnDone { get; set; } [Parameter] public EventCallback<string> OnDone { get; set; }
[Inject] private NavigationManager _navigator { get; set; }
[Inject] private HttpInterceptorService _interceptor { get; set; }
[Inject] private ITaskItemHttpRepository _taskRepo { get; set; }
private Confirmation _confirmation = new (); private Confirmation _confirmation = new ();
private string _taskItemId = ""; private string _taskItemId = "";
private void CallConfirmationModal(string taskItemId) private void ShowConfirmationModal(string taskItemId)
{ {
_taskItemId = taskItemId; _taskItemId = taskItemId;
_confirmation.Show(); _confirmation.Show();
} }
private async Task CloseTaskItem(string taskItemId) private void ModifyTaskItem(string taskItemId)
{
_navigator.NavigateTo($"/task-items/{taskItemId}");
}
private async Task TaskItemDone(string taskItemId)
{ {
await OnDone.InvokeAsync(_taskItemId); await OnDone.InvokeAsync(_taskItemId);
} }
private async Task DeleteTaskItem() private async Task DeleteConfirmed(string taskItemId)
{ {
_confirmation.Hide(); _confirmation.Hide();
await OnDelete.InvokeAsync(_taskItemId); await OnDelete.InvokeAsync(_taskItemId);

View file

@ -15,12 +15,16 @@
using Wonky.Client.Pages; using Wonky.Client.Pages;
using Wonky.Entity.DTO;
namespace Wonky.Client.HttpRepository; namespace Wonky.Client.HttpRepository;
public interface ITaskItemHttpRepository public interface ITaskItemHttpRepository
{ {
Task<List<TaskItemViewPage>?> GetTaskList(); Task<List<TaskItemDto>?> GetTaskList();
Task CreateTaskItem(TaskItemViewPage taskItem); Task<List<TaskItemDto>?> GetTaskList(string workDate);
Task<TaskItemViewPage?> GetTaskItem(string taskItemId); Task<TaskItemDto?> GetTaskItem(string taskItemId);
Task CreateTaskItem(TaskItemDto taskItem);
Task UpdateTaskItem(string taskItemId, TaskItemDto taskItem);
Task DeleteTaskItem(string taskItemId);
} }

View file

@ -20,6 +20,7 @@ using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Wonky.Client.Pages; using Wonky.Client.Pages;
using Wonky.Entity.Configuration; using Wonky.Entity.Configuration;
using Wonky.Entity.DTO;
using Wonky.Entity.Views; using Wonky.Entity.Views;
namespace Wonky.Client.HttpRepository; namespace Wonky.Client.HttpRepository;
@ -28,7 +29,8 @@ public class TaskItemHttpRepository : ITaskItemHttpRepository
{ {
private readonly JsonSerializerOptions _options = new JsonSerializerOptions private readonly JsonSerializerOptions _options = new JsonSerializerOptions
{ {
PropertyNameCaseInsensitive = true PropertyNameCaseInsensitive = true,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
}; };
private readonly NavigationManager _navigation; private readonly NavigationManager _navigation;
@ -46,18 +48,34 @@ public class TaskItemHttpRepository : ITaskItemHttpRepository
_apiConfig = configuration.Value; _apiConfig = configuration.Value;
} }
public async Task<List<TaskItemViewPage>?> GetTaskList()
public async Task<List<TaskItemDto>?> GetTaskList()
{ {
return await _client.GetFromJsonAsync<List<TaskItemViewPage>>($"{_apiConfig.TaskUri}"); return await _client.GetFromJsonAsync<List<TaskItemDto>>($"{_apiConfig.TaskUri}", _options);
} }
public async Task CreateTaskItem(TaskItemViewPage taskItem) public async Task<List<TaskItemDto>?> GetTaskList(string workDate)
{ {
await _client.PostAsJsonAsync($"{_apiConfig.TaskUri}", taskItem); return await _client.GetFromJsonAsync<List<TaskItemDto>>($"{_apiConfig.TaskUri}/date/{workDate}", _options);
} }
public async Task<TaskItemViewPage?> GetTaskItem(string taskItemId) public async Task<TaskItemDto?> GetTaskItem(string taskItemId)
{ {
return await _client.GetFromJsonAsync<TaskItemViewPage>($"{_apiConfig.TaskUri}/{taskItemId}"); return await _client.GetFromJsonAsync<TaskItemDto>($"{_apiConfig.TaskUri}/{taskItemId}", _options);
}
public async Task CreateTaskItem(TaskItemDto taskItem)
{
await _client.PostAsJsonAsync($"{_apiConfig.TaskUri}", taskItem, _options);
}
public async Task UpdateTaskItem(string taskItemId, TaskItemDto taskItem)
{
await _client.PutAsJsonAsync($"{_apiConfig.TaskUri}/{taskItemId}", taskItem, _options);
}
public async Task DeleteTaskItem(string taskItemId)
{
await _client.DeleteAsync($"{_apiConfig.TaskUri}/{taskItemId}");
} }
} }

View file

@ -15,6 +15,8 @@
// //
*@ *@
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize(Roles = "Admin")]
@page "/admin/users/advisers" @page "/admin/users/advisers"
<div class="card"> <div class="card">

View file

@ -15,6 +15,8 @@
// //
*@ *@
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize(Roles = "Admin")]
@page "/admin/users/office" @page "/admin/users/office"
<div class="card"> <div class="card">

View file

@ -16,6 +16,8 @@
*@ *@
@using Wonky.Client.Components @using Wonky.Client.Components
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize(Roles = "Adviser")]
@page "/companies/{CompanyId}/h/p/{Sku}" @page "/companies/{CompanyId}/h/p/{Sku}"
<div class="card"> <div class="card">

View file

@ -16,6 +16,8 @@
*@ *@
@using Wonky.Client.Components @using Wonky.Client.Components
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize(Roles = "Adviser")]
@page "/companies/{CompanyId}/h/p" @page "/companies/{CompanyId}/h/p"
<div class="card"> <div class="card">

View file

@ -16,6 +16,8 @@
*@ *@
@using Wonky.Client.Components @using Wonky.Client.Components
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize(Roles = "Adviser")]
@page "/task-items" @page "/task-items"
<div class="card"> <div class="card">
@ -34,5 +36,5 @@
</div> </div>
</div> </div>
<div class="card-body"> <div class="card-body">
<TaskItemsTableComponent Activities="_view.Activities"></TaskItemsTableComponent> <TaskItemTableComponent TaskItemList="_taskItems" />
</div> </div>

View file

@ -19,6 +19,7 @@ using Wonky.Client.Components;
using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpInterceptors;
using Wonky.Client.HttpRepository; using Wonky.Client.HttpRepository;
using Wonky.Client.Services; using Wonky.Client.Services;
using Wonky.Entity.DTO;
using Wonky.Entity.Views; using Wonky.Entity.Views;
namespace Wonky.Client.Pages; namespace Wonky.Client.Pages;
@ -29,11 +30,12 @@ public partial class TaskItemListPage : IDisposable
[Inject] public ILogger<Home> Logger { get; set; } [Inject] public ILogger<Home> Logger { get; set; }
[Inject] private HttpInterceptorService _interceptor { get; set; } [Inject] private HttpInterceptorService _interceptor { get; set; }
[Inject] private NavigationManager _navigator { get; set; } [Inject] private NavigationManager _navigator { get; set; }
[Inject] private ITaskItemHttpRepository _activityRepo { get; set; } [Inject] private ITaskItemHttpRepository _taskItemRepo { get; set; }
[Inject] private IToastService _toast { get; set; } [Inject] private IToastService _toast { get; set; }
private Preferences _prefs { get; set; } = new(); private Preferences _prefs { get; set; } = new();
private string _workDate { get; set; } = $"{DateTime.Now:yyyy-MM-dd}"; private string _workDate { get; set; } = $"{DateTime.Now:yyyy-MM-dd}";
private bool _reportExist = false; private bool _reportExist = false;
private List<TaskItemDto>? _taskItems { get; set; } = new();
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
@ -49,7 +51,7 @@ public partial class TaskItemListPage : IDisposable
private async Task GetTaskItems(string workDate) private async Task GetTaskItems(string workDate)
{ {
_toast.ShowInfo("Vent nogle sekunder for data"); _toast.ShowInfo("Vent nogle sekunder for data");
_workDate = workDate; _taskItems = await _taskItemRepo.GetTaskList(workDate);
} }
public void Dispose() public void Dispose()
{ {

View file

@ -1,13 +1,13 @@
{ {
"appInfo": { "appInfo": {
"name": "Wonky Client", "name": "Wonky Client",
"version": "0.8.152", "version": "0.8.153",
"isBeta": false, "isBeta": false,
"sandBox": false, "sandBox": false,
"image": "grumpy-coder.png" "image": "grumpy-coder.png"
}, },
"apiConfig": { "apiConfig": {
"innoBaseUrl": "https://production.innotec.dk", "innoBaseUrl": "https://staging.innotec.dk",
"glsTrackUrl": "https://www.gls-group.eu/276-I-PORTAL-WEB/content/GLS/DK01/DA/5004.htm?txtAction=71000&txtRefNo=", "glsTrackUrl": "https://www.gls-group.eu/276-I-PORTAL-WEB/content/GLS/DK01/DA/5004.htm?txtAction=71000&txtRefNo=",
"glsId": "", "glsId": "",
"virkUrl": "api/v2/services/virk", "virkUrl": "api/v2/services/virk",

View file

@ -13,7 +13,7 @@
<meta name="theme-color" content="#000"> <meta name="theme-color" content="#000">
<base href="/" /> <base href="/" />
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet"> <link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="css/app-152.css" rel="stylesheet" /> <link href="css/app.css" rel="stylesheet" />
<link href="Wonky.Client.styles.css" rel="stylesheet" /> <link href="Wonky.Client.styles.css" rel="stylesheet" />
<link href="_content/Blazored.Toast/blazored-toast.min.css" rel="stylesheet" /> <link href="_content/Blazored.Toast/blazored-toast.min.css" rel="stylesheet" />
</head> </head>

View file

@ -13,35 +13,55 @@
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
// //
using System.ComponentModel.DataAnnotations;
namespace Wonky.Entity.DTO; namespace Wonky.Entity.DTO;
public class TaskItemDto public class TaskItemDto
{ {
/// <summary> /// <summary>
/// Task item entity Id /// Task item entity id
/// </summary> /// </summary>
[MaxLength(36)]
public string TaskItemId { get; set; } = ""; public string TaskItemId { get; set; } = "";
/// <summary> /// <summary>
/// User entity Id /// User entity id
/// </summary> /// </summary>
[MaxLength(36)]
public string ErpUserId { get; set; } = ""; public string ErpUserId { get; set; } = "";
/// <summary>
/// Reference entity id
/// </summary>
[Required(ErrorMessage = "Reference id skal angives")]
public string ReferenceId { get; set; } = "";
/// <summary> /// <summary>
/// Task name /// Task name
/// </summary> /// </summary>
[Required(ErrorMessage = "Opgaven skal have et navn.")]
[MaxLength(128, ErrorMessage = "Der kan bruges 128 tegn.")]
public string Name { get; set; } = ""; public string Name { get; set; } = "";
/// <summary> /// <summary>
/// Task description /// Task description
/// </summary> /// </summary>
public string Text { get; set; } = ""; [MaxLength(1000, ErrorMessage = "Der kan højst bruges 1000 tegn.")]
public string Description { get; set; } = "";
/// <summary> /// <summary>
/// Task due date /// Task due date / time
/// </summary> /// </summary>
/// <remarks>Format "yyyy-MM-dd'T'HH:mm"</remarks>
public string DueTimestamp { get; set; } = ""; public string DueTimestamp { get; set; } = "";
/// <summary>
/// Task type enum as string
/// </summary>
/// <value>None,Recall,Revision,Reminder</value>
public string TaskTypeEnum { get; set; } = "";
/// <summary> /// <summary>
/// Task interval /// Task interval
/// </summary> /// </summary>
@ -61,5 +81,6 @@ public class TaskItemDto
/// Recurring flag /// Recurring flag
/// </summary> /// </summary>
/// <value>Interval != 0</value> /// <value>Interval != 0</value>
public virtual bool Recurring { get; set; } public bool Recurring { get; set; }
} }