Compare commits

...

2 Commits

Author SHA1 Message Date
544c9e8237 Gestiti allegati da galleria e fotocamera e aggiunto sentry 2026-02-17 10:23:46 +01:00
c1a133c61e Aggiunti nuovi campi al form 2026-02-17 09:47:14 +01:00
16 changed files with 244 additions and 77 deletions

View File

@@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="androidx.lifecycle.lifecycle-common-java8">
<CLASSES>
<root url="jar://$USER_HOME$/.nuget/packages/xamarin.androidx.lifecycle.common.java8/2.8.7.2/jar/androidx.lifecycle.lifecycle-common-java8.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="org.jetbrains.kotlin.kotlin-stdlib-jdk7-2.0.0">
<CLASSES>
<root url="jar://$USER_HOME$/.nuget/packages/xamarin.kotlin.stdlib.jdk7/2.0.0/jar/org.jetbrains.kotlin.kotlin-stdlib-jdk7-2.0.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="org.jetbrains.kotlin.kotlin-stdlib-jdk8-2.0.0">
<CLASSES>
<root url="jar://$USER_HOME$/.nuget/packages/xamarin.kotlin.stdlib.jdk8/2.0.0/jar/org.jetbrains.kotlin.kotlin-stdlib-jdk8-2.0.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</component>

View File

@@ -0,0 +1,101 @@
using SteUp.Shared.Core.Dto;
using SteUp.Shared.Core.Interface.System;
namespace SteUp.Maui.Core.Services;
public class AttachedService : IAttachedService
{
public async Task<AttachedDto?> SelectImageFromCamera()
{
var cameraPerm = await Permissions.RequestAsync<Permissions.Camera>();
var storagePerm = await Permissions.RequestAsync<Permissions.StorageWrite>();
if (cameraPerm != PermissionStatus.Granted || storagePerm != PermissionStatus.Granted)
return null;
FileResult? result;
try
{
result = await MediaPicker.Default.CapturePhotoAsync();
}
catch (Exception ex)
{
Console.WriteLine($"Errore cattura foto: {ex.Message}");
SentrySdk.CaptureException(ex);
return null;
}
return result is null ? null : await ConvertToDto(result, AttachedDto.TypeAttached.Image);
}
public async Task<AttachedDto?> SelectImageFromGallery()
{
var storagePerm = await Permissions.RequestAsync<Permissions.StorageRead>();
if (storagePerm != PermissionStatus.Granted)
return null;
FileResult? result;
try
{
result = await MediaPicker.Default.PickPhotoAsync();
}
catch (Exception ex)
{
Console.WriteLine($"Errore selezione galleria: {ex.Message}");
SentrySdk.CaptureException(ex);
return null;
}
return result is null ? null : await ConvertToDto(result, AttachedDto.TypeAttached.Image);
}
private static async Task<AttachedDto> ConvertToDto(FileResult file, AttachedDto.TypeAttached type)
{
var stream = await file.OpenReadAsync();
using var ms = new MemoryStream();
await stream.CopyToAsync(ms);
return new AttachedDto
{
Name = file.FileName,
Path = file.FullPath,
MimeType = file.ContentType,
DimensionBytes = ms.Length,
FileBytes = ms.ToArray(),
Type = type
};
}
public async Task<string> SaveToTempStorage(Stream file, string fileName, CancellationToken ct = default)
{
ArgumentNullException.ThrowIfNull(file);
if (file.CanSeek)
file.Position = 0;
fileName = Path.GetFileName(fileName);
var dir = FileSystem.CacheDirectory;
var filePath = Path.Combine(dir, fileName);
await using var fileStream = File.Create(filePath);
await file.CopyToAsync(fileStream, ct);
return filePath;
}
public Task OpenFile(string fileName, string filePath)
{
#if IOS
throw new NotImplementedException();
#else
return Launcher.OpenAsync(new OpenFileRequest
{
Title = "Apri file",
File = new ReadOnlyFile(filePath)
});
#endif
}
}

View File

@@ -4,5 +4,12 @@ namespace SteUp.Maui.Core.System;
public class GenericSystemService : IGenericSystemService public class GenericSystemService : IGenericSystemService
{ {
public string GetCurrentAppVersion() => AppInfo.VersionString; public string GetCurrentAppVersion()
{
#if DEBUG
return $"v{AppInfo.VersionString} [DEBUG]";
#else
return $"v{AppInfo.VersionString}";
#endif
}
} }

View File

@@ -23,6 +23,14 @@ namespace SteUp.Maui
.UseMauiApp<App>() .UseMauiApp<App>()
.UseIntegry(appToken: AppToken, useLoginAzienda: true) .UseIntegry(appToken: AppToken, useLoginAzienda: true)
.UseMauiCommunityToolkit() .UseMauiCommunityToolkit()
.UseSentry(options =>
{
options.Dsn = "https://c1ff03e3d1d2dd973a1ce73c58f92a8d@o4508499810254848.ingest.de.sentry.io/4510900455866448";
#if DEBUG
options.Debug = true;
#endif
options.TracesSampleRate = 1.0;
})
.ConfigureFonts(fonts => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); }); .ConfigureFonts(fonts => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); });
builder.Services.AddMauiBlazorWebView(); builder.Services.AddMauiBlazorWebView();

View File

@@ -120,6 +120,7 @@
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="9.0.120"/> <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="9.0.120"/>
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="9.0.120"/> <PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="9.0.120"/>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.12" /> <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.12" />
<PackageReference Include="Sentry.Maui" Version="5.16.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -43,7 +43,7 @@
else else
{ {
<MudMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@NewActivity"> <MudMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="@NewActivity">
Nuova rilevazione Nuova ispezione
</MudMenuItem> </MudMenuItem>
} }
</ChildContent> </ChildContent>

View File

@@ -36,7 +36,7 @@ else
</div> </div>
<div class="my-4 login-footer"> <div class="my-4 login-footer">
<span>@($"v{GenericSystemService.GetCurrentAppVersion()} | Powered by")</span> <span>@GenericSystemService.GetCurrentAppVersion() | Powered by")</span>
<img src="_content/SteUp.Shared/images/logoIntegry.svg" class="img-fluid" alt="Integry"> <img src="_content/SteUp.Shared/images/logoIntegry.svg" class="img-fluid" alt="Integry">
</div> </div>
</div> </div>

View File

@@ -2,21 +2,5 @@
@inject IGenericSystemService GenericSystemService @inject IGenericSystemService GenericSystemService
<div class="app-version"> <div class="app-version">
<span>@Version</span> <span>@GenericSystemService.GetCurrentAppVersion()</span>
</div> </div>
@code
{
private string Version { get; set; } = "";
protected override void OnInitialized()
{
#if DEBUG
Version = $"v{GenericSystemService.GetCurrentAppVersion()} [DEBUG]";
#else
Version = $"v{GenericSystemService.GetCurrentAppVersion()}";
#endif
StateHasChanged();
}
}

View File

@@ -1,5 +1,7 @@
@using SteUp.Shared.Components.Layout @using SteUp.Shared.Components.Layout
@using SteUp.Shared.Components.Layout.Overlay @using SteUp.Shared.Core.Dto
@using SteUp.Shared.Core.Interface.System
@inject IAttachedService AttachedService
<MudDialog Class="customDialog-form disable-safe-area"> <MudDialog Class="customDialog-form disable-safe-area">
<DialogContent> <DialogContent>
@@ -34,18 +36,11 @@
</DialogActions> </DialogActions>
</MudDialog> </MudDialog>
<SaveOverlay VisibleOverlay="VisibleOverlay" SuccessAnimation="SuccessAnimation"/>
@code { @code {
[CascadingParameter] private IMudDialogInstance MudDialog { get; set; } [CascadingParameter] private IMudDialogInstance MudDialog { get; set; } = null!;
[Parameter] public bool CanAddPosition { get; set; } [Parameter] public bool CanAddPosition { get; set; }
//Overlay for save private AttachedDto? Attached { get; set; }
private bool VisibleOverlay { get; set; }
private bool SuccessAnimation { get; set; }
// private AttachedDTO? Attached { get; set; }
private bool _requireNewName; private bool _requireNewName;
@@ -60,8 +55,6 @@
} }
} }
private bool SelectTypePicture { get; set; }
private string TitleModal { get; set; } = "Aggiungi allegati"; private string TitleModal { get; set; } = "Aggiungi allegati";
private string? _newName; private string? _newName;
@@ -76,66 +69,53 @@
} }
} }
protected override async Task OnInitializedAsync() protected override void OnInitialized()
{ {
SelectTypePicture = true;
RequireNewName = false; RequireNewName = false;
Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter; Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter;
} }
private async Task OnCamera() private async Task OnCamera()
{ {
// Attached = await AttachedService.SelectImageFromCamera(); Attached = await AttachedService.SelectImageFromCamera();
//
// if (Attached != null) if (Attached != null)
// { {
// RequireNewName = true; RequireNewName = true;
// StateHasChanged(); StateHasChanged();
// } }
} }
private async Task OnGallery() private async Task OnGallery()
{ {
// Attached = await AttachedService.SelectImageFromGallery(); Attached = await AttachedService.SelectImageFromGallery();
//
// if (Attached != null) if (Attached != null)
// { {
// RequireNewName = true; RequireNewName = true;
// StateHasChanged(); StateHasChanged();
// } }
} }
private void OnNewName() private void OnNewName()
{ {
// if (Attached != null) if (Attached != null)
// { {
// switch (Attached.Type) switch (Attached.Type)
// { {
// case AttachedDTO.TypeAttached.Position: case AttachedDto.TypeAttached.Image:
// { {
// CanAddPosition = false; var extension = Path.GetExtension(Attached.Name);
// Attached.Name = NewName! + extension;
// Attached.Description = NewName!;
// Attached.Name = NewName!; break;
// }
// break; default:
// } throw new ArgumentOutOfRangeException();
// case AttachedDTO.TypeAttached.Image: }
// { }
// var extension = Path.GetExtension(Attached.Name);
// Attached.Name = NewName! + extension;
//
// break;
// }
// case AttachedDTO.TypeAttached.Document:
// break;
// default:
// throw new ArgumentOutOfRangeException();
// }
// }
// MudDialog.Close(Attached); MudDialog.Close(Attached);
MudDialog.Close();
} }
} }

View File

@@ -119,6 +119,27 @@
} }
<div class="input-card"> <div class="input-card">
<div class="form-container">
<span class="disable-full-width">Scadenza</span>
<MudSelectExtended FullWidth="true" ReadOnly="@IsView" T="int" Variant="Variant.Text"
@bind-Value="@SchedaDto.Scadenza" @bind-Value:after="OnAfterChangeValue"
Class="customIcon-select" AdornmentIcon="@Icons.Material.Filled.Code">
<MudSelectItemExtended Class="custom-item-select" Text="24H" Value="24" />
<MudSelectItemExtended Class="custom-item-select" Text="1 Settimana" Value="168" />
<MudSelectItemExtended Class="custom-item-select" Text="1 Mese" Value="730" />
<MudSelectItemExtended Class="custom-item-select" Text="2 Mesi" Value="1460" />
</MudSelectExtended>
</div>
<div class="divider"></div>
<MudTextField ReadOnly="IsView" T="string?" Placeholder="Responsabile" Variant="Variant.Text"
@bind-Value="SchedaDto.Responsabile" @bind-Value:after="OnAfterChangeValue"
DebounceInterval="500" OnDebounceIntervalElapsed="OnAfterChangeValue"/>
<div class="divider"></div>
<MudTextField ReadOnly="IsView" T="string?" Placeholder="Note" Variant="Variant.Text" Lines="3" <MudTextField ReadOnly="IsView" T="string?" Placeholder="Note" Variant="Variant.Text" Lines="3"
@bind-Value="SchedaDto.Note" @bind-Value:after="OnAfterChangeValue" @bind-Value="SchedaDto.Note" @bind-Value:after="OnAfterChangeValue"
DebounceInterval="500" OnDebounceIntervalElapsed="OnAfterChangeValue"/> DebounceInterval="500" OnDebounceIntervalElapsed="OnAfterChangeValue"/>

View File

@@ -0,0 +1,23 @@
namespace SteUp.Shared.Core.Dto;
public class AttachedDto
{
public string? Name { get; set; }
public string? Description { get; set; }
public string? MimeType { get; set; }
public long? DimensionBytes { get; set; }
public string? Path { get; set; }
public byte[]? FileBytes { get; set; }
public Stream? FileContent =>
FileBytes is null ? null : new MemoryStream(FileBytes);
public TypeAttached Type { get; set; }
public enum TypeAttached
{
Image
}
}

View File

@@ -5,4 +5,6 @@ public class SchedaDto
public JtbFasiDto? Reparto { get; set; } public JtbFasiDto? Reparto { get; set; }
public string? ActivityTypeId { get; set; } public string? ActivityTypeId { get; set; }
public string? Note { get; set; } public string? Note { get; set; }
public string? Responsabile { get; set; }
public int Scadenza { get; set; } = 24;
} }

View File

@@ -0,0 +1,12 @@
using SteUp.Shared.Core.Dto;
namespace SteUp.Shared.Core.Interface.System;
public interface IAttachedService
{
Task<AttachedDto?> SelectImageFromCamera();
Task<AttachedDto?> SelectImageFromGallery();
Task<string> SaveToTempStorage(Stream file, string fileName, CancellationToken ct = default);
Task OpenFile(string fileName, string filePath);
}

View File

@@ -16,6 +16,7 @@
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0"/> <PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0"/>
<PackageReference Include="MudBlazor" Version="8.13.0" /> <PackageReference Include="MudBlazor" Version="8.13.0" />
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="8.2.4" /> <PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="8.2.4" />
<PackageReference Include="Sentry" Version="5.16.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.14.0"/> <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.14.0"/>
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="9.0.12"/> <PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="9.0.12"/>
<PackageReference Include="Microsoft.Maui.Essentials" Version="9.0.120"/> <PackageReference Include="Microsoft.Maui.Essentials" Version="9.0.120"/>