Vario
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
@using System.Globalization
|
||||
@using System.Text.RegularExpressions
|
||||
@using CommunityToolkit.Mvvm.Messaging
|
||||
@using Java.Util.Jar
|
||||
@using salesbook.Shared.Core.Dto
|
||||
@using salesbook.Shared.Components.Layout
|
||||
@using salesbook.Shared.Core.Entity
|
||||
@@ -126,13 +125,13 @@
|
||||
{
|
||||
@if (item.p.Type == AttachedDTO.TypeAttached.Position)
|
||||
{
|
||||
<MudChip T="string" Icon="@Icons.Material.Rounded.LocationOn" Color="Color.Success" OnClose="() => OnRemoveAttached(item.index)">
|
||||
<MudChip T="string" Icon="@Icons.Material.Rounded.LocationOn" Color="Color.Success" OnClick="() => OpenPosition(item.p)" OnClose="() => OnRemoveAttached(item.index)">
|
||||
@item.p.Description
|
||||
</MudChip>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudChip T="string" Color="Color.Default" OnClose="() => OnRemoveAttached(item.index)">
|
||||
<MudChip T="string" Color="Color.Default" OnClick="() => OpenAttached(item.p)" OnClose="() => OnRemoveAttached(item.index)">
|
||||
@item.p.Name
|
||||
</MudChip>
|
||||
}
|
||||
@@ -542,4 +541,37 @@
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task OpenAttached(AttachedDTO attached)
|
||||
{
|
||||
if (attached is { FileContent: not null, MimeType: not null })
|
||||
{
|
||||
var fileViewerUrl = $"data:{attached.MimeType};base64,{Convert.ToBase64String(attached.FileContent)}";
|
||||
await ModalHelpers.OpenViewAttach(Dialog, fileViewerUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar.Clear();
|
||||
Snackbar.Add("Impossibile aprire il file", Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void OpenPosition(AttachedDTO attached)
|
||||
{
|
||||
if (attached is { Lat: not null, Lng: not null })
|
||||
{
|
||||
const string baseUrl = "https://www.google.it/maps/place/";
|
||||
NavigationManager.NavigateTo(
|
||||
$"{baseUrl}{AdjustCoordinate(attached.Lat.Value)},{AdjustCoordinate(attached.Lng.Value)}"
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar.Clear();
|
||||
Snackbar.Add("Impossibile aprire la posizione", Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private static string AdjustCoordinate(double coordinate) =>
|
||||
coordinate.ToString(CultureInfo.InvariantCulture).Replace(",", ".");
|
||||
|
||||
}
|
||||
@@ -559,6 +559,9 @@
|
||||
|
||||
private async Task ConvertProspectToContact()
|
||||
{
|
||||
|
||||
await IntegryApiService.TransferProspect(new CRMTransferProspectRequestDTO
|
||||
{
|
||||
CodPpro = ContactModel.CodContact
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<MudDialog Class="customDialog-form">
|
||||
<DialogContent>
|
||||
@if (!string.IsNullOrEmpty(FileViewerUrl))
|
||||
{
|
||||
<iframe src="@FileViewerUrl" style="width:100%; height:80vh; border:none;"></iframe>
|
||||
}
|
||||
</DialogContent>
|
||||
</MudDialog>
|
||||
|
||||
@code {
|
||||
[CascadingParameter] private IMudDialogInstance MudDialog { get; set; }
|
||||
|
||||
[Parameter] public string? FileViewerUrl { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
.content.attached {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2rem;
|
||||
padding: 1rem;
|
||||
height: unset;
|
||||
}
|
||||
@@ -85,4 +85,23 @@ public class ModalHelpers
|
||||
|
||||
return await modal.Result;
|
||||
}
|
||||
|
||||
public static async Task<DialogResult?> OpenViewAttach(IDialogService dialog, string? fileViewUrl)
|
||||
{
|
||||
var modal = await dialog.ShowAsync<ViewAttached>(
|
||||
"View attached",
|
||||
new DialogParameters<ViewAttached>
|
||||
{
|
||||
{ x => x.FileViewerUrl, fileViewUrl }
|
||||
},
|
||||
new DialogOptions
|
||||
{
|
||||
FullScreen = true,
|
||||
CloseButton = true,
|
||||
NoHeader = true
|
||||
}
|
||||
);
|
||||
|
||||
return await modal.Result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user