wip - administravie tasks

This commit is contained in:
Frede Hundewadt 2022-06-26 11:38:47 +02:00
parent dc3323ba23
commit 2948b91c1f
10 changed files with 165 additions and 6 deletions

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]
//
*@
@if (UserList.Any())
{
<div class="list-group">
<div class="list-group-item bg-dark bg-opacity-75 text-white">
<div class="row">
<div class="col">
Navn
</div>
<div class="col">
Land
</div>
<div class="col">
Email
</div>
<div class="col">
Telefonnr.
</div>
</div>
</div>
@foreach (var user in UserList)
{
<a class="list-group-item list-group-item-action" href="/admin/users/@user.UserId">
<div class="row">
<div class="col">
@user.FullName
</div>
<div class="col">
@user.CountryCode
</div>
<div class="col">
@user.Email
</div>
<div class="col">
@user.PhoneNUmber
</div>
</div>
</a>
}
</div>
}

View file

@ -0,0 +1,10 @@
using Microsoft.AspNetCore.Components;
using Wonky.Entity.DTO;
using Wonky.Entity.Views;
namespace Wonky.Client.Components;
public partial class UserTableComponent
{
[Parameter] public List<AdminUserListView> UserList { get; set; }
}

View file

@ -0,0 +1,8 @@
using Wonky.Entity.DTO;
namespace Wonky.Client.HttpRepository;
public interface IUserHttpRepository
{
Task<List<AdminUserListView>?> GetSalesReps();
}

View file

@ -0,0 +1,40 @@
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 UserHttpRepository : IUserHttpRepository
{
private readonly JsonSerializerOptions? _options = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
};
private readonly NavigationManager _navigation;
private ILogger<UserHttpRepository> _logger;
private readonly HttpClient _client;
private readonly ApiConfig _api;
public UserHttpRepository(HttpClient client,
ILogger<UserHttpRepository> logger,
NavigationManager navigation,
IOptions<ApiConfig> configuration)
{
_client = client;
_logger = logger;
_navigation = navigation;
_api = configuration.Value;
}
public async Task<List<AdminUserListView>?> GetSalesReps()
{
var response = await _client.GetAsync(_api.AdminSalesRepUri);
var content = await response.Content.ReadAsStringAsync();
return !response.IsSuccessStatusCode
? new List<AdminUserListView>()
: JsonSerializer.Deserialize<List<AdminUserListView>>(content, _options);
}
}

View file

@ -0,0 +1,10 @@
@using Wonky.Client.Components
@page "/admin/users"
<div class="card">
<div class="card-heder">
<h3>Sælgere</h3>
</div>
<div class="card-body">
<UserTableComponent UserList="_salesReps"></UserTableComponent>
</div>
</div>

View file

@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Components;
using Wonky.Client.HttpInterceptors;
using Wonky.Client.HttpRepository;
using Wonky.Entity.DTO;
namespace Wonky.Client.Pages;
public partial class AdminUserList
{
[Inject] private HttpInterceptorService _interceptor { get; set; }
[Inject] private IUserHttpRepository _userRepo { get; set; }
private List<AdminUserListView>? _salesReps { get; set; } = new();
protected override async Task OnInitializedAsync()
{
_interceptor.RegisterEvent();
_interceptor.RegisterBeforeSendEvent();
_salesReps = await _userRepo.GetSalesReps();
}
}

View file

@ -54,6 +54,7 @@ builder.Services.AddScoped<IActivityHttpRepository, ActivityHttpRepository>();
builder.Services.AddScoped<IReportHttpRepository, ReportHttpRepository>();
builder.Services.AddScoped<ITaskItemHttpRepository, TaskItemHttpRepository>();
builder.Services.AddScoped<IHistoryHttpRepository, HistoryHttpRepository>();
builder.Services.AddScoped<IUserHttpRepository, UserHttpRepository>();
builder.Services.AddScoped<HttpInterceptorService>();
builder.Services.AddBlazoredLocalStorage();

View file

@ -18,12 +18,12 @@
},
"appInfo": {
"name": "Wonky Client",
"version": "0.8.37",
"version": "0.8.38",
"isBeta": true,
"image": "grumpy-coder.png"
},
"apiConfig": {
"innoBaseUrl": "https://staging.innotec.dk",
"innoBaseUrl": "https://dev.innotec.dk",
"glsTrackUrl": "https://www.gls-group.eu/276-I-PORTAL-WEB/content/GLS/DK01/DA/5004.htm?txtAction=71000&txtRefNo=",
"glsId": "",
"virkUrl": "api/v2/services/virk",
@ -38,6 +38,7 @@
"companyUri": "api/v2/crm/companies",
"inventoryUri": "history/inventory",
"productUri": "history/products",
"syncUri": "history/sync"
"syncUri": "history/sync",
"adminSalesRepUri": "api/v2/admin/users/salesreps"
}
}

View file

@ -34,12 +34,13 @@ public class ApiConfig
public string InventoryUri { get; set; } = "";
public string ProductUri { get; set; } = "";
public string SyncUri { get; set; } = "";
public string AdminSalesRepUri { get; set; } = "";
// public string KrvVariantsUri { get; set; } = "";
// public string KrvProductsUri { get; set; } = "";
// public string ImageUploadUri { get; set; } = "";
// public string UserRegistrationUri { get; set; } = "";
}

View file

@ -0,0 +1,10 @@
namespace Wonky.Entity.DTO;
public class AdminUserListView
{
public string UserId { get; set; } = "";
public string FullName { get; set; } = "";
public string Email { get; set; } = "";
public string CountryCode { get; set; } = "";
public string PhoneNUmber { get; set; } = "";
}