This commit is contained in:
Frede Hundewadt 2022-06-21 17:05:21 +02:00
parent 42cf1110e9
commit 16b934e3f4
18 changed files with 269 additions and 29 deletions

View file

@ -0,0 +1,38 @@
@*
// 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 (TaskItemList.Any())
{
<div class="list-group list-group-flush">
@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">
</div>
<div class="col">
</div>
<div class="col">
</div>
<div class="col">
</div>
</div>
</a>
}
</div>
}

View file

@ -0,0 +1,44 @@
// 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.Shared;
using Wonky.Entity.DTO;
namespace Wonky.Client.Components
{
public partial class TaskItemTableComponent
{
[Parameter] public List<TaskItemDto> TaskItemList { get; set; } = new();
[Parameter] public EventCallback<string> OnDelete { get; set; }
[Parameter] public EventCallback<string> OnSelect { get; set; }
private Confirmation _confirmation = new ();
private string _taskItemId = "";
private void CallConfirmationModal(string taskItemId)
{
_taskItemId = taskItemId;
_confirmation.Show();
}
private async Task DeleteTaskItem()
{
_confirmation.Hide();
await OnDelete.InvokeAsync(_taskItemId);
}
}
}

View file

@ -67,7 +67,7 @@ public class CompanyHttpRepository : ICompanyHttpRepository
["isHidden"] = pagingParameters.IsHidden.ToString(),
["hasFolded"] = pagingParameters.HasFolded.ToString()
};
var response = await _client.GetAsync(QueryHelpers.AddQueryString($"{_apiConfig.CustomerEndpoint}/page", queryString));
var response = await _client.GetAsync(QueryHelpers.AddQueryString($"{_apiConfig.CompanyEndpoint}/page", queryString));
var content = await response.Content.ReadAsStringAsync();
@ -81,13 +81,13 @@ public class CompanyHttpRepository : ICompanyHttpRepository
public async Task<CompanyDto> GetCompanyByAccount(string accountNumber)
{
var company = await _client.GetFromJsonAsync<CompanyDto>($"{_apiConfig.CustomerEndpoint}/account/{accountNumber}");
var company = await _client.GetFromJsonAsync<CompanyDto>($"{_apiConfig.CompanyEndpoint}/account/{accountNumber}");
return company ?? new CompanyDto();
}
public async Task<CompanyDto> GetCompanyById(string companyId)
{
var company = await _client.GetFromJsonAsync<CompanyDto>($"{_apiConfig.CustomerEndpoint}/{companyId}");
var company = await _client.GetFromJsonAsync<CompanyDto>($"{_apiConfig.CompanyEndpoint}/{companyId}");
return company ?? new CompanyDto();
}
@ -98,7 +98,7 @@ public class CompanyHttpRepository : ICompanyHttpRepository
/// <returns>company id</returns>
public async Task<string> CreateCompany(CompanyDto model)
{
var response = await _client.PostAsJsonAsync($"{_apiConfig.CustomerEndpoint}", model);
var response = await _client.PostAsJsonAsync($"{_apiConfig.CompanyEndpoint}", model);
var content = await response.Content.ReadAsStringAsync();
var result = JsonSerializer.Deserialize<CompanyDto>(content, _options);
return result.CompanyId;
@ -106,13 +106,13 @@ public class CompanyHttpRepository : ICompanyHttpRepository
public async Task<bool> UpdateCompany(string companyId, CompanyDto model)
{
var response = await _client.PutAsJsonAsync($"{_apiConfig.CustomerEndpoint}/{companyId}", model);
var response = await _client.PutAsJsonAsync($"{_apiConfig.CompanyEndpoint}/{companyId}", model);
return response.IsSuccessStatusCode;
}
public async Task<bool> DeleteCompany(string companyId)
{
var response = await _client.DeleteAsync($"{_apiConfig.CustomerEndpoint}/{companyId}");
var response = await _client.DeleteAsync($"{_apiConfig.CompanyEndpoint}/{companyId}");
return response.IsSuccessStatusCode;
}
}

View file

@ -0,0 +1,10 @@
using Wonky.Client.Pages;
namespace Wonky.Client.HttpRepository;
public interface ITaskItemHttpRepository
{
Task<List<TaskItemView>> GetTaskList();
Task CreateTaskItem(TaskItemView taskItem);
Task<TaskItemView> GetTaskItem(string taskItemId);
}

View file

@ -0,0 +1,47 @@
using System.Net.Http.Json;
using System.Text.Json;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Options;
using Wonky.Client.Pages;
using Wonky.Entity.Configuration;
using Wonky.Entity.Views;
namespace Wonky.Client.HttpRepository;
public class TaskItemHttpRepository : ITaskItemHttpRepository
{
private readonly JsonSerializerOptions _options = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
};
private readonly NavigationManager _navigation;
private ILogger<TaskItemHttpRepository> _logger;
private readonly HttpClient _client;
private readonly ApiConfig _apiConfig;
public TaskItemHttpRepository(HttpClient client,
ILogger<TaskItemHttpRepository> logger,
NavigationManager navigation, IOptions<ApiConfig> configuration)
{
_client = client;
_logger = logger;
_navigation = navigation;
_apiConfig = configuration.Value;
}
public async Task<List<TaskItemView>> GetTaskList()
{
return await _client.GetFromJsonAsync<List<TaskItemView>>($"{_apiConfig.TaskItemEndpoint}");
}
public async Task CreateTaskItem(TaskItemView taskItem)
{
await _client.PostAsJsonAsync($"{_apiConfig.TaskItemEndpoint}", taskItem);
}
public async Task<TaskItemView> GetTaskItem(string taskItemId)
{
return await _client.GetFromJsonAsync<TaskItemView>($"{_apiConfig.TaskItemEndpoint}/{taskItemId}");
}
}

View file

@ -28,7 +28,7 @@
</div>
<div class="col">
<h5>Browservalg</h5>
Det anbefales at bruge en Chrome baseret browser f.eks. Edge, Safari, Vivaldi, Chrome eller Chromium
De nyeste udgaver af Firefox, Edge, Safari, Vivaldi, Chrome eller Chromium.
</div>
</div>
<div class="row">

View file

@ -31,7 +31,7 @@
<WorkDateComponent OnChanged="SetWorkDate"></WorkDateComponent>
</div>
<div class="col">
@if (_fetching)
@if (_working)
{
<AppSpinner></AppSpinner>
}

View file

@ -44,7 +44,7 @@ public partial class ReportCreate : IDisposable
private Preferences _prefs { get; set; } = new();
private bool _formInvalid = true;
private bool _noFigures = true;
private bool _fetching = false;
private bool _working = false;
private DateTime _workDate { get; set; } = DateTime.Now;
private TimeOnly _timestampIn { get; set; } = new(12, 0);
private TimeOnly _timestampOut { get; set; } = new(12, 0);
@ -110,15 +110,15 @@ public partial class ReportCreate : IDisposable
_report.FromDateTime = $"{checkIn:yyyy-MM-dd hh:mm}";
_report.ToDateTime = $"{checkOut:yyyy-MM-dd hh:mm}";
_report.Figures.Distance = _report.Figures.KmEvening - _report.Figures.KmMorning;
_report.Figures.DistanceMonth += _report.Figures.Distance;
_report.Figures.DistancePrivateMonth += _report.Figures.DistancePrivate;
_working = true;
_fetching = true;
var result = await ReportRepo.PostReport($"{_workDate:yyyy-MM-dd}", _report);
if (result.IsSuccess)
{
_toast.ShowInfo($"Rapport oprettet {_workDate}");
}
_fetching = false;
_toast.ShowInfo($"Rapport oprettet {_workDate}");
Navigator.NavigateTo("/home");
}
@ -149,7 +149,7 @@ public partial class ReportCreate : IDisposable
private async Task GetKeyFigures()
{
_fetching = true;
_working = true;
var data = await ReportRepo.InitializeReportData($"{_workDate:yyyy-MM-dd}");
if(data.Closed)
Navigator.NavigateTo($"/sales-reports/view/{_workDate:yyyy-MM-dd}");
@ -157,7 +157,7 @@ public partial class ReportCreate : IDisposable
_report.Figures = data.Figures;
_init = data.Figures;
_activities = data.Activities;
_fetching = false;
_working = false;
}
public void Dispose()

View file

@ -0,0 +1,20 @@
@page "/task-items"
<div class="card">
<div class="card-header">
<div class="row mb-1 align-items-center">
<div class="col">
<h3 class="workDate">@(string.IsNullOrWhiteSpace(_workDate) ? "" : $"{DateTime.Parse(_workDate).ToLongDateString()}")</h3>
</div>
<div class="col">
<WorkDateComponent OnChanged="GetTaskItems"></WorkDateComponent>
</div>
<div class="col">
<a class="btn btn-primary" href="/task-items/new">NY OPGAVE</a>
</div>
</div>
</div>
</div>
<div class="card-body">
<TaskItemsTableComponent Activities="_view.Activities"></TaskItemsTableComponent>
</div>

View file

@ -0,0 +1,40 @@
using Blazored.Toast.Services;
using Microsoft.AspNetCore.Components;
using Wonky.Client.Components;
using Wonky.Client.HttpInterceptors;
using Wonky.Client.HttpRepository;
using Wonky.Client.Services;
using Wonky.Entity.Views;
namespace Wonky.Client.Pages;
public partial class TaskItemList
{
[Inject] public UserPreferenceService UserPrefs { get; set; }
[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 IToastService _toast { get; set; }
private Preferences _prefs { get; set; } = new();
private string _workDate { get; set; } = $"{DateTime.Now:yyyy-MM-dd}";
private bool _reportExist = false;
protected override async Task OnInitializedAsync()
{
_prefs = await UserPrefs.GetPreferences();
if(!string.IsNullOrWhiteSpace(_prefs.WorkDate))
_workDate = _prefs.WorkDate;
_interceptor.RegisterEvent();
_interceptor.RegisterBeforeSendEvent();
await GetActivities(_workDate);
}
private async Task GetActivities(string workDate)
{
_toast.ShowInfo("Vent nogle sekunder for data");
_workDate = workDate;
}
}

View file

@ -0,0 +1,7 @@
@page "/taskitems/view"
<div class="card">
<div class="card-header">
<h3>Task Item</h3>
</div>
</div>

View file

@ -0,0 +1,14 @@
using Microsoft.AspNetCore.Components;
namespace Wonky.Client.Pages;
public partial class TaskItemView
{
[Parameter] public string TaskItemId { get; set; }
protected override Task OnParametersSetAsync()
{
return base.OnParametersSetAsync();
}
}

View file

@ -17,7 +17,7 @@ using System.Net.Http.Headers;
using System.Security.Claims;
using Blazored.LocalStorage;
using Microsoft.AspNetCore.Components.Authorization;
using Wonky.Entity.Views;
using Wonky.Entity.DTO;
namespace Wonky.Client.Shared
{

View file

@ -18,7 +18,7 @@
<div class="modal" tabindex="-1" role="dialog" style="display:@_modalDisplay">
<div class="modal-dialog" role="document">
<div class="modal-content">
<h5 class="modal-header">Bekræft handling</h5>
<h5 class="modal-header">Bekræft venligst</h5>
<button type="button" class="close" @onclick="Hide" aria-label="Luk"></button>
<span aria-hidden="true">&times;</span>
</div>

View file

@ -18,15 +18,15 @@
},
"appInfo": {
"name": "Wonky Client",
"version": "0.8.15",
"version": "0.8.20",
"isBeta": true,
"image": "grumpy-coder.png"
},
"apiConfig": {
"baseAddress": "https://staging.innotec.dk",
"baseAddress": "https://dev.innotec.dk",
"tokenPath": "token",
"userInfo": "api/auth/userinfo",
"customerEndpoint": "api/v2/crm/companies",
"companyEndpoint": "api/v2/crm/companies",
"catalogEndpoint": "api/v2/crm/catalog",
"virkEndpoint": "api/v2/services/virk",
"brRegEndpoint": "api/v2/services/brReg",
@ -34,6 +34,9 @@
"glsTrackUrl": "https://www.gls-group.eu/276-I-PORTAL-WEB/content/GLS/DK01/DA/5004.htm?txtAction=71000&txtRefNo=",
"glsId": "",
"activityEndpoint": "api/v2/crm/salesReps/sales",
"reportEndpoint": "api/v2/crm/salesReps/reports"
"reportEndpoint": "api/v2/crm/salesReps/reports",
"taskItemEndpoint": "api/v2/crm/salesRps/tasks",
"productHistoryEndpoint": "products",
"accountHistoryEndpoint": "account"
}
}

View file

@ -17,7 +17,7 @@ namespace Wonky.Entity.Configuration;
public class ApiConfig
{
public string BaseAddress { get; set; } = "";
public string CustomerEndpoint { get; set; } = "";
public string CompanyEndpoint { get; set; } = "";
public string CatalogEndpoint { get; set; } = "";
public string KrvVariants { get; set; } = "";
public string KrvProducts { get; set; } = "";
@ -32,4 +32,7 @@ public class ApiConfig
public string GlsId { get; set; } = "";
public string ActivityEndpoint { get; set; } = "";
public string ReportEndpoint { get; set; } = "";
public string TaskItemEndpoint { get; set; } = "";
public string ProductHistoryEndpoint { get; set; } = "";
public string AccountHistoryEndpoint { get; set; } = "";
}

View file

@ -0,0 +1,14 @@
namespace Wonky.Entity.DTO;
public class TaskItemDto
{
public string TaskItemId { get; set; } = "";
public string ErpUserId { get; set; } = "";
public string Name { get; set; } = "";
public string Text { get; set; } = "";
public string DueTimestamp { get; set; } = "";
public int Interval { get; set; }
public bool IsCompleted { get; set; }
public bool OverDue { get; set; }
public bool Recurring { get; set; }
}

View file

@ -15,11 +15,11 @@
using System.Text.Json.Serialization;
namespace Wonky.Entity.Views;
namespace Wonky.Entity.DTO;
public class UserInfoView
{
[JsonPropertyName("Id")] public string Id { get; set; } = "";
[JsonPropertyName("id")] public string Id { get; set; } = "";
[JsonPropertyName("adviser")] public string Adviser { get; set; } = "";
[JsonPropertyName("companyId")] public string CrmCompanyKey { get; set; } = "";
[JsonPropertyName("countryCode")] public string CountryCode { get; set; } = "";