WIP: evaluation and management

This commit is contained in:
Frede Hundewadt 2023-04-24 14:00:24 +02:00
parent 21aabcc596
commit a906c9966f
26 changed files with 472 additions and 37 deletions

View file

@ -0,0 +1,99 @@
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 EvaluationRepository : IEvaluationRepository
{
private readonly JsonSerializerOptions? _options = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
};
private readonly NavigationManager _navigation;
private readonly ILogger<EvaluationRepository> _logger;
private readonly HttpClient _client;
private readonly ApiConfig _api;
public EvaluationRepository(HttpClient client,
ILogger<EvaluationRepository> logger,
NavigationManager navigation, IOptions<ApiConfig> configuration)
{
_client = client;
_logger = logger;
_navigation = navigation;
_api = configuration.Value;
}
public async Task<List<EvaluationEditView>> GetByManager(string managerId)
{
var result = await _client
.GetFromJsonAsync<List<EvaluationEditView>>(
$"{_api.UserEvaluations}/manager/{managerId}", _options);
return result ?? new List<EvaluationEditView>();
}
public async Task<List<EvaluationEditView>> GetByMember(string memberId)
{
var result = await _client
.GetFromJsonAsync<List<EvaluationEditView>>(
$"{_api.UserEvaluations}/member/{memberId}", _options);
return result ?? new List<EvaluationEditView>();
}
public async Task<EvaluationEditView> GetById(string evaluationId)
{
var result = await _client
.GetFromJsonAsync<EvaluationEditView>(
$"{_api.UserEvaluations}/id/{evaluationId}", _options);
return result ?? new EvaluationEditView();
}
public async Task<EvaluationEditView> CreateEvaluation(EvaluationEditView evaluation)
{
var result = await _client
.PostAsJsonAsync($"{_api.UserEvaluations}", evaluation, _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 evaluation)
{
var result = await _client
.PutAsJsonAsync($"{_api.UserEvaluations}/{evaluationId}", evaluation, _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.UserEvaluations}/{evaluationId}");
}
}

View file

@ -0,0 +1,13 @@
using Wonky.Entity.DTO;
namespace Wonky.Client.HttpRepository;
public interface IEvaluationRepository
{
Task<List<EvaluationEditView>> GetByManager(string managerId);
Task<List<EvaluationEditView>> GetByMember(string memberId);
Task<EvaluationEditView> GetById(string evaluationId);
Task<EvaluationEditView> CreateEvaluation(EvaluationEditView evaluation);
Task<EvaluationEditView> UpdateEvaluation(string evaluationId, EvaluationEditView evaluation);
Task DeleteEvaluation(string evaluationId);
}

View file

@ -118,6 +118,6 @@ public class SystemUserRepository : ISystemUserRepository
{
var passwd = new Dictionary<string, string>
{ { "newPassword", newPasswd }, { "confirmPassword", confirmPasswd } };
await _client.PostAsJsonAsync($"{_api.UserManager}/passwd/{userId}", passwd, _options);
await _client.PostAsJsonAsync($"{_api.UserManagerSetPasswd}/{userId}", passwd, _options);
}
}

View file

@ -15,8 +15,8 @@
@using Wonky.Client.Components
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize(Roles = "Admin,Management,Supervisor")]
@page "/supervisor/advisors/{UserId}/reports/{ReportDate}"
@attribute [Authorize(Roles = "Management,Supervisor")]
@page "/management/advisors/{UserId}/reports/{ReportDate}"
<div class="report-main d-print-print">
@if (!string.IsNullOrWhiteSpace(Report.ReportData.DayTypeEnum))

View file

@ -30,13 +30,13 @@ using Wonky.Entity.Views;
namespace Wonky.Client.Pages;
public partial class SupervisorAdvisorReportViewPage : IDisposable
public partial class ManagerAdvisorReportViewPage : IDisposable
{
// #############################################################
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public ICountryReportRepository ReportRepo { get; set; }
[Inject] public NavigationManager Navigator { get; set; }
[Inject] public ILogger<SupervisorAdvisorReportViewPage> Logger { get; set; }
[Inject] public ILogger<ManagerAdvisorReportViewPage> Logger { get; set; }
[Inject] public ILocalStorageService Storage { get; set; }
[Inject] public UserPreferenceService PreferenceService { get; set; }
[Inject] public IToastService Toaster { get; set; }
@ -79,7 +79,7 @@ public partial class SupervisorAdvisorReportViewPage : IDisposable
{
// shoe order/activity document
// the supervisor version
Navigator.NavigateTo($"/supervisor/advisors/{UserId}/reports/{ReportDate}/activities/{documentId}");
Navigator.NavigateTo($"/management/advisors/{UserId}/reports/{ReportDate}/activities/{documentId}");
}
@ -98,7 +98,7 @@ public partial class SupervisorAdvisorReportViewPage : IDisposable
ReportDate = workDate;
// ensure the browser address bar contains the correct link
Navigator.NavigateTo($"/supervisor/advisors/{UserId}/reports/{workDate}", false, true);
Navigator.NavigateTo($"/management/advisors/{UserId}/reports/{workDate}", false, true);
// return if we are already at it
if (Working)

View file

@ -15,8 +15,8 @@
@using Microsoft.AspNetCore.Authorization
@using Wonky.Client.Components
@attribute [Authorize(Roles = "Admin,Management,Supervisor")]
@page "/supervisor/advisors/{UserId}"
@attribute [Authorize(Roles = "Management,Supervisor")]
@page "/management/advisors/{UserId}"
<PageTitle>Rapport Arkiv @InfoAdvisor.FirstName @InfoAdvisor.LastName</PageTitle>
<div class="card">

View file

@ -7,14 +7,14 @@ using Wonky.Entity.Views;
namespace Wonky.Client.Pages;
public partial class SupervisorAdvisorViewPage : IDisposable
public partial class ManagerAdvisorViewPage : IDisposable
{
// #############################################################
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public IOfficeUserInfoRepository UserRepo { get; set; }
[Inject] public ICountryReportRepository ReportRepo { get; set; }
[Inject] public NavigationManager Navigator { get; set; }
[Inject] public ILogger<SupervisorAdvisorViewPage> Logger { get; set; }
[Inject] public ILogger<ManagerAdvisorViewPage> Logger { get; set; }
// #############################################################

View file

@ -0,0 +1,25 @@
@* 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 = "Management,Supervisor")]
@page "/ManagerEvaluationListPage"
<h3>ManagerEvaluationListPage</h3>
@code {
}

View file

@ -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 Microsoft.AspNetCore.Components;
using Wonky.Client.HttpInterceptors;
using Wonky.Client.HttpRepository;
using Wonky.Entity.Views;
namespace Wonky.Client.Pages;
#pragma warning disable CS8618
public partial class ManagerEvaluationListPage
{
}

View file

@ -0,0 +1,25 @@
@* 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 "/ManagerEvaluationNewPage"
<h3>ManagerEvaluationNewPage</h3>
@code {
}

View file

@ -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 Microsoft.AspNetCore.Components;
using Wonky.Client.HttpInterceptors;
using Wonky.Client.HttpRepository;
using Wonky.Entity.Views;
namespace Wonky.Client.Pages;
#pragma warning disable CS8618
public partial class ManagerEvaluationNewPage
{
}

View file

@ -0,0 +1,24 @@
@* 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")]
<h3>ManagerEvaluationViewEditPage</h3>
@code {
}

View file

@ -0,0 +1,29 @@
// 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.Views;
namespace Wonky.Client.Pages;
#pragma warning disable CS8618
public partial class ManagerEvaluationViewEditPage
{
}

View file

@ -0,0 +1,77 @@
@* 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"
<PageTitle>Supervisor</PageTitle>
<div class="row">
<div class="col">
<h3>Supervisor Sælger Oversigt</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>
@if (Users.Any())
{
<div class="row">
@foreach (var user in Users)
{
<div class="col">
<div class="card">
<div class="card-header">
<div class="card-title">
<h4>@user.FullName</h4>
</div>
</div>
<div class="card-body">
<table class="table table-striped">
<tr>
<th scope="row">Mobile</th>
<td>@user.PhoneNumber</td>
</tr>
<tr>
<th scope="row">Email</th>
<td>@user.Email</td>
</tr>
<tr>
<th scope="row">Beskrivelse</th>
<td>@user.Description</td>
</tr>
<tr>
<th scope="row">@user.CountryCode</th>
<td>@user.SalesRep</td>
</tr>
</table>
</div>
<div class="card-footer">
<a class="btn btn-info" href="/management/advisors/@user.UserId">Dagsrapporter</a>
<a class="btn btn-primary" href="#">Evalueringer</a>
</div>
</div>
</div>
}
</div>
}

View file

@ -1,14 +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 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 SupervisorUserListPage : IDisposable
public partial class ManagerHomePage
{
// #############################################################
[Inject] public HttpInterceptorService Interceptor { get; set; }
@ -18,6 +32,7 @@ public partial class SupervisorUserListPage : IDisposable
private List<UserInfoListView> Users { get; set; } = new();
private bool Working { get; set; } = true;
protected override async Task OnInitializedAsync()
{
Interceptor.RegisterEvent();
@ -34,8 +49,10 @@ public partial class SupervisorUserListPage : IDisposable
Working = false;
}
public void Dispose()
{
Interceptor.DisposeEvent();
}
}
}

View file

@ -14,8 +14,8 @@
*@
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize(Roles = "Admin,Management,Supervisor")]
@page "/supervisor/advisors"
@attribute [Authorize(Roles = "Management,Supervisor")]
@page "/management/advisors"
<PageTitle>Supervisor Sælger Oversigt</PageTitle>
<div class="row">
@ -57,7 +57,7 @@
{
foreach (var user in Users)
{
<a class="list-group-item list-group-item-action" href="/supervisor/advisors/@user.UserId">
<a class="list-group-item list-group-item-action" href="/management/advisors/@user.UserId">
<div class="row">
<div class="col-sm-1">
@user.CountryCode @user.SalesRep

View file

@ -0,0 +1,57 @@
// 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.Views;
namespace Wonky.Client.Pages;
#pragma warning disable CS8618
public partial class ManagerUserListPage : IDisposable
{
// #############################################################
[Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public IOfficeUserInfoRepository UserRepo { get; set; }
// #############################################################
private List<UserInfoListView> Users { get; set; } = new();
private bool Working { get; set; } = true;
protected override async Task OnInitializedAsync()
{
Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent();
Users = await UserRepo.GetSupervisorUsers();
if (Users.Any())
{
Users = Users
.OrderBy(x => x.FullName)
.ThenBy(x => x.CountryCode)
.ToList();
}
Working = false;
}
public void Dispose()
{
Interceptor.DisposeEvent();
}
}

View file

@ -16,8 +16,8 @@
@using Microsoft.AspNetCore.Authorization
@using Wonky.Client.Components
@attribute [Authorize(Roles = "Supervisor")]
@page "/supervisor/advisors/{UserId}/reports/{ReportDate}/activities/{DocumentId}"
@attribute [Authorize(Roles = "Management,Supervisor")]
@page "/management/advisors/{UserId}/reports/{ReportDate}/activities/{DocumentId}"
<PageTitle>@ReportItem.ESalesNumber - @ReportItem.Company.Name</PageTitle>
<table class="table table-sm table-striped d-print-table">
<thead>

View file

@ -28,7 +28,7 @@ using Wonky.Entity.Views;
namespace Wonky.Client.Pages;
public partial class SupervisorVisitViewPage : IDisposable
public partial class ManagerVisitViewPage : IDisposable
{
// #############################################################
[Inject] public HttpInterceptorService Interceptor { get; set; }

View file

@ -1,11 +0,0 @@
@using Microsoft.AspNetCore.Authorization
@attribute [Authorize(Roles = "Admin,Management,Supervisor")]
@page "/supervisor"
<PageTitle>Supervisor</PageTitle>
<div class="h3">Supervisor</div>
<div class="list-group">
<a class="list-group-item list-group-item-action" href="/supervisor/advisors">Sælgere</a>
</div>

View file

@ -1,6 +0,0 @@
namespace Wonky.Client.Pages;
public partial class SupervisorHomePage
{
}

View file

@ -74,6 +74,7 @@ builder.Services.AddScoped<ISystemLabelsRepository, SystemLabelsRepository>();
builder.Services.AddScoped<ISystemTextsRepository, SystemTextsRepository>();
builder.Services.AddScoped<ISystemUserRepository, SystemUserRepository>();
builder.Services.AddScoped<IOfficeUserInfoRepository, OfficeUserInfoRepository>();
builder.Services.AddScoped<IEvaluationRepository, EvaluationRepository>();
// warehouse repository
builder.Services.AddScoped<IOrderProcessRepository, OrderProcessRepository>();
// mail service

View file

@ -47,6 +47,7 @@
"systemLabels": "api/v2/admin/doc/labels",
"systemTexts": "api/v2/admin/doc/texts",
"userData": "/api/v2/client/users",
"userEvaluations": "/api/v2/app/manage/evaluations",
"userInfo": "api/v2/auth/userinfo",
"userManager": "api/v2/app/manage/users",
"userManagerSetPasswd": "api/v2/app/manage/passwd",

View file

@ -150,6 +150,11 @@ public class ApiConfig
/// Get system document texts for translation
/// </summary>
public string SystemTexts { get; set; } = "";
/// <summary>
/// Endpoint for user evaluations
/// </summary>
public string UserEvaluations { get; set; } = "";
/// <summary>
/// Application uri for user information request

View file

@ -0,0 +1,23 @@
namespace Wonky.Entity.DTO;
public class EvaluationEditView
{
public class EvaluationViewEdit
{
public string Content { get; set; } = "";
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; } = "";
}
}