FEAT: link copy to clipboard - send link to email - link to qr-codes
This commit is contained in:
parent
e96e10412e
commit
328a2d89f8
9 changed files with 154 additions and 46 deletions
|
@ -26,6 +26,22 @@ namespace Wonky.Client.Helpers;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class Utils
|
public static class Utils
|
||||||
{
|
{
|
||||||
|
public static List<EmailContact> ParseRecipientsFromString(string recipients)
|
||||||
|
{
|
||||||
|
var addresses = recipients
|
||||||
|
.Replace(" ", ",")
|
||||||
|
.Replace(",,",",")
|
||||||
|
.Split(",");
|
||||||
|
|
||||||
|
return (from address
|
||||||
|
in addresses
|
||||||
|
where IsValidEmail(address)
|
||||||
|
select new EmailContact
|
||||||
|
{
|
||||||
|
Name = address, Email = address
|
||||||
|
}).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// map user role edit model to role assignment model
|
/// map user role edit model to role assignment model
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -150,7 +166,6 @@ public static class Utils
|
||||||
{
|
{
|
||||||
validConditions++;
|
validConditions++;
|
||||||
}
|
}
|
||||||
else return false;
|
|
||||||
|
|
||||||
return validConditions == 3;
|
return validConditions == 3;
|
||||||
}
|
}
|
||||||
|
|
17
Wonky.Client/Local.Services/ClipboardService.cs
Normal file
17
Wonky.Client/Local.Services/ClipboardService.cs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
using Microsoft.JSInterop;
|
||||||
|
|
||||||
|
namespace Wonky.Client.Local.Services;
|
||||||
|
|
||||||
|
public class ClipboardService :IClipboardService
|
||||||
|
{
|
||||||
|
private readonly IJSRuntime _jsInterop;
|
||||||
|
|
||||||
|
public ClipboardService(IJSRuntime jsInterop)
|
||||||
|
{
|
||||||
|
_jsInterop = jsInterop;
|
||||||
|
}
|
||||||
|
public async Task CopyToClipboard(string text)
|
||||||
|
{
|
||||||
|
await _jsInterop.InvokeVoidAsync("navigator.clipboard.writeText", text);
|
||||||
|
}
|
||||||
|
}
|
6
Wonky.Client/Local.Services/IClipboardService.cs
Normal file
6
Wonky.Client/Local.Services/IClipboardService.cs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
namespace Wonky.Client.Local.Services;
|
||||||
|
|
||||||
|
public interface IClipboardService
|
||||||
|
{
|
||||||
|
Task CopyToClipboard(string test);
|
||||||
|
}
|
|
@ -105,16 +105,41 @@
|
||||||
<button type="submit" class="form-control btn btn-success"><i class="bi-cloud-upload"></i> Gem</button>
|
<button type="submit" class="form-control btn btn-success"><i class="bi-cloud-upload"></i> Gem</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<div class="col-sm-12 col-md-6">
|
||||||
|
<div class="input-group">
|
||||||
|
<label class="input-group-text" for="qrlink">
|
||||||
|
<i class="bi-clipboard-plus"></i>
|
||||||
|
</label>
|
||||||
|
<input class="form-control text-muted" id="qrlink" type="text" readonly value="@Workplace.ShortUrl" />
|
||||||
|
<button type="button" class="@_buttonStyle" @onclick="@OnCopyLink">@_buttonText</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-12 col-md-6">
|
||||||
|
<div class="input-group">
|
||||||
|
<label class="input-group-text" for="mailto">
|
||||||
|
<i class="bi-at"></i>
|
||||||
|
</label>
|
||||||
|
<input class="form-control" id="mailto" type="email" placeholder="Indtast email adresse"
|
||||||
|
@bind-Value:event="onchange" @bind-Value="LinkRecipients" required/>
|
||||||
|
<button type="button" class="btn btn-primary" onclick="@OnSendLink">Send Link</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</EditForm>
|
</EditForm>
|
||||||
|
|
||||||
|
|
||||||
<ol class="list-group mb-3">
|
<ol class="list-group mb-3">
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-5">
|
||||||
Produkt Liste
|
<div class="h3 pt-1">Produkt Oversigt</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-4">
|
||||||
<button class="btn btn-primary btn-sm"><i class="bi-plus-lg"></i> Produkt(er)</button>
|
<a class="btn btn-primary" href="@Workplace.ShortUrl" target="_blank"><i class="bi-list-ul"></i> Åbn liste med QR-koder</a>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-3 text-end">
|
||||||
|
<button class="btn btn-primary"><i class="bi-plus-lg"></i> Produkt(er)</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
@ -153,4 +178,4 @@
|
||||||
<WorkingThreeDots/>
|
<WorkingThreeDots/>
|
||||||
}
|
}
|
||||||
|
|
||||||
<ConfirmDeleteModal BodyMessage="@DeleteMessage" OnOkClicked="OnDeleteWorkplace" @ref="ConfirmDelete" />
|
<ConfirmDeleteModal BodyMessage="@DeleteMessage" OnOkClicked="OnDeleteWorkplace" @ref="ConfirmDelete"/>
|
|
@ -13,15 +13,19 @@
|
||||||
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
|
||||||
//
|
//
|
||||||
|
|
||||||
|
using System.Text;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
using Blazored.Toast.Services;
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
using Microsoft.AspNetCore.Components.Forms;
|
using Microsoft.AspNetCore.Components.Forms;
|
||||||
using Wonky.Client.HttpInterceptors;
|
using Wonky.Client.HttpInterceptors;
|
||||||
using Wonky.Client.HttpRepository;
|
using Wonky.Client.HttpRepository;
|
||||||
|
using Wonky.Client.Local.Services;
|
||||||
using Wonky.Client.Models;
|
using Wonky.Client.Models;
|
||||||
using Wonky.Client.Shared;
|
using Wonky.Client.Shared;
|
||||||
using Wonky.Entity.DTO;
|
using Wonky.Entity.DTO;
|
||||||
using Wonky.Entity.Views;
|
using Wonky.Entity.Views;
|
||||||
|
using Wonky.Client.Helpers;
|
||||||
|
|
||||||
#pragma warning disable CS8618
|
#pragma warning disable CS8618
|
||||||
namespace Wonky.Client.Pages;
|
namespace Wonky.Client.Pages;
|
||||||
|
@ -35,6 +39,10 @@ public partial class AdvisorCustomerWorkplaceViewEditPage : IDisposable
|
||||||
[Inject] public HttpInterceptorService Interceptor { get; set; }
|
[Inject] public HttpInterceptorService Interceptor { get; set; }
|
||||||
[Inject] public NavigationManager Navigator { get; set; }
|
[Inject] public NavigationManager Navigator { get; set; }
|
||||||
[Inject] public ILogger<AdvisorCustomerWorkplaceViewEditPage> Logger { get; set; }
|
[Inject] public ILogger<AdvisorCustomerWorkplaceViewEditPage> Logger { get; set; }
|
||||||
|
[Inject] public ISystemSendMailService SendMail { get; set; }
|
||||||
|
[Inject] public IUserInfoService UserInfo { get; set; }
|
||||||
|
[Inject] public IClipboardService Clipboard { get; set; }
|
||||||
|
[Inject] public IToastService Toaster { get; set; }
|
||||||
|
|
||||||
// #############################################################
|
// #############################################################
|
||||||
[Parameter] public string CompanyId { get; set; } = "";
|
[Parameter] public string CompanyId { get; set; } = "";
|
||||||
|
@ -48,6 +56,14 @@ public partial class AdvisorCustomerWorkplaceViewEditPage : IDisposable
|
||||||
private List<DocView> DocViews { get; set; } = new();
|
private List<DocView> DocViews { get; set; } = new();
|
||||||
private ConfirmDeleteModal ConfirmDelete { get; set; }
|
private ConfirmDeleteModal ConfirmDelete { get; set; }
|
||||||
private string DeleteMessage { get; set; } = "";
|
private string DeleteMessage { get; set; } = "";
|
||||||
|
private string LinkRecipients { get; set; } = "";
|
||||||
|
private const string CopyText = "Kopier";
|
||||||
|
private const string CopyStyle = "btn btn-primary";
|
||||||
|
private const string SuccessText = "Kopieret";
|
||||||
|
private const string SuccessStyle = "btn btn-success";
|
||||||
|
private string _buttonText = CopyText;
|
||||||
|
private string _buttonStyle = CopyStyle;
|
||||||
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
|
@ -65,7 +81,72 @@ public partial class AdvisorCustomerWorkplaceViewEditPage : IDisposable
|
||||||
Working = false;
|
Working = false;
|
||||||
DeleteMessage = $"Bekræft at du sletter<br/><strong>{Workplace.Name}</strong> fra <strong>{Workplace.CompanyName}</strong>?<br/>AL INFORMATION slettes og handlingen er uigenkaldelig.";
|
DeleteMessage = $"Bekræft at du sletter<br/><strong>{Workplace.Name}</strong> fra <strong>{Workplace.CompanyName}</strong>?<br/>AL INFORMATION slettes og handlingen er uigenkaldelig.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async Task OnSendLink()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(LinkRecipients))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Logger.LogDebug("email.To => {}", LinkRecipients);
|
||||||
|
|
||||||
|
var bodyText = new StringBuilder();
|
||||||
|
bodyText.AppendLine("Produkt oversigt med QR-koder findes ved at følge linket nedenfor.");
|
||||||
|
bodyText.AppendLine();
|
||||||
|
bodyText.AppendLine();
|
||||||
|
bodyText.AppendLine(Workplace.ShortUrl);
|
||||||
|
bodyText.AppendLine();
|
||||||
|
bodyText.AppendLine();
|
||||||
|
bodyText.AppendLine("Med venlig hilsen");
|
||||||
|
bodyText.AppendLine();
|
||||||
|
bodyText.AppendLine();
|
||||||
|
bodyText.AppendLine("Innotec Danmark A/S");
|
||||||
|
bodyText.AppendLine();
|
||||||
|
bodyText.AppendLine();
|
||||||
|
bodyText.AppendLine("Telefon +45 86 28 63 36");
|
||||||
|
bodyText.AppendLine();
|
||||||
|
bodyText.AppendLine();
|
||||||
|
bodyText.AppendLine("Denne mail er sendt af en robot og kan ikke besvares");
|
||||||
|
|
||||||
|
var email = new EmailMessage
|
||||||
|
{
|
||||||
|
To = Utils.ParseRecipientsFromString(LinkRecipients),
|
||||||
|
Subject = "Innotec Kemi - Produkt Oversigt",
|
||||||
|
Body = bodyText.ToString(),
|
||||||
|
IsBodyHtml = false
|
||||||
|
};
|
||||||
|
|
||||||
|
if (email.To.Any())
|
||||||
|
{
|
||||||
|
var result = await SendMail.SendMail("system", email);
|
||||||
|
if (result.IsSuccess)
|
||||||
|
{
|
||||||
|
Toaster.ShowSuccess("Email er sendt");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Toaster.ShowWarning("Email er ikke sendt.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnCopyLink()
|
||||||
|
{
|
||||||
|
await Clipboard.CopyToClipboard(Workplace.ShortUrl);
|
||||||
|
|
||||||
|
_buttonText = SuccessText;
|
||||||
|
_buttonStyle = SuccessStyle;
|
||||||
|
|
||||||
|
StateHasChanged();
|
||||||
|
|
||||||
|
await Task.Delay(TimeSpan.FromSeconds(2));
|
||||||
|
|
||||||
|
_buttonText = CopyText;
|
||||||
|
_buttonStyle = CopyStyle;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private async Task OnSubmitUpdate()
|
private async Task OnSubmitUpdate()
|
||||||
{
|
{
|
||||||
|
@ -80,6 +161,7 @@ public partial class AdvisorCustomerWorkplaceViewEditPage : IDisposable
|
||||||
Logger.LogDebug("ConfirmDeleteWorkplace");
|
Logger.LogDebug("ConfirmDeleteWorkplace");
|
||||||
ConfirmDelete.Show();
|
ConfirmDelete.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private async Task OnDeleteWorkplace()
|
private async Task OnDeleteWorkplace()
|
||||||
{
|
{
|
||||||
|
|
|
@ -54,6 +54,8 @@ builder.Services.AddHttpClientInterceptor();
|
||||||
builder.Services.Configure<ApiConfig>(builder.Configuration.GetSection("ApiConfig"));
|
builder.Services.Configure<ApiConfig>(builder.Configuration.GetSection("ApiConfig"));
|
||||||
// app info object
|
// app info object
|
||||||
builder.Services.Configure<AppInfo>(builder.Configuration.GetSection("AppInfo"));
|
builder.Services.Configure<AppInfo>(builder.Configuration.GetSection("AppInfo"));
|
||||||
|
// interface
|
||||||
|
builder.Services.AddScoped<IClipboardService, ClipboardService>();
|
||||||
// user
|
// user
|
||||||
builder.Services.AddScoped<IUserInfoService, UserInfoService>();
|
builder.Services.AddScoped<IUserInfoService, UserInfoService>();
|
||||||
builder.Services.AddScoped<UserPreferenceService, UserPreferenceService>();
|
builder.Services.AddScoped<UserPreferenceService, UserPreferenceService>();
|
||||||
|
|
|
@ -1,12 +1,4 @@
|
||||||
{
|
{
|
||||||
"iisSettings": {
|
|
||||||
"windowsAuthentication": false,
|
|
||||||
"anonymousAuthentication": true,
|
|
||||||
"iisExpress": {
|
|
||||||
"applicationUrl": "http://localhost:61714",
|
|
||||||
"sslPort": 44308
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"profiles": {
|
"profiles": {
|
||||||
"Wonky.Client": {
|
"Wonky.Client": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
|
@ -17,34 +9,6 @@
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"Chrome": {
|
|
||||||
"commandName": "Project",
|
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"launchBrowser": true,
|
|
||||||
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
|
|
||||||
"applicationUrl": "https://localhost:7174;http://localhost:5280",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"Firefox": {
|
|
||||||
"commandName": "Project",
|
|
||||||
"dotnetRunMessages": true,
|
|
||||||
"launchBrowser": true,
|
|
||||||
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
|
|
||||||
"applicationUrl": "https://localhost:7174;http://localhost:5280",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"IIS Express": {
|
|
||||||
"commandName": "IISExpress",
|
|
||||||
"launchBrowser": true,
|
|
||||||
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
|
|
||||||
"environmentVariables": {
|
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,6 @@
|
||||||
<Content Remove="Pages\AdvisorCustomerOrderViewPage.razor" />
|
<Content Remove="Pages\AdvisorCustomerOrderViewPage.razor" />
|
||||||
<Content Remove="Pages\OfficeUserAdvisorViewEditPage.razor" />
|
<Content Remove="Pages\OfficeUserAdvisorViewEditPage.razor" />
|
||||||
<Content Remove="wwwroot\scripts\document-event-load.js" />
|
<Content Remove="wwwroot\scripts\document-event-load.js" />
|
||||||
<Content Update="wwwroot\appsettings.release.json">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</Content>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"appInfo": {
|
"appInfo": {
|
||||||
"name": "Wonky Online",
|
"name": "Wonky Online",
|
||||||
"version": "138.17",
|
"version": "141.2",
|
||||||
"rc": true,
|
"rc": true,
|
||||||
"sandBox": false,
|
"sandBox": false,
|
||||||
"image": "grumpy-coder.png"
|
"image": "grumpy-coder.png"
|
||||||
|
|
Loading…
Reference in a new issue