PRODUCTION - v.138.2

This commit is contained in:
Frede Hundewadt 2023-04-26 17:00:53 +02:00
parent 568baf098d
commit a6e4d0748b
32 changed files with 557 additions and 377 deletions

View file

@ -1,16 +0,0 @@
using Wonky.Entity.DTO;
using Wonky.Entity.Views;
namespace Wonky.Client.HttpRepository;
public interface IMemberSupportRepository
{
Task<ManagerView> GetManagerByUserId(string userId);
Task<MemberView> GetMemberByUserId(string userId);
Task<List<EvaluationEditView>> GetEvaluationsByManagerId(string managerId);
Task<List<EvaluationEditView>> GetEvaluationsByMemberId(string memberId);
Task<EvaluationEditView> GetById(string evaluationId);
Task<EvaluationEditView> CreateEvaluation(EvaluationEditView evaluationEditView);
Task<EvaluationEditView> UpdateEvaluation(string evaluationId, EvaluationEditView evaluationEditView);
Task DeleteEvaluation(string evaluationId);
}

View file

@ -0,0 +1,14 @@
using Wonky.Entity.DTO;
using Wonky.Entity.Views;
namespace Wonky.Client.HttpRepository;
public interface ISupportDocumentRepository
{
Task<List<SupportDocumentEditView>> GetDocumentsBySupervisorId(string supervisorId);
Task<List<SupportDocumentEditView>> GetDocumentsByAdvisorId(string advisorId);
Task<SupportDocumentEditView> GetById(string documentId);
Task<SupportDocumentEditView> CreateDocument(SupportDocumentEditView model);
Task<SupportDocumentEditView> UpdateDocument(string documentId, SupportDocumentEditView model);
Task DeleteDocument(string documentId);
}

View file

@ -0,0 +1,10 @@
using Wonky.Entity.DTO;
using Wonky.Entity.Views;
namespace Wonky.Client.HttpRepository;
public interface ISupportManagementRepository
{
Task<SupportSupervisorView> GetSupervisorByUserId(string userId);
Task<SupportAdvisorView> GetAdvisorByUserId(string userId);
}

View file

@ -1,133 +0,0 @@
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 MemberSupportRepository : IMemberSupportRepository
{
private readonly JsonSerializerOptions? _options = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
};
private readonly NavigationManager _navigation;
private readonly ILogger<MemberSupportRepository> _logger;
private readonly HttpClient _client;
private readonly ApiConfig _api;
public MemberSupportRepository(HttpClient client,
ILogger<MemberSupportRepository> logger,
NavigationManager navigation, IOptions<ApiConfig> configuration)
{
_client = client;
_logger = logger;
_navigation = navigation;
_api = configuration.Value;
}
public async Task<ManagerView> GetManagerByUserId(string userId)
{
var result = await _client
.GetAsync($"{_api.UserSupport}/user/manager/{userId}");
var content = await result.Content.ReadAsStringAsync();
if (!result.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content))
{
return new ManagerView();
}
return JsonSerializer.Deserialize<ManagerView>(content, _options) ?? new ManagerView();
}
public async Task<MemberView> GetMemberByUserId(string userId)
{
var result = await _client
.GetAsync($"{_api.UserSupport}/user/member/{userId}");
var content = await result.Content.ReadAsStringAsync();
if (!result.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content))
{
return new MemberView();
}
return JsonSerializer.Deserialize<MemberView>(content, _options) ?? new MemberView();
}
public async Task<List<EvaluationEditView>> GetEvaluationsByManagerId(string managerId)
{
var result = await _client
.GetFromJsonAsync<List<EvaluationEditView>>(
$"{_api.UserSupport}/manager/{managerId}", _options);
return result ?? new List<EvaluationEditView>();
}
public async Task<List<EvaluationEditView>> GetEvaluationsByMemberId(string memberId)
{
var result = await _client
.GetFromJsonAsync<List<EvaluationEditView>>(
$"{_api.UserSupport}/member/{memberId}", _options);
return result ?? new List<EvaluationEditView>();
}
public async Task<EvaluationEditView> GetById(string evaluationId)
{
var result = await _client
.GetFromJsonAsync<EvaluationEditView>(
$"{_api.UserSupport}/evaluation/{evaluationId}", _options);
return result ?? new EvaluationEditView();
}
public async Task<EvaluationEditView> CreateEvaluation(EvaluationEditView evaluationEditView)
{
var result = await _client
.PostAsJsonAsync($"{_api.UserSupport}", evaluationEditView, _options);
if (!result.IsSuccessStatusCode)
{
return new EvaluationEditView();
}
var content = await result.Content.ReadAsStringAsync();
return (string.IsNullOrWhiteSpace(content)
? new EvaluationEditView()
: JsonSerializer.Deserialize<EvaluationEditView>(content, _options))!;
}
public async Task<EvaluationEditView> UpdateEvaluation(string evaluationId, EvaluationEditView evaluationEditView)
{
var result = await _client
.PutAsJsonAsync($"{_api.UserSupport}/{evaluationId}", evaluationEditView, _options);
if (!result.IsSuccessStatusCode)
{
return new EvaluationEditView();
}
var content = await result.Content.ReadAsStringAsync();
return (string.IsNullOrWhiteSpace(content)
? new EvaluationEditView()
: JsonSerializer.Deserialize<EvaluationEditView>(content, _options))!;
}
public async Task DeleteEvaluation(string evaluationId)
{
await _client.DeleteAsync($"{_api.UserSupport}/{evaluationId}");
}
}

View file

@ -0,0 +1,106 @@
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 SupportDocumentRepository : ISupportDocumentRepository
{
private readonly JsonSerializerOptions? _options = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
};
private readonly NavigationManager _navigation;
private readonly ILogger<SupportDocumentRepository> _logger;
private readonly HttpClient _client;
private readonly ApiConfig _api;
public SupportDocumentRepository(HttpClient client,
ILogger<SupportDocumentRepository> logger,
NavigationManager navigation, IOptions<ApiConfig> configuration)
{
_client = client;
_logger = logger;
_navigation = navigation;
_api = configuration.Value;
}
public async Task<List<SupportDocumentEditView>> GetDocumentsBySupervisorId(string supervisorId)
{
var result = await _client
.GetFromJsonAsync<List<SupportDocumentEditView>>(
$"{_api.UserSupport}/documents/supervisor/{supervisorId}", _options);
return result ?? new List<SupportDocumentEditView>();
}
public async Task<List<SupportDocumentEditView>> GetDocumentsByAdvisorId(string advisorId)
{
var result = await _client
.GetFromJsonAsync<List<SupportDocumentEditView>>(
$"{_api.UserSupport}/documents/advisor/{advisorId}", _options);
return result ?? new List<SupportDocumentEditView>();
}
public async Task<SupportDocumentEditView> GetById(string documentId)
{
var result = await _client
.GetFromJsonAsync<SupportDocumentEditView>(
$"{_api.UserSupport}/documents/{documentId}", _options);
return result ?? new SupportDocumentEditView();
}
public async Task<SupportDocumentEditView> CreateDocument(SupportDocumentEditView model)
{
var result = await _client
.PostAsJsonAsync($"{_api.UserSupport}/documents", model, _options);
if (!result.IsSuccessStatusCode)
{
return new SupportDocumentEditView();
}
var content = await result.Content.ReadAsStringAsync();
return (string.IsNullOrWhiteSpace(content)
? new SupportDocumentEditView()
: JsonSerializer.Deserialize<SupportDocumentEditView>(content, _options))!;
}
public async Task<SupportDocumentEditView> UpdateDocument(string documentId, SupportDocumentEditView model)
{
var result = await _client
.PutAsJsonAsync($"{_api.UserSupport}/documents/{documentId}", model, _options);
if (!result.IsSuccessStatusCode)
{
return new SupportDocumentEditView();
}
var content = await result.Content.ReadAsStringAsync();
return (string.IsNullOrWhiteSpace(content)
? new SupportDocumentEditView()
: JsonSerializer.Deserialize<SupportDocumentEditView>(content, _options))!;
}
public async Task DeleteDocument(string documentId)
{
await _client.DeleteAsync($"{_api.UserSupport}/documents/{documentId}");
}
}

View file

@ -0,0 +1,59 @@
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 SupportManagementRepository : ISupportManagementRepository
{
private readonly JsonSerializerOptions? _options = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
};
private readonly NavigationManager _navigation;
private readonly ILogger<SupportManagementRepository> _logger;
private readonly HttpClient _client;
private readonly ApiConfig _api;
public SupportManagementRepository(HttpClient client,
ILogger<SupportManagementRepository> logger,
NavigationManager navigation, IOptions<ApiConfig> configuration)
{
_client = client;
_logger = logger;
_navigation = navigation;
_api = configuration.Value;
}
public async Task<SupportAdvisorView> GetAdvisorByUserId(string userId)
{
var result = await _client
.GetAsync($"{_api.UserSupport}/user/advisor/{userId}");
var content = await result.Content.ReadAsStringAsync();
if (!result.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content))
{
return new SupportAdvisorView();
}
return JsonSerializer.Deserialize<SupportAdvisorView>(content, _options) ?? new SupportAdvisorView();
}
public async Task<SupportSupervisorView> GetSupervisorByUserId(string userId)
{
var result = await _client
.GetAsync($"{_api.UserSupport}/user/supervisor/{userId}");
var content = await result.Content.ReadAsStringAsync();
if (!result.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content))
{
return new SupportSupervisorView();
}
return JsonSerializer.Deserialize<SupportSupervisorView>(content, _options) ?? new SupportSupervisorView();
}
}

View file

@ -1,35 +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 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 = "Management,Supervisor")]
@page "/supervisor/members/{UserId}/evaluations/{EvaluationId}"
<div class="row">
<div class="col">
<h3>Evalueringer</h3>
</div>
<div class="col">
<div class="text-end">
<div class="busy-signal" style="display:@(Working ? "block" : "none")">
<div class="spinner-grow text-info" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
</div>
</div>
</div>

View file

@ -1,59 +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 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;
namespace Wonky.Client.Pages;
#pragma warning disable CS8618
public partial class ManagerEvaluationViewEditPage : IDisposable
{
// #########################################################
[Inject] public IMemberSupportRepository MemberSupportRepo { get; set; }
[Inject] public HttpInterceptorService Interceptor { get; set; }
// #########################################################
[Parameter] public string UserId { get; set; } = "";
[Parameter] public string EvaluationId { get; set; } = "";
// #########################################################
private bool Working { get; set; } = true;
private EvaluationEditView Evaluation { get; set; } = new();
private MemberView Member { get; set; } = new();
protected override async Task OnInitializedAsync()
{
Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent();
Member = await MemberSupportRepo.GetMemberByUserId(UserId);
Evaluation = await MemberSupportRepo.GetById(EvaluationId);
Working = false;
}
public void Dispose()
{
Interceptor.DisposeEvent();
}
}

View file

@ -37,10 +37,10 @@
@if (Users.Any())
{
<div class="row">
<div class="row d-flex g-3">
@foreach (var user in Users)
{
<div class="col-sm-4">
<div class="col-sm-6">
<div class="card">
<div class="card-header">
<div class="card-title">
@ -68,8 +68,14 @@
</table>
</div>
<div class="card-footer">
<a class="btn btn-info" href="/supervisor/members/@user.UserId">Dagsrapporter</a>
<a class="btn btn-primary" href="/supervisor/members/@user.UserId/evaluations">Evalueringer</a>
<div class="row d-flex g-3">
<div class="col">
<a class="btn btn-info" href="/supervisor/advisors/@user.UserId">Aktivitet</a>
</div>
<div class="col">
<a class="btn btn-primary" href="/supervisor/advisors/@user.UserId/documents">Dokumentation</a>
</div>
</div>
</div>
</div>
</div>

View file

@ -22,7 +22,7 @@ namespace Wonky.Client.Pages;
#pragma warning disable CS8618
public partial class ManagerMemberListPage
public partial class SuportAdvisorListPage
{
// #############################################################
[Inject] public HttpInterceptorService Interceptor { get; set; }

View file

@ -17,7 +17,7 @@
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize(Roles = "Management,Supervisor")]
@page "/supervisor/members/{UserId}/activities/{ReportDate}"
@page "/supervisor/advisors/{AdvisorId}/activities/{ReportDate}"
<div class="report-main d-print-print">
@if (!string.IsNullOrWhiteSpace(Report.ReportData.DayTypeEnum))
@ -42,7 +42,7 @@
else
{
<div class="row">
<div class="col">Ingen rapport data</div>
<div class="col">Ingen data</div>
</div>
}
</div>

View file

@ -30,22 +30,18 @@ using Wonky.Entity.Views;
namespace Wonky.Client.Pages;
public partial class ManagerMemberActivityListViewPage : IDisposable
public partial class SupportAdvisorActivityListViewPage : IDisposable
{
// #############################################################
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public ICountryReportRepository ReportRepo { get; set; }
[Inject] public NavigationManager Navigator { get; set; }
[Inject] public ILogger<ManagerMemberActivityListViewPage> Logger { get; set; }
[Inject] public ILogger<SupportAdvisorActivityListViewPage> Logger { get; set; }
[Inject] public ILocalStorageService Storage { get; set; }
[Inject] public UserPreferenceService PreferenceService { get; set; }
[Inject] public IToastService Toaster { get; set; }
[Inject] public IOrderProcessRepository ProcessRepo { get; set; }
// [Inject] public EventCallback<string> OnShowDocument { get; set; }
// #############################################################
[Parameter] public string UserId { get; set; } = "";
[Parameter] public string AdvisorId { get; set; } = "";
[Parameter] public string ReportDate { get; set; } = "";
@ -55,7 +51,7 @@ public partial class ManagerMemberActivityListViewPage : IDisposable
private List<ReportItemView> Activities { get; set; } = new();
private bool Working { get; set; } = true;
private UserPreference Profile { get; set; } = new();
private string _returnUrl = "";
// private string _returnUrl = "";
protected override async Task OnParametersSetAsync()
@ -78,7 +74,7 @@ public partial class ManagerMemberActivityListViewPage : IDisposable
{
// shoe order/activity document
// the supervisor version
Navigator.NavigateTo($"/supervisor/members/{UserId}/activities/{ReportDate}/visits/{documentId}");
Navigator.NavigateTo($"/supervisor/advisors/{AdvisorId}/activities/{ReportDate}/visits/{documentId}");
}
@ -97,7 +93,7 @@ public partial class ManagerMemberActivityListViewPage : IDisposable
ReportDate = workDate;
// ensure the browser address bar contains the correct link
Navigator.NavigateTo($"/supervisor/members/{UserId}/activities/{workDate}", false, true);
Navigator.NavigateTo($"/supervisor/advisors/{AdvisorId}/activities/{workDate}", false, true);
// return if we are already at it
if (Working)
@ -112,9 +108,9 @@ public partial class ManagerMemberActivityListViewPage : IDisposable
// set busy signal
Working = true;
Logger.LogDebug("UserId => {}", UserId);
Logger.LogDebug("UserId => {}", AdvisorId);
// fetch report
Report = await ReportRepo.GetCountryReport(UserId, workDate);
Report = await ReportRepo.GetCountryReport(AdvisorId, workDate);
Logger.LogDebug("Report => {}", JsonSerializer.Serialize(Report, new JsonSerializerOptions(JsonSerializerDefaults.Web)));
// extract activities
@ -123,7 +119,7 @@ public partial class ManagerMemberActivityListViewPage : IDisposable
// store locally
if (!string.IsNullOrWhiteSpace(Report.ReportData.ReportDate))
{
await Storage.SetItemAsync($"{UserId}-{workDate}", Report);
await Storage.SetItemAsync($"{AdvisorId}-{workDate}", Report);
}
// remove busy signal

View file

@ -18,7 +18,7 @@
@using Wonky.Client.Components
@attribute [Authorize(Roles = "Management,Supervisor")]
@page "/supervisor/members/{UserId}/activities/{ReportDate}/visits/{DocumentId}"
@page "/supervisor/advisors/{AdvisorId}/activities/{ReportDate}/visits/{DocumentId}"
<PageTitle>@ReportItem.ESalesNumber - @ReportItem.Company.Name</PageTitle>
<table class="table table-sm table-striped d-print-table">

View file

@ -28,21 +28,16 @@ using Wonky.Entity.Views;
namespace Wonky.Client.Pages;
public partial class ManagerMemberActivityViewPage : IDisposable
public partial class SupportAdvisorActivityViewPage : IDisposable
{
// #############################################################
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public ICountryActivityRepository ActivityRepo { get; set; }
[Inject] public ISystemSendMailService MailService { get; set; }
[Inject] public ILocalStorageService Storage { get; set; }
[Inject] public ICountryUserInfoRepository UserRepo { get; set; }
[Inject] public ILogger<OfficeOrderViewPage> Logger { get; set; }
[Inject] public IToastService Toast { get; set; }
[Inject] public IUserInfoService UserInfoService { get; set; }
// #############################################################
[Parameter] public string UserId { get; set; } = "";
[Parameter] public string AdvisorId { get; set; } = "";
[Parameter] public string DocumentId { get; set; } = "";
[Parameter] public string ReportDate { get; set; } = "";
@ -56,8 +51,7 @@ public partial class ManagerMemberActivityViewPage : IDisposable
PropertyNameCaseInsensitive = true
};
protected override async Task OnInitializedAsync()
{
Interceptor.RegisterEvent();

View file

@ -17,7 +17,7 @@
@using Wonky.Client.Components
@attribute [Authorize(Roles = "Management,Supervisor")]
@page "/supervisor/members/{UserId}"
@page "/supervisor/advisors/{AdvisorId}"
<PageTitle>Rapport Arkiv @InfoAdvisor.FirstName @InfoAdvisor.LastName</PageTitle>
<div class="card">

View file

@ -7,18 +7,18 @@ using Wonky.Entity.Views;
namespace Wonky.Client.Pages;
public partial class ManagerMemberBaseViewPage : IDisposable
public partial class SupportAdvisorViewPage : IDisposable
{
// #############################################################
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public ICountryUserInfoRepository UserRepo { get; set; }
[Inject] public ICountryReportRepository ReportRepo { get; set; }
[Inject] public NavigationManager Navigator { get; set; }
[Inject] public ILogger<ManagerMemberBaseViewPage> Logger { get; set; }
[Inject] public ILogger<SupportAdvisorViewPage> Logger { get; set; }
// #############################################################
[Parameter] public string UserId { get; set; } = "";
[Parameter] public string AdvisorId { get; set; } = "";
// #############################################################
@ -32,14 +32,14 @@ public partial class ManagerMemberBaseViewPage : IDisposable
Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent();
InfoAdvisor = await UserRepo.GetUserInfo(UserId);
InfoAdvisor = await UserRepo.GetUserInfo(AdvisorId);
while (string.IsNullOrWhiteSpace(InfoAdvisor.UserId))
{
await Task.Delay(500);
}
var reports = await ReportRepo.GetCountryReports(UserId);
var reports = await ReportRepo.GetCountryReports(AdvisorId);
if (reports.Any())
ActivityReports = reports.OrderByDescending(x => x.ReportDate).ToList();
}

View file

@ -16,17 +16,17 @@
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize(Roles = "Management,Supervisor")]
@page "/supervisor/members/{UserId}/evaluations"
@page "/supervisor/advisors/{AdvisorId}/documents"
<PageTitle>Evalueringer</PageTitle>
<PageTitle>Support Dokumentation</PageTitle>
<div class="row">
<div class="col">
<h3>Evalueringer</h3>
<h3>Support Dokumentation</h3>
</div>
<div class="col">
<div class="text-end">
<a class="btn btn-primary" href="/supervisor/members/@UserId/evaluations/new"><i class="bi-plus-circle-fill"></i> Opret Evaluering</a>
<a class="btn btn-primary" href="/supervisor/advisors/@AdvisorId/documents/new"><i class="bi-plus-circle-fill"></i> Opret</a>
@*
<div class="busy-signal" style="display:@(_working ? "block" : "none")">
<div class="spinner-grow text-info" role="status">
@ -38,9 +38,33 @@
</div>
</div>
@if (Evaluations.Any())
@if (Documents.Any())
{
<div class="list-group">
<div class="list-group-item">
<div class="row">
<div class="col-sm-3">Dato</div>
<div class="col-sm-3">Supervisor</div>
<div class="col-sm-6">Navn</div>
</div>
</div>
@foreach (var document in Documents)
{
<a class="list-group-item list-group-item-action" href="/supervisor/advisors/@AdvisorId/documents/@document.DocumentId">
<div class="row">
<div class="col-sm-3">
@document.DocumentDate
</div>
<div class="col-sm-3">
@document.SupervisorName
</div>
<div class="col-sm-6">
@document.Description
</div>
</div>
</a>
}
</div>
}
else
{

View file

@ -24,20 +24,21 @@ namespace Wonky.Client.Pages;
#pragma warning disable CS8618
public partial class ManagerEvaluationListPage : IDisposable
public partial class SupportDocumentListPage : IDisposable
{
// #########################################################
[Inject] public IMemberSupportRepository MemberSupportRepo { get; set; }
[Inject] public ISupportDocumentRepository DocumentRepo { get; set; }
[Inject] public ISupportManagementRepository SupportRepo { get; set; }
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public ILogger<ManagerEvaluationListPage> Logger { get; set; }
[Inject] public ILogger<SupportDocumentListPage> Logger { get; set; }
// #########################################################
[Parameter] public string UserId { get; set; } = "";
[Parameter] public string AdvisorId { get; set; } = "";
// #########################################################
private List<EvaluationEditView> Evaluations { get; set; } = new();
private MemberView Member { get; set; } = new();
private bool _working = true;
private List<SupportDocumentEditView> Documents { get; set; } = new();
private SupportAdvisorView Advisor { get; set; } = new();
// private bool _working = true;
protected override async Task OnInitializedAsync()
@ -46,17 +47,17 @@ public partial class ManagerEvaluationListPage : IDisposable
Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent();
Logger.LogDebug("UserId => {}", UserId);
Logger.LogDebug("UserId => {}", AdvisorId);
Member = await MemberSupportRepo.GetMemberByUserId(UserId);
Advisor = await SupportRepo.GetAdvisorByUserId(AdvisorId);
Logger.LogDebug("Member => {}",JsonSerializer.Serialize(Member));
Logger.LogDebug("Advisor => {}",JsonSerializer.Serialize(Advisor));
Evaluations = await MemberSupportRepo.GetEvaluationsByMemberId(Member.MemberId);
Documents = await DocumentRepo.GetDocumentsByAdvisorId(Advisor.AdvisorId);
Logger.LogDebug("Evaluations => {}",JsonSerializer.Serialize(Evaluations));
Logger.LogDebug("Documents => {}",JsonSerializer.Serialize(Documents));
_working = false;
// _working = false;
}

View file

@ -17,31 +17,38 @@
@attribute [Authorize(Roles = "Management,Supervisor")]
@page "/supervisor/members/{UserId}/evaluations/new"
@page "/supervisor/advisors/{AdvisorId}/documents/new"
<PageTitle>Ny evaluering</PageTitle>
<PageTitle>Support Dokumentation</PageTitle>
<EditForm EditContext="FormContext" OnValidSubmit="SubmitDocument">
<DataAnnotationsValidator/>
<div class="card">
<div class="card-title">
<h3>Evaluering</h3>
<h3>Opret Dokumentation</h3>
</div>
<div class="card-body">
<div class="row d-flex g-3">
<label for="supervisor" class="col-sm-2 col-form-label-sm">Supervisor</label>
<div class="col-sm-4">
<InputText id="supervisor" class="form-control" @bind-Value="Document.ManagerName" readonly></InputText>
<label for="supervisor" class="col-sm-1 col-form-label-sm">Supervisor</label>
<div class="col-sm-5">
<InputText id="supervisor" class="form-control" @bind-Value="Document.SupervisorName" readonly></InputText>
</div>
<label for="salesRep" class="col-sm-2 col-form-label-sm">Sælger</label>
<div class="col-sm-4">
<InputText id="salesRep" class="form-control" @bind-Value="Document.MemberName" readonly></InputText>
<label for="advisor" class="col-sm-1 col-form-label-sm">Sælger</label>
<div class="col-sm-5">
<InputText id="advisor" class="form-control" @bind-Value="Document.AdvisorName" readonly></InputText>
</div>
<label for="documentDate" class="col-sm-2 col-form-label-sm">Dato</label>
<div class="col-sm-4">
<label for="countryCode" class="col-sm-1 col-form-label-sm">Land</label>
<div class="col-2">
<InputText id="countryCode" class="form-control" @bind-Value="Document.CountryCode" ></InputText>
</div>
<label for="documentDate" class="col-sm-1 col-form-label-sm">Dato</label>
<div class="col-sm-3">
<InputDate id="documentDate" class="form-control" @bind-Value="DocumentDate"></InputDate>
</div>
<div class="col-sm-6"></div>
<label for="lastModifiedDate" class="col-sm-1 col-form-label-sm">Ændring</label>
<div class="col-sm-3">
<InputText id="lastModifiedDate" class="form-control" @bind-Value="Document.LastModifiedDate" readonly></InputText>
</div>
<label for="description" class="col-sm-2 col-form-label-sm">Overskrift</label>
<div class="col-sm-10">
<InputText id="description" class="form-control" @bind-Value="Document.Description"></InputText>

View file

@ -27,26 +27,27 @@ namespace Wonky.Client.Pages;
#pragma warning disable CS8618
public partial class ManagerEvaluationNewPage : IDisposable
public partial class SupportDocumentNewPage : IDisposable
{
// ############################################################
[Inject] public IMemberSupportRepository MemberSupportRepo { get; set; }
[Inject] public ISupportDocumentRepository DocumentRepo { get; set; }
[Inject] public ISupportManagementRepository SupportRepo { get; set; }
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public IUserInfoService UserService { get; set; }
[Inject] public ILogger<ManagerEvaluationNewPage> Logger { get; set; }
[Inject] public ILogger<SupportDocumentNewPage> Logger { get; set; }
[Inject] public IToastService Toaster { get; set; }
[Inject] public NavigationManager Navigator { get; set; }
// ############################################################
[Parameter] public string UserId { get; set; } = "";
[Parameter] public string AdvisorId { get; set; } = "";
// ############################################################
private EditContext FormContext { get; set; }
private MemberView Member { get; set; } = new();
private ManagerView Manager { get; set; } = new();
private EvaluationEditView Document { get; set; } = new();
private SupportAdvisorView Advisor { get; set; } = new();
private SupportSupervisorView Supervisor { get; set; } = new();
private SupportDocumentEditView Document { get; set; } = new();
private DateTime DocumentDate { get; set; } = DateTime.Now;
private bool FormInvalid { get; set; } = true;
@ -60,44 +61,46 @@ public partial class ManagerEvaluationNewPage : IDisposable
FormContext.OnFieldChanged += HandleFieldChanged!;
FormContext.OnValidationStateChanged += ValidationChanged!;
Member = await MemberSupportRepo.GetMemberByUserId(UserId);
Advisor = await SupportRepo.GetAdvisorByUserId(AdvisorId);
Logger.LogDebug("Member => {}", JsonSerializer.Serialize(Member));
Logger.LogDebug("Advisor => {}", JsonSerializer.Serialize(Advisor));
var managerId = await UserService.GetUserId();
var supervisorId = await UserService.GetUserId();
Logger.LogDebug("ManagerId => {}", managerId);
Logger.LogDebug("SupervisorId => {}", supervisorId);
Manager = await MemberSupportRepo.GetManagerByUserId(managerId);
Supervisor = await SupportRepo.GetSupervisorByUserId(supervisorId);
Logger.LogDebug("Manager => {}", JsonSerializer.Serialize(Manager));
Logger.LogDebug("Supervisor => {}", JsonSerializer.Serialize(Supervisor));
Document.EvaluationDate = $"{DocumentDate:yyyy-MM-dd}";
Document.ManagerId = Manager.ManagerId;
Document.ManagerName = Manager.FullName;
Document.MemberId = Member.MemberId;
Document.MemberName = Member.FullName;
Document.SupervisorId = Supervisor.SupervisorId;
Document.SupervisorName = Supervisor.FullName;
Document.AdvisorId = Advisor.AdvisorId;
Document.AdvisorName = Advisor.FullName;
Document.CountryCode = Advisor.CountryCode;
}
private async Task SubmitDocument()
{
Document.DocumentDate = $"{DocumentDate:yyyy-MM-dd}";
Toaster.ShowInfo("Gemmer Evaluering");
var x = await MemberSupportRepo.CreateEvaluation(Document);
if (string.IsNullOrWhiteSpace(x.EvaluationId))
Logger.LogDebug("Document => {}", JsonSerializer.Serialize(Document, new JsonSerializerOptions(JsonSerializerDefaults.Web)));
var x = await DocumentRepo.CreateDocument(Document);
if (string.IsNullOrWhiteSpace(x.DocumentId))
{
Toaster.ShowError("Fejl");
}
else
{
Toaster.ShowSuccess("Ok");
Navigator.NavigateTo($"/supervisor/members/{UserId}/evaluations/{x.EvaluationId}");
Navigator.NavigateTo("/supervisor/advisors/{AdvisorId}/documents/{x.DocumentId}");
}
}
private void HandleFieldChanged(object sender, FieldChangedEventArgs e)
{
Document.EvaluationDate = $"{DocumentDate:yyyy-MM-dd}";
Document.DocumentDate = $"{DocumentDate:yyyy-MM-dd}";
FormInvalid = !FormContext.Validate();

View file

@ -0,0 +1,81 @@
@* 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 = "Management,Supervisor")]
@page "/supervisor/advisors/{AdvisorId}/documents/{DocumentId}"
<div class="row">
<div class="col">
<h3>Support Dokumentation</h3>
</div>
<div class="col">
<div class="text-end">
<div class="busy-signal" style="display:@(Working ? "block" : "none")">
<div class="spinner-grow text-info" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
</div>
</div>
</div>
<EditForm EditContext="FormContext" OnValidSubmit="SubmitDocument">
<div class="card">
<div class="card-body">
<div class="row d-flex g-3">
<label for="supervisor" class="col-sm-1 col-form-label-sm">Supervisor</label>
<div class="col-sm-5">
<InputText id="supervisor" class="form-control" @bind-Value="Document.SupervisorName" readonly></InputText>
</div>
<label for="advisor" class="col-sm-1 col-form-label-sm">Sælger</label>
<div class="col-sm-5">
<InputText id="advisor" class="form-control" @bind-Value="Document.AdvisorName" readonly></InputText>
</div>
<label for="countryCode" class="col-sm-1 col-form-label-sm">Land</label>
<div class="col-2">
<InputText id="countryCode" class="form-control" @bind-Value="Document.CountryCode"></InputText>
</div>
<label for="documentDate" class="col-sm-1 col-form-label-sm">Dato</label>
<div class="col-sm-3">
<InputText id="documentDate" class="form-control" @bind-Value="Document.DocumentDate" readonly></InputText>
</div>
<label for="lastModifiedDate" class="col-sm-1 col-form-label-sm">Ændring</label>
<div class="col-sm-3">
<InputText id="lastModifiedDate" class="form-control" @bind-Value="Document.LastModifiedDate" readonly></InputText>
</div>
<label for="description" class="col-sm-1 col-form-label-sm">Overskrift</label>
<div class="col-sm-11">
<InputText id="description" class="form-control" @bind-Value="Document.Description"></InputText>
</div>
<label for="content" class="col-sm-1 col-form-label-sm">Indhold</label>
<div class="col-sm-11">
<InputTextArea id="content" class="form-control" rows="10" @bind-Value="Document.Content"></InputTextArea>
</div>
</div>
</div>
<div class="card-footer">
<div class="row">
<div class="col text-start">
<button type="button" class="btn btn-warning" @onclick="RemoveDocument"><i class="bi-trash"></i> Slet</button>
</div>
<div class="col text-end">
<button type="submit" class="btn btn-primary"><i class="bi-cloud-upload"></i> Gem</button>
</div>
</div>
</div>
</div>
</EditForm>

View file

@ -0,0 +1,104 @@
// 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 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;
#pragma warning disable CS8618
public partial class SupportDocumentViewEditPage : IDisposable
{
// ############################################################
[Inject] public ISupportDocumentRepository DocumentRepo { get; set; }
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public IToastService Toaster { get; set; }
[Inject] public NavigationManager Navigator { get; set; }
// ############################################################
[Parameter] public string AdvisorId { get; set; } = "";
[Parameter] public string DocumentId { get; set; } = "";
// ############################################################
private EditContext FormContext { get; set; }
private SupportDocumentEditView Document { get; set; } = new();
private bool Working { get; set; } = true;
protected override async Task OnInitializedAsync()
{
Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent();
FormContext = new EditContext(Document);
FormContext.OnFieldChanged += HandleFieldChanged!;
FormContext.OnValidationStateChanged += ValidationChanged!;
Document = await DocumentRepo.GetById(DocumentId);
Working = false;
StateHasChanged();
}
private async Task RemoveDocument()
{
Toaster.ShowInfo("Sletter Dokument");
await DocumentRepo.DeleteDocument(Document.DocumentId);
Navigator.NavigateTo($"/supervisor/advisors/{AdvisorId}/documents");
}
private async Task SubmitDocument()
{
var x = await DocumentRepo.UpdateDocument(Document.DocumentId, Document);
Toaster.ShowSuccess("Ok");
}
private void HandleFieldChanged(object sender, FieldChangedEventArgs e)
{
StateHasChanged();
}
private void ValidationChanged(object sender, ValidationStateChangedEventArgs e)
{
FormContext.OnFieldChanged -= HandleFieldChanged!;
FormContext.OnValidationStateChanged -= ValidationChanged!;
FormContext = new EditContext(Document);
FormContext.OnFieldChanged += HandleFieldChanged!;
FormContext.OnValidationStateChanged += ValidationChanged!;
}
public void Dispose()
{
Interceptor.DisposeEvent();
FormContext.OnFieldChanged -= HandleFieldChanged!;
FormContext.OnValidationStateChanged -= ValidationChanged!;
}
}

View file

@ -28,6 +28,7 @@ using Wonky.Client.HttpRepository;
using Wonky.Client.Local.Services;
using Wonky.Client.Shared;
using Wonky.Entity.Configuration;
using Wonky.Entity.DTO;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
@ -74,7 +75,8 @@ builder.Services.AddScoped<ISystemLabelsRepository, SystemLabelsRepository>();
builder.Services.AddScoped<ISystemTextsRepository, SystemTextsRepository>();
builder.Services.AddScoped<ISystemUserRepository, SystemUserRepository>();
builder.Services.AddScoped<ICountryUserInfoRepository, CountryUserInfoRepository>();
builder.Services.AddScoped<IMemberSupportRepository, MemberSupportRepository>();
builder.Services.AddScoped<ISupportDocumentRepository, SupportDocumentRepository>();
builder.Services.AddScoped<ISupportManagementRepository, SupportManagementRepository>();
builder.Services.AddScoped<ICountryActivityRepository, CountryActivityRepository>();
// warehouse repository
builder.Services.AddScoped<IOrderProcessRepository, OrderProcessRepository>();

View file

@ -111,12 +111,12 @@
<AuthorizeView Roles="Admin">
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/system">
<i class="bi-gear-wide-connected pe-2" style="font-size:1.3em;" aria-hidden="true"></i> System
<i class="bi-gear-wide-connected pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Administration
</NavLink>
</div>
</AuthorizeView>
<AuthorizeView Roles="Management,Supervisor">
<AuthorizeView Roles="Supervisor">
<Authorized>
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/supervisor">
@ -125,7 +125,17 @@
</div>
</Authorized>
</AuthorizeView>
<AuthorizeView Roles="Management">
<Authorized>
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/management">
<i class="bi-people pe-2" style="font-size:1.3em;" aria-hidden="true"></i> Management
</NavLink>
</div>
</Authorized>
</AuthorizeView>
<AuthorizeView Roles="Admin,Advisor,Management,Office,Supervisor,Warehouse">
<div class="nav-item px-3">
<NavLink class="nav-link ps-2" href="/info">

View file

@ -1,15 +1,15 @@
{
"appInfo": {
"name": "Wonky Online",
"version": "0.138.0",
"rc": true,
"version": "0.138.2",
"rc": false,
"sandBox": false,
"image": "grumpy-coder.png"
},
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Debug",
"Default": "Information",
"System": "Information",
"Microsoft": "Information"
},
"Debug": {
@ -19,7 +19,7 @@
}
},
"apiConfig": {
"baseUrl": "https://dev.innotec.dk",
"baseUrl": "https://zeta.innotec.dk",
"catalog": "api/v2/catalog/country",
"crmCustomers": "api/v2/crm/companies",
"crmInventoryExt": "history/inventory",
@ -47,12 +47,12 @@
"systemDocStringUrl": "api/v2/admin/doc",
"systemLabels": "api/v2/admin/doc/labels",
"systemTexts": "api/v2/admin/doc/texts",
"userSupport": "/api/v2/app/manage/support",
"userInfoClient": "/api/v2/client/users",
"userInfoAuth": "api/v2/auth/userinfo",
"userManager": "api/v2/app/manage/users",
"userManagerSetPasswd": "api/v2/app/manage/passwd",
"userRoles": "api/v2/app/manage/roles",
"userSupport": "/api/v2/app/manage/support",
"warehouse": "api/v2/warehouse/packages"
}
}

View file

@ -3,9 +3,11 @@
<head>
<meta charset="utf-8" />
<title>Innotec WWO</title>
<!--
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
-->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png" />

View file

@ -1,25 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace Wonky.Entity.DTO;
public class EvaluationEditView
{
[Required(ErrorMessage = "Indhold mangler")]
public string Content { get; set; } = "";
[Required(ErrorMessage = "Beskrivelse mangler")]
[MaxLength(128, ErrorMessage = "Der er kun afsat 128 tegn.")]
public string Description { get; set; } = "";
public string EvaluationDate { get; set; } = "";
public string EvaluationId { get; set; } = "";
public string ManagerId { get; set; } = "";
public string ManagerName { get; set; } = "";
public string MemberId { get; set; } = "";
public string MemberName { get; set; } = "";
}

View file

@ -0,0 +1,28 @@
using System.ComponentModel.DataAnnotations;
namespace Wonky.Entity.DTO;
public class SupportDocumentEditView
{
[Required(ErrorMessage = "Indhold mangler")]
public string Content { get; set; } = "";
[Required(ErrorMessage = "Beskrivelse mangler")]
[MaxLength(128, ErrorMessage = "Der er kun afsat 128 tegn.")]
public string Description { get; set; } = "";
public string DocumentDate { get; set; } = "";
public string DocumentId { get; set; } = "";
public string SupervisorId { get; set; } = "";
public string SupervisorName { get; set; } = "";
public string AdvisorId { get; set; } = "";
public string AdvisorName { get; set; } = "";
public string LastModifiedDate { get; set; } = "";
public string CountryCode { get; set; } = "";
}

View file

@ -1,8 +0,0 @@
namespace Wonky.Entity.Views;
public class MemberView
{
public string MemberId { get; set; } = "";
public string UserId { get; set; } = "";
public string FullName { get; set; } = "";
}

View file

@ -0,0 +1,9 @@
namespace Wonky.Entity.Views;
public class SupportAdvisorView
{
public string AdvisorId { get; set; } = "";
public string FullName { get; set; } = "";
public string CountryCode { get; set; } = "";
}

View file

@ -1,8 +1,8 @@
namespace Wonky.Entity.Views;
public class ManagerView
public class SupportSupervisorView
{
public string ManagerId { get; set; } = "";
public string SupervisorId { get; set; } = "";
public string UserId { get; set; } = "";
public string FullName { get; set; } = "";
}