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

View file

@ -14,6 +14,7 @@
// 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.Toast.Services;
using Microsoft.AspNetCore.Components;
@ -30,34 +31,59 @@ using Wonky.Entity.Views;
namespace Wonky.Client.Components;
public partial class Home : IDisposable
{
// [Inject] public ILocalStorageService Storage { get; set; }
[Inject] public UserPreferenceService UserPrefs { get; set; }
[Inject] public ILogger<Home> Logger { get; set; }
[Inject] private HttpInterceptorService Interceptor { get; set; }
[Inject] private UserPreferenceService _preferenceService { get; set; }
[Inject] private ILogger<Home> _logger { get; set; }
[Inject] private HttpInterceptorService _interceptor { 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 string _workDate { get; set; } = $"{DateTime.Now:yyyy-MM-dd}";
private List<TaskItemDto>? _taskItems { get; set; } = new();
protected override async Task OnInitializedAsync()
{
_prefs = await UserPrefs.GetPreferences();
_prefs = await _preferenceService.GetPreferences();
if(!string.IsNullOrWhiteSpace(_prefs.WorkDate))
_workDate = _prefs.WorkDate;
Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent();
_interceptor.RegisterEvent();
_interceptor.RegisterBeforeSendEvent();
await GetCalender(_workDate);
await GetTaskItems(_workDate);
}
private async Task GetCalender(string workDate)
private async Task GetTaskItems(string 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()
{
Interceptor.DisposeEvent();
_interceptor.DisposeEvent();
}
}

View file

@ -15,47 +15,31 @@
//
*@
@if (TaskItemList.Any())
@if (TaskItemList != null)
{
<div class="list-group list-group-flush">
<div class="list-group-item bg-black opacity-75 text-white">
<div class="row align-content-center">
<div class="col">
</div>
<div class="col">
</div>
<div class="col">
</div>
<div class="col">
</div>
</div>
</div>
<table class="table table-striped">
<thead>
<tr>
<th scope="col"></th>
<th scope="col"></th>
<th scope="col"></th>
<th scope="col"></th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
@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">
<div class="col">
@task.Name
</div>
<div class="col">
@task.DueTimestamp
</div>
<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>
<tr @onclick="() => ModifyTaskItem(task.TaskItemId)">
<td class="align-middle">@task.Description</td>
<td class="align-middle">@task.Name</td>
<td class="align-middle">@task.DueTimestamp</td>
<td class="align-middle"><button type="button" class="btn btn-primary" @onclick="() => ShowConfirmationModal(task.TaskItemId)">Slet</button></td>
<td class="align-middle"><button type="button" class="btn btn-danger" @onclick="() => TaskItemDone(task.TaskItemId)">Udført</button></td>
</tr>
}
</div>
</tbody>
</table>
}

View file

@ -25,27 +25,30 @@ namespace Wonky.Client.Components
{
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> OnSelect { get; set; }
[Parameter] public EventCallback<string> OnDone { get; set; }
[Inject] private HttpInterceptorService _interceptor { get; set; }
[Inject] private ITaskItemHttpRepository _taskRepo { get; set; }
[Inject] private NavigationManager _navigator { get; set; }
private Confirmation _confirmation = new ();
private string _taskItemId = "";
private void CallConfirmationModal(string taskItemId)
private void ShowConfirmationModal(string taskItemId)
{
_taskItemId = taskItemId;
_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);
}
private async Task DeleteTaskItem()
private async Task DeleteConfirmed(string taskItemId)
{
_confirmation.Hide();
await OnDelete.InvokeAsync(_taskItemId);

View file

@ -15,12 +15,16 @@
using Wonky.Client.Pages;
using Wonky.Entity.DTO;
namespace Wonky.Client.HttpRepository;
public interface ITaskItemHttpRepository
{
Task<List<TaskItemViewPage>?> GetTaskList();
Task CreateTaskItem(TaskItemViewPage taskItem);
Task<TaskItemViewPage?> GetTaskItem(string taskItemId);
Task<List<TaskItemDto>?> GetTaskList();
Task<List<TaskItemDto>?> GetTaskList(string workDate);
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 Wonky.Client.Pages;
using Wonky.Entity.Configuration;
using Wonky.Entity.DTO;
using Wonky.Entity.Views;
namespace Wonky.Client.HttpRepository;
@ -28,7 +29,8 @@ public class TaskItemHttpRepository : ITaskItemHttpRepository
{
private readonly JsonSerializerOptions _options = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
PropertyNameCaseInsensitive = true,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};
private readonly NavigationManager _navigation;
@ -45,19 +47,35 @@ public class TaskItemHttpRepository : ITaskItemHttpRepository
_navigation = navigation;
_apiConfig = configuration.Value;
}
public async Task<List<TaskItemDto>?> GetTaskList()
{
return await _client.GetFromJsonAsync<List<TaskItemDto>>($"{_apiConfig.TaskUri}", _options);
}
public async Task<List<TaskItemDto>?> GetTaskList(string workDate)
{
return await _client.GetFromJsonAsync<List<TaskItemDto>>($"{_apiConfig.TaskUri}/date/{workDate}", _options);
}
public async Task<TaskItemDto?> GetTaskItem(string taskItemId)
{
return await _client.GetFromJsonAsync<TaskItemDto>($"{_apiConfig.TaskUri}/{taskItemId}", _options);
}
public async Task<List<TaskItemViewPage>?> GetTaskList()
public async Task CreateTaskItem(TaskItemDto taskItem)
{
return await _client.GetFromJsonAsync<List<TaskItemViewPage>>($"{_apiConfig.TaskUri}");
await _client.PostAsJsonAsync($"{_apiConfig.TaskUri}", taskItem, _options);
}
public async Task CreateTaskItem(TaskItemViewPage taskItem)
public async Task UpdateTaskItem(string taskItemId, TaskItemDto taskItem)
{
await _client.PostAsJsonAsync($"{_apiConfig.TaskUri}", taskItem);
await _client.PutAsJsonAsync($"{_apiConfig.TaskUri}/{taskItemId}", taskItem, _options);
}
public async Task<TaskItemViewPage?> GetTaskItem(string taskItemId)
public async Task DeleteTaskItem(string taskItemId)
{
return await _client.GetFromJsonAsync<TaskItemViewPage>($"{_apiConfig.TaskUri}/{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"
<div class="card">

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,13 +1,13 @@
{
"appInfo": {
"name": "Wonky Client",
"version": "0.8.152",
"version": "0.8.153",
"isBeta": false,
"sandBox": false,
"image": "grumpy-coder.png"
},
"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=",
"glsId": "",
"virkUrl": "api/v2/services/virk",

View file

@ -13,7 +13,7 @@
<meta name="theme-color" content="#000">
<base href="/" />
<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="_content/Blazored.Toast/blazored-toast.min.css" rel="stylesheet" />
</head>

View file

@ -13,35 +13,55 @@
// 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;
public class TaskItemDto
{
/// <summary>
/// Task item entity Id
/// Task item entity id
/// </summary>
[MaxLength(36)]
public string TaskItemId { get; set; } = "";
/// <summary>
/// User entity Id
/// User entity id
/// </summary>
[MaxLength(36)]
public string ErpUserId { get; set; } = "";
/// <summary>
/// Reference entity id
/// </summary>
[Required(ErrorMessage = "Reference id skal angives")]
public string ReferenceId { get; set; } = "";
/// <summary>
/// Task name
/// </summary>
[Required(ErrorMessage = "Opgaven skal have et navn.")]
[MaxLength(128, ErrorMessage = "Der kan bruges 128 tegn.")]
public string Name { get; set; } = "";
/// <summary>
/// Task description
/// </summary>
public string Text { get; set; } = "";
[MaxLength(1000, ErrorMessage = "Der kan højst bruges 1000 tegn.")]
public string Description { get; set; } = "";
/// <summary>
/// Task due date
/// Task due date / time
/// </summary>
/// <remarks>Format "yyyy-MM-dd'T'HH:mm"</remarks>
public string DueTimestamp { get; set; } = "";
/// <summary>
/// Task type enum as string
/// </summary>
/// <value>None,Recall,Revision,Reminder</value>
public string TaskTypeEnum { get; set; } = "";
/// <summary>
/// Task interval
/// </summary>
@ -61,5 +81,6 @@ public class TaskItemDto
/// Recurring flag
/// </summary>
/// <value>Interval != 0</value>
public virtual bool Recurring { get; set; }
public bool Recurring { get; set; }
}