This commit is contained in:
2025-08-21 10:51:32 +02:00
parent cd88c79b32
commit 9957229e70
5 changed files with 80 additions and 5 deletions

View File

@@ -1,7 +1,6 @@
@using System.Globalization @using System.Globalization
@using System.Text.RegularExpressions @using System.Text.RegularExpressions
@using CommunityToolkit.Mvvm.Messaging @using CommunityToolkit.Mvvm.Messaging
@using Java.Util.Jar
@using salesbook.Shared.Core.Dto @using salesbook.Shared.Core.Dto
@using salesbook.Shared.Components.Layout @using salesbook.Shared.Components.Layout
@using salesbook.Shared.Core.Entity @using salesbook.Shared.Core.Entity
@@ -126,13 +125,13 @@
{ {
@if (item.p.Type == AttachedDTO.TypeAttached.Position) @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 @item.p.Description
</MudChip> </MudChip>
} }
else 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 @item.p.Name
</MudChip> </MudChip>
} }
@@ -542,4 +541,37 @@
StateHasChanged(); 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(",", ".");
} }

View File

@@ -559,6 +559,9 @@
private async Task ConvertProspectToContact() private async Task ConvertProspectToContact()
{ {
await IntegryApiService.TransferProspect(new CRMTransferProspectRequestDTO
{
CodPpro = ContactModel.CodContact
});
} }
} }

View File

@@ -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; }
}

View File

@@ -0,0 +1,7 @@
.content.attached {
display: flex;
flex-direction: column;
gap: 2rem;
padding: 1rem;
height: unset;
}

View File

@@ -85,4 +85,23 @@ public class ModalHelpers
return await modal.Result; 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;
}
} }