23 Commits

Author SHA1 Message Date
2e51420b2c Finish V2.0.1(7) 2025-09-22 18:16:59 +02:00
4521b2a02d -> v2.0.1 (7) 2025-09-22 18:16:52 +02:00
ec7bedeff6 Fix compilazione in release 2025-09-22 18:16:08 +02:00
ea2f2d47c3 Finish v2.0.0(6) 2025-09-22 15:11:22 +02:00
149eb27628 Finish v2.0.0(6) 2025-09-22 15:11:20 +02:00
8b331d5824 -> v2.0.0 (6) 2025-09-22 15:11:15 +02:00
31db52d0d7 Fix vari 2025-09-22 15:10:24 +02:00
ce56e9e57d Migliorata UI 2025-09-22 12:26:10 +02:00
c61093a942 Sistemati caricamenti 2025-09-18 15:47:20 +02:00
4645b2660e Migliorie grefiche 2025-09-18 12:17:45 +02:00
06bda7c881 Gestita fotocamera per allegare immagini 2025-09-18 10:56:21 +02:00
8a45bffebc Fix e migliorati caricamenti 2025-09-18 09:40:31 +02:00
e9a0ffdb7a Fix ui 2025-09-16 10:46:56 +02:00
83264731f3 Migliorato modal activity 2025-09-15 17:11:17 +02:00
0f3047a2b6 Gestito notificationData nelle notifiche push 2025-09-12 17:37:36 +02:00
223e74c490 Migliorata gestione e visualizzazione notifiche 2025-09-12 15:42:56 +02:00
b798b01da0 Sistemazioni grafiche 2025-09-12 09:32:34 +02:00
85f19acda6 Finish Firebase 2025-09-11 16:08:13 +02:00
7bfe67a97c Gestita pagina notifiche 2025-09-11 16:06:19 +02:00
7319378e75 Creata card notifiche 2025-09-09 16:30:51 +02:00
dfb86e3cd7 Implementate notifiche 2025-09-09 11:43:07 +02:00
54be40518a Merge branch 'develop' into feature/Firebase
# Conflicts:
#	salesbook.Shared/Components/Pages/Home.razor
2025-09-08 12:22:24 +02:00
833a1e456f Iniziata implementazione notifiche firebase 2025-08-25 10:00:41 +02:00
101 changed files with 2602 additions and 665 deletions

View File

@@ -1,20 +1,15 @@
using CommunityToolkit.Mvvm.Messaging;
namespace salesbook.Maui namespace salesbook.Maui
{ {
public partial class App : Application public partial class App : Application
{ {
private readonly IMessenger _messenger; public App()
public App(IMessenger messenger)
{ {
InitializeComponent(); InitializeComponent();
_messenger = messenger;
} }
protected override Window CreateWindow(IActivationState? activationState) protected override Window CreateWindow(IActivationState? activationState)
{ {
return new Window(new MainPage(_messenger)); return new Window(new MainPage());
} }
} }
} }

View File

@@ -0,0 +1,10 @@
using System.Text.Json.Serialization;
namespace salesbook.Maui.Core.RestClient.IntegryApi.Dto;
public class RegisterDeviceDTO
{
[JsonPropertyName("userDeviceToken")]
public WtbUserDeviceTokenDTO UserDeviceToken { get; set; }
}

View File

@@ -0,0 +1,22 @@
using System.Text.Json.Serialization;
namespace salesbook.Maui.Core.RestClient.IntegryApi.Dto;
public class WtbUserDeviceTokenDTO
{
[JsonPropertyName("type")]
public string Type => "wtb_user_device_tokens";
[JsonPropertyName("deviceToken")]
public string DeviceToken { get; set; }
[JsonPropertyName("userName")]
public string Username { get; set; }
[JsonPropertyName("appName")]
public int AppName => 7; //salesbook
[JsonPropertyName("platform")]
public string Platform { get; set; }
}

View File

@@ -0,0 +1,38 @@
using IntegryApiClient.Core.Domain.Abstraction.Contracts.Account;
using IntegryApiClient.Core.Domain.RestClient.Contacts;
using Microsoft.Extensions.Logging;
using salesbook.Maui.Core.RestClient.IntegryApi.Dto;
using salesbook.Shared.Core.Interface.IntegryApi;
namespace salesbook.Maui.Core.RestClient.IntegryApi;
public class IntegryRegisterNotificationRestClient(
ILogger<IntegryRegisterNotificationRestClient> logger,
IUserSession userSession,
IIntegryApiRestClient integryApiRestClient
) : IIntegryRegisterNotificationRestClient
{
public async Task Register(string fcmToken, ILogger? logger1 = null)
{
logger1 ??= logger;
var userDeviceToken = new RegisterDeviceDTO()
{
UserDeviceToken = new WtbUserDeviceTokenDTO()
{
DeviceToken = fcmToken,
Platform = OperatingSystem.IsAndroid() ? "Android" : "iOS",
Username = userSession.User.Username
}
};
try
{
await integryApiRestClient.AuthorizedPost<object>($"device_tokens/insert", userDeviceToken,
logger: logger1);
}
catch (Exception ex)
{
SentrySdk.CaptureException(ex);
}
}
}

View File

@@ -5,20 +5,49 @@ namespace salesbook.Maui.Core.Services;
public class AttachedService : IAttachedService public class AttachedService : IAttachedService
{ {
public async Task<AttachedDTO?> SelectImage() public async Task<AttachedDTO?> SelectImageFromCamera()
{ {
var perm = await Permissions.RequestAsync<Permissions.Photos>(); var cameraPerm = await Permissions.RequestAsync<Permissions.Camera>();
if (perm != PermissionStatus.Granted) return null; if (cameraPerm != PermissionStatus.Granted)
return null;
var result = await FilePicker.PickAsync(new PickOptions FileResult? result = null;
try
{ {
PickerTitle = "Scegli un'immagine", result = await MediaPicker.Default.CapturePhotoAsync();
FileTypes = FilePickerFileType.Images }
}); catch (Exception ex)
{
Console.WriteLine($"Errore cattura foto: {ex.Message}");
return null;
}
return result is null ? null : await ConvertToDto(result, AttachedDTO.TypeAttached.Image); 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 = null;
try
{
result = await MediaPicker.Default.PickPhotoAsync();
}
catch (Exception ex)
{
Console.WriteLine($"Errore selezione galleria: {ex.Message}");
return null;
}
return result is null ? null : await ConvertToDto(result, AttachedDTO.TypeAttached.Image);
}
public async Task<AttachedDTO?> SelectFile() public async Task<AttachedDTO?> SelectFile()
{ {
var perm = await Permissions.RequestAsync<Permissions.StorageRead>(); var perm = await Permissions.RequestAsync<Permissions.StorageRead>();

View File

@@ -1,18 +1,23 @@
using AutoMapper; using AutoMapper;
using IntegryApiClient.Core.Domain.Abstraction.Contracts.Storage;
using salesbook.Shared.Core.Dto; using salesbook.Shared.Core.Dto;
using salesbook.Shared.Core.Dto.Activity; using salesbook.Shared.Core.Dto.Activity;
using salesbook.Shared.Core.Dto.Contact; using salesbook.Shared.Core.Dto.Contact;
using salesbook.Shared.Core.Entity; using salesbook.Shared.Core.Entity;
using salesbook.Shared.Core.Helpers;
using salesbook.Shared.Core.Helpers.Enum; using salesbook.Shared.Core.Helpers.Enum;
using salesbook.Shared.Core.Interface; using salesbook.Shared.Core.Interface;
using Sentry.Protocol; using salesbook.Shared.Core.Interface.IntegryApi;
using salesbook.Shared.Core.Interface.System.Network;
using System.Linq.Expressions; using System.Linq.Expressions;
using salesbook.Shared.Core.Dto.PageState;
namespace salesbook.Maui.Core.Services; namespace salesbook.Maui.Core.Services;
public class ManageDataService( public class ManageDataService(
LocalDbService localDb, LocalDbService localDb,
IMapper mapper, IMapper mapper,
UserListState userListState,
IIntegryApiService integryApiService, IIntegryApiService integryApiService,
INetworkService networkService INetworkService networkService
) : IManageDataService ) : IManageDataService
@@ -82,7 +87,7 @@ public class ManageDataService(
return prospect; return prospect;
} }
public async Task<List<ContactDTO>> GetContact(WhereCondContact? whereCond) public async Task<List<ContactDTO>> GetContact(WhereCondContact? whereCond, DateTime? lastSync)
{ {
List<AnagClie>? contactList; List<AnagClie>? contactList;
List<PtbPros>? prospectList; List<PtbPros>? prospectList;
@@ -90,26 +95,37 @@ public class ManageDataService(
if (networkService.ConnectionAvailable) if (networkService.ConnectionAvailable)
{ {
var response = new UsersSyncResponseDTO();
var clienti = await integryApiService.RetrieveAnagClie( var clienti = await integryApiService.RetrieveAnagClie(
new CRMAnagRequestDTO new CRMAnagRequestDTO
{ {
CodAnag = whereCond.CodAnag, CodAnag = whereCond.CodAnag,
FlagStato = whereCond.FlagStato, FlagStato = whereCond.FlagStato,
PartIva = whereCond.PartIva, PartIva = whereCond.PartIva,
ReturnPersRif = !whereCond.OnlyContact ReturnPersRif = !whereCond.OnlyContact,
FilterDate = lastSync
} }
); );
_ = UpdateDbUsers(clienti);
response.AnagClie = clienti.AnagClie;
response.VtbDest = clienti.VtbDest;
response.VtbCliePersRif = clienti.VtbCliePersRif;
var prospect = await integryApiService.RetrieveProspect( var prospect = await integryApiService.RetrieveProspect(
new CRMProspectRequestDTO new CRMProspectRequestDTO
{ {
CodPpro = whereCond.CodAnag, CodPpro = whereCond.CodAnag,
PartIva = whereCond.PartIva, PartIva = whereCond.PartIva,
ReturnPersRif = !whereCond.OnlyContact ReturnPersRif = !whereCond.OnlyContact,
FilterDate = lastSync
} }
); );
_ = UpdateDbUsers(prospect);
response.PtbPros = prospect.PtbPros;
response.PtbProsRif = prospect.PtbProsRif;
_ = UpdateDbUsers(response);
contactList = clienti.AnagClie; contactList = clienti.AnagClie;
prospectList = prospect.PtbPros; prospectList = prospect.PtbPros;
@@ -156,6 +172,35 @@ public class ManageDataService(
} }
} }
public async Task<List<ActivityDTO>> GetActivityTryLocalDb(WhereCondActivity whereCond)
{
List<StbActivity>? activities;
activities = await localDb.Get<StbActivity>(x =>
(whereCond.ActivityId != null && x.ActivityId != null && whereCond.ActivityId.Equals(x.ActivityId)) ||
(whereCond.Start != null && whereCond.End != null && x.EffectiveDate == null &&
x.EstimatedDate >= whereCond.Start && x.EstimatedDate <= whereCond.End) ||
(x.EffectiveDate >= whereCond.Start && x.EffectiveDate <= whereCond.End) ||
(whereCond.ActivityId == null && (whereCond.Start == null || whereCond.End == null))
);
if (activities.IsNullOrEmpty() && networkService.ConnectionAvailable)
{
activities = await integryApiService.RetrieveActivity(
new CRMRetrieveActivityRequestDTO
{
StarDate = whereCond.Start,
EndDate = whereCond.End,
ActivityId = whereCond.ActivityId
}
);
_ = UpdateDb(activities);
}
return await MapActivity(activities);
}
public async Task<List<ActivityDTO>> GetActivity(WhereCondActivity whereCond, bool useLocalDb) public async Task<List<ActivityDTO>> GetActivity(WhereCondActivity whereCond, bool useLocalDb)
{ {
List<StbActivity>? activities; List<StbActivity>? activities;
@@ -184,6 +229,11 @@ public class ManageDataService(
); );
} }
return await MapActivity(activities);
}
public async Task<List<ActivityDTO>> MapActivity(List<StbActivity>? activities)
{
if (activities == null) return []; if (activities == null) return [];
var codJcomList = activities var codJcomList = activities
@@ -192,23 +242,35 @@ public class ManageDataService(
.Distinct().ToList(); .Distinct().ToList();
var jtbComtList = await localDb.Get<JtbComt>(x => codJcomList.Contains(x.CodJcom)); var jtbComtList = await localDb.Get<JtbComt>(x => codJcomList.Contains(x.CodJcom));
var commesseDict = jtbComtList.ToDictionary(x => x.CodJcom, x => x.Descrizione);
var codAnagList = activities var codAnagList = activities
.Select(x => x.CodAnag) .Select(x => x.CodAnag)
.Where(x => !string.IsNullOrEmpty(x)) .Where(x => !string.IsNullOrEmpty(x))
.Distinct().ToList(); .Distinct().ToList();
var clientList = await localDb.Get<AnagClie>(x => codAnagList.Contains(x.CodAnag));
var distinctClient = clientList.ToDictionary(x => x.CodAnag, x => x.RagSoc);
var prospectList = await localDb.Get<PtbPros>(x => codAnagList.Contains(x.CodPpro)); IDictionary<string, string?>? distinctUser = null;
var distinctProspect = prospectList.ToDictionary(x => x.CodPpro, x => x.RagSoc);
if (userListState.AllUsers != null)
{
distinctUser = userListState.AllUsers
.Where(x => codAnagList.Contains(x.CodContact))
.ToDictionary(x => x.CodContact, x => x.RagSoc);
}
var returnDto = activities var returnDto = activities
.Select(activity => .Select(activity =>
{ {
var dto = mapper.Map<ActivityDTO>(activity); var dto = mapper.Map<ActivityDTO>(activity);
if (activity is { AlarmTime: not null, EstimatedTime: not null })
{
var minuteBefore = activity.EstimatedTime.Value - activity.AlarmTime.Value;
dto.MinuteBefore = (int)Math.Abs(minuteBefore.TotalMinutes);
dto.NotificationDate = dto.MinuteBefore == 0 ?
activity.EstimatedTime : activity.AlarmTime;
}
if (activity.CodJcom != null) if (activity.CodJcom != null)
{ {
dto.Category = ActivityCategoryEnum.Commessa; dto.Category = ActivityCategoryEnum.Commessa;
@@ -222,16 +284,14 @@ public class ManageDataService(
{ {
string? ragSoc; string? ragSoc;
if (distinctClient.TryGetValue(activity.CodAnag, out ragSoc) || if (distinctUser != null && (distinctUser.TryGetValue(activity.CodAnag, out ragSoc) ||
distinctProspect.TryGetValue(activity.CodAnag, out ragSoc)) distinctUser.TryGetValue(activity.CodAnag, out ragSoc)))
{ {
dto.Cliente = ragSoc; dto.Cliente = ragSoc;
} }
} }
dto.Commessa = activity.CodJcom != null && commesseDict.TryGetValue(activity.CodJcom, out var descr) dto.Commessa = jtbComtList.Find(x => x.CodJcom.Equals(dto.CodJcom));
? descr
: null;
return dto; return dto;
}) })
.ToList(); .ToList();
@@ -275,6 +335,26 @@ public class ManageDataService(
public Task InsertOrUpdate<T>(T objectToSave) => public Task InsertOrUpdate<T>(T objectToSave) =>
localDb.InsertOrUpdate<T>([objectToSave]); localDb.InsertOrUpdate<T>([objectToSave]);
public async Task DeleteProspect(string codPpro)
{
var persRifList = await GetTable<PtbProsRif>(x => x.CodPpro!.Equals(codPpro));
if (!persRifList.IsNullOrEmpty())
{
foreach (var persRif in persRifList)
{
await localDb.Delete(persRif);
}
}
var ptbPros = (await GetTable<PtbPros>(x => x.CodPpro!.Equals(codPpro))).FirstOrDefault();
if (ptbPros != null)
{
await localDb.Delete(ptbPros);
}
}
public Task Delete<T>(T objectToDelete) => public Task Delete<T>(T objectToDelete) =>
localDb.Delete(objectToDelete); localDb.Delete(objectToDelete);

View File

@@ -1,5 +1,6 @@
using salesbook.Shared.Core.Helpers; using salesbook.Shared.Core.Helpers;
using salesbook.Shared.Core.Interface; using salesbook.Shared.Core.Interface;
using salesbook.Shared.Core.Interface.IntegryApi;
namespace salesbook.Maui.Core.Services; namespace salesbook.Maui.Core.Services;

View File

@@ -1,6 +1,7 @@
using salesbook.Shared.Core.Interface; using salesbook.Shared.Core.Interface;
using salesbook.Shared.Core.Interface.System.Network;
namespace salesbook.Maui.Core.Services; namespace salesbook.Maui.Core.System.Network;
public class NetworkService : INetworkService public class NetworkService : INetworkService
{ {

View File

@@ -0,0 +1,37 @@
using salesbook.Shared.Core.Interface;
using salesbook.Shared.Core.Interface.IntegryApi;
using Shiny;
using Shiny.Notifications;
using Shiny.Push;
namespace salesbook.Maui.Core.System.Notification;
public class FirebaseNotificationService(
IPushManager pushManager,
IIntegryRegisterNotificationRestClient integryRegisterNotificationRestClient,
INotificationManager notificationManager
) : IFirebaseNotificationService
{
public async Task InitFirebase()
{
CreateNotificationChannel();
var (accessState, token) = await pushManager.RequestAccess();
if (accessState == AccessState.Denied || token is null) return;
await integryRegisterNotificationRestClient.Register(token);
}
private void CreateNotificationChannel()
{
var channel = new Channel
{
Identifier = "salesbook_push",
Description = "Notifiche push di SalesBook",
Importance = ChannelImportance.High,
Actions = []
};
notificationManager.AddChannel(channel);
}
}

View File

@@ -0,0 +1,63 @@
using CommunityToolkit.Mvvm.Messaging;
using salesbook.Shared.Core.Dto;
using salesbook.Shared.Core.Entity;
using salesbook.Shared.Core.Helpers;
using salesbook.Shared.Core.Interface.IntegryApi;
using salesbook.Shared.Core.Messages.Notification.NewPush;
using Shiny.Push;
using System.Text.Json;
namespace salesbook.Maui.Core.System.Notification.Push;
public class PushNotificationDelegate(
IIntegryRegisterNotificationRestClient integryRegisterNotificationRestClient,
IMessenger messenger
) : IPushDelegate
{
public Task OnEntry(PushNotification notification)
{
// fires when the user taps on a push notification
return Task.CompletedTask;
}
public Task OnReceived(PushNotification notification)
{
if (notification.Notification is null) return Task.CompletedTask;
var data = notification.Data;
NotificationDataDTO? notificationDataDto = null;
if (!data.IsNullOrEmpty())
{
var json = JsonSerializer.Serialize(data);
notificationDataDto = JsonSerializer.Deserialize<NotificationDataDTO>(json);
}
if (notificationDataDto?.NotificationId == null) return Task.CompletedTask;
var notificationId = long.Parse(notificationDataDto.NotificationId);
var pushNotification = new WtbNotification
{
Id = notificationId,
Title = notification.Notification.Title,
Body = notification.Notification.Message,
NotificationData = notificationDataDto
};
messenger.Send(new NewPushNotificationMessage(pushNotification));
return Task.CompletedTask;
}
public Task OnNewToken(string token)
{
integryRegisterNotificationRestClient.Register(token);
return Task.CompletedTask;
}
public Task OnUnRegistered(string token)
{
// fires when a push notification change is set by the operating system or provider
return Task.CompletedTask;
}
}

View File

@@ -0,0 +1,9 @@
using salesbook.Shared.Core.Interface.System.Notification;
using Shiny.Notifications;
namespace salesbook.Maui.Core.System.Notification;
public class ShinyNotificationManager(INotificationManager notificationManager) : IShinyNotificationManager
{
public Task RequestAccess() => notificationManager.RequestAccess();
}

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>API_KEY</key>
<string>AIzaSyC_QtQpsVortjzgl-B7__IQZ-85lOct55E</string>
<key>GCM_SENDER_ID</key>
<string>830771692001</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>it.integry.salesbook</string>
<key>PROJECT_ID</key>
<string>salesbook-smetar</string>
<key>STORAGE_BUCKET</key>
<string>salesbook-smetar.firebasestorage.app</string>
<key>IS_ADS_ENABLED</key>
<false></false>
<key>IS_ANALYTICS_ENABLED</key>
<false></false>
<key>IS_APPINVITE_ENABLED</key>
<true></true>
<key>IS_GCM_ENABLED</key>
<true></true>
<key>IS_SIGNIN_ENABLED</key>
<true></true>
<key>GOOGLE_APP_ID</key>
<string>1:830771692001:ios:59d8b1d8570ac81f3752a0</string>
</dict>
</plist>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<linker>
<assembly fullname="salesbook.Shared" preserve="all" />
</linker>

View File

@@ -1,23 +1,10 @@
using CommunityToolkit.Mvvm.Messaging;
using salesbook.Shared.Core.Messages.Back;
namespace salesbook.Maui namespace salesbook.Maui
{ {
public partial class MainPage : ContentPage public partial class MainPage : ContentPage
{ {
private readonly IMessenger _messenger; public MainPage()
public MainPage(IMessenger messenger)
{ {
InitializeComponent(); InitializeComponent();
_messenger = messenger;
} }
protected override bool OnBackButtonPressed()
{
_messenger.Send(new HardwareBackMessage("back"));
return true;
}
} }
} }

View File

@@ -1,4 +1,3 @@
using AutoMapper;
using CommunityToolkit.Maui; using CommunityToolkit.Maui;
using CommunityToolkit.Mvvm.Messaging; using CommunityToolkit.Mvvm.Messaging;
using IntegryApiClient.MAUI; using IntegryApiClient.MAUI;
@@ -6,17 +5,27 @@ using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using MudBlazor.Services; using MudBlazor.Services;
using MudExtensions.Services; using MudExtensions.Services;
using salesbook.Maui.Core.RestClient.IntegryApi;
using salesbook.Maui.Core.Services; using salesbook.Maui.Core.Services;
using salesbook.Maui.Core.System.Network;
using salesbook.Maui.Core.System.Notification;
using salesbook.Maui.Core.System.Notification.Push;
using salesbook.Shared; using salesbook.Shared;
using salesbook.Shared.Core.Dto; using salesbook.Shared.Core.Dto;
using salesbook.Shared.Core.Dto.PageState; using salesbook.Shared.Core.Dto.PageState;
using salesbook.Shared.Core.Helpers; using salesbook.Shared.Core.Helpers;
using salesbook.Shared.Core.Interface; using salesbook.Shared.Core.Interface;
using salesbook.Shared.Core.Interface.IntegryApi;
using salesbook.Shared.Core.Interface.System.Network;
using salesbook.Shared.Core.Interface.System.Notification;
using salesbook.Shared.Core.Messages.Activity.Copy; using salesbook.Shared.Core.Messages.Activity.Copy;
using salesbook.Shared.Core.Messages.Activity.New; using salesbook.Shared.Core.Messages.Activity.New;
using salesbook.Shared.Core.Messages.Back; using salesbook.Shared.Core.Messages.Back;
using salesbook.Shared.Core.Messages.Contact; using salesbook.Shared.Core.Messages.Contact;
using salesbook.Shared.Core.Messages.Notification.Loaded;
using salesbook.Shared.Core.Messages.Notification.NewPush;
using salesbook.Shared.Core.Services; using salesbook.Shared.Core.Services;
using Shiny;
namespace salesbook.Maui namespace salesbook.Maui
{ {
@@ -24,7 +33,7 @@ namespace salesbook.Maui
{ {
private const string AppToken = "f0484398-1f8b-42f5-ab79-5282c164e1d8"; private const string AppToken = "f0484398-1f8b-42f5-ab79-5282c164e1d8";
public static MauiApp CreateMauiApp() public static MauiAppBuilder CreateMauiAppBuilder()
{ {
InteractiveRenderSettings.ConfigureBlazorHybridRenderModes(); InteractiveRenderSettings.ConfigureBlazorHybridRenderModes();
@@ -33,6 +42,7 @@ namespace salesbook.Maui
.UseMauiApp<App>() .UseMauiApp<App>()
.UseIntegry(appToken: AppToken, useLoginAzienda: true) .UseIntegry(appToken: AppToken, useLoginAzienda: true)
.UseMauiCommunityToolkit() .UseMauiCommunityToolkit()
.UseShiny()
.UseSentry(options => .UseSentry(options =>
{ {
options.Dsn = "https://453b6b38f94fd67e40e0d5306d6caff8@o4508499810254848.ingest.de.sentry.io/4509605099667536"; options.Dsn = "https://453b6b38f94fd67e40e0d5306d6caff8@o4508499810254848.ingest.de.sentry.io/4509605099667536";
@@ -63,14 +73,26 @@ namespace salesbook.Maui
builder.Services.AddSingleton<JobSteps>(); builder.Services.AddSingleton<JobSteps>();
builder.Services.AddSingleton<UserPageState>(); builder.Services.AddSingleton<UserPageState>();
builder.Services.AddSingleton<UserListState>(); builder.Services.AddSingleton<UserListState>();
builder.Services.AddSingleton<NotificationState>();
builder.Services.AddSingleton<FilterUserDTO>(); builder.Services.AddSingleton<FilterUserDTO>();
//Message //Message
builder.Services.AddScoped<IMessenger, WeakReferenceMessenger>(); builder.Services.AddSingleton<IMessenger, WeakReferenceMessenger>();
builder.Services.AddScoped<NewActivityService>(); builder.Services.AddSingleton<NewActivityService>();
builder.Services.AddScoped<BackNavigationService>(); builder.Services.AddSingleton<BackNavigationService>();
builder.Services.AddScoped<CopyActivityService>(); builder.Services.AddSingleton<CopyActivityService>();
builder.Services.AddScoped<NewContactService>(); builder.Services.AddSingleton<NewContactService>();
builder.Services.AddSingleton<NotificationsLoadedService>();
builder.Services.AddSingleton<NewPushNotificationService>();
//Notification
builder.Services.AddNotifications();
builder.Services.AddPush<PushNotificationDelegate>();
builder.Services.AddSingleton<IIntegryRegisterNotificationRestClient, IntegryRegisterNotificationRestClient>();
builder.Services.AddSingleton<IIntegryNotificationRestClient, IntegryNotificationRestClient>();
builder.Services.AddSingleton<IFirebaseNotificationService, FirebaseNotificationService>();
builder.Services.AddSingleton<IShinyNotificationManager, ShinyNotificationManager>();
builder.Services.AddSingleton<INotificationService, NotificationService>();
#if DEBUG #if DEBUG
builder.Services.AddBlazorWebViewDeveloperTools(); builder.Services.AddBlazorWebViewDeveloperTools();
@@ -82,7 +104,7 @@ namespace salesbook.Maui
builder.Services.AddSingleton<INetworkService, NetworkService>(); builder.Services.AddSingleton<INetworkService, NetworkService>();
builder.Services.AddSingleton<LocalDbService>(); builder.Services.AddSingleton<LocalDbService>();
return builder.Build(); return builder;
} }
} }
} }

View File

@@ -1,9 +1,27 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="it.integry.salesbook">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:usesCleartextTraffic="true" android:supportsRtl="true"></application> <application android:allowBackup="true" android:icon="@mipmap/appicon" android:usesCleartextTraffic="true" android:supportsRtl="true">
<receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" />
<receiver android:name="com.google.firebase.iid.FirebaseInstanceIdReceiver" android:exported="true" android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="28" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.BATTERY_STATS" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
</manifest> </manifest>

View File

@@ -0,0 +1,13 @@
using salesbook.Maui.Core;
using salesbook.Shared.Core.Interface.System.Battery;
namespace salesbook.Maui;
public static class AndroidModule
{
public static MauiAppBuilder RegisterAndroidAppServices(this MauiAppBuilder mauiAppBuilder)
{
mauiAppBuilder.Services.AddSingleton<IBatteryOptimizationManagerService, BatteryOptimizationManagerService>();
return mauiAppBuilder;
}
}

View File

@@ -0,0 +1,28 @@
using Android.App;
using Android.Content;
using Android.OS;
using Android.Provider;
using salesbook.Shared.Core.Interface.System.Battery;
using Application = Android.App.Application;
namespace salesbook.Maui.Core;
public class BatteryOptimizationManagerService : IBatteryOptimizationManagerService
{
public bool IsBatteryOptimizationEnabled()
{
var packageName = AppInfo.PackageName;
var pm = (PowerManager)Application.Context.GetSystemService(Context.PowerService)!;
return !pm.IsIgnoringBatteryOptimizations(packageName);
}
public void OpenBatteryOptimizationSettings(Action<bool> onCompleted)
{
var packageName = AppInfo.PackageName;
var intent = new Intent(Settings.ActionRequestIgnoreBatteryOptimizations);
intent.SetData(Android.Net.Uri.Parse("package:" + packageName));
((MainActivity)Platform.CurrentActivity!).StartActivityForResult(intent, (result, _) => { onCompleted(result == Result.Ok); });
}
}

View File

@@ -1,13 +1,42 @@
using Android.App; using Android.App;
using Android.Content;
using Android.Content.PM; using Android.Content.PM;
namespace salesbook.Maui namespace salesbook.Maui
{ {
[Activity(Theme = "@style/Maui.SplashTheme", [Activity(
Theme = "@style/Maui.SplashTheme",
MainLauncher = true, MainLauncher = true,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode |
ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)] ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
[IntentFilter(
[
Shiny.ShinyPushIntents.NotificationClickAction
],
Categories =
[
"android.intent.category.DEFAULT"
]
)]
public class MainActivity : MauiAppCompatActivity public class MainActivity : MauiAppCompatActivity
{ {
private readonly IDictionary<int, Action<Result, Intent>> _onActivityResultSubscriber =
new Dictionary<int, Action<Result, Intent>>();
public void StartActivityForResult(Intent intent, Action<Result, Intent> onResultAction)
{
var requestCode = new Random(DateTime.Now.Millisecond).Next();
_onActivityResultSubscriber.Add(requestCode, onResultAction);
StartActivityForResult(intent, requestCode);
}
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
if (_onActivityResultSubscriber.TryGetValue(requestCode, out var value))
value(resultCode, data);
base.OnActivityResult(requestCode, resultCode, data);
}
} }
} }

View File

@@ -1,16 +1,16 @@
using Android.App; using Android.App;
using Android.Runtime; using Android.Runtime;
namespace salesbook.Maui namespace salesbook.Maui;
[Application(HardwareAccelerated = true)]
public class MainApplication : MauiApplication
{ {
[Application(HardwareAccelerated = true)]
public class MainApplication : MauiApplication
{
public MainApplication(IntPtr handle, JniHandleOwnership ownership) public MainApplication(IntPtr handle, JniHandleOwnership ownership)
: base(handle, ownership) : base(handle, ownership)
{ {
} }
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiAppBuilder()
} .RegisterAndroidAppServices().Build();
} }

View File

@@ -1,10 +1,24 @@
using Foundation; using Foundation;
using UIKit;
namespace salesbook.Maui namespace salesbook.Maui
{ {
[Register("AppDelegate")] [Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate public class AppDelegate : MauiUIApplicationDelegate
{ {
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp(); protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiAppBuilder()
.RegisterIosAppServices().Build();
[Export("application:didRegisterForRemoteNotificationsWithDeviceToken:")]
public void RegisteredForRemoteNotifications(UIApplication application, NSData deviceToken)
=> global::Shiny.Hosting.Host.Lifecycle.OnRegisteredForRemoteNotifications(deviceToken);
[Export("application:didFailToRegisterForRemoteNotificationsWithError:")]
public void FailedToRegisterForRemoteNotifications(UIApplication application, NSError error)
=> global::Shiny.Hosting.Host.Lifecycle.OnFailedToRegisterForRemoteNotifications(error);
[Export("application:didReceiveRemoteNotification:fetchCompletionHandler:")]
public void DidReceiveRemoteNotification(UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler)
=> global::Shiny.Hosting.Host.Lifecycle.OnDidReceiveRemoteNotification(userInfo, completionHandler);
} }
} }

View File

@@ -0,0 +1,12 @@
using salesbook.Shared.Core.Interface.System.Battery;
namespace salesbook.Maui.Core;
public class BatteryOptimizationManagerService : IBatteryOptimizationManagerService
{
public bool IsBatteryOptimizationEnabled() => true;
public void OpenBatteryOptimizationSettings(Action<bool> onCompleted)
{
}
}

View File

@@ -39,11 +39,18 @@
<key>NSLocationWhenInUseUsageDescription</key> <key>NSLocationWhenInUseUsageDescription</key>
<string>L'app utilizza la tua posizione per allegarla alle attività.</string> <string>L'app utilizza la tua posizione per allegarla alle attività.</string>
<key>NSCameraUsageDescription</key>
<string>Questa app necessita di accedere alla fotocamera per scattare foto.</string>
<key>NSPhotoLibraryUsageDescription</key> <key>NSPhotoLibraryUsageDescription</key>
<string>Consente di selezionare immagini da allegare alle attività.</string> <string>Questa app necessita di accedere alla libreria foto.</string>
<key>NSPhotoLibraryAddUsageDescription</key> <key>NSPhotoLibraryAddUsageDescription</key>
<string>Permette all'app di salvare file o immagini nella tua libreria fotografica se necessario.</string> <string>Permette all'app di salvare file o immagini nella tua libreria fotografica se necessario.</string>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
</dict> </dict>
</plist> </plist>

View File

@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>C617.1</string>
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategorySystemBootTime</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>35F9.1</string>
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryDiskSpace</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>E174.1</string>
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>CA92.1</string>
</array>
</dict>
</array>
<key>NSPrivacyCollectedDataTypes</key>
<array>
<!--user info-->
<dict>
<key>NSPrivacyCollectedDataTypeUserID</key>
<string>NSPrivacyCollectedDataTypeLocation</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<true />
<key>NSPrivacyCollectedDataTypeTracking</key>
<false />
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
</array>
</dict>
<dict>
<key>NSPrivacyCollectedDataTypeEmailAddress</key>
<string>NSPrivacyCollectedDataTypeLocation</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<true />
<key>NSPrivacyCollectedDataTypeTracking</key>
<false />
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
</array>
</dict>
<dict>
<key>NSPrivacyCollectedDataTypePhoneNumber</key>
<string>NSPrivacyCollectedDataTypeLocation</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<true />
<key>NSPrivacyCollectedDataTypeTracking</key>
<false />
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
</array>
</dict>
<!--crashlytics/analytics-->
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypeOtherDiagnosticData</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<false />
<key>NSPrivacyCollectedDataTypeTracking</key>
<false />
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
</array>
</dict>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypeCrashData</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<true />
<key>NSPrivacyCollectedDataTypeTracking</key>
<false />
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
</array>
</dict>
</array>
</dict>
</plist>

View File

@@ -0,0 +1,13 @@
using salesbook.Maui.Core;
using salesbook.Shared.Core.Interface.System.Battery;
namespace salesbook.Maui;
public static class iOSModule
{
public static MauiAppBuilder RegisterIosAppServices(this MauiAppBuilder mauiAppBuilder)
{
mauiAppBuilder.Services.AddSingleton<IBatteryOptimizationManagerService, BatteryOptimizationManagerService>();
return mauiAppBuilder;
}
}

View File

@@ -0,0 +1,29 @@
{
"project_info": {
"project_number": "830771692001",
"project_id": "salesbook-smetar",
"storage_bucket": "salesbook-smetar.firebasestorage.app"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:830771692001:android:06bc5a9706bc9bef3752a0",
"android_client_info": {
"package_name": "it.integry.salesbook"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyB43ai_Ph0phO_OkBC1wAOazKZUV9KsLaM"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}

View File

@@ -29,8 +29,8 @@
<ApplicationId>it.integry.salesbook</ApplicationId> <ApplicationId>it.integry.salesbook</ApplicationId>
<!-- Versions --> <!-- Versions -->
<ApplicationDisplayVersion>1.1.0</ApplicationDisplayVersion> <ApplicationDisplayVersion>2.0.1</ApplicationDisplayVersion>
<ApplicationVersion>5</ApplicationVersion> <ApplicationVersion>7</ApplicationVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion> <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<!--<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'"> <!--<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">
@@ -78,19 +78,21 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)'=='net9.0-ios'"> <PropertyGroup Condition="'$(TargetFramework)'=='net9.0-ios'">
<CodesignKey>Apple Distribution: Integry S.r.l. (UNP26J4R89)</CodesignKey> <CodesignKey>Apple Development: Created via API (5B7B69P4JY)</CodesignKey>
<CodesignProvision></CodesignProvision> <CodesignProvision>VS: it.integry.salesbook Development</CodesignProvision>
<ProvisioningType>manual</ProvisioningType> <ProvisioningType>manual</ProvisioningType>
</PropertyGroup> </PropertyGroup>
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios' OR $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'"> <ItemGroup Condition="$(TargetFramework.Contains('-ios'))">
<!-- <!--
<BundleResource Include="Platforms\iOS\PrivacyInfo.xcprivacy" LogicalName="PrivacyInfo.xcprivacy" /> // For scheduled notifications, you need to setup "Time Sensitive Notifications" in the Apple Developer Portal for your app provisioning and uncomment below
// <CustomEntitlements Include="com.apple.developer.usernotifications.time-sensitive" Type="Boolean" Value="true" Visible="false" />
<CustomEntitlements Include="keychain-access-groups" Type="StringArray" Value="%24(AppIdentifierPrefix)$(ApplicationId)" Visible="false" /> -->
<CustomEntitlements Include="aps-environment" Type="string" Value="development" Condition="'$(Configuration)' == 'Debug'" Visible="false" /> <CustomEntitlements Include="aps-environment" Type="string" Value="development" Condition="'$(Configuration)' == 'Debug'" Visible="false" />
<CustomEntitlements Include="aps-environment" Type="string" Value="production" Condition="'$(Configuration)' == 'Release'" Visible="false" /> <CustomEntitlements Include="aps-environment" Type="string" Value="production" Condition="'$(Configuration)' == 'Release'" Visible="false" />
--> </ItemGroup>
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios' OR $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">
<BundleResource Include="Platforms\iOS\PrivacyInfo.xcprivacy" LogicalName="PrivacyInfo.xcprivacy" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'"> <ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
@@ -103,6 +105,20 @@
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" /> <MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<BlazorWebAssemblyLazyLoad Include="salesbook.Shared.dll" />
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<PublishTrimmed>true</PublishTrimmed>
<RunAOTCompilation>true</RunAOTCompilation>
</PropertyGroup>
<ItemGroup>
<TrimmerRootAssembly Include="salesbook.Shared" RootMode="All" />
<TrimmerRootDescriptor Include="ILLink.Descriptors.xml" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<!-- Splash Screen --> <!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#dff2ff" BaseSize="128,128" /> <MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#dff2ff" BaseSize="128,128" />
@@ -118,16 +134,29 @@
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" /> <MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
<GoogleServicesJson Include="google-services.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</GoogleServicesJson>
</ItemGroup>
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
<BundleResource Include="GoogleService-Info.plist" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="12.0.0" /> <PackageReference Include="CommunityToolkit.Maui" Version="12.2.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" /> <PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
<PackageReference Include="IntegryApiClient.MAUI" Version="1.1.6" /> <PackageReference Include="IntegryApiClient.MAUI" Version="1.2.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.6" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.9" />
<PackageReference Include="Microsoft.Maui.Controls" Version="9.0.81" /> <PackageReference Include="Microsoft.Maui.Controls" Version="9.0.110" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="9.0.81" /> <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="9.0.110" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="9.0.81" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="9.0.110" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.6" /> <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.9" />
<PackageReference Include="Sentry.Maui" Version="5.11.2" /> <PackageReference Include="Sentry.Maui" Version="5.15.0" />
<PackageReference Include="Shiny.Hosting.Maui" Version="3.3.4" />
<PackageReference Include="Shiny.Notifications" Version="3.3.4" />
<PackageReference Include="Shiny.Push" Version="3.3.4" />
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" /> <PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
</ItemGroup> </ItemGroup>

View File

@@ -53,6 +53,7 @@
<script src="_content/salesbook.Shared/js/main.js"></script> <script src="_content/salesbook.Shared/js/main.js"></script>
<script src="_content/salesbook.Shared/js/calendar.js"></script> <script src="_content/salesbook.Shared/js/calendar.js"></script>
<script src="_content/salesbook.Shared/js/alphaScroll.js"></script> <script src="_content/salesbook.Shared/js/alphaScroll.js"></script>
<script src="_content/salesbook.Shared/js/notifications.js"></script>
</body> </body>

View File

@@ -0,0 +1,26 @@
<div class="Connection @(ShowWarning ? "Show" : "Hide") @(IsNetworkAvailable? ServicesIsDown ? "ServicesIsDown" : "SystemOk" : "NetworkKo")">
@if (IsNetworkAvailable)
{
if(ServicesIsDown)
{
<i class="ri-cloud-off-fill"></i>
<span>Servizi offline</span>
}
else
{
<i class="ri-cloud-fill"></i>
<span>Online</span>
}
}
else
{
<i class="ri-wifi-off-line"></i>
<span>Nessuna connessione</span>
}
</div>
@code{
[Parameter] public bool IsNetworkAvailable { get; set; }
[Parameter] public bool ServicesIsDown { get; set; }
[Parameter] public bool ShowWarning { get; set; }
}

View File

@@ -14,6 +14,8 @@
position: relative; position: relative;
} }
.header-content > .title { width: 100%; }
.header-content.with-back .page-title { .header-content.with-back .page-title {
position: absolute; position: absolute;
left: 50%; left: 50%;

View File

@@ -1,5 +1,6 @@
@using System.Globalization @using System.Globalization
@using salesbook.Shared.Core.Interface @using salesbook.Shared.Core.Interface.IntegryApi
@using salesbook.Shared.Core.Interface.System.Network
@using salesbook.Shared.Core.Messages.Back @using salesbook.Shared.Core.Messages.Back
@inherits LayoutComponentBase @inherits LayoutComponentBase
@inject IJSRuntime JS @inject IJSRuntime JS
@@ -12,30 +13,11 @@
<MudDialogProvider/> <MudDialogProvider/>
<MudSnackbarProvider/> <MudSnackbarProvider/>
<ConnectionState IsNetworkAvailable="IsNetworkAvailable" ServicesIsDown="ServicesIsDown" ShowWarning="ShowWarning" />
<div class="page"> <div class="page">
<NavMenu/> <NavMenu/>
<div class="Connection @(ShowWarning ? "Show" : "Hide") @(IsNetworkAvailable? ServicesIsDown ? "ServicesIsDown" : "SystemOk" : "NetworkKo")">
@if (IsNetworkAvailable)
{
if(ServicesIsDown)
{
<i class="ri-cloud-off-fill"></i>
<span>Servizi offline</span>
}
else
{
<i class="ri-cloud-fill"></i>
<span>Online</span>
}
}
else
{
<i class="ri-wifi-off-line"></i>
<span>Nessuna connessione</span>
}
</div>
<main> <main>
<article> <article>
@Body @Body
@@ -49,13 +31,12 @@
private string _mainContentClass = ""; private string _mainContentClass = "";
//Connection state //Connection state
private bool FirstCheck { get; set; } = true;
private bool _isNetworkAvailable; private bool _isNetworkAvailable;
private bool _servicesIsDown; private bool _servicesIsDown;
private bool _showWarning; private bool _showWarning;
private DateTime _lastApiCheck = DateTime.MinValue; private DateTime _lastApiCheck = DateTime.MinValue;
private const int DelaySeconds = 60; private const int DelaySeconds = 90;
private CancellationTokenSource? _cts; private CancellationTokenSource? _cts;

View File

@@ -1,13 +1,21 @@
@using CommunityToolkit.Mvvm.Messaging @using CommunityToolkit.Mvvm.Messaging
@using salesbook.Shared.Core.Dto @using salesbook.Shared.Core.Dto
@using salesbook.Shared.Core.Dto.Activity @using salesbook.Shared.Core.Dto.Activity
@using salesbook.Shared.Core.Dto.PageState
@using salesbook.Shared.Core.Entity @using salesbook.Shared.Core.Entity
@using salesbook.Shared.Core.Interface.System.Network
@using salesbook.Shared.Core.Messages.Activity.Copy @using salesbook.Shared.Core.Messages.Activity.Copy
@using salesbook.Shared.Core.Messages.Activity.New @using salesbook.Shared.Core.Messages.Activity.New
@using salesbook.Shared.Core.Messages.Contact @using salesbook.Shared.Core.Messages.Contact
@using salesbook.Shared.Core.Messages.Notification.Loaded
@using salesbook.Shared.Core.Messages.Notification.NewPush
@inject IDialogService Dialog @inject IDialogService Dialog
@inject IMessenger Messenger @inject IMessenger Messenger
@inject CopyActivityService CopyActivityService @inject CopyActivityService CopyActivityService
@inject NewPushNotificationService NewPushNotificationService
@inject NotificationState Notification
@inject INetworkService NetworkService
@inject NotificationsLoadedService NotificationsLoadedService
<div class="container animated-navbar @(IsVisible ? "show-nav" : "hide-nav") @(IsVisible ? PlusVisible ? "with-plus" : "without-plus" : "with-plus")"> <div class="container animated-navbar @(IsVisible ? "show-nav" : "hide-nav") @(IsVisible ? PlusVisible ? "with-plus" : "without-plus" : "with-plus")">
<nav class="navbar @(IsVisible ? PlusVisible ? "with-plus" : "without-plus" : "with-plus")"> <nav class="navbar @(IsVisible ? PlusVisible ? "with-plus" : "without-plus" : "with-plus")">
@@ -30,12 +38,14 @@
</NavLink> </NavLink>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<MudBadge Content="Notification.Count" Visible="Notification.Count > 0" Color="Color.Error" Overlap="true">
<NavLink class="nav-link" href="Notifications" Match="NavLinkMatch.All"> <NavLink class="nav-link" href="Notifications" Match="NavLinkMatch.All">
<div class="d-flex flex-column"> <div class="d-flex flex-column">
<i class="ri-notification-4-line"></i> <i class="ri-notification-4-line"></i>
<span>Notifiche</span> <span>Notifiche</span>
</div> </div>
</NavLink> </NavLink>
</MudBadge>
</li> </li>
</ul> </ul>
</div> </div>
@@ -47,8 +57,8 @@
<MudFab Class="custom-plus-button" Color="Color.Surface" Size="Size.Medium" IconSize="Size.Medium" IconColor="Color.Primary" StartIcon="@Icons.Material.Filled.Add"/> <MudFab Class="custom-plus-button" Color="Color.Surface" Size="Size.Medium" IconSize="Size.Medium" IconColor="Color.Primary" StartIcon="@Icons.Material.Filled.Add"/>
</ActivatorContent> </ActivatorContent>
<ChildContent> <ChildContent>
<MudMenuItem OnClick="() => CreateUser()">Nuovo contatto</MudMenuItem> <MudMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="() => CreateUser()">Nuovo contatto</MudMenuItem>
<MudMenuItem OnClick="() => CreateActivity()">Nuova attivit<69></MudMenuItem> <MudMenuItem Disabled="!NetworkService.IsNetworkAvailable()" OnClick="() => CreateActivity()">Nuova attivit<69></MudMenuItem>
</ChildContent> </ChildContent>
</MudMenu> </MudMenu>
} }
@@ -62,7 +72,7 @@
protected override Task OnInitializedAsync() protected override Task OnInitializedAsync()
{ {
CopyActivityService.OnCopyActivity += async dto => await CreateActivity(dto); InitMessage();
NavigationManager.LocationChanged += (_, args) => NavigationManager.LocationChanged += (_, args) =>
{ {
@@ -104,4 +114,17 @@
Messenger.Send(new NewContactMessage((CRMCreateContactResponseDTO)result.Data)); Messenger.Send(new NewContactMessage((CRMCreateContactResponseDTO)result.Data));
} }
} }
private void NewNotificationReceived(WtbNotification notification)
{
Notification.ReceivedNotifications.Add(notification);
InvokeAsync(StateHasChanged);
}
private void InitMessage()
{
CopyActivityService.OnCopyActivity += async dto => await CreateActivity(dto);
NewPushNotificationService.OnNotificationReceived += NewNotificationReceived;
NotificationsLoadedService.OnNotificationsLoaded += () => InvokeAsync(StateHasChanged);
}
} }

View File

@@ -9,7 +9,7 @@
.animated-navbar.show-nav { transform: translateY(0); } .animated-navbar.show-nav { transform: translateY(0); }
.animated-navbar.hide-nav { transform: translateY(100%); } .animated-navbar.hide-nav { transform: translateY(150%); }
.animated-navbar.with-plus { margin-left: 30px; } .animated-navbar.with-plus { margin-left: 30px; }

View File

@@ -0,0 +1,12 @@
<MudOverlay Visible="Visible" DarkBackground="false">
<div class="overlay-container">
<span>Caricamento</span>
<MudProgressLinear Color="Color.Primary" Rounded="true" Size="Size.Medium" Indeterminate="true" />
</div>
</MudOverlay>
@code
{
[Parameter] public bool Visible { get; set; }
}

View File

@@ -0,0 +1,18 @@
.overlay-container {
background: var(--mud-palette-background);
width: 20rem;
height: 6rem;
padding: 0 1rem;
display: flex;
gap: .5rem;
flex-direction: column;
justify-content: center;
border-radius: 20px;
box-shadow: var(--custom-box-shadow);
}
.overlay-container > span {
text-align: center;
font-size: 20px;
font-weight: 600;
}

View File

@@ -4,11 +4,13 @@
@using salesbook.Shared.Components.SingleElements @using salesbook.Shared.Components.SingleElements
@using salesbook.Shared.Components.SingleElements.BottomSheet @using salesbook.Shared.Components.SingleElements.BottomSheet
@using salesbook.Shared.Core.Dto.Activity @using salesbook.Shared.Core.Dto.Activity
@using salesbook.Shared.Core.Dto.PageState
@using salesbook.Shared.Core.Interface @using salesbook.Shared.Core.Interface
@using salesbook.Shared.Core.Messages.Activity.New @using salesbook.Shared.Core.Messages.Activity.New
@inject IManageDataService ManageData @inject IManageDataService ManageData
@inject IJSRuntime JS @inject IJSRuntime JS
@inject NewActivityService NewActivity @inject NewActivityService NewActivity
@inject UserListState UserState
<HeaderLayout Title="@_headerTitle" <HeaderLayout Title="@_headerTitle"
ShowFilter="true" ShowFilter="true"
@@ -168,7 +170,6 @@
<FilterActivity @bind-IsSheetVisible="OpenFilter" @bind-Filter="Filter" @bind-Filter:after="ApplyFilter"/> <FilterActivity @bind-IsSheetVisible="OpenFilter" @bind-Filter="Filter" @bind-Filter:after="ApplyFilter"/>
@code { @code {
// Modelli per ottimizzazione rendering // Modelli per ottimizzazione rendering
private record DayData(DateTime Date, string CssClass, bool HasEvents, CategoryData[] EventCategories, string DayName = ""); private record DayData(DateTime Date, string CssClass, bool HasEvents, CategoryData[] EventCategories, string DayName = "");
@@ -221,11 +222,20 @@
PrepareRenderingData(); PrepareRenderingData();
NewActivity.OnActivityCreated += async activityId => await OnActivityCreated(activityId); NewActivity.OnActivityCreated += async activityId => await OnActivityCreated(activityId);
UserState.OnUsersLoaded += async () => await InvokeAsync(LoadData);
} }
protected override async Task OnAfterRenderAsync(bool firstRender) protected override async Task OnAfterRenderAsync(bool firstRender)
{ {
if (firstRender) if (firstRender && UserState.IsLoaded)
{
await LoadData();
}
}
private async Task LoadData()
{
if (!_isInitialized)
{ {
Filter.User = new HashSet<string> { UserSession.User.Username }; Filter.User = new HashSet<string> { UserSession.User.Username };

View File

@@ -24,6 +24,7 @@
padding-bottom: 1rem; padding-bottom: 1rem;
overflow-x: hidden; overflow-x: hidden;
overflow-y: visible; overflow-y: visible;
min-height: 7rem;
} }
.week-slider.expanded { .week-slider.expanded {
@@ -31,7 +32,7 @@
grid-template-columns: repeat(7, 1fr); grid-template-columns: repeat(7, 1fr);
gap: 0.4rem; gap: 0.4rem;
padding: 1rem; padding: 1rem;
overflow-y: auto; overflow-y: hidden;
} }
.week-slider.expand-animation { animation: expandFromCenter 0.3s ease forwards; } .week-slider.expand-animation { animation: expandFromCenter 0.3s ease forwards; }
@@ -79,13 +80,12 @@
} }
.day { .day {
background: var(--mud-palette-surface);
border-radius: 10px; border-radius: 10px;
text-align: center; text-align: center;
cursor: pointer; cursor: pointer;
transition: background 0.3s ease, transform 0.2s ease; transition: background 0.3s ease, transform 0.2s ease;
font-size: 0.95rem; font-size: 0.95rem;
box-shadow: var(--custom-box-shadow); background: var(--mud-palette-background-gray);
width: 38px; width: 38px;
height: 38px; height: 38px;
display: flex; display: flex;
@@ -93,7 +93,7 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
color: var(--mud-palette-text-primary); color: var(--mud-palette-text-primary);
border: 1px solid var(--mud-palette-surface); border: 1px solid var(--mud-palette-background-gray);
margin: 0 auto; margin: 0 auto;
} }
@@ -122,8 +122,7 @@
flex-direction: column; flex-direction: column;
-ms-overflow-style: none; -ms-overflow-style: none;
scrollbar-width: none; scrollbar-width: none;
padding-bottom: 16vh; padding-bottom: 9vh;
height: calc(100% - 130px);
} }
.appointments.ah-calendar-m { height: calc(100% - 315px) !important; } .appointments.ah-calendar-m { height: calc(100% - 315px) !important; }

View File

@@ -11,6 +11,7 @@
@using salesbook.Shared.Core.Dto.PageState @using salesbook.Shared.Core.Dto.PageState
@using salesbook.Shared.Core.Entity @using salesbook.Shared.Core.Entity
@using salesbook.Shared.Core.Interface @using salesbook.Shared.Core.Interface
@using salesbook.Shared.Core.Interface.IntegryApi
@inject JobSteps JobSteps @inject JobSteps JobSteps
@inject IManageDataService ManageData @inject IManageDataService ManageData
@inject IIntegryApiService IntegryApiService @inject IIntegryApiService IntegryApiService
@@ -24,7 +25,7 @@
} }
else else
{ {
<div class="container content"> <div class="container content pb-safe-area">
@if (CommessaModel == null) @if (CommessaModel == null)
{ {
<NoDataAvailable Text="Nessuna commessa trovata"/> <NoDataAvailable Text="Nessuna commessa trovata"/>
@@ -148,8 +149,7 @@ else
await Task.Run(async () => await Task.Run(async () =>
{ {
var activities = await IntegryApiService.RetrieveActivity(new CRMRetrieveActivityRequestDTO { CodJcom = CodJcom }); var activities = await IntegryApiService.RetrieveActivity(new CRMRetrieveActivityRequestDTO { CodJcom = CodJcom });
ActivityList = Mapper.Map<List<ActivityDTO>>(activities) ActivityList = (await ManageData.MapActivity(activities)).OrderByDescending(x =>
.OrderBy(x =>
(x.EffectiveTime ?? x.EstimatedTime) ?? x.DataInsAct (x.EffectiveTime ?? x.EstimatedTime) ?? x.DataInsAct
).ToList(); ).ToList();
}); });

View File

@@ -118,7 +118,7 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
width: -webkit-fill-available; width: -webkit-fill-available;
box-shadow: var(--custom-box-shadow); background: var(--light-card-background);
border-radius: 16px; border-radius: 16px;
overflow: clip; overflow: clip;
margin-bottom: 1rem; margin-bottom: 1rem;
@@ -135,7 +135,6 @@
display: flex; display: flex;
position: relative; position: relative;
z-index: 1; z-index: 1;
background: var(--mud-palette-surface);
} }
/* la lineetta */ /* la lineetta */

View File

@@ -1,11 +1,19 @@
@page "/" @page "/"
@attribute [Authorize] @attribute [Authorize]
@using CommunityToolkit.Mvvm.Messaging
@using salesbook.Shared.Core.Interface @using salesbook.Shared.Core.Interface
@using salesbook.Shared.Components.Layout.Spinner @using salesbook.Shared.Components.Layout.Spinner
@using salesbook.Shared.Core.Interface.System.Network
@using salesbook.Shared.Core.Interface.System.Notification
@using salesbook.Shared.Core.Messages.Notification.Loaded
@using salesbook.Shared.Core.Services @using salesbook.Shared.Core.Services
@inject IFormFactor FormFactor @inject IFormFactor FormFactor
@inject INetworkService NetworkService @inject INetworkService NetworkService
@inject IFirebaseNotificationService FirebaseNotificationService
@inject IShinyNotificationManager NotificationManager
@inject INotificationService NotificationService
@inject PreloadService PreloadService @inject PreloadService PreloadService
@inject IMessenger Messenger
<SpinnerLayout FullScreen="true" /> <SpinnerLayout FullScreen="true" />
@@ -13,6 +21,20 @@
{ {
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
NetworkService.ConnectionAvailable = NetworkService.IsNetworkAvailable();
await LoadNotification();
await CheckAndRequestPermissions();
try
{
await FirebaseNotificationService.InitFirebase();
}
catch (Exception e)
{
Console.WriteLine($"Firebase init: {e.Message}");
}
var lastSyncDate = LocalStorage.Get<DateTime>("last-sync"); var lastSyncDate = LocalStorage.Get<DateTime>("last-sync");
if (!FormFactor.IsWeb() && NetworkService.ConnectionAvailable && lastSyncDate.Equals(DateTime.MinValue)) if (!FormFactor.IsWeb() && NetworkService.ConnectionAvailable && lastSyncDate.Equals(DateTime.MinValue))
@@ -25,6 +47,17 @@
NavigationManager.NavigateTo("/Calendar"); NavigationManager.NavigateTo("/Calendar");
} }
private async Task LoadNotification()
{
await NotificationService.LoadNotification();
Messenger.Send(new NotificationsLoadedMessage());
}
private async Task CheckAndRequestPermissions()
{
await NotificationManager.RequestAccess();
}
private Task StartSyncUser() private Task StartSyncUser()
{ {
return Task.Run(() => return Task.Run(() =>

View File

@@ -1,6 +1,7 @@
@page "/login" @page "/login"
@using salesbook.Shared.Components.Layout.Spinner @using salesbook.Shared.Components.Layout.Spinner
@using salesbook.Shared.Core.Interface @using salesbook.Shared.Core.Interface
@using salesbook.Shared.Core.Interface.System.Network
@using salesbook.Shared.Core.Services @using salesbook.Shared.Core.Services
@inject IUserAccountService UserAccountService @inject IUserAccountService UserAccountService
@inject AppAuthenticationStateProvider AuthenticationStateProvider @inject AppAuthenticationStateProvider AuthenticationStateProvider

View File

@@ -1,14 +1,146 @@
@page "/Notifications" @page "/Notifications"
@attribute [Authorize] @attribute [Authorize]
@using CommunityToolkit.Mvvm.Messaging
@using salesbook.Shared.Components.Layout @using salesbook.Shared.Components.Layout
@using salesbook.Shared.Components.Layout.Spinner
@using salesbook.Shared.Components.SingleElements @using salesbook.Shared.Components.SingleElements
@using salesbook.Shared.Core.Dto.PageState
@using salesbook.Shared.Core.Entity
@using salesbook.Shared.Core.Interface
@using salesbook.Shared.Core.Interface.IntegryApi
@using salesbook.Shared.Core.Messages.Notification.Loaded
@using salesbook.Shared.Core.Messages.Notification.NewPush
@inject NotificationState Notification
@inject NewPushNotificationService NewPushNotificationService
@inject IJSRuntime JS
@inject IIntegryNotificationRestClient IntegryNotificationRestClient
@inject INotificationService NotificationService
@inject IMessenger Messenger
<HeaderLayout Title="Notifiche" /> <HeaderLayout Title="Notifiche" />
<div class="container"> <div class="container container-notifications">
@if (Loading)
{
<SpinnerLayout FullScreen="true" />
}
else
{
if (Notification.ReceivedNotifications.IsNullOrEmpty() && Notification.UnreadNotifications.IsNullOrEmpty() && Notification.NotificationsRead.IsNullOrEmpty())
{
<NoDataAvailable Text="Nessuna notifica meno recente" /> <NoDataAvailable Text="Nessuna notifica meno recente" />
}
else
{
<div class="list" id="list">
@foreach(var notification in Notification.ReceivedNotifications)
{
<NotificationCard Unread="true" Notification="notification" />
}
@foreach(var notification in Notification.UnreadNotifications)
{
<NotificationCard Unread="true" Notification="notification" />
}
@foreach (var notification in Notification.NotificationsRead)
{
<NotificationCard Notification="notification" />
}
</div>
}
}
</div> </div>
@code { @code {
private DotNetObjectReference<Notifications>? _objectReference;
private bool Loading { get; set; }
protected override Task OnInitializedAsync()
{
_objectReference = DotNetObjectReference.Create(this);
NewPushNotificationService.OnNotificationReceived += NewNotificationReceived;
return Task.CompletedTask;
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await JS.InvokeVoidAsync("initNotifications", _objectReference);
}
private void NewNotificationReceived(WtbNotification notification)
{
InvokeAsync(StateHasChanged);
}
[JSInvokable]
public async Task Delete(string id)
{
if (!long.TryParse(id, out var notificationId)) return;
Loading = true;
StateHasChanged();
var removed = false;
if (Notification.ReceivedNotifications.RemoveAll(x => x.Id == notificationId) > 0)
removed = true;
else if (Notification.UnreadNotifications.RemoveAll(x => x.Id == notificationId) > 0)
removed = true;
else if (Notification.NotificationsRead.RemoveAll(x => x.Id == notificationId) > 0)
removed = true;
if (!removed)
{
Loading = false;
StateHasChanged();
return;
}
await IntegryNotificationRestClient.Delete(notificationId);
NotificationService.OrderNotificationList();
Loading = false;
StateHasChanged();
Messenger.Send(new NotificationsLoadedMessage());
}
[JSInvokable]
public async Task MarkAsRead(string id)
{
Loading = true;
StateHasChanged();
var notificationId = long.Parse(id);
var wtbNotification = Notification.ReceivedNotifications
.FindLast(x => x.Id == notificationId);
if (wtbNotification == null)
{
wtbNotification = Notification.UnreadNotifications
.FindLast(x => x.Id == notificationId);
Notification.UnreadNotifications.Remove(wtbNotification!);
}
else
{
Notification.ReceivedNotifications.Remove(wtbNotification);
}
wtbNotification = await IntegryNotificationRestClient.MarkAsRead(notificationId);
Notification.NotificationsRead.Add(wtbNotification);
NotificationService.OrderNotificationList();
Messenger.Send(new NotificationsLoadedMessage());
Loading = false;
StateHasChanged();
}
public void Dispose()
{
_objectReference?.Dispose();
}
} }

View File

@@ -0,0 +1,21 @@
.container-notifications {
height: 100%;
overflow: auto;
padding: .2rem 0 75px 0;
}
.list {
display: flex;
flex-direction: column;
align-items: center;
gap: 12px;
}
.container-notifications::-webkit-scrollbar {
width: 6px;
}
.container-notifications::-webkit-scrollbar-thumb {
background: #bbb;
border-radius: 3px;
}

View File

@@ -3,6 +3,7 @@
@using salesbook.Shared.Components.Layout @using salesbook.Shared.Components.Layout
@using salesbook.Shared.Core.Authorization.Enum @using salesbook.Shared.Core.Authorization.Enum
@using salesbook.Shared.Core.Interface @using salesbook.Shared.Core.Interface
@using salesbook.Shared.Core.Interface.System.Network
@using salesbook.Shared.Core.Services @using salesbook.Shared.Core.Services
@inject AppAuthenticationStateProvider AuthenticationStateProvider @inject AppAuthenticationStateProvider AuthenticationStateProvider
@inject INetworkService NetworkService @inject INetworkService NetworkService
@@ -12,7 +13,7 @@
@if (IsLoggedIn) @if (IsLoggedIn)
{ {
<div class="container content"> <div class="container content pb-safe-area">
<div class="container-primary-info"> <div class="container-primary-info">
<div class="section-primary-info"> <div class="section-primary-info">
<MudAvatar Style="height: 70px; width: 70px; font-size: 2rem; font-weight: bold" Color="Color.Secondary"> <MudAvatar Style="height: 70px; width: 70px; font-size: 2rem; font-weight: bold" Color="Color.Secondary">

View File

@@ -1,5 +1,5 @@
.container-primary-info { .container-primary-info {
box-shadow: var(--custom-box-shadow); background: var(--light-card-background);
width: 100%; width: 100%;
margin-bottom: 2rem; margin-bottom: 2rem;
border-radius: 12px; border-radius: 12px;

View File

@@ -10,6 +10,7 @@
@using salesbook.Shared.Core.Dto.Activity @using salesbook.Shared.Core.Dto.Activity
@using salesbook.Shared.Core.Dto.JobProgress @using salesbook.Shared.Core.Dto.JobProgress
@using salesbook.Shared.Core.Dto.PageState @using salesbook.Shared.Core.Dto.PageState
@using salesbook.Shared.Core.Interface.IntegryApi
@implements IAsyncDisposable @implements IAsyncDisposable
@inject IManageDataService ManageData @inject IManageDataService ManageData
@inject IMapper Mapper @inject IMapper Mapper
@@ -23,18 +24,18 @@
Back="true" Back="true"
BackOnTop="true" BackOnTop="true"
Title="" Title=""
ShowProfile="false" /> ShowProfile="false"/>
@if (IsLoading) @if (IsLoading)
{ {
<SpinnerLayout FullScreen="true" /> <SpinnerLayout FullScreen="true"/>
} }
else else
{ {
<div class="container content" style="overflow: auto;" id="topPage"> <div class="container content pb-safe-area" style="overflow: auto;" id="topPage">
<div class="container-primary-info"> <div class="container-primary-info">
<div class="section-primary-info"> <div class="section-primary-info">
<MudAvatar Style="height: 70px; width: 70px; font-size: 2rem; font-weight: bold" Color="Color.Secondary"> <MudAvatar Style="height: 70px; width: 70px; font-size: 2rem; font-weight: bold" Variant="@(IsContact ? Variant.Filled : Variant.Outlined)" Color="Color.Secondary">
@UtilityString.ExtractInitials(Anag.RagSoc) @UtilityString.ExtractInitials(Anag.RagSoc)
</MudAvatar> </MudAvatar>
@@ -54,44 +55,49 @@ else
<div class="divider"></div> <div class="divider"></div>
<div class="section-info"> <div class="section-info">
@if (Agente != null)
{
<div class="section-personal-info"> <div class="section-personal-info">
<div>
<span class="info-title">Agente</span>
<span class="info-text">@Agente.FullName</span>
</div>
</div>
}
@if (!string.IsNullOrEmpty(Anag.Telefono)) @if (!string.IsNullOrEmpty(Anag.Telefono))
{ {
<div class="section-personal-info">
<div> <div>
<span class="info-title">Telefono</span> <span class="info-title">Telefono</span>
<span class="info-text">@Anag.Telefono</span> <span class="info-text">@Anag.Telefono</span>
</div> </div>
</div>
} }
@if (!string.IsNullOrEmpty(Anag.PartIva)) @if (!string.IsNullOrEmpty(Anag.PartIva))
{ {
<div class="section-personal-info">
<div> <div>
<span class="info-title">P. IVA</span> <span class="info-title">P. IVA</span>
<span class="info-text">@Anag.PartIva</span> <span class="info-text">@Anag.PartIva</span>
</div> </div>
}
</div> </div>
}
<div class="section-personal-info">
@if (!string.IsNullOrEmpty(Anag.EMail)) @if (!string.IsNullOrEmpty(Anag.EMail))
{ {
<div class="section-personal-info">
<div> <div>
<span class="info-title">E-mail</span> <span class="info-title">E-mail</span>
<span class="info-text">@Anag.EMail</span> <span class="info-text">@Anag.EMail</span>
</div> </div>
}
@if (Agente != null)
{
<div>
<span class="info-title">Agente</span>
<span class="info-text">@Agente.FullName</span>
</div> </div>
} }
</div> </div>
</div> </div>
</div>
<div class="tab-section">
<input type="radio" class="tab-toggle" name="tab-toggle" id="tab1" checked="@(ActiveTab == 0)"> <input type="radio" class="tab-toggle" name="tab-toggle" id="tab1" checked="@(ActiveTab == 0)">
<input type="radio" class="tab-toggle" name="tab-toggle" id="tab2" checked="@(ActiveTab == 1)"> <input type="radio" class="tab-toggle" name="tab-toggle" id="tab2" checked="@(ActiveTab == 1)">
<input type="radio" class="tab-toggle" name="tab-toggle" id="tab3" checked="@(ActiveTab == 2)"> <input type="radio" class="tab-toggle" name="tab-toggle" id="tab3" checked="@(ActiveTab == 2)">
@@ -118,7 +124,7 @@ else
<div class="container-pers-rif"> <div class="container-pers-rif">
@foreach (var person in PersRif) @foreach (var person in PersRif)
{ {
<ContactCard Contact="person" /> <ContactCard Contact="person"/>
@if (person != PersRif.Last()) @if (person != PersRif.Last())
{ {
<div class="divider"></div> <div class="divider"></div>
@@ -128,9 +134,12 @@ else
} }
<div class="container-button"> <div class="container-button">
<div class="divider"></div>
<MudButton Class="button-settings infoText" <MudButton Class="button-settings infoText"
FullWidth="true" FullWidth="true"
Size="Size.Medium" Size="Size.Medium"
StartIcon="@Icons.Material.Rounded.Add"
OnClick="OpenPersRifForm" OnClick="OpenPersRifForm"
Variant="Variant.Outlined"> Variant="Variant.Outlined">
Aggiungi contatto Aggiungi contatto
@@ -142,28 +151,30 @@ else
<div class="tab-content" style="display: @(ActiveTab == 1 ? "block" : "none")"> <div class="tab-content" style="display: @(ActiveTab == 1 ? "block" : "none")">
@if (IsLoadingCommesse) @if (IsLoadingCommesse)
{ {
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-7" /> <MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-7"/>
} }
else if (Commesse?.Count == 0) else if (Commesse?.Count == 0)
{ {
<NoDataAvailable Text="Nessuna commessa presente" /> <NoDataAvailable Text="Nessuna commessa presente"/>
} }
else if (Commesse != null) else if (Commesse != null)
{ {
<!-- Filtri e ricerca --> <!-- Filtri e ricerca -->
<div class="input-card clearButton"> <div class="input-card clearButton custom-border-bottom">
<MudTextField T="string?" <MudTextField T="string?"
Placeholder="Cerca..." Placeholder="Cerca..."
Variant="Variant.Text" Variant="Variant.Text"
@bind-Value="SearchTermCommesse" @bind-Value="SearchTermCommesse"
AdornmentIcon="@Icons.Material.Rounded.Search"
Adornment="Adornment.Start"
OnDebounceIntervalElapsed="() => ApplyFiltersCommesse()" OnDebounceIntervalElapsed="() => ApplyFiltersCommesse()"
DebounceInterval="500" /> DebounceInterval="500"/>
</div> </div>
<div class="commesse-container"> <div class="commesse-container">
@if (IsLoadingSteps) @if (IsLoadingSteps)
{ {
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-3" /> <MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-3"/>
} }
@foreach (var commessa in CurrentPageCommesse) @foreach (var commessa in CurrentPageCommesse)
@@ -171,14 +182,14 @@ else
<div class="commessa-wrapper" style="@(IsLoadingStep(commessa.CodJcom) ? "opacity: 0.7;" : "")"> <div class="commessa-wrapper" style="@(IsLoadingStep(commessa.CodJcom) ? "opacity: 0.7;" : "")">
@if (Steps.TryGetValue(commessa.CodJcom, out var steps)) @if (Steps.TryGetValue(commessa.CodJcom, out var steps))
{ {
<CommessaCard Steps="@steps" RagSoc="@Anag.RagSoc" Commessa="commessa" /> <CommessaCard Steps="@steps" RagSoc="@Anag.RagSoc" Commessa="commessa"/>
} }
else else
{ {
<CommessaCard Steps="null" RagSoc="@Anag.RagSoc" Commessa="commessa" /> <CommessaCard Steps="null" RagSoc="@Anag.RagSoc" Commessa="commessa"/>
@if (IsLoadingStep(commessa.CodJcom)) @if (IsLoadingStep(commessa.CodJcom))
{ {
<MudProgressLinear Indeterminate="true" Color="Color.Primary" Class="my-1" Style="height: 2px;" /> <MudProgressLinear Indeterminate="true" Color="Color.Primary" Class="my-1" Style="height: 2px;"/>
} }
} }
</div> </div>
@@ -189,7 +200,7 @@ else
<div class="custom-pagination"> <div class="custom-pagination">
<MudPagination BoundaryCount="1" MiddleCount="1" Count="@TotalPagesCommesse" <MudPagination BoundaryCount="1" MiddleCount="1" Count="@TotalPagesCommesse"
@bind-Selected="SelectedPageCommesse" @bind-Selected="SelectedPageCommesse"
Color="Color.Primary" /> Color="Color.Primary"/>
</div> </div>
<div class="SelectedPageSize"> <div class="SelectedPageSize">
@@ -212,28 +223,30 @@ else
<div class="tab-content" style="display: @(ActiveTab == 2 ? "block" : "none")"> <div class="tab-content" style="display: @(ActiveTab == 2 ? "block" : "none")">
@if (ActivityIsLoading) @if (ActivityIsLoading)
{ {
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-7" /> <MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-7"/>
} }
else if (ActivityList?.Count == 0) else if (ActivityList?.Count == 0)
{ {
<NoDataAvailable Text="Nessuna attivit<69> presente" /> <NoDataAvailable Text="Nessuna attivit<69> presente"/>
} }
else if (ActivityList != null) else if (ActivityList != null)
{ {
<!-- Filtri e ricerca --> <!-- Filtri e ricerca -->
<div class="input-card clearButton"> <div class="input-card clearButton custom-border-bottom">
<MudTextField T="string?" <MudTextField T="string?"
Placeholder="Cerca..." Placeholder="Cerca..."
Variant="Variant.Text" Variant="Variant.Text"
AdornmentIcon="@Icons.Material.Rounded.Search"
Adornment="Adornment.Start"
@bind-Value="SearchTermActivity" @bind-Value="SearchTermActivity"
OnDebounceIntervalElapsed="() => ApplyFiltersActivity()" OnDebounceIntervalElapsed="() => ApplyFiltersActivity()"
DebounceInterval="500" /> DebounceInterval="500"/>
</div> </div>
<div class="attivita-container"> <div class="attivita-container">
@foreach (var activity in CurrentPageActivity) @foreach (var activity in CurrentPageActivity)
{ {
<ActivityCard ShowDate="true" Activity="activity" /> <ActivityCard ShowDate="true" Activity="activity"/>
} }
@if (TotalPagesActivity > 1) @if (TotalPagesActivity > 1)
@@ -241,7 +254,7 @@ else
<div class="custom-pagination"> <div class="custom-pagination">
<MudPagination BoundaryCount="1" MiddleCount="1" Count="@TotalPagesActivity" <MudPagination BoundaryCount="1" MiddleCount="1" Count="@TotalPagesActivity"
@bind-Selected="CurrentPageActivityIndex" @bind-Selected="CurrentPageActivityIndex"
Color="Color.Primary" /> Color="Color.Primary"/>
</div> </div>
<div class="SelectedPageSize"> <div class="SelectedPageSize">
@@ -262,9 +275,10 @@ else
</div> </div>
<MudScrollToTop Selector="#topPage" VisibleCssClass="visible absolute" TopOffset="100" HiddenCssClass="invisible"> <MudScrollToTop Selector="#topPage" VisibleCssClass="visible absolute" TopOffset="100" HiddenCssClass="invisible">
<MudFab Size="Size.Small" Color="Color.Primary" StartIcon="@Icons.Material.Rounded.KeyboardArrowUp" /> <MudFab Size="Size.Small" Color="Color.Primary" StartIcon="@Icons.Material.Rounded.KeyboardArrowUp"/>
</MudScrollToTop> </MudScrollToTop>
</div> </div>
</div>
} }
@code { @code {
@@ -522,8 +536,7 @@ else
await Task.Run(async () => await Task.Run(async () =>
{ {
var activities = await IntegryApiService.RetrieveActivity(new CRMRetrieveActivityRequestDTO { CodAnag = Anag.CodContact }); var activities = await IntegryApiService.RetrieveActivity(new CRMRetrieveActivityRequestDTO { CodAnag = Anag.CodContact });
ActivityList = Mapper.Map<List<ActivityDTO>>(activities) ActivityList = (await ManageData.MapActivity(activities)).OrderByDescending(x =>
.OrderByDescending(x =>
(x.EffectiveTime ?? x.EstimatedTime) ?? x.DataInsAct (x.EffectiveTime ?? x.EstimatedTime) ?? x.DataInsAct
).ToList(); ).ToList();
}); });
@@ -574,6 +587,9 @@ else
Steps = UserState.Steps; Steps = UserState.Steps;
ActivityList = UserState.Activitys; ActivityList = UserState.Activitys;
if (ActiveTab != UserState.ActiveTab)
SwitchTab(UserState.ActiveTab);
ApplyFiltersCommesse(); ApplyFiltersCommesse();
ApplyFiltersActivity(); ApplyFiltersActivity();
@@ -679,6 +695,7 @@ else
private void SwitchTab(int tabIndex) private void SwitchTab(int tabIndex)
{ {
ActiveTab = tabIndex; ActiveTab = tabIndex;
UserState.ActiveTab = ActiveTab;
if (tabIndex == 1 && Commesse == null) if (tabIndex == 1 && Commesse == null)
{ {
@@ -768,7 +785,16 @@ else
{ {
var result = await ModalHelpers.OpenUserForm(Dialog, anag); var result = await ModalHelpers.OpenUserForm(Dialog, anag);
if (result is { Canceled: false }) if (result is { Canceled: false, Data: not null } && result.Data.GetType() == typeof(AnagClie))
{
var clie = (AnagClie)result.Data;
IsContact = true;
CodContact = clie.CodAnag!;
await LoadAnagAsync();
SaveDataToSession();
}
else if (result is { Canceled: false })
{ {
await LoadAnagAsync(); await LoadAnagAsync();
SaveDataToSession(); SaveDataToSession();
@@ -776,4 +802,5 @@ else
} }
#endregion #endregion
} }

View File

@@ -1,5 +1,11 @@
.tab-section {
width: 100%;
border-radius: var(--mud-default-borderradius);
background: var(--light-card-background);
}
.container-primary-info { .container-primary-info {
box-shadow: var(--custom-box-shadow); background: var(--light-card-background);
width: 100%; width: 100%;
margin-bottom: 2rem; margin-bottom: 2rem;
border-radius: 16px; border-radius: 16px;
@@ -39,9 +45,10 @@
.section-info { .section-info {
display: flex; display: flex;
justify-content: space-between;
flex-direction: row; flex-direction: row;
padding: .4rem 1.2rem .8rem; padding: .4rem 1.2rem .8rem;
flex-wrap: wrap;
justify-content: space-between;
} }
.section-personal-info { .section-personal-info {
@@ -84,8 +91,9 @@
.container-button { .container-button {
width: 100%; width: 100%;
box-shadow: var(--custom-box-shadow); background: var(--light-card-background);
padding: .25rem 0; padding: 0 !important;
padding-bottom: .5rem !important;
border-radius: 16px; border-radius: 16px;
margin-bottom: 0 !important; margin-bottom: 0 !important;
} }
@@ -137,15 +145,20 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 1rem; gap: 1rem;
margin-bottom: 1rem; background: var(--light-card-background);
box-shadow: var(--custom-box-shadow);
border-radius: 16px; border-radius: 16px;
max-height: 32vh; max-height: 32vh;
overflow: auto; overflow: auto;
scrollbar-width: none; scrollbar-width: none;
padding: 1rem 0;
} }
.container-pers-rif::-webkit-scrollbar { display: none; } .container-pers-rif::-webkit-scrollbar { width: 3px; }
.container-pers-rif::-webkit-scrollbar-thumb {
background: #bbb;
border-radius: 2px;
}
.container-pers-rif .divider { .container-pers-rif .divider {
margin: 0 0 0 3.5rem; margin: 0 0 0 3.5rem;
@@ -174,12 +187,14 @@
/*-------------- /*--------------
TabPanel TabPanel
----------------*/ ----------------*/
.box { .box {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
width: -webkit-fill-available; width: -webkit-fill-available;
box-shadow: var(--custom-box-shadow); background: var(--light-card-background);
border-radius: 16px; border-radius: 20px 20px 0 0;
border-bottom: .1rem solid var(--card-border-color);
overflow: clip; overflow: clip;
margin-bottom: 1rem; margin-bottom: 1rem;
} }
@@ -195,7 +210,6 @@
display: flex; display: flex;
position: relative; position: relative;
z-index: 1; z-index: 1;
background: var(--mud-palette-surface);
} }
/* la lineetta */ /* la lineetta */
@@ -266,9 +280,7 @@
#tab1:checked ~ .tab-container .tab-content:nth-child(1), #tab1:checked ~ .tab-container .tab-content:nth-child(1),
#tab2:checked ~ .tab-container .tab-content:nth-child(2), #tab2:checked ~ .tab-container .tab-content:nth-child(2),
#tab3:checked ~ .tab-container .tab-content:nth-child(3) { #tab3:checked ~ .tab-container .tab-content:nth-child(3) { display: block; }
display: block;
}
@keyframes fade { @keyframes fade {
from { from {
@@ -284,10 +296,6 @@
.custom-pagination ::deep ul { padding-left: 0 !important; } .custom-pagination ::deep ul { padding-left: 0 !important; }
.SelectedPageSize { .SelectedPageSize { width: 100%; }
width: 100%;
}
.FilterSection { .FilterSection { display: flex; }
display: flex;
}

View File

@@ -5,8 +5,7 @@
flex-direction: column; flex-direction: column;
-ms-overflow-style: none; -ms-overflow-style: none;
scrollbar-width: none; scrollbar-width: none;
padding-bottom: 70px; padding-bottom: 9vh;
height: 100%;
} }
.users .divider { .users .divider {

View File

@@ -1,7 +1,7 @@
@using salesbook.Shared.Components.Layout.Spinner @using salesbook.Shared.Components.Layout.Spinner
@using salesbook.Shared.Core.Dto @using salesbook.Shared.Core.Dto
@using salesbook.Shared.Core.Interface
@using salesbook.Shared.Components.Layout.Overlay @using salesbook.Shared.Components.Layout.Overlay
@using salesbook.Shared.Core.Interface.IntegryApi
@inject IIntegryApiService IntegryApiService @inject IIntegryApiService IntegryApiService
<div class="bottom-sheet-backdrop @(IsSheetVisible ? "show" : "")" @onclick="CloseBottomSheet"></div> <div class="bottom-sheet-backdrop @(IsSheetVisible ? "show" : "")" @onclick="CloseBottomSheet"></div>

View File

@@ -1,4 +1,3 @@
@using salesbook.Shared.Core.Dto
@using salesbook.Shared.Core.Dto.Activity @using salesbook.Shared.Core.Dto.Activity
@using salesbook.Shared.Core.Entity @using salesbook.Shared.Core.Entity
@using salesbook.Shared.Core.Helpers.Enum @using salesbook.Shared.Core.Helpers.Enum
@@ -12,7 +11,7 @@
@switch (Activity.Category) @switch (Activity.Category)
{ {
case ActivityCategoryEnum.Commessa: case ActivityCategoryEnum.Commessa:
@Activity.Commessa @Activity.Commessa?.Descrizione
break; break;
case ActivityCategoryEnum.Interna: case ActivityCategoryEnum.Interna:
@Activity.Cliente @Activity.Cliente

View File

@@ -5,14 +5,23 @@
padding: .5rem .5rem; padding: .5rem .5rem;
border-radius: 12px; border-radius: 12px;
line-height: normal; line-height: normal;
box-shadow: var(--custom-box-shadow); /*box-shadow: var(--custom-box-shadow);*/
} }
.activity-card.memo { border-left: 5px solid var(--mud-palette-info-darken); } .activity-card.memo {
border-left: 5px solid var(--mud-palette-info-darken);
background-color: hsl(from var(--mud-palette-info-darken) h s 98%);
}
.activity-card.interna { border-left: 5px solid var(--mud-palette-success-darken); } .activity-card.interna {
border-left: 5px solid var(--mud-palette-success-darken);
background-color: hsl(from var(--mud-palette-success-darken) h s 98%);
}
.activity-card.commessa { border-left: 5px solid var(--mud-palette-warning); } .activity-card.commessa {
border-left: 5px solid var(--mud-palette-warning);
background-color: hsl(from var(--mud-palette-warning) h s 98%);
}
.activity-left-section { .activity-left-section {
display: flex; display: flex;

View File

@@ -1,5 +1,6 @@
@using salesbook.Shared.Core.Dto @using salesbook.Shared.Core.Dto
@using salesbook.Shared.Core.Interface @using salesbook.Shared.Core.Interface
@using salesbook.Shared.Core.Interface.IntegryApi
@inject IIntegryApiService IntegryApiService @inject IIntegryApiService IntegryApiService
@inject IAttachedService AttachedService @inject IAttachedService AttachedService

View File

@@ -5,7 +5,7 @@
padding: .5rem .5rem; padding: .5rem .5rem;
border-radius: 12px; border-radius: 12px;
line-height: normal; line-height: normal;
box-shadow: var(--custom-box-shadow); background: var(--light-card-background);
} }
.activity-card.memo { border-left: 5px solid var(--mud-palette-info-darken); } .activity-card.memo { border-left: 5px solid var(--mud-palette-info-darken); }

View File

@@ -44,21 +44,25 @@
{ {
if (Steps is null) return; if (Steps is null) return;
// Ultimo step non skip
var lastBeforeSkip = Steps var lastBeforeSkip = Steps
.TakeWhile(s => s.Status is { Skip: false }) .LastOrDefault(s => s.Status is { Skip: false });
.LastOrDefault();
if (lastBeforeSkip is not null) Stato = lastBeforeSkip.StepName; if (lastBeforeSkip is not null)
Stato = lastBeforeSkip.StepName;
// Ultima data disponibile
LastUpd = Steps LastUpd = Steps
.Where(s => s.Date.HasValue) .Where(s => s.Date.HasValue)
.Select(s => s.Date!.Value) .Select(s => s.Date!.Value)
.DefaultIfEmpty() .DefaultIfEmpty()
.Max(); .Max();
if (LastUpd.Equals(DateTime.MinValue)) LastUpd = null; if (LastUpd.Equals(DateTime.MinValue))
LastUpd = null;
} }
private void OpenPageCommessa() private void OpenPageCommessa()
{ {
JobSteps.Steps = Steps; JobSteps.Steps = Steps;

View File

@@ -5,15 +5,11 @@
padding: .5rem .5rem; padding: .5rem .5rem;
border-radius: 12px; border-radius: 12px;
line-height: normal; line-height: normal;
box-shadow: var(--custom-box-shadow);
border-left: 5px solid var(--card-border-color);
background-color: hsl(from var(--card-border-color) h s 99%);
} }
.activity-card.memo { border-left: 5px solid var(--mud-palette-info-darken); }
.activity-card.interna { border-left: 5px solid var(--mud-palette-success-darken); }
.activity-card.commessa { border-left: 5px solid var(--mud-palette-warning); }
.activity-left-section { .activity-left-section {
display: flex; display: flex;
align-items: center; align-items: center;

View File

@@ -2,8 +2,7 @@
width: 100%; width: 100%;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
padding: 0 .75rem; padding: 0 .5rem;
border-radius: 16px;
line-height: normal; line-height: normal;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;

View File

@@ -0,0 +1,121 @@
@using Java.Sql
@using salesbook.Shared.Components.Layout.Spinner
@using salesbook.Shared.Core.Dto.Activity
@using salesbook.Shared.Core.Entity
@using salesbook.Shared.Core.Interface
@inject IManageDataService ManageDataService
@inject ISnackbar Snackbar
@inject IDialogService Dialog
<div class="row" id="@Notification.Id" @onclick="OpenActivity">
<div class="behind-left">
<button class="read-btn">
<MudIcon Icon="@Icons.Material.Rounded.Check" />
</button>
</div>
<div class="behind-right">
<button class="trash-btn">
<MudIcon Icon="@Icons.Material.Rounded.Delete" />
</button>
</div>
<div class="notification-card">
@if (Notification.NotificationData is { Type: not null })
{
@switch (Notification.NotificationData.Type)
{
case "memo":
<div class="avatar"><MudIcon Icon="@Icons.Material.Rounded.ContentPaste" /></div>
break;
case "newPlanned":
<div class="avatar"><MudIcon Icon="@Icons.Material.Rounded.CalendarMonth" /></div>
break;
}
}
<div class="notification-body">
<div class="title-row">
<div class="title">@Notification.Title</div>
<div class="section-time">
<div class="notification-time">@GetTimeAgo(Notification.StartDate)</div>
@if (Unread)
{
<span class="unread-dot"></span>
}
</div>
</div>
@if (
Notification.StartDate < DateTime.Today && Notification.Body != null && Notification.Body.Contains("Oggi")
)
{
<div class="subtitle">@Notification.Body.Replace("Oggi", $"{Notification.StartDate:d}")</div>
}
else
{
<div class="subtitle">@Notification.Body</div>
}
</div>
</div>
</div>
<OverlayLayout Visible="VisibleOverlay" />
@code {
[Parameter] public bool Unread { get; set; }
[Parameter] public WtbNotification Notification { get; set; } = new();
private bool VisibleOverlay { get; set; }
private async Task OpenActivity()
{
if(Notification.NotificationData?.ActivityId == null) return;
var activityId = Notification.NotificationData.ActivityId;
Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter;
Snackbar.Clear();
VisibleOverlay = true;
StateHasChanged();
var activity = (await ManageDataService.GetActivityTryLocalDb(new WhereCondActivity { ActivityId = activityId })).LastOrDefault();
VisibleOverlay = false;
StateHasChanged();
if (activity == null) Snackbar.Add("Impossibile aprire l'attivit<69>", Severity.Error);
_ = ModalHelpers.OpenActivityForm(Dialog, activity, null);
}
private static string GetTimeAgo(DateTime? timestamp)
{
if (timestamp is null) return "";
var difference = DateTime.Now - timestamp.Value;
if (DateTime.Now.Day != timestamp.Value.Day)
return timestamp.Value.ToString("dd/MM/yyyy");
switch (difference.TotalMinutes)
{
case < 1:
return "Adesso";
case < 60:
return $"{(int)difference.TotalMinutes} minuti fa";
default:
{
switch (difference.TotalHours)
{
case < 2:
return $"{(int)difference.TotalHours} ora fa";
case < 24:
return $"{timestamp.Value:t}";
default:
{
return timestamp.Value.ToString("dd/MM/yyyy");
}
}
}
}
}
}

View File

@@ -0,0 +1,109 @@
.row {
position: relative;
overflow: hidden;
border-radius: var(--mud-default-borderradius);
width: 100%;
}
.behind-left, .behind-right {
position: absolute;
inset: 0;
display: flex;
align-items: center;
z-index: 0;
}
.behind-right {
justify-content: flex-end;
padding-right: 14px;
background: var(--mud-palette-error);
}
.behind-left {
justify-content: flex-start;
padding-left: 14px;
background: var(--mud-palette-info);
}
.read-btn, .trash-btn {
color: white;
padding: 10px 15px;
cursor: pointer;
}
.notification-card {
position: relative;
z-index: 1;
display: flex;
align-items: center;
padding: 12px;
gap: 12px;
background: var(--light-card-background);
transition: transform .2s ease;
touch-action: pan-y;
will-change: transform;
transform: translateX(0);
}
.avatar {
min-width: 42px;
height: 42px;
border-radius: 12px;
display: grid;
place-items: center;
background: var(--mud-palette-background);
border: 1px solid var(--mud-palette-divider);
font-weight: bold;
color: var(--mud-palette-primary);
}
.notification-body {
width: 100%
}
.title-row {
display: flex;
gap: 8px;
justify-items: center;
align-items: flex-start;
justify-content: space-between;
}
.unread-dot {
width: 10px;
height: 10px;
background-color: var(--mud-palette-error);
border-radius: 50%;
}
.title {
font-weight: 700;
margin-bottom: unset !important;
line-height: normal;
}
.section-time {
display: flex;
gap: .65rem;
min-width: max-content;
justify-content: flex-end;
align-items: center;
}
.notification-time {
font-size: 13px;
color: #94a3b8;
line-height: normal;
}
.collapsing {
transition: height .22s ease, margin .22s ease, opacity .22s ease;
overflow: hidden;
}
.notification-body ::deep > .subtitle {
font-size: 12px;
color: var(--mud-palette-drawer-text);
line-height: inherit;
margin-top: .5rem;
}

View File

@@ -1,5 +1,4 @@
@using System.Globalization @using System.Globalization
@using System.Text.RegularExpressions
@using CommunityToolkit.Mvvm.Messaging @using CommunityToolkit.Mvvm.Messaging
@using salesbook.Shared.Components.Layout @using salesbook.Shared.Components.Layout
@using salesbook.Shared.Components.Layout.Overlay @using salesbook.Shared.Components.Layout.Overlay
@@ -9,6 +8,8 @@
@using salesbook.Shared.Core.Dto.Contact @using salesbook.Shared.Core.Dto.Contact
@using salesbook.Shared.Core.Entity @using salesbook.Shared.Core.Entity
@using salesbook.Shared.Core.Interface @using salesbook.Shared.Core.Interface
@using salesbook.Shared.Core.Interface.IntegryApi
@using salesbook.Shared.Core.Interface.System.Network
@using salesbook.Shared.Core.Messages.Activity.Copy @using salesbook.Shared.Core.Messages.Activity.Copy
@inject IManageDataService ManageData @inject IManageDataService ManageData
@inject INetworkService NetworkService @inject INetworkService NetworkService
@@ -38,18 +39,25 @@
<div class="form-container"> <div class="form-container">
<span class="disable-full-width">Commessa</span> <span class="disable-full-width">Commessa</span>
@if (Commesse.IsNullOrEmpty()) @if (ActivityModel.CodJcom != null && SelectedComessa == null)
{ {
<span class="warning-text">Nessuna commessa presente</span> <MudSkeleton />
} }
else else
{ {
<MudSelectExtended FullWidth="true" ReadOnly="@(IsView || Commesse.IsNullOrEmpty())" T="string?" Variant="Variant.Text" @bind-Value="ActivityModel.CodJcom" @bind-Value:after="OnCommessaChanged" Class="customIcon-select" AdornmentIcon="@Icons.Material.Filled.Code"> <MudAutocomplete
@foreach (var com in Commesse) Disabled="ActivityModel.Cliente.IsNullOrEmpty()"
{ T="JtbComt?" ReadOnly="IsView"
<MudSelectItemExtended Class="custom-item-select" Value="@com.CodJcom">@($"{com.CodJcom} - {com.Descrizione}")</MudSelectItemExtended> @bind-Value="SelectedComessa"
} @bind-Value:after="OnCommessaSelectedAfter"
</MudSelectExtended> SearchFunc="SearchCommesseAsync"
ToStringFunc="@(c => c == null ? string.Empty : $"{c.CodJcom} - {c.Descrizione}")"
Clearable="true"
OnClearButtonClick="OnCommessaClear"
ShowProgressIndicator="true"
DebounceInterval="300"
MaxItems="50"
Class="customIcon-select" AdornmentIcon="@Icons.Material.Filled.Code"/>
} }
</div> </div>
</div> </div>
@@ -72,9 +80,17 @@
<div class="divider"></div> <div class="divider"></div>
<div class="form-container"> <div class="form-container">
<span>Avviso</span> <span class="disable-full-width">Avviso</span>
<MudSwitch ReadOnly="IsView" T="bool" Disabled="true" Color="Color.Primary"/> <MudSelectExtended FullWidth="true" ReadOnly="@(IsView || ActivityModel.EstimatedTime == null)" T="int" Variant="Variant.Text" @bind-Value="ActivityModel.MinuteBefore" @bind-Value:after="OnAfterChangeTimeBefore" Class="customIcon-select" AdornmentIcon="@Icons.Material.Filled.Code">
<MudSelectItemExtended Class="custom-item-select" Text="Nessuno" Value="-1">Nessuno</MudSelectItemExtended>
<MudSelectItemExtended Class="custom-item-select" Text="All'ora pianificata" Value="0">All'ora pianificata</MudSelectItemExtended>
<MudSelectItemExtended Class="custom-item-select" Text="30 minuti prima" Value="30">30 minuti prima</MudSelectItemExtended>
<MudSelectItemExtended Class="custom-item-select" Text="1 ora prima" Value="60">1 ora prima</MudSelectItemExtended>
<MudSelectItemExtended Class="custom-item-select" Text="2 ore prima" Value="120">2 ore prima</MudSelectItemExtended>
<MudSelectItemExtended Class="custom-item-select" Text="1 giorno prima" Value="1440">1 giorno prima</MudSelectItemExtended>
<MudSelectItemExtended Class="custom-item-select" Text="1 settimana prima" Value="10080">1 settimana prima</MudSelectItemExtended>
</MudSelectExtended>
</div> </div>
</div> </div>
@@ -82,12 +98,27 @@
<div class="form-container"> <div class="form-container">
<span class="disable-full-width">Assegnata a</span> <span class="disable-full-width">Assegnata a</span>
<MudSelectExtended FullWidth="true" ReadOnly="IsView" T="string?" Variant="Variant.Text" @bind-Value="ActivityModel.UserName" @bind-Value:after="OnAfterChangeValue" Class="customIcon-select" AdornmentIcon="@Icons.Material.Filled.Code"> @if (ActivityModel.UserName != null && SelectedUser == null)
@foreach (var user in Users)
{ {
<MudSelectItemExtended Class="custom-item-select" Value="@user.UserName">@user.FullName</MudSelectItemExtended> <MudSkeleton />
}
else
{
<MudAutocomplete
Disabled="Users.IsNullOrEmpty()" ReadOnly="IsView"
T="StbUser"
@bind-Value="SelectedUser"
@bind-Value:after="OnUserSelectedAfter"
SearchFunc="SearchUtentiAsync"
ToStringFunc="@(u => u == null ? string.Empty : u.FullName)"
Clearable="true"
OnClearButtonClick="OnUserClear"
ShowProgressIndicator="true"
DebounceInterval="300"
MaxItems="50"
Class="customIcon-select"
AdornmentIcon="@Icons.Material.Filled.Code"/>
} }
</MudSelectExtended>
</div> </div>
<div class="divider"></div> <div class="divider"></div>
@@ -95,12 +126,19 @@
<div class="form-container"> <div class="form-container">
<span class="disable-full-width">Tipo</span> <span class="disable-full-width">Tipo</span>
@if (ActivityType.IsNullOrEmpty())
{
<MudSkeleton />
}
else
{
<MudSelectExtended ReadOnly="IsView" FullWidth="true" T="string?" Variant="Variant.Text" @bind-Value="ActivityModel.ActivityTypeId" @bind-Value:after="OnAfterChangeValue" Class="customIcon-select" AdornmentIcon="@Icons.Material.Filled.Code"> <MudSelectExtended ReadOnly="IsView" FullWidth="true" T="string?" Variant="Variant.Text" @bind-Value="ActivityModel.ActivityTypeId" @bind-Value:after="OnAfterChangeValue" Class="customIcon-select" AdornmentIcon="@Icons.Material.Filled.Code">
@foreach (var type in ActivityType) @foreach (var type in ActivityType)
{ {
<MudSelectItemExtended Class="custom-item-select" Value="@type.ActivityTypeId">@type.ActivityTypeId</MudSelectItemExtended> <MudSelectItemExtended Class="custom-item-select" Value="@type.ActivityTypeId">@type.ActivityTypeId</MudSelectItemExtended>
} }
</MudSelectExtended> </MudSelectExtended>
}
</div> </div>
<div class="divider"></div> <div class="divider"></div>
@@ -152,6 +190,8 @@
} }
</div> </div>
@if (!IsView)
{
<div class="container-button"> <div class="container-button">
<MudButton Class="button-settings green-icon" <MudButton Class="button-settings green-icon"
FullWidth="true" FullWidth="true"
@@ -187,6 +227,7 @@
</MudButton> </MudButton>
} }
</div> </div>
}
</div> </div>
<MudMessageBox @ref="ConfirmDelete" Class="c-messageBox" Title="Attenzione!" CancelText="Annulla"> <MudMessageBox @ref="ConfirmDelete" Class="c-messageBox" Title="Attenzione!" CancelText="Annulla">
@@ -200,30 +241,6 @@
</MudButton> </MudButton>
</YesButton> </YesButton>
</MudMessageBox> </MudMessageBox>
<MudMessageBox @ref="AddNamePosition" Class="c-messageBox" Title="Nome della posizione" CancelText="Annulla">
<MessageContent>
<MudTextField @bind-Value="NamePosition" Variant="Variant.Outlined" />
</MessageContent>
<YesButton>
<MudButton Size="Size.Small" Variant="Variant.Filled" Color="Color.Primary"
StartIcon="@Icons.Material.Rounded.Check">
Salva
</MudButton>
</YesButton>
</MudMessageBox>
<MudMessageBox @ref="ConfirmMemo" Class="c-messageBox" Title="Attenzione!" CancelText="Annulla">
<MessageContent>
Vuoi creare un promemoria?
</MessageContent>
<YesButton>
<MudButton Size="Size.Small" Variant="Variant.Filled" Color="Color.Primary"
StartIcon="@Icons.Material.Rounded.Check">
Crea
</MudButton>
</YesButton>
</MudMessageBox>
</DialogContent> </DialogContent>
</MudDialog> </MudDialog>
@@ -264,14 +281,20 @@
//MessageBox //MessageBox
private MudMessageBox ConfirmDelete { get; set; } private MudMessageBox ConfirmDelete { get; set; }
private MudMessageBox ConfirmMemo { get; set; }
private MudMessageBox AddNamePosition { get; set; }
//Attached //Attached
private List<AttachedDTO>? AttachedList { get; set; } private List<AttachedDTO>? AttachedList { get; set; }
private string? NamePosition { get; set; }
private bool CanAddPosition { get; set; } = true; private bool CanAddPosition { get; set; } = true;
// cache per commesse
private string? _lastLoadedCodAnag;
//Commessa
private JtbComt? SelectedComessa { get; set; }
//User
private StbUser? SelectedUser { get; set; }
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter; Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter;
@@ -281,24 +304,24 @@
ActivityModel = ActivityCopied.Clone(); ActivityModel = ActivityCopied.Clone();
} }
else if (!Id.IsNullOrEmpty()) else if (!Id.IsNullOrEmpty())
{
ActivityModel = (await ManageData.GetActivity(new WhereCondActivity { ActivityId = Id }, true)).Last(); ActivityModel = (await ManageData.GetActivity(new WhereCondActivity { ActivityId = Id }, true)).Last();
}
if (Id.IsNullOrEmpty()) Id = ActivityModel.ActivityId; if (Id.IsNullOrEmpty()) Id = ActivityModel.ActivityId;
IsNew = Id.IsNullOrEmpty(); IsNew = Id.IsNullOrEmpty();
LabelSave = IsNew ? "Aggiungi" : null; LabelSave = IsNew ? "Aggiungi" : null;
_ = LoadData();
await LoadCommesse();
if (IsNew) if (IsNew)
{ {
ActivityModel.EstimatedTime = DateTime.Today.Add(TimeSpan.FromHours(DateTime.Now.Hour)); ActivityModel.EstimatedTime = DateTime.Today.AddHours(DateTime.Now.Hour);
ActivityModel.EstimatedEndtime = DateTime.Today.Add(TimeSpan.FromHours(DateTime.Now.Hour) + TimeSpan.FromHours(1)); ActivityModel.EstimatedEndtime = ActivityModel.EstimatedTime?.AddHours(1);
ActivityModel.UserName = UserSession.User.Username; ActivityModel.UserName = UserSession.User.Username;
} }
await LoadActivityType(); _ = LoadData();
await LoadActivityType();
OriginalModel = ActivityModel.Clone(); OriginalModel = ActivityModel.Clone();
} }
@@ -310,167 +333,259 @@
StateHasChanged(); StateHasChanged();
await SavePosition(); await SavePosition();
var response = await IntegryApiService.SaveActivity(ActivityModel); var response = await IntegryApiService.SaveActivity(ActivityModel);
if (response == null) if (response == null)
return; return;
var newActivity = response.Last(); var newActivity = response.Last();
await ManageData.InsertOrUpdate(newActivity); await ManageData.InsertOrUpdate(newActivity);
await SaveAttached(newActivity.ActivityId!); await SaveAttached(newActivity.ActivityId!);
SuccessAnimation = true; SuccessAnimation = true;
StateHasChanged(); StateHasChanged();
await Task.Delay(1250); await Task.Delay(1250);
MudDialog.Close(newActivity); MudDialog.Close(newActivity);
} }
private async Task SavePosition() private async Task SavePosition()
{ {
if (AttachedList != null) if (AttachedList is null) return;
{
foreach (var attached in AttachedList)
{
if (attached.Type != AttachedDTO.TypeAttached.Position) continue;
var positionTasks = AttachedList
.Where(a => a.Type == AttachedDTO.TypeAttached.Position)
.Select(async attached =>
{
var position = new PositionDTO var position = new PositionDTO
{ {
Description = attached.Description, Description = attached.Description,
Lat = attached.Lat, Lat = attached.Lat,
Lng = attached.Lng Lng = attached.Lng
}; };
ActivityModel.Position = await IntegryApiService.SavePosition(position); ActivityModel.Position = await IntegryApiService.SavePosition(position);
} });
}
await Task.WhenAll(positionTasks);
} }
private async Task SaveAttached(string activityId) private async Task SaveAttached(string activityId)
{ {
if (AttachedList != null) if (AttachedList is null) return;
{
foreach (var attached in AttachedList) var uploadTasks = AttachedList
{ .Where(a => a.FileContent is not null && a.Type != AttachedDTO.TypeAttached.Position)
if (attached.FileContent is not null && attached.Type != AttachedDTO.TypeAttached.Position) .Select(a => IntegryApiService.UploadFile(activityId, a.FileBytes, a.Name));
{
await IntegryApiService.UploadFile(activityId, attached.FileBytes, attached.Name); await Task.WhenAll(uploadTasks);
}
}
}
} }
private bool CheckPreSave() private bool CheckPreSave()
{ {
Snackbar.Clear(); Snackbar.Clear();
if (!ActivityModel.ActivityTypeId.IsNullOrEmpty()) return true; if (!ActivityModel.ActivityTypeId.IsNullOrEmpty()) return true;
Snackbar.Add("Tipo attività obbligatorio!", Severity.Error);
Snackbar.Add("Tipo attività obbligatorio!", Severity.Error);
return false; return false;
} }
private async Task LoadData() private Task LoadData()
{ {
if (!IsNew && Id != null) return Task.Run(async () =>
{ {
ActivityFileList = await IntegryApiService.GetActivityFile(Id); SelectedComessa = ActivityModel.Commessa;
}
Users = await ManageData.GetTable<StbUser>(); Users = await ManageData.GetTable<StbUser>();
if (!ActivityModel.UserName.IsNullOrEmpty())
SelectedUser = Users.FindLast(x => x.UserName.Equals(ActivityModel.UserName));
if (!IsNew && Id != null)
ActivityFileList = await IntegryApiService.GetActivityFile(Id);
ActivityResult = await ManageData.GetTable<StbActivityResult>(); ActivityResult = await ManageData.GetTable<StbActivityResult>();
Clienti = await ManageData.GetClienti(new WhereCondContact {FlagStato = "A"}); Clienti = await ManageData.GetClienti(new WhereCondContact { FlagStato = "A" });
Pros = await ManageData.GetProspect(); Pros = await ManageData.GetProspect();
await InvokeAsync(StateHasChanged);
});
} }
private async Task LoadActivityType() private async Task LoadActivityType()
{ {
if (ActivityModel.UserName is null) ActivityType = []; if (ActivityModel.UserName is null)
ActivityType = await ManageData.GetTable<SrlActivityTypeUser>(x =>
x.UserName != null && x.UserName.Equals(ActivityModel.UserName)
);
}
private async Task LoadCommesse() =>
Commesse = await ManageData.GetTable<JtbComt>(x => x.CodAnag != null && x.CodAnag.Equals(ActivityModel.CodAnag));
private async Task<IEnumerable<string>?> SearchCliente(string value, CancellationToken token)
{ {
if (string.IsNullOrEmpty(value)) ActivityType = [];
return null; return;
var listToReturn = new List<string>();
listToReturn.AddRange(
Clienti.Where(x => x.RagSoc.Contains(value, StringComparison.OrdinalIgnoreCase)).Select(x => $"{x.CodAnag} - {x.RagSoc}")
);
listToReturn.AddRange(
Pros.Where(x => x.RagSoc.Contains(value, StringComparison.OrdinalIgnoreCase)).Select(x => $"{x.CodPpro} - {x.RagSoc}")
);
return listToReturn;
} }
private async Task OnClienteChanged() ActivityType = await ManageData.GetTable<SrlActivityTypeUser>(x => x.UserName != null && x.UserName.Equals(ActivityModel.UserName)
);
}
private async Task LoadCommesse()
{
if (_lastLoadedCodAnag == ActivityModel.CodAnag) return;
Commesse = await ManageData.GetTable<JtbComt>(x => x.CodAnag == ActivityModel.CodAnag);
Commesse = Commesse.OrderByDescending(x => x.CodJcom).ToList();
_lastLoadedCodAnag = ActivityModel.CodAnag;
}
private async Task<IEnumerable<JtbComt>> SearchCommesseAsync(string value, CancellationToken token)
{
await LoadCommesse();
if (Commesse.IsNullOrEmpty()) return [];
IEnumerable<JtbComt> list;
if (string.IsNullOrWhiteSpace(value))
{
list = Commesse.OrderByDescending(x => x.CodJcom).Take(10);
}
else
{
list = Commesse
.Where(x => (x.CodJcom.Contains(value, StringComparison.OrdinalIgnoreCase)
|| x.Descrizione.Contains(value, StringComparison.OrdinalIgnoreCase))
&& (x.CodAnag == ActivityModel.CodAnag || ActivityModel.CodAnag == null))
.OrderByDescending(x => x.CodJcom)
.Take(50);
}
return token.IsCancellationRequested ? [] : list;
}
private Task<IEnumerable<StbUser>> SearchUtentiAsync(string value, CancellationToken token)
{
IEnumerable<StbUser> list;
if (string.IsNullOrWhiteSpace(value))
{
list = Users.OrderBy(u => u.FullName).Take(50);
}
else
{
list = Users
.Where(x => x.UserName.Contains(value, StringComparison.OrdinalIgnoreCase)
|| x.FullName.Contains(value, StringComparison.OrdinalIgnoreCase))
.OrderBy(u => u.FullName)
.Take(50);
}
return Task.FromResult(token.IsCancellationRequested ? [] : list);
}
private Task<IEnumerable<string>?> SearchCliente(string value, CancellationToken token)
{
if (string.IsNullOrWhiteSpace(value))
return Task.FromResult<IEnumerable<string>?>(null);
var results = new List<string>();
results.AddRange(Clienti
.Where(x => x.RagSoc.Contains(value, StringComparison.OrdinalIgnoreCase))
.Select(x => $"{x.CodAnag} - {x.RagSoc}"));
results.AddRange(Pros
.Where(x => x.RagSoc.Contains(value, StringComparison.OrdinalIgnoreCase))
.Select(x => $"{x.CodPpro} - {x.RagSoc}"));
return Task.FromResult<IEnumerable<string>?>(results);
}
private Task OnClienteChanged()
{ {
ActivityModel.CodJcom = null; ActivityModel.CodJcom = null;
if (string.IsNullOrWhiteSpace(ActivityModel.Cliente)) return Task.CompletedTask;
if (ActivityModel.Cliente.IsNullOrEmpty()) return; var parts = ActivityModel.Cliente.Split('-', 2, StringSplitOptions.TrimEntries);
if (parts.Length == 2)
{
ActivityModel.CodAnag = parts[0];
ActivityModel.Cliente = parts[1];
}
var match = Regex.Match(ActivityModel.Cliente!, @"^\s*(\S+)\s*-\s*(.*)$"); OnAfterChangeValue();
if (!match.Success) return Task.CompletedTask;
return; }
ActivityModel.CodAnag = match.Groups[1].Value; private async Task OnCommessaSelectedAfter()
ActivityModel.Cliente = match.Groups[2].Value; {
var com = SelectedComessa;
if (com != null)
{
ActivityModel.CodJcom = com.CodJcom;
ActivityModel.Commessa = com;
}
else
{
ActivityModel.CodJcom = null;
ActivityModel.Commessa = null;
}
await LoadCommesse();
OnAfterChangeValue(); OnAfterChangeValue();
} }
private async Task OnCommessaChanged() private async Task OnUserSelectedAfter()
{
ActivityModel.Commessa = (await ManageData.GetTable<JtbComt>(x => x.CodJcom.Equals(ActivityModel.CodJcom))).Last().Descrizione;
OnAfterChangeValue();
}
private async Task OnUserChanged()
{ {
ActivityModel.UserName = SelectedUser?.UserName;
await LoadActivityType(); await LoadActivityType();
OnAfterChangeValue(); OnAfterChangeValue();
} }
private async Task OnCommessaClear()
{
ActivityModel.Commessa = null;
ActivityModel.CodJcom = null;
StateHasChanged();
}
private async Task OnUserClear()
{
ActivityModel.UserName = null;
ActivityType = [];
StateHasChanged();
}
private void OnAfterChangeTimeBefore()
{
if (ActivityModel.EstimatedTime is not null)
{
ActivityModel.NotificationDate = ActivityModel.MinuteBefore switch
{
-1 => null,
0 => ActivityModel.EstimatedTime,
_ => ActivityModel.EstimatedTime.Value.AddMinutes(ActivityModel.MinuteBefore * -1)
};
}
OnAfterChangeValue();
}
private void OnAfterChangeValue() private void OnAfterChangeValue()
{ {
if (!IsNew) if (!IsNew)
{
LabelSave = !OriginalModel.Equals(ActivityModel) ? "Aggiorna" : null; LabelSave = !OriginalModel.Equals(ActivityModel) ? "Aggiorna" : null;
}
if (ActivityModel.EstimatedEndtime <= ActivityModel.EstimatedTime) if (ActivityModel.EstimatedTime is not null &&
(ActivityModel.EstimatedEndtime is null || ActivityModel.EstimatedEndtime <= ActivityModel.EstimatedTime))
{ {
ActivityModel.EstimatedEndtime = ActivityModel.EstimatedTime.Value.AddHours(1); ActivityModel.EstimatedEndtime = ActivityModel.EstimatedTime.Value.AddHours(1);
} }
StateHasChanged();
} }
private async Task OnAfterChangeEsito() private Task OnAfterChangeEsito()
{ {
OnAfterChangeValue(); OnAfterChangeValue();
return Task.CompletedTask;
// var result = await ConfirmMemo.ShowAsync();
// if (result is true)
// OpenAddMemo = !OpenAddMemo;
} }
private void OpenSelectEsito() private void OpenSelectEsito()
{ {
if (IsView) return;
if (!IsNew && (ActivityModel.UserName is null || !ActivityModel.UserName.Equals(UserSession.User.Username))) if (!IsNew && (ActivityModel.UserName is null || !ActivityModel.UserName.Equals(UserSession.User.Username)))
{ {
Snackbar.Add("Non puoi inserire un esito per un'attività che non ti è stata assegnata.", Severity.Info); Snackbar.Add("Non puoi inserire un esito per un'attività che non ti è stata assegnata.", Severity.Info);
@@ -529,16 +644,8 @@
var attached = (AttachedDTO)result.Data; var attached = (AttachedDTO)result.Data;
if (attached.Type == AttachedDTO.TypeAttached.Position) if (attached.Type == AttachedDTO.TypeAttached.Position)
{
CanAddPosition = false; CanAddPosition = false;
var resultNamePosition = await AddNamePosition.ShowAsync();
if (resultNamePosition is true)
attached.Description = NamePosition;
attached.Name = NamePosition!;
}
AttachedList ??= []; AttachedList ??= [];
AttachedList.Add(attached); AttachedList.Add(attached);

View File

@@ -4,10 +4,18 @@
@using salesbook.Shared.Components.Layout.Overlay @using salesbook.Shared.Components.Layout.Overlay
@inject IAttachedService AttachedService @inject IAttachedService AttachedService
<MudDialog Class="customDialog-form"> <MudDialog Class="customDialog-form disable-safe-area">
<DialogContent> <DialogContent>
<HeaderLayout ShowProfile="false" SmallHeader="true" Cancel="true" OnCancel="() => MudDialog.Cancel()" Title="Aggiungi allegati"/> <HeaderLayout ShowProfile="false" SmallHeader="true" Cancel="true" OnCancel="() => MudDialog.Cancel()" Title="Aggiungi allegati"/>
@if (RequireNewName)
{
<MudTextField @bind-Value="NewName" Class="px-3" Variant="Variant.Outlined"/>
}
else
{
@if (!SelectTypePicture)
{
<div style="margin-bottom: 1rem;" class="content attached"> <div style="margin-bottom: 1rem;" class="content attached">
<MudFab Size="Size.Small" Color="Color.Primary" <MudFab Size="Size.Small" Color="Color.Primary"
StartIcon="@Icons.Material.Rounded.Image" StartIcon="@Icons.Material.Rounded.Image"
@@ -24,7 +32,30 @@
Label="Posizione" OnClick="OnPosition"/> Label="Posizione" OnClick="OnPosition"/>
} }
</div> </div>
}
else
{
<div style="margin-bottom: 1rem;" class="content attached">
<MudFab Size="Size.Small" Color="Color.Primary"
StartIcon="@Icons.Material.Rounded.CameraAlt"
Label="Camera" OnClick="OnCamera"/>
<MudFab Size="Size.Small" Color="Color.Primary"
StartIcon="@Icons.Material.Rounded.Image"
Label="Galleria" OnClick="OnGallery"/>
</div>
}
}
</DialogContent> </DialogContent>
<DialogActions>
@if (RequireNewName)
{
<MudButton Disabled="NewName.IsNullOrEmpty()" Class="my-3" Size="Size.Small" Variant="Variant.Filled" Color="Color.Primary"
StartIcon="@Icons.Material.Rounded.Check" OnClick="OnNewName">
Salva
</MudButton>
}
</DialogActions>
</MudDialog> </MudDialog>
<SaveOverlay VisibleOverlay="VisibleOverlay" SuccessAnimation="SuccessAnimation"/> <SaveOverlay VisibleOverlay="VisibleOverlay" SuccessAnimation="SuccessAnimation"/>
@@ -40,34 +71,47 @@
private AttachedDTO? Attached { get; set; } private AttachedDTO? Attached { get; set; }
private bool RequireNewName { get; set; }
private bool SelectTypePicture { get; set; }
private string? _newName;
private string? NewName
{
get => _newName;
set
{
_newName = value;
StateHasChanged();
}
}
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
SelectTypePicture = false;
RequireNewName = false;
Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter; Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter;
_ = LoadData();
}
private async Task LoadData()
{
}
private async Task Save()
{
VisibleOverlay = true;
StateHasChanged();
SuccessAnimation = true;
StateHasChanged();
await Task.Delay(1250);
MudDialog.Close();
} }
private async Task OnImage() private async Task OnImage()
{ {
Attached = await AttachedService.SelectImage(); SelectTypePicture = true;
MudDialog.Close(Attached); StateHasChanged();
}
private async Task OnCamera()
{
Attached = await AttachedService.SelectImageFromCamera();
RequireNewName = true;
StateHasChanged();
}
private async Task OnGallery()
{
Attached = await AttachedService.SelectImageFromGallery();
RequireNewName = true;
StateHasChanged();
} }
private async Task OnFile() private async Task OnFile()
@@ -79,6 +123,37 @@
private async Task OnPosition() private async Task OnPosition()
{ {
Attached = await AttachedService.SelectPosition(); Attached = await AttachedService.SelectPosition();
RequireNewName = true;
StateHasChanged();
}
private void OnNewName()
{
switch (Attached.Type)
{
case AttachedDTO.TypeAttached.Position:
{
CanAddPosition = false;
Attached.Description = NewName!;
Attached.Name = NewName!;
break;
}
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);
} }

View File

@@ -1,7 +1,9 @@
.content.attached { .content.attached {
display: flex; display: flex;
flex-direction: column;
gap: 2rem; gap: 2rem;
padding: 1rem; padding: 1rem;
height: unset; height: unset;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
} }

View File

@@ -5,6 +5,8 @@
@using salesbook.Shared.Core.Entity @using salesbook.Shared.Core.Entity
@using salesbook.Shared.Components.SingleElements.BottomSheet @using salesbook.Shared.Components.SingleElements.BottomSheet
@using salesbook.Shared.Core.Dto.Contact @using salesbook.Shared.Core.Dto.Contact
@using salesbook.Shared.Core.Interface.IntegryApi
@using salesbook.Shared.Core.Interface.System.Network
@inject IManageDataService ManageData @inject IManageDataService ManageData
@inject INetworkService NetworkService @inject INetworkService NetworkService
@inject IIntegryApiService IntegryApiService @inject IIntegryApiService IntegryApiService
@@ -85,19 +87,18 @@
<div class="form-container"> <div class="form-container">
<span class="disable-full-width">Tipo cliente</span> <span class="disable-full-width">Tipo cliente</span>
@if (VtbTipi.IsNullOrEmpty()) <MudAutocomplete Disabled="VtbTipi.IsNullOrEmpty()" ReadOnly="IsView"
{ T="VtbTipi"
<span class="warning-text">Nessun tipo cliente trovato</span> @bind-Value="SelectedType"
} @bind-Value:after="OnTypeSelectedAfter"
else SearchFunc="SearchTypeAsync"
{ ToStringFunc="@(u => u == null ? string.Empty : $"{u.CodVtip} - {u.Descrizione}")"
<MudSelectExtended FullWidth="true" ReadOnly="@(IsView || VtbTipi.IsNullOrEmpty())" T="string?" Variant="Variant.Text" @bind-Value="ContactModel.CodVtip" @bind-Value:after="OnAfterChangeValue" Class="customIcon-select" AdornmentIcon="@Icons.Material.Filled.Code"> Clearable="true"
@foreach (var tipo in VtbTipi) ShowProgressIndicator="true"
{ DebounceInterval="300"
<MudSelectItemExtended Class="custom-item-select" Value="@tipo.CodVtip">@($"{tipo.CodVtip} - {tipo.Descrizione}")</MudSelectItemExtended> MaxItems="50"
} Class="customIcon-select"
</MudSelectExtended> AdornmentIcon="@Icons.Material.Filled.Code" />
}
</div> </div>
</div> </div>
@@ -240,14 +241,18 @@
<div class="form-container"> <div class="form-container">
<span class="disable-full-width">Agente</span> <span class="disable-full-width">Agente</span>
<MudSelectExtended FullWidth="true" T="string?" Variant="Variant.Text" NoWrap="true" <MudAutocomplete Disabled="Users.IsNullOrEmpty()" ReadOnly="IsView"
@bind-Value="ContactModel.CodVage" @bind-Value:after="OnAfterChangeValue" T="StbUser"
Class="customIcon-select" AdornmentIcon="@Icons.Material.Filled.Code"> @bind-Value="SelectedUser"
@foreach (var user in Users) @bind-Value:after="OnUserSelectedAfter"
{ SearchFunc="SearchUtentiAsync"
<MudSelectItemExtended Class="custom-item-select" Value="@user.UserCode">@($"{user.UserCode} - {user.FullName}")</MudSelectItemExtended> ToStringFunc="@(u => u == null ? string.Empty : u.FullName)"
} Clearable="true"
</MudSelectExtended> ShowProgressIndicator="true"
DebounceInterval="300"
MaxItems="50"
Class="customIcon-select"
AdornmentIcon="@Icons.Material.Filled.Code" />
</div> </div>
</div> </div>
@@ -266,9 +271,9 @@
</div> </div>
} }
<div class="container-button">
@if (IsNew) @if (IsNew)
{ {
<div class="container-button">
<MudButton Class="button-settings gray-icon" <MudButton Class="button-settings gray-icon"
FullWidth="true" FullWidth="true"
StartIcon="@Icons.Material.Filled.PersonAddAlt1" StartIcon="@Icons.Material.Filled.PersonAddAlt1"
@@ -277,11 +282,13 @@
Variant="Variant.Outlined"> Variant="Variant.Outlined">
Persona di riferimento Persona di riferimento
</MudButton> </MudButton>
</div>
} }
else else
{ {
@if (NetworkService.ConnectionAvailable && !ContactModel.IsContact) @if (NetworkService.ConnectionAvailable && !ContactModel.IsContact)
{ {
<div class="container-button">
<MudButton Class="button-settings blue-icon" <MudButton Class="button-settings blue-icon"
FullWidth="true" FullWidth="true"
StartIcon="@Icons.Material.Rounded.Sync" StartIcon="@Icons.Material.Rounded.Sync"
@@ -290,9 +297,9 @@
Variant="Variant.Outlined"> Variant="Variant.Outlined">
Converti in cliente Converti in cliente
</MudButton> </MudButton>
}
}
</div> </div>
}
}
</div> </div>
<MudMessageBox MarkupMessage="new MarkupString(VatMessage)" @ref="CheckVat" Class="c-messageBox" Title="Verifica partita iva" CancelText="@(VatAlreadyRegistered ? "" : "Annulla")"> <MudMessageBox MarkupMessage="new MarkupString(VatMessage)" @ref="CheckVat" Class="c-messageBox" Title="Verifica partita iva" CancelText="@(VatAlreadyRegistered ? "" : "Annulla")">
@@ -349,11 +356,17 @@
private bool OpenSearchAddress { get; set; } private bool OpenSearchAddress { get; set; }
private IndirizzoDTO Address { get; set; } private IndirizzoDTO Address { get; set; }
//Agente
private StbUser? SelectedUser { get; set; }
//Type
private VtbTipi? SelectedType { get; set; }
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter; Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter;
await LoadData(); _ = LoadData();
LabelSave = IsNew ? "Aggiungi" : null; LabelSave = IsNew ? "Aggiungi" : null;
} }
@@ -401,7 +414,9 @@
MudDialog.Close(response); MudDialog.Close(response);
} }
private async Task LoadData() private Task LoadData()
{
return Task.Run(async () =>
{ {
if (IsNew) if (IsNew)
{ {
@@ -419,6 +434,7 @@
Users = await ManageData.GetTable<StbUser>(x => x.KeyGroup == 5); Users = await ManageData.GetTable<StbUser>(x => x.KeyGroup == 5);
Nazioni = await ManageData.GetTable<Nazioni>(); Nazioni = await ManageData.GetTable<Nazioni>();
VtbTipi = await ManageData.GetTable<VtbTipi>(); VtbTipi = await ManageData.GetTable<VtbTipi>();
});
} }
private void OnAfterChangeValue() private void OnAfterChangeValue()
@@ -560,9 +576,83 @@
private async Task ConvertProspectToContact() private async Task ConvertProspectToContact()
{ {
await IntegryApiService.TransferProspect(new CRMTransferProspectRequestDTO VisibleOverlay = true;
StateHasChanged();
var response = await IntegryApiService.TransferProspect(new CRMTransferProspectRequestDTO
{ {
CodPpro = ContactModel.CodContact CodPpro = ContactModel.CodContact
}); });
await ManageData.DeleteProspect(ContactModel.CodContact);
if (response.AnagClie != null)
await ManageData.InsertOrUpdate(response.AnagClie);
if (response.VtbCliePersRif != null)
await ManageData.InsertOrUpdate(response.VtbCliePersRif);
if (response.VtbDest != null)
await ManageData.InsertOrUpdate(response.VtbDest);
SuccessAnimation = true;
StateHasChanged();
await Task.Delay(1250);
MudDialog.Close(response.AnagClie);
}
private async Task OnUserSelectedAfter()
{
ContactModel.CodVage = SelectedUser?.UserCode;
OnAfterChangeValue();
}
private Task<IEnumerable<StbUser>> SearchUtentiAsync(string value, CancellationToken token)
{
IEnumerable<StbUser> list;
if (string.IsNullOrWhiteSpace(value))
{
list = Users.OrderBy(u => u.FullName).Take(50);
}
else
{
list = Users
.Where(x => x.UserName.Contains(value, StringComparison.OrdinalIgnoreCase)
|| x.FullName.Contains(value, StringComparison.OrdinalIgnoreCase))
.OrderBy(u => u.FullName)
.Take(50);
}
return Task.FromResult(token.IsCancellationRequested ? [] : list);
}
private async Task OnTypeSelectedAfter()
{
ContactModel.CodVtip = SelectedType?.CodVtip;
OnAfterChangeValue();
}
private Task<IEnumerable<VtbTipi>> SearchTypeAsync(string value, CancellationToken token)
{
IEnumerable<VtbTipi> list = [];
if (VtbTipi == null) return Task.FromResult(token.IsCancellationRequested ? [] : list);
if (string.IsNullOrWhiteSpace(value))
{
list = VtbTipi.OrderBy(u => u.CodVtip);
}
else
{
list = VtbTipi
.Where(x => x.CodVtip.Contains(value, StringComparison.OrdinalIgnoreCase)
|| x.Descrizione.Contains(value, StringComparison.OrdinalIgnoreCase))
.OrderBy(u => u.CodVtip)
.Take(50);
}
return Task.FromResult(token.IsCancellationRequested ? [] : list);
} }
} }

View File

@@ -2,6 +2,8 @@
@using salesbook.Shared.Components.Layout @using salesbook.Shared.Components.Layout
@using salesbook.Shared.Core.Interface @using salesbook.Shared.Core.Interface
@using salesbook.Shared.Components.Layout.Overlay @using salesbook.Shared.Components.Layout.Overlay
@using salesbook.Shared.Core.Interface.IntegryApi
@using salesbook.Shared.Core.Interface.System.Network
@inject IManageDataService ManageData @inject IManageDataService ManageData
@inject INetworkService NetworkService @inject INetworkService NetworkService
@inject IIntegryApiService IntegryApiService @inject IIntegryApiService IntegryApiService

View File

@@ -1,15 +1,21 @@
using salesbook.Shared.Core.Entity; using System.Text.Json.Serialization;
using salesbook.Shared.Core.Entity;
using salesbook.Shared.Core.Helpers.Enum; using salesbook.Shared.Core.Helpers.Enum;
namespace salesbook.Shared.Core.Dto.Activity; namespace salesbook.Shared.Core.Dto.Activity;
public class ActivityDTO : StbActivity public class ActivityDTO : StbActivity
{ {
public string? Commessa { get; set; } public JtbComt? Commessa { get; set; }
public string? Cliente { get; set; } public string? Cliente { get; set; }
public ActivityCategoryEnum Category { get; set; } public ActivityCategoryEnum Category { get; set; }
public bool Complete { get; set; } public bool Complete { get; set; }
//Notification
public int MinuteBefore { get; set; } = -1;
[JsonPropertyName("notificationDate")]
public DateTime? NotificationDate { get; set; }
public bool Deleted { get; set; } public bool Deleted { get; set; }
public PositionDTO? Position { get; set; } public PositionDTO? Position { get; set; }
@@ -23,6 +29,9 @@ public class ActivityDTO : StbActivity
{ {
return Commessa == other.Commessa && return Commessa == other.Commessa &&
Cliente == other.Cliente && Cliente == other.Cliente &&
Position == other.Position &&
MinuteBefore == other.MinuteBefore &&
NotificationDate == other.NotificationDate &&
Category == other.Category && Category == other.Category &&
Complete == other.Complete && ActivityId == other.ActivityId && ActivityResultId == other.ActivityResultId && ActivityTypeId == other.ActivityTypeId && DataInsAct.Equals(other.DataInsAct) && ActivityDescription == other.ActivityDescription && ParentActivityId == other.ParentActivityId && TipoAnag == other.TipoAnag && CodAnag == other.CodAnag && CodJcom == other.CodJcom && CodJfas == other.CodJfas && Nullable.Equals(EstimatedDate, other.EstimatedDate) && Nullable.Equals(EstimatedTime, other.EstimatedTime) && Nullable.Equals(AlarmDate, other.AlarmDate) && Nullable.Equals(AlarmTime, other.AlarmTime) && Nullable.Equals(EffectiveDate, other.EffectiveDate) && Nullable.Equals(EffectiveTime, other.EffectiveTime) && ResultDescription == other.ResultDescription && Nullable.Equals(EstimatedEnddate, other.EstimatedEnddate) && Nullable.Equals(EstimatedEndtime, other.EstimatedEndtime) && Nullable.Equals(EffectiveEnddate, other.EffectiveEnddate) && Nullable.Equals(EffectiveEndtime, other.EffectiveEndtime) && UserCreator == other.UserCreator && UserName == other.UserName && Nullable.Equals(PercComp, other.PercComp) && Nullable.Equals(EstimatedHours, other.EstimatedHours) && CodMart == other.CodMart && PartitaMag == other.PartitaMag && Matricola == other.Matricola && Priorita == other.Priorita && Nullable.Equals(ActivityPlayCounter, other.ActivityPlayCounter) && ActivityEvent == other.ActivityEvent && Guarantee == other.Guarantee && Note == other.Note && Rfid == other.Rfid && IdLotto == other.IdLotto && PersonaRif == other.PersonaRif && HrNum == other.HrNum && Gestione == other.Gestione && Nullable.Equals(DataOrd, other.DataOrd) && NumOrd == other.NumOrd && IdStep == other.IdStep && IdRiga == other.IdRiga && Nullable.Equals(OraInsAct, other.OraInsAct) && IndiceGradimento == other.IndiceGradimento && NoteGradimento == other.NoteGradimento && FlagRisolto == other.FlagRisolto && FlagTipologia == other.FlagTipologia && OreRapportino == other.OreRapportino && UserModifier == other.UserModifier && Nullable.Equals(OraModAct, other.OraModAct) && Nullable.Equals(OraViewAct, other.OraViewAct) && CodVdes == other.CodVdes && CodCmac == other.CodCmac && WrikeId == other.WrikeId && CodMgrp == other.CodMgrp && PlanId == other.PlanId; Complete == other.Complete && ActivityId == other.ActivityId && ActivityResultId == other.ActivityResultId && ActivityTypeId == other.ActivityTypeId && DataInsAct.Equals(other.DataInsAct) && ActivityDescription == other.ActivityDescription && ParentActivityId == other.ParentActivityId && TipoAnag == other.TipoAnag && CodAnag == other.CodAnag && CodJcom == other.CodJcom && CodJfas == other.CodJfas && Nullable.Equals(EstimatedDate, other.EstimatedDate) && Nullable.Equals(EstimatedTime, other.EstimatedTime) && Nullable.Equals(AlarmDate, other.AlarmDate) && Nullable.Equals(AlarmTime, other.AlarmTime) && Nullable.Equals(EffectiveDate, other.EffectiveDate) && Nullable.Equals(EffectiveTime, other.EffectiveTime) && ResultDescription == other.ResultDescription && Nullable.Equals(EstimatedEnddate, other.EstimatedEnddate) && Nullable.Equals(EstimatedEndtime, other.EstimatedEndtime) && Nullable.Equals(EffectiveEnddate, other.EffectiveEnddate) && Nullable.Equals(EffectiveEndtime, other.EffectiveEndtime) && UserCreator == other.UserCreator && UserName == other.UserName && Nullable.Equals(PercComp, other.PercComp) && Nullable.Equals(EstimatedHours, other.EstimatedHours) && CodMart == other.CodMart && PartitaMag == other.PartitaMag && Matricola == other.Matricola && Priorita == other.Priorita && Nullable.Equals(ActivityPlayCounter, other.ActivityPlayCounter) && ActivityEvent == other.ActivityEvent && Guarantee == other.Guarantee && Note == other.Note && Rfid == other.Rfid && IdLotto == other.IdLotto && PersonaRif == other.PersonaRif && HrNum == other.HrNum && Gestione == other.Gestione && Nullable.Equals(DataOrd, other.DataOrd) && NumOrd == other.NumOrd && IdStep == other.IdStep && IdRiga == other.IdRiga && Nullable.Equals(OraInsAct, other.OraInsAct) && IndiceGradimento == other.IndiceGradimento && NoteGradimento == other.NoteGradimento && FlagRisolto == other.FlagRisolto && FlagTipologia == other.FlagTipologia && OreRapportino == other.OreRapportino && UserModifier == other.UserModifier && Nullable.Equals(OraModAct, other.OraModAct) && Nullable.Equals(OraViewAct, other.OraViewAct) && CodVdes == other.CodVdes && CodCmac == other.CodCmac && WrikeId == other.WrikeId && CodMgrp == other.CodMgrp && PlanId == other.PlanId;
} }
@@ -97,6 +106,9 @@ public class ActivityDTO : StbActivity
hashCode.Add(Cliente); hashCode.Add(Cliente);
hashCode.Add(Category); hashCode.Add(Category);
hashCode.Add(Complete); hashCode.Add(Complete);
hashCode.Add(Position);
hashCode.Add(MinuteBefore);
hashCode.Add(NotificationDate);
return hashCode.ToHashCode(); return hashCode.ToHashCode();
} }
} }

View File

@@ -7,4 +7,10 @@ public class CRMTransferProspectResponseDTO
{ {
[JsonPropertyName("anagClie")] [JsonPropertyName("anagClie")]
public AnagClie? AnagClie { get; set; } public AnagClie? AnagClie { get; set; }
[JsonPropertyName("vtbDest")]
public List<VtbDest>? VtbDest { get; set; }
[JsonPropertyName("vtbCliePersRif")]
public List<VtbCliePersRif>? VtbCliePersRif { get; set; }
} }

View File

@@ -0,0 +1,15 @@
using System.Text.Json.Serialization;
namespace salesbook.Shared.Core.Dto;
public class NotificationDataDTO
{
[JsonPropertyName("notificationId")]
public string? NotificationId { get; set; }
[JsonPropertyName("activityId")]
public string? ActivityId { get; set; }
[JsonPropertyName("type")]
public string? Type { get; set; }
}

View File

@@ -0,0 +1,12 @@
using salesbook.Shared.Core.Entity;
namespace salesbook.Shared.Core.Dto.PageState;
public class NotificationState
{
public List<WtbNotification> ReceivedNotifications { get; set; } = [];
public List<WtbNotification> UnreadNotifications { get; set; } = [];
public List<WtbNotification> NotificationsRead { get; set; } = [];
public int Count => ReceivedNotifications.Count() + UnreadNotifications.Count();
}

View File

@@ -7,6 +7,8 @@ public class UserListState
public List<UserDisplayItem>? GroupedUserList { get; set; } public List<UserDisplayItem>? GroupedUserList { get; set; }
public List<UserDisplayItem>? FilteredGroupedUserList { get; set; } public List<UserDisplayItem>? FilteredGroupedUserList { get; set; }
public List<ContactDTO>? AllUsers { get; set; }
public bool IsLoaded { get; set; } public bool IsLoaded { get; set; }
public bool IsLoading { get; set; } public bool IsLoading { get; set; }

View File

@@ -14,4 +14,6 @@ public class UserPageState
public StbUser? Agente { get; set; } public StbUser? Agente { get; set; }
public Dictionary<string, List<CRMJobStepDTO>?> Steps { get; set; } public Dictionary<string, List<CRMJobStepDTO>?> Steps { get; set; }
public List<ActivityDTO> Activitys { get; set; } public List<ActivityDTO> Activitys { get; set; }
public int ActiveTab { get; set; }
} }

View File

@@ -0,0 +1,15 @@
using System.Text.Json.Serialization;
namespace salesbook.Shared.Core.Dto;
public class ReadNotificationRequestDTO
{
[JsonPropertyName("deviceToken")]
public string DeviceToken { get; set; }
[JsonPropertyName("username")]
public string Username { get; set; }
[JsonPropertyName("notificationId")]
public long NotificationId { get; set; }
}

View File

@@ -0,0 +1,15 @@
using System.Text.Json.Serialization;
namespace salesbook.Shared.Core.Entity;
public class WtbDeviceNotification
{
[JsonPropertyName("userDeviceId")]
public long? UserDeviceId { get; set; }
[JsonPropertyName("notificationId")]
public long? NotificationId { get; set; }
[JsonPropertyName("readDate")]
public DateTime? ReadDate { get; set; }
}

View File

@@ -0,0 +1,37 @@
using System.Text.Json.Serialization;
using salesbook.Shared.Core.Dto;
namespace salesbook.Shared.Core.Entity;
public class WtbNotification
{
[JsonPropertyName("id")]
public long Id { get; set; }
[JsonPropertyName("title")]
public string? Title { get; set; }
[JsonPropertyName("body")]
public string? Body { get; set; }
[JsonPropertyName("imageUrl")]
public string? ImageUrl { get; set; }
[JsonPropertyName("notificationData")]
public NotificationDataDTO? NotificationData { get; set; }
[JsonPropertyName("startDate")]
public DateTime? StartDate { get; set; }
[JsonPropertyName("endDate")]
public DateTime? EndDate { get; set; }
[JsonPropertyName("persistent")]
public bool? Persistent { get; set; }
[JsonPropertyName("topics")]
public List<string>? Topics { get; set; }
[JsonPropertyName("wtbDeviceNotifications")]
public List<WtbDeviceNotification>? WtbDeviceNotifications { get; set; }
}

View File

@@ -80,7 +80,8 @@ public class ModalHelpers
{ {
FullScreen = false, FullScreen = false,
CloseButton = false, CloseButton = false,
NoHeader = true NoHeader = true,
BackdropClick = false
} }
); );

View File

@@ -4,7 +4,8 @@ namespace salesbook.Shared.Core.Interface;
public interface IAttachedService public interface IAttachedService
{ {
Task<AttachedDTO?> SelectImage(); Task<AttachedDTO?> SelectImageFromCamera();
Task<AttachedDTO?> SelectImageFromGallery();
Task<AttachedDTO?> SelectFile(); Task<AttachedDTO?> SelectFile();
Task<AttachedDTO?> SelectPosition(); Task<AttachedDTO?> SelectPosition();
Task OpenFile(Stream file, string fileName); Task OpenFile(Stream file, string fileName);

View File

@@ -0,0 +1,6 @@
namespace salesbook.Shared.Core.Interface;
public interface IFirebaseNotificationService
{
Task InitFirebase();
}

View File

@@ -12,16 +12,20 @@ public interface IManageDataService
Task<List<AnagClie>> GetClienti(WhereCondContact? whereCond = null); Task<List<AnagClie>> GetClienti(WhereCondContact? whereCond = null);
Task<List<PtbPros>> GetProspect(WhereCondContact? whereCond = null); Task<List<PtbPros>> GetProspect(WhereCondContact? whereCond = null);
Task<List<ContactDTO>> GetContact(WhereCondContact whereCond); Task<List<ContactDTO>> GetContact(WhereCondContact whereCond, DateTime? lastSync = null);
Task<ContactDTO?> GetSpecificContact(string codAnag, bool IsContact); Task<ContactDTO?> GetSpecificContact(string codAnag, bool IsContact);
Task<List<ActivityDTO>> GetActivityTryLocalDb(WhereCondActivity whereCond);
Task<List<ActivityDTO>> GetActivity(WhereCondActivity whereCond, bool useLocalDb = false); Task<List<ActivityDTO>> GetActivity(WhereCondActivity whereCond, bool useLocalDb = false);
Task InsertOrUpdate<T>(T objectToSave); Task InsertOrUpdate<T>(T objectToSave);
Task InsertOrUpdate<T>(List<T> listToSave); Task InsertOrUpdate<T>(List<T> listToSave);
Task DeleteProspect(string codPpro);
Task Delete<T>(T objectToDelete); Task Delete<T>(T objectToDelete);
Task DeleteActivity(ActivityDTO activity); Task DeleteActivity(ActivityDTO activity);
Task<List<ActivityDTO>> MapActivity(List<StbActivity>? activities);
Task ClearDb(); Task ClearDb();
} }

View File

@@ -0,0 +1,7 @@
namespace salesbook.Shared.Core.Interface;
public interface INotificationService
{
Task LoadNotification();
void OrderNotificationList();
}

View File

@@ -4,7 +4,7 @@ using salesbook.Shared.Core.Dto.Contact;
using salesbook.Shared.Core.Dto.JobProgress; using salesbook.Shared.Core.Dto.JobProgress;
using salesbook.Shared.Core.Entity; using salesbook.Shared.Core.Entity;
namespace salesbook.Shared.Core.Interface; namespace salesbook.Shared.Core.Interface.IntegryApi;
public interface IIntegryApiService public interface IIntegryApiService
{ {

View File

@@ -0,0 +1,11 @@
using salesbook.Shared.Core.Entity;
namespace salesbook.Shared.Core.Interface.IntegryApi;
public interface IIntegryNotificationRestClient
{
Task<List<WtbNotification>?> Get();
Task<WtbNotification> MarkAsRead(long id);
Task Delete(long id);
Task DeleteAll();
}

View File

@@ -0,0 +1,8 @@
using Microsoft.Extensions.Logging;
namespace salesbook.Shared.Core.Interface.IntegryApi;
public interface IIntegryRegisterNotificationRestClient
{
Task Register(string fcmToken, ILogger? logger1 = null);
}

View File

@@ -0,0 +1,8 @@
namespace salesbook.Shared.Core.Interface.System.Battery;
public interface IBatteryOptimizationManagerService
{
bool IsBatteryOptimizationEnabled();
void OpenBatteryOptimizationSettings(Action<bool> onCompleted);
}

View File

@@ -1,4 +1,4 @@
namespace salesbook.Shared.Core.Interface; namespace salesbook.Shared.Core.Interface.System.Network;
public interface INetworkService public interface INetworkService
{ {

View File

@@ -0,0 +1,6 @@
namespace salesbook.Shared.Core.Interface.System.Notification;
public interface IShinyNotificationManager
{
Task RequestAccess();
}

View File

@@ -0,0 +1,5 @@
using CommunityToolkit.Mvvm.Messaging.Messages;
namespace salesbook.Shared.Core.Messages.Notification.Loaded;
public class NotificationsLoadedMessage(object? value = null) : ValueChangedMessage<object?>(value);

View File

@@ -0,0 +1,13 @@
using CommunityToolkit.Mvvm.Messaging;
namespace salesbook.Shared.Core.Messages.Notification.Loaded;
public class NotificationsLoadedService
{
public event Action? OnNotificationsLoaded;
public NotificationsLoadedService(IMessenger messenger)
{
messenger.Register<NotificationsLoadedMessage>(this, (_, _) => { OnNotificationsLoaded?.Invoke(); });
}
}

View File

@@ -0,0 +1,6 @@
using CommunityToolkit.Mvvm.Messaging.Messages;
using salesbook.Shared.Core.Entity;
namespace salesbook.Shared.Core.Messages.Notification.NewPush;
public class NewPushNotificationMessage(WtbNotification value) : ValueChangedMessage<WtbNotification>(value);

View File

@@ -0,0 +1,14 @@
using CommunityToolkit.Mvvm.Messaging;
using salesbook.Shared.Core.Entity;
namespace salesbook.Shared.Core.Messages.Notification.NewPush;
public class NewPushNotificationService
{
public event Action<WtbNotification>? OnNotificationReceived;
public NewPushNotificationService(IMessenger messenger)
{
messenger.Register<NewPushNotificationMessage>(this, (_, o) => { OnNotificationReceived?.Invoke(o.Value); });
}
}

View File

@@ -7,6 +7,7 @@ using salesbook.Shared.Core.Entity;
using salesbook.Shared.Core.Interface; using salesbook.Shared.Core.Interface;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using salesbook.Shared.Core.Dto.Contact; using salesbook.Shared.Core.Dto.Contact;
using salesbook.Shared.Core.Interface.IntegryApi;
namespace salesbook.Shared.Core.Services; namespace salesbook.Shared.Core.Services;

View File

@@ -0,0 +1,33 @@
using IntegryApiClient.Core.Domain.Abstraction.Contracts.Account;
using IntegryApiClient.Core.Domain.RestClient.Contacts;
using salesbook.Shared.Core.Dto;
using salesbook.Shared.Core.Entity;
using salesbook.Shared.Core.Interface.IntegryApi;
namespace salesbook.Shared.Core.Services;
public class IntegryNotificationRestClient(
IUserSession userSession,
IIntegryApiRestClient integryApiRestClient) : IIntegryNotificationRestClient
{
public Task<List<WtbNotification>?> Get()
{
var queryParams = new Dictionary<string, object>
{
{ "mode", "ENABLED" },
{ "forUser", userSession.User.Username }
};
return integryApiRestClient.Get<List<WtbNotification>>("notification", queryParams);
}
public Task<WtbNotification> MarkAsRead(long id) =>
integryApiRestClient.Post<WtbNotification>("notification/read",
new ReadNotificationRequestDTO { NotificationId = id, Username = userSession.User.Username })!;
public Task Delete(long id) =>
integryApiRestClient.Delete<object>($"notification/{id}", null);
public Task DeleteAll() =>
integryApiRestClient.Delete<object>($"notification/all/{userSession.User.Username}", null);
}

View File

@@ -0,0 +1,47 @@
using salesbook.Shared.Core.Dto.PageState;
using salesbook.Shared.Core.Interface;
using salesbook.Shared.Core.Interface.IntegryApi;
namespace salesbook.Shared.Core.Services;
public class NotificationService(
IIntegryNotificationRestClient integryNotificationRestClient,
NotificationState Notification
) : INotificationService
{
public async Task LoadNotification()
{
var allNotifications = await integryNotificationRestClient.Get();
if (allNotifications == null) return;
var allIds = allNotifications.Select(n => n.Id).ToHashSet();
Notification.ReceivedNotifications = Notification.ReceivedNotifications
.Where(r => !allIds.Contains(r.Id))
.ToList();
Notification.UnreadNotifications = allNotifications
.Where(x =>
x.WtbDeviceNotifications == null ||
x.WtbDeviceNotifications.Any(y => y.ReadDate == null))
.ToList();
Notification.NotificationsRead = allNotifications
.Where(x =>
x.WtbDeviceNotifications != null &&
x.WtbDeviceNotifications.All(y => y.ReadDate != null))
.ToList();
}
public void OrderNotificationList()
{
Notification.ReceivedNotifications = Notification.ReceivedNotifications
.OrderByDescending(x => x.StartDate).ToList();
Notification.UnreadNotifications = Notification.UnreadNotifications
.OrderByDescending(x => x.StartDate).ToList();
Notification.NotificationsRead = Notification.NotificationsRead
.OrderByDescending(x => x.StartDate).ToList();
}
}

View File

@@ -25,6 +25,7 @@ public class PreloadService(IManageDataService manageData, UserListState userSta
userState.GroupedUserList = BuildGroupedList(sorted); userState.GroupedUserList = BuildGroupedList(sorted);
userState.FilteredGroupedUserList = userState.GroupedUserList; userState.FilteredGroupedUserList = userState.GroupedUserList;
userState.AllUsers = users;
userState.NotifyUsersLoaded(); userState.NotifyUsersLoaded();
} }

View File

@@ -4,8 +4,10 @@ namespace salesbook.Shared.Core.Utility;
public static class UtilityString public static class UtilityString
{ {
public static string ExtractInitials(string fullname) public static string ExtractInitials(string? fullname)
{ {
if (fullname == null) return "";
return string.Concat(fullname return string.Concat(fullname
.Split(' ', StringSplitOptions.RemoveEmptyEntries) .Split(' ', StringSplitOptions.RemoveEmptyEntries)
.Take(3) .Take(3)

View File

@@ -24,13 +24,13 @@
<PackageReference Include="AutoMapper" Version="14.0.0" /> <PackageReference Include="AutoMapper" Version="14.0.0" />
<PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="8.2.2" /> <PackageReference Include="CodeBeam.MudBlazor.Extensions" Version="8.2.2" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" /> <PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
<PackageReference Include="IntegryApiClient.Core" Version="1.1.6" /> <PackageReference Include="IntegryApiClient.Core" Version="1.2.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="9.0.6" /> <PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="9.0.9" />
<PackageReference Include="Microsoft.Maui.Essentials" Version="9.0.81" /> <PackageReference Include="Microsoft.Maui.Essentials" Version="9.0.110" />
<PackageReference Include="sqlite-net-pcl" Version="1.9.172" /> <PackageReference Include="sqlite-net-pcl" Version="1.9.172" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.12.1" /> <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.14.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="9.0.6" /> <PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="9.0.9" />
<PackageReference Include="MudBlazor" Version="8.6.0" /> <PackageReference Include="MudBlazor" Version="8.12.0" />
<PackageReference Include="MudBlazor.ThemeManager" Version="3.0.0" /> <PackageReference Include="MudBlazor.ThemeManager" Version="3.0.0" />
</ItemGroup> </ItemGroup>

View File

@@ -1,6 +1,6 @@
html { overflow: hidden; } html { overflow: hidden; }
.page, article, main { height: 100% !important; } .page, article, main { height: 100% !important; overflow: hidden; }
#app { height: 100vh; } #app { height: 100vh; }
@@ -22,6 +22,11 @@ a, .btn-link {
color: inherit; color: inherit;
} }
article {
display: flex;
flex-direction: column;
}
/*ServicesIsDown" : "SystemOk" : "NetworkKo*/ /*ServicesIsDown" : "SystemOk" : "NetworkKo*/
.Connection { .Connection {
@@ -53,7 +58,7 @@ a, .btn-link {
transform: translateY(0); transform: translateY(0);
} }
.page > .Connection.Hide ~ main { .Connection.Hide ~ .page {
transition: all 0.5s ease; transition: all 0.5s ease;
transform: translateY(-35px); transform: translateY(-35px);
} }
@@ -263,8 +268,7 @@ h1:focus { outline: none; }
#app { #app {
margin-top: env(safe-area-inset-top); margin-top: env(safe-area-inset-top);
margin-bottom: env(safe-area-inset-bottom); height: calc(100vh - env(safe-area-inset-top));
height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
} }
.flex-column, .navbar-brand { padding-left: env(safe-area-inset-left); } .flex-column, .navbar-brand { padding-left: env(safe-area-inset-left); }

View File

@@ -5,7 +5,9 @@
/*Utility*/ /*Utility*/
--exception-box-shadow: 1px 2px 5px rgba(0, 0, 0, 0.3); --exception-box-shadow: 1px 2px 5px rgba(0, 0, 0, 0.3);
--custom-box-shadow: 1px 2px 5px var(--gray-for-shadow); --custom-box-shadow: 1px 2px 5px var(--gray-for-shadow);
--mud-default-borderradius: 12px !important; --mud-default-borderradius: 20px !important;
--m-page-x: 1rem; --m-page-x: 1rem;
--mh-header: 4rem; --mh-header: 4rem;
--light-card-background: hsl(from var(--mud-palette-background-gray) h s 97%);
} }

View File

@@ -5,6 +5,10 @@
margin-bottom: 1rem; margin-bottom: 1rem;
} }
.customDialog-form.disable-safe-area .mud-dialog-content { margin-top: unset !important; }
.customDialog-form.disable-safe-area .content { height: 100% !important; }
.customDialog-form .content { .customDialog-form .content {
height: calc(100vh - (.6rem + 40px)); height: calc(100vh - (.6rem + 40px));
overflow: auto; overflow: auto;
@@ -12,6 +16,14 @@
scrollbar-width: none; scrollbar-width: none;
} }
@supports (-webkit-touch-callout: none) {
.customDialog-form .content { height: calc(100vh - (.6rem + 40px) - env(safe-area-inset-top)) !important; }
.customDialog-form.disable-safe-area .content { height: 100% !important; }
.customDialog-form.disable-safe-area .mud-dialog-content { margin-top: unset !important; }
}
.customDialog-form .header { padding: 0 !important; } .customDialog-form .header { padding: 0 !important; }
.customDialog-form .content::-webkit-scrollbar { display: none; } .customDialog-form .content::-webkit-scrollbar { display: none; }
@@ -31,6 +43,8 @@
padding: .4rem 1rem !important; padding: .4rem 1rem !important;
} }
.input-card.clearButton.custom-border-bottom { border-bottom: .1rem solid var(--card-border-color); }
.input-card > .divider { margin: 0 !important; } .input-card > .divider { margin: 0 !important; }
.form-container { .form-container {
@@ -92,7 +106,7 @@
.container-button { .container-button {
width: 100%; width: 100%;
box-shadow: var(--custom-box-shadow); background: var(--light-card-background);
padding: .5rem 0; padding: .5rem 0;
border-radius: 12px; border-radius: 12px;
margin-bottom: 2rem; margin-bottom: 2rem;

View File

@@ -0,0 +1,172 @@
const FIRST_THRESHOLD = 80;
const SECOND_THRESHOLD = 160;
const CLOSE_THRESHOLD = 40;
const MAX_SWIPE = 200;
let dotnetHelper;
window.initNotifications = (dotnetRef) => {
dotnetHelper = dotnetRef;
document.querySelectorAll('.row').forEach(initRow);
};
function initRow(row) {
const card = row.querySelector('.notification-card');
const btnTrash = row.querySelector('.trash-btn');
const btnRead = row.querySelector('.read-btn');
const behindRight = row.querySelector('.behind-right'); // cestino
const behindLeft = row.querySelector('.behind-left'); // mark as read
let startX = 0, currentX = 0, dragging = false;
let open = null; // "left", "right" oppure null
// inizializza nascosti
behindRight.style.visibility = "hidden";
behindLeft.style.visibility = "hidden";
// funzione di utilità → controlla se c'è unread-dot
function canMarkAsRead() {
return row.querySelector('.unread-dot') !== null;
}
card.addEventListener('pointerdown', (e) => {
if (e.pointerType === 'mouse' && e.button !== 0) return;
dragging = true;
startX = e.clientX;
card.setPointerCapture(e.pointerId);
card.style.transition = 'none';
});
card.addEventListener('pointermove', (e) => {
if (!dragging) return;
const dx = e.clientX - startX;
if (dx > 0 && !canMarkAsRead() && !open) {
currentX = 0;
return; // niente movimento
}
let translate = dx;
if (!open) {
translate = Math.max(-MAX_SWIPE, Math.min(MAX_SWIPE, dx));
} else if (open === "left") {
translate = Math.min(MAX_SWIPE, FIRST_THRESHOLD + dx);
} else if (open === "right") {
translate = Math.max(-MAX_SWIPE, -FIRST_THRESHOLD + dx);
}
currentX = translate;
card.style.transform = `translateX(${translate}px)`;
// mostra/nascondi i behind in tempo reale
if (currentX < 0) {
behindRight.style.visibility = "visible"; // cestino
behindLeft.style.visibility = "hidden";
} else if (currentX > 0) {
behindLeft.style.visibility = "visible"; // mark as read
behindRight.style.visibility = "hidden";
} else {
behindLeft.style.visibility = "hidden";
behindRight.style.visibility = "hidden";
}
});
function endDrag() {
if (!dragging) return;
dragging = false;
card.style.transition = 'transform .2s ease';
// blocca swipe destro se non consentito
if (currentX > 0 && !canMarkAsRead() && !open) {
card.style.transform = 'translateX(0)';
currentX = 0;
open = null;
behindRight.style.visibility = "hidden";
behindLeft.style.visibility = "hidden";
return;
}
// Swipe a sinistra → elimina
if (!open && currentX < 0) {
if (currentX < -SECOND_THRESHOLD) {
card.style.transform = `translateX(-${MAX_SWIPE}px)`;
setTimeout(() => removeRow(row), 200);
} else if (currentX < -FIRST_THRESHOLD) {
card.style.transform = `translateX(-${FIRST_THRESHOLD}px)`;
open = "right";
} else {
card.style.transform = 'translateX(0)';
open = null;
behindRight.style.visibility = "hidden";
behindLeft.style.visibility = "hidden";
}
}
// Swipe a destra → mark as read SOLO se consentito
else if (!open && currentX > 0) {
if (currentX > SECOND_THRESHOLD) {
card.style.transform = `translateX(${MAX_SWIPE}px)`;
setTimeout(() => markAsRead(row), 200);
} else if (currentX > FIRST_THRESHOLD) {
card.style.transform = `translateX(${FIRST_THRESHOLD}px)`;
open = "left";
} else {
card.style.transform = 'translateX(0)';
open = null;
behindRight.style.visibility = "hidden";
behindLeft.style.visibility = "hidden";
}
}
// Se già aperta, gestisci chiusura
else {
if (open === "right" && currentX > -FIRST_THRESHOLD + CLOSE_THRESHOLD) {
card.style.transform = 'translateX(0)';
open = null;
behindRight.style.visibility = "hidden";
behindLeft.style.visibility = "hidden";
} else if (open === "left" && currentX < FIRST_THRESHOLD - CLOSE_THRESHOLD) {
card.style.transform = 'translateX(0)';
open = null;
behindRight.style.visibility = "hidden";
behindLeft.style.visibility = "hidden";
} else if (open) {
card.style.transform = `translateX(${open === "right" ? -FIRST_THRESHOLD : FIRST_THRESHOLD}px)`;
}
}
}
card.addEventListener('pointerup', endDrag);
card.addEventListener('pointercancel', endDrag);
btnTrash.addEventListener('click', () => removeRow(row));
btnRead.addEventListener('click', () => markAsRead(row));
}
function removeRow(row) {
const id = row.id;
collapseAndRemove(row);
dotnetHelper.invokeMethodAsync('Delete', id);
}
function markAsRead(row) {
const id = row.id;
collapseAndRemove(row);
dotnetHelper.invokeMethodAsync('MarkAsRead', id);
}
function collapseAndRemove(row) {
const h = row.getBoundingClientRect().height;
row.style.height = h + 'px';
row.classList.add('collapsing');
requestAnimationFrame(() => {
row.style.opacity = '0';
row.style.marginTop = '0';
row.style.marginBottom = '0';
row.style.height = '0';
});
setTimeout(() => row.remove(), 220);
}

View File

@@ -14,17 +14,17 @@ public class ManageDataService : IManageDataService
throw new NotImplementedException(); throw new NotImplementedException();
} }
public Task<List<AnagClie>> GetClienti(WhereCondContact? whereCond) public Task<List<AnagClie>> GetClienti(WhereCondContact? whereCond = null)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public Task<List<PtbPros>> GetProspect(WhereCondContact? whereCond) public Task<List<PtbPros>> GetProspect(WhereCondContact? whereCond = null)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
public Task<List<ContactDTO>> GetContact(WhereCondContact whereCond) public Task<List<ContactDTO>> GetContact(WhereCondContact whereCond, DateTime? lastSync = null)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@@ -34,6 +34,11 @@ public class ManageDataService : IManageDataService
throw new NotImplementedException(); throw new NotImplementedException();
} }
public Task<List<ActivityDTO>> GetActivityTryLocalDb(WhereCondActivity whereCond)
{
throw new NotImplementedException();
}
public Task<List<ActivityDTO>> GetActivity(WhereCondActivity whereCond, bool useLocalDb = false) public Task<List<ActivityDTO>> GetActivity(WhereCondActivity whereCond, bool useLocalDb = false)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
@@ -49,6 +54,11 @@ public class ManageDataService : IManageDataService
throw new NotImplementedException(); throw new NotImplementedException();
} }
public Task DeleteProspect(string codPpro)
{
throw new NotImplementedException();
}
public Task Delete<T>(T objectToDelete) public Task Delete<T>(T objectToDelete)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
@@ -59,6 +69,11 @@ public class ManageDataService : IManageDataService
throw new NotImplementedException(); throw new NotImplementedException();
} }
public Task<List<ActivityDTO>> MapActivity(List<StbActivity>? activities)
{
throw new NotImplementedException();
}
public Task ClearDb() public Task ClearDb()
{ {
throw new NotImplementedException(); throw new NotImplementedException();

View File

@@ -1,4 +1,5 @@
using salesbook.Shared.Core.Interface; using salesbook.Shared.Core.Interface;
using salesbook.Shared.Core.Interface.System.Network;
namespace salesbook.Web.Core.Services; namespace salesbook.Web.Core.Services;

View File

@@ -5,6 +5,8 @@ using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using MudBlazor.Services; using MudBlazor.Services;
using salesbook.Shared.Components; using salesbook.Shared.Components;
using salesbook.Shared.Core.Interface; using salesbook.Shared.Core.Interface;
using salesbook.Shared.Core.Interface.IntegryApi;
using salesbook.Shared.Core.Interface.System.Network;
using salesbook.Shared.Core.Services; using salesbook.Shared.Core.Services;
using salesbook.Web.Core.Services; using salesbook.Web.Core.Services;

Some files were not shown because too many files have changed in this diff Show More