Fix downloadFile
This commit is contained in:
@@ -121,6 +121,7 @@
|
||||
background: var(--light-card-background);
|
||||
border-radius: 16px;
|
||||
overflow: clip;
|
||||
min-height: 45px;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
|
||||
@@ -274,9 +274,9 @@ else
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<MudScrollToTop Selector="#topPage" VisibleCssClass="visible absolute" TopOffset="100" HiddenCssClass="invisible">
|
||||
<MudFab Size="Size.Small" Color="Color.Primary" StartIcon="@Icons.Material.Rounded.KeyboardArrowUp"/>
|
||||
</MudScrollToTop>
|
||||
@* <MudScrollToTop Selector="#topPage" VisibleCssClass="visible absolute" TopOffset="100" HiddenCssClass="invisible"> *@
|
||||
@* <MudFab Size="Size.Small" Color="Color.Primary" StartIcon="@Icons.Material.Rounded.KeyboardArrowUp"/> *@
|
||||
@* </MudScrollToTop> *@
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -170,6 +170,7 @@
|
||||
|
||||
var matchesText =
|
||||
(!string.IsNullOrEmpty(user.RagSoc) && user.RagSoc.Contains(filter, StringComparison.OrdinalIgnoreCase)) ||
|
||||
(!string.IsNullOrEmpty(user.CodContact) && user.CodContact.Contains(filter, StringComparison.OrdinalIgnoreCase)) ||
|
||||
(!string.IsNullOrEmpty(user.Indirizzo) && user.Indirizzo.Contains(filter, StringComparison.OrdinalIgnoreCase)) ||
|
||||
(!string.IsNullOrEmpty(user.Telefono) && user.Telefono.Contains(filter, StringComparison.OrdinalIgnoreCase)) ||
|
||||
(!string.IsNullOrEmpty(user.EMail) && user.EMail.Contains(filter, StringComparison.OrdinalIgnoreCase)) ||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
@using salesbook.Shared.Components.Layout.Spinner
|
||||
@using salesbook.Shared.Core.Dto
|
||||
@using salesbook.Shared.Core.Interface
|
||||
@using salesbook.Shared.Core.Interface.IntegryApi
|
||||
@@ -34,12 +35,24 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<OverlayLayout Visible="VisibleOverlay" />
|
||||
|
||||
@code {
|
||||
[Parameter] public CRMAttachedResponseDTO Attached { get; set; } = new();
|
||||
|
||||
private bool VisibleOverlay { get; set; }
|
||||
|
||||
private async Task OpenAttached()
|
||||
{
|
||||
var bytes = await IntegryApiService.DownloadFileFromRefUuid(Attached.RefUuid, Attached.FileName);
|
||||
await AttachedService.OpenFile(bytes, Attached.FileName);
|
||||
VisibleOverlay = true;
|
||||
StateHasChanged();
|
||||
|
||||
await using var file = await IntegryApiService.DownloadFileFromRefUuid(Attached.RefUuid, Attached.FileName);
|
||||
var path = await AttachedService.SaveToTempStorage(file, Attached.FileName);
|
||||
|
||||
VisibleOverlay = false;
|
||||
StateHasChanged();
|
||||
|
||||
await AttachedService.OpenFile(Attached.FileName, path);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
@using CommunityToolkit.Mvvm.Messaging
|
||||
@using salesbook.Shared.Components.Layout
|
||||
@using salesbook.Shared.Components.Layout.Overlay
|
||||
@using salesbook.Shared.Components.Layout.Spinner
|
||||
@using salesbook.Shared.Components.SingleElements.BottomSheet
|
||||
@using salesbook.Shared.Core.Dto
|
||||
@using salesbook.Shared.Core.Dto.Activity
|
||||
@@ -235,7 +236,7 @@
|
||||
{
|
||||
foreach (var file in ActivityFileList)
|
||||
{
|
||||
<MudChip T="string" OnClick="@(() => OpenAttached(file.Id, file.FileName))"
|
||||
<MudChip T="string" OnClick="@(() => OpenAttached(file.FileName))"
|
||||
OnClose="@(() => DeleteAttach(file))" Color="Color.Default">
|
||||
@file.FileName
|
||||
</MudChip>
|
||||
@@ -304,6 +305,8 @@
|
||||
|
||||
<SaveOverlay VisibleOverlay="VisibleOverlay" SuccessAnimation="SuccessAnimation"/>
|
||||
|
||||
<OverlayLayout Visible="VisibleLoadingOverlay"/>
|
||||
|
||||
<SelectEsito @bind-IsSheetVisible="OpenEsito" @bind-ActivityModel="ActivityModel"
|
||||
@bind-ActivityModel:after="OnAfterChangeEsito"/>
|
||||
|
||||
@@ -332,8 +335,9 @@
|
||||
|
||||
private string? LabelSave { get; set; }
|
||||
|
||||
//Overlay for save
|
||||
//Overlay
|
||||
private bool VisibleOverlay { get; set; }
|
||||
private bool VisibleLoadingOverlay { get; set; }
|
||||
private bool SuccessAnimation { get; set; }
|
||||
|
||||
private bool OpenEsito { get; set; }
|
||||
@@ -770,15 +774,29 @@
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task OpenAttached(string idAttached, string fileName)
|
||||
private async Task OpenAttached(string fileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var bytes = await IntegryApiService.DownloadFile(ActivityModel.ActivityId!, fileName);
|
||||
await AttachedService.OpenFile(bytes, fileName);
|
||||
VisibleOverlay = true;
|
||||
StateHasChanged();
|
||||
|
||||
await using var file = await IntegryApiService.DownloadFile(ActivityModel.ActivityId!, fileName);
|
||||
var path = await AttachedService.SaveToTempStorage(file, fileName);
|
||||
|
||||
VisibleOverlay = false;
|
||||
StateHasChanged();
|
||||
|
||||
await AttachedService.OpenFile(fileName, path);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (VisibleOverlay)
|
||||
{
|
||||
VisibleOverlay = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
Snackbar.Clear();
|
||||
Snackbar.Add("Impossibile aprire il file", Severity.Error);
|
||||
Console.WriteLine($"Errore durante l'apertura del file: {ex.Message}");
|
||||
@@ -789,7 +807,15 @@
|
||||
{
|
||||
if (attached is { FileContent: not null, MimeType: not null })
|
||||
{
|
||||
await AttachedService.OpenFile(attached.FileContent!, attached.Name);
|
||||
VisibleOverlay = true;
|
||||
StateHasChanged();
|
||||
|
||||
var path = await AttachedService.SaveToTempStorage(attached.FileContent!, attached.Name);
|
||||
|
||||
VisibleOverlay = false;
|
||||
StateHasChanged();
|
||||
|
||||
await AttachedService.OpenFile(attached.Name, path);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user