generated from Integry/Template_NetMauiBlazorHybrid
Merge branch 'develop' into feature/Firebase
# Conflicts: # salesbook.Shared/Components/Pages/Home.razor
This commit is contained in:
@@ -57,9 +57,53 @@ public class AttachedService : IAttachedService
|
||||
Name = file.FileName,
|
||||
Path = file.FullPath,
|
||||
MimeType = file.ContentType,
|
||||
DimensionBytes= ms.Length,
|
||||
FileContent = ms.ToArray(),
|
||||
DimensionBytes = ms.Length,
|
||||
FileBytes = ms.ToArray(),
|
||||
Type = type
|
||||
};
|
||||
}
|
||||
|
||||
private static async Task<string?> SaveToTempStorage(Stream file, string fileName)
|
||||
{
|
||||
var cacheDirectory = FileSystem.CacheDirectory;
|
||||
var targetDirectory = Path.Combine(cacheDirectory, "file");
|
||||
|
||||
if (!Directory.Exists(targetDirectory)) Directory.CreateDirectory(targetDirectory);
|
||||
|
||||
var tempFilePath = Path.Combine(targetDirectory, fileName + ".temp");
|
||||
var filePath = Path.Combine(targetDirectory, fileName);
|
||||
|
||||
if (File.Exists(filePath)) return filePath;
|
||||
|
||||
try
|
||||
{
|
||||
await using var fileStream =
|
||||
new FileStream(tempFilePath, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
await file.CopyToAsync(fileStream);
|
||||
|
||||
File.Move(tempFilePath, filePath);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine($"Errore durante il salvataggio dello stream: {e.Message}");
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (File.Exists(tempFilePath)) File.Delete(tempFilePath);
|
||||
}
|
||||
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public async Task OpenFile(Stream file, string fileName)
|
||||
{
|
||||
var filePath = await SaveToTempStorage(file, fileName);
|
||||
|
||||
if (filePath is null) return;
|
||||
await Launcher.OpenAsync(new OpenFileRequest
|
||||
{
|
||||
File = new ReadOnlyFile(filePath)
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ public class LocalDbService
|
||||
_connection.CreateTableAsync<VtbDest>();
|
||||
_connection.CreateTableAsync<StbActivityResult>();
|
||||
_connection.CreateTableAsync<StbActivityType>();
|
||||
_connection.CreateTableAsync<SrlActivityTypeUser>();
|
||||
_connection.CreateTableAsync<StbUser>();
|
||||
_connection.CreateTableAsync<VtbTipi>();
|
||||
_connection.CreateTableAsync<Nazioni>();
|
||||
@@ -33,12 +34,14 @@ public class LocalDbService
|
||||
{
|
||||
await _connection.ExecuteAsync("DROP TABLE IF EXISTS stb_activity_result;");
|
||||
await _connection.ExecuteAsync("DROP TABLE IF EXISTS stb_activity_type;");
|
||||
await _connection.ExecuteAsync("DROP TABLE IF EXISTS srl_activity_type_user;");
|
||||
await _connection.ExecuteAsync("DROP TABLE IF EXISTS stb_user;");
|
||||
await _connection.ExecuteAsync("DROP TABLE IF EXISTS vtb_tipi;");
|
||||
await _connection.ExecuteAsync("DROP TABLE IF EXISTS nazioni;");
|
||||
|
||||
await _connection.CreateTableAsync<StbActivityResult>();
|
||||
await _connection.CreateTableAsync<StbActivityType>();
|
||||
await _connection.CreateTableAsync<SrlActivityTypeUser>();
|
||||
await _connection.CreateTableAsync<StbUser>();
|
||||
await _connection.CreateTableAsync<VtbTipi>();
|
||||
await _connection.CreateTableAsync<Nazioni>();
|
||||
|
||||
@@ -1,21 +1,131 @@
|
||||
using AutoMapper;
|
||||
using System.Linq.Expressions;
|
||||
using salesbook.Shared.Core.Dto;
|
||||
using salesbook.Shared.Core.Dto.Activity;
|
||||
using salesbook.Shared.Core.Dto.Contact;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
using salesbook.Shared.Core.Helpers.Enum;
|
||||
using salesbook.Shared.Core.Interface;
|
||||
using Sentry.Protocol;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace salesbook.Maui.Core.Services;
|
||||
|
||||
public class ManageDataService(LocalDbService localDb, IMapper mapper) : IManageDataService
|
||||
public class ManageDataService(
|
||||
LocalDbService localDb,
|
||||
IMapper mapper,
|
||||
IIntegryApiService integryApiService,
|
||||
INetworkService networkService
|
||||
) : IManageDataService
|
||||
{
|
||||
public Task<List<T>> GetTable<T>(Expression<Func<T, bool>>? whereCond = null) where T : new() =>
|
||||
localDb.Get(whereCond);
|
||||
|
||||
public async Task<List<ContactDTO>> GetContact()
|
||||
public async Task<List<AnagClie>> GetClienti(WhereCondContact? whereCond)
|
||||
{
|
||||
var contactList = await localDb.Get<AnagClie>(x => x.FlagStato.Equals("A"));
|
||||
var prospectList = await localDb.Get<PtbPros>();
|
||||
List<AnagClie> clienti = [];
|
||||
whereCond ??= new WhereCondContact();
|
||||
whereCond.OnlyContact = true;
|
||||
|
||||
if (networkService.ConnectionAvailable)
|
||||
{
|
||||
var response = await integryApiService.RetrieveAnagClie(
|
||||
new CRMAnagRequestDTO
|
||||
{
|
||||
CodAnag = whereCond.CodAnag,
|
||||
FlagStato = whereCond.FlagStato,
|
||||
PartIva = whereCond.PartIva,
|
||||
ReturnPersRif = !whereCond.OnlyContact
|
||||
}
|
||||
);
|
||||
|
||||
clienti = response.AnagClie ?? [];
|
||||
}
|
||||
else
|
||||
{
|
||||
clienti = await localDb.Get<AnagClie>(x =>
|
||||
(whereCond.FlagStato != null && x.FlagStato.Equals(whereCond.FlagStato)) ||
|
||||
(whereCond.PartIva != null && x.PartIva.Equals(whereCond.PartIva)) ||
|
||||
(whereCond.PartIva == null && whereCond.FlagStato == null)
|
||||
);
|
||||
}
|
||||
|
||||
return clienti;
|
||||
}
|
||||
|
||||
public async Task<List<PtbPros>> GetProspect(WhereCondContact? whereCond)
|
||||
{
|
||||
List<PtbPros> prospect = [];
|
||||
whereCond ??= new WhereCondContact();
|
||||
whereCond.OnlyContact = true;
|
||||
|
||||
if (networkService.ConnectionAvailable)
|
||||
{
|
||||
var response = await integryApiService.RetrieveProspect(
|
||||
new CRMProspectRequestDTO
|
||||
{
|
||||
CodPpro = whereCond.CodAnag,
|
||||
PartIva = whereCond.PartIva,
|
||||
ReturnPersRif = !whereCond.OnlyContact
|
||||
}
|
||||
);
|
||||
|
||||
prospect = response.PtbPros ?? [];
|
||||
}
|
||||
else
|
||||
{
|
||||
prospect = await localDb.Get<PtbPros>(x =>
|
||||
(whereCond.PartIva != null && x.PartIva.Equals(whereCond.PartIva)) ||
|
||||
(whereCond.PartIva == null)
|
||||
);
|
||||
}
|
||||
|
||||
return prospect;
|
||||
}
|
||||
|
||||
public async Task<List<ContactDTO>> GetContact(WhereCondContact? whereCond)
|
||||
{
|
||||
List<AnagClie>? contactList;
|
||||
List<PtbPros>? prospectList;
|
||||
whereCond ??= new WhereCondContact();
|
||||
|
||||
if (networkService.ConnectionAvailable)
|
||||
{
|
||||
var clienti = await integryApiService.RetrieveAnagClie(
|
||||
new CRMAnagRequestDTO
|
||||
{
|
||||
CodAnag = whereCond.CodAnag,
|
||||
FlagStato = whereCond.FlagStato,
|
||||
PartIva = whereCond.PartIva,
|
||||
ReturnPersRif = !whereCond.OnlyContact
|
||||
}
|
||||
);
|
||||
_ = UpdateDbUsers(clienti);
|
||||
|
||||
var prospect = await integryApiService.RetrieveProspect(
|
||||
new CRMProspectRequestDTO
|
||||
{
|
||||
CodPpro = whereCond.CodAnag,
|
||||
PartIva = whereCond.PartIva,
|
||||
ReturnPersRif = !whereCond.OnlyContact
|
||||
}
|
||||
);
|
||||
_ = UpdateDbUsers(prospect);
|
||||
|
||||
contactList = clienti.AnagClie;
|
||||
prospectList = prospect.PtbPros;
|
||||
}
|
||||
else
|
||||
{
|
||||
contactList = await localDb.Get<AnagClie>(x =>
|
||||
(whereCond.FlagStato != null && x.FlagStato.Equals(whereCond.FlagStato)) ||
|
||||
(whereCond.PartIva != null && x.PartIva.Equals(whereCond.PartIva)) ||
|
||||
(whereCond.PartIva == null && whereCond.FlagStato == null)
|
||||
);
|
||||
prospectList = await localDb.Get<PtbPros>(x =>
|
||||
(whereCond.PartIva != null && x.PartIva.Equals(whereCond.PartIva)) ||
|
||||
(whereCond.PartIva == null)
|
||||
);
|
||||
}
|
||||
|
||||
// Mappa i contatti
|
||||
var contactMapper = mapper.Map<List<ContactDTO>>(contactList);
|
||||
@@ -46,9 +156,35 @@ public class ManageDataService(LocalDbService localDb, IMapper mapper) : IManage
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<ActivityDTO>> GetActivity(Expression<Func<StbActivity, bool>>? whereCond = null)
|
||||
public async Task<List<ActivityDTO>> GetActivity(WhereCondActivity whereCond, bool useLocalDb)
|
||||
{
|
||||
var activities = await localDb.Get(whereCond);
|
||||
List<StbActivity>? activities;
|
||||
|
||||
if (networkService.ConnectionAvailable && !useLocalDb)
|
||||
{
|
||||
activities = await integryApiService.RetrieveActivity(
|
||||
new CRMRetrieveActivityRequestDTO
|
||||
{
|
||||
StarDate = whereCond.Start,
|
||||
EndDate = whereCond.End,
|
||||
ActivityId = whereCond.ActivityId
|
||||
}
|
||||
);
|
||||
|
||||
_ = UpdateDb(activities);
|
||||
}
|
||||
else
|
||||
{
|
||||
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 == null) return [];
|
||||
|
||||
var codJcomList = activities
|
||||
.Select(x => x.CodJcom)
|
||||
@@ -103,7 +239,37 @@ public class ManageDataService(LocalDbService localDb, IMapper mapper) : IManage
|
||||
return returnDto;
|
||||
}
|
||||
|
||||
public Task InsertOrUpdate<T>(List<T> listToSave) =>
|
||||
private Task UpdateDbUsers(UsersSyncResponseDTO response)
|
||||
{
|
||||
return Task.Run(async () =>
|
||||
{
|
||||
if (response.AnagClie != null)
|
||||
{
|
||||
await localDb.InsertOrUpdate(response.AnagClie);
|
||||
|
||||
if (response.VtbDest != null) await localDb.InsertOrUpdate(response.VtbDest);
|
||||
if (response.VtbCliePersRif != null) await localDb.InsertOrUpdate(response.VtbCliePersRif);
|
||||
}
|
||||
|
||||
if (response.PtbPros != null)
|
||||
{
|
||||
await localDb.InsertOrUpdate(response.PtbPros);
|
||||
|
||||
if (response.PtbProsRif != null) await localDb.InsertOrUpdate(response.PtbProsRif);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Task UpdateDb<T>(List<T>? entityList)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
if (entityList == null) return;
|
||||
_ = localDb.InsertOrUpdate(entityList);
|
||||
});
|
||||
}
|
||||
|
||||
public Task InsertOrUpdate<T>(List<T> listToSave) =>
|
||||
localDb.InsertOrUpdate(listToSave);
|
||||
|
||||
public Task InsertOrUpdate<T>(T objectToSave) =>
|
||||
|
||||
@@ -5,17 +5,6 @@ namespace salesbook.Maui.Core.Services;
|
||||
|
||||
public class SyncDbService(IIntegryApiService integryApiService, LocalDbService localDb) : ISyncDbService
|
||||
{
|
||||
public async Task GetAndSaveActivity(string? dateFilter)
|
||||
{
|
||||
var allActivity = await integryApiService.RetrieveActivity(dateFilter);
|
||||
|
||||
if (!allActivity.IsNullOrEmpty())
|
||||
if (dateFilter is null)
|
||||
await localDb.InsertAll(allActivity!);
|
||||
else
|
||||
await localDb.InsertOrUpdate(allActivity!);
|
||||
}
|
||||
|
||||
public async Task GetAndSaveCommesse(string? dateFilter)
|
||||
{
|
||||
var allCommesse = await integryApiService.RetrieveAllCommesse(dateFilter);
|
||||
@@ -27,46 +16,6 @@ public class SyncDbService(IIntegryApiService integryApiService, LocalDbService
|
||||
await localDb.InsertOrUpdate(allCommesse!);
|
||||
}
|
||||
|
||||
public async Task GetAndSaveProspect(string? dateFilter)
|
||||
{
|
||||
var taskSyncResponseDto = await integryApiService.RetrieveProspect(dateFilter);
|
||||
|
||||
if (!taskSyncResponseDto.PtbPros.IsNullOrEmpty())
|
||||
if (dateFilter is null)
|
||||
await localDb.InsertAll(taskSyncResponseDto.PtbPros!);
|
||||
else
|
||||
await localDb.InsertOrUpdate(taskSyncResponseDto.PtbPros!);
|
||||
|
||||
if (!taskSyncResponseDto.PtbProsRif.IsNullOrEmpty())
|
||||
if (dateFilter is null)
|
||||
await localDb.InsertAll(taskSyncResponseDto.PtbProsRif!);
|
||||
else
|
||||
await localDb.InsertOrUpdate(taskSyncResponseDto.PtbProsRif!);
|
||||
}
|
||||
|
||||
public async Task GetAndSaveClienti(string? dateFilter)
|
||||
{
|
||||
var taskSyncResponseDto = await integryApiService.RetrieveAnagClie(dateFilter);
|
||||
|
||||
if (!taskSyncResponseDto.AnagClie.IsNullOrEmpty())
|
||||
if (dateFilter is null)
|
||||
await localDb.InsertAll(taskSyncResponseDto.AnagClie!);
|
||||
else
|
||||
await localDb.InsertOrUpdate(taskSyncResponseDto.AnagClie!);
|
||||
|
||||
if (!taskSyncResponseDto.VtbDest.IsNullOrEmpty())
|
||||
if (dateFilter is null)
|
||||
await localDb.InsertAll(taskSyncResponseDto.VtbDest!);
|
||||
else
|
||||
await localDb.InsertOrUpdate(taskSyncResponseDto.VtbDest!);
|
||||
|
||||
if (!taskSyncResponseDto.VtbCliePersRif.IsNullOrEmpty())
|
||||
if (dateFilter is null)
|
||||
await localDb.InsertAll(taskSyncResponseDto.VtbCliePersRif!);
|
||||
else
|
||||
await localDb.InsertOrUpdate(taskSyncResponseDto.VtbCliePersRif!);
|
||||
}
|
||||
|
||||
public async Task GetAndSaveSettings(string? dateFilter)
|
||||
{
|
||||
if (dateFilter is not null)
|
||||
@@ -80,6 +29,9 @@ public class SyncDbService(IIntegryApiService integryApiService, LocalDbService
|
||||
if (!settingsResponse.ActivityTypes.IsNullOrEmpty())
|
||||
await localDb.InsertAll(settingsResponse.ActivityTypes!);
|
||||
|
||||
if (!settingsResponse.ActivityTypeUsers.IsNullOrEmpty())
|
||||
await localDb.InsertAll(settingsResponse.ActivityTypeUsers!);
|
||||
|
||||
if (!settingsResponse.StbUsers.IsNullOrEmpty())
|
||||
await localDb.InsertAll(settingsResponse.StbUsers!);
|
||||
|
||||
|
||||
@@ -4,8 +4,11 @@ namespace salesbook.Maui.Core.System.Network;
|
||||
|
||||
public class NetworkService : INetworkService
|
||||
{
|
||||
public bool ConnectionAvailable { get; set; }
|
||||
|
||||
public bool IsNetworkAvailable()
|
||||
{
|
||||
//return false;
|
||||
return Connectivity.Current.NetworkAccess == NetworkAccess.Internet;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ using salesbook.Maui.Core.System.Notification;
|
||||
using salesbook.Maui.Core.System.Notification.Push;
|
||||
using salesbook.Shared;
|
||||
using salesbook.Shared.Core.Dto;
|
||||
using salesbook.Shared.Core.Dto.PageState;
|
||||
using salesbook.Shared.Core.Helpers;
|
||||
using salesbook.Shared.Core.Interface;
|
||||
using salesbook.Shared.Core.Messages.Activity.Copy;
|
||||
@@ -58,10 +59,16 @@ namespace salesbook.Maui
|
||||
builder.Services.AddScoped<AuthenticationStateProvider>(provider =>
|
||||
provider.GetRequiredService<AppAuthenticationStateProvider>());
|
||||
|
||||
builder.Services.AddScoped<INetworkService, NetworkService>();
|
||||
builder.Services.AddScoped<IIntegryApiService, IntegryApiService>();
|
||||
builder.Services.AddScoped<ISyncDbService, SyncDbService>();
|
||||
builder.Services.AddScoped<IManageDataService, ManageDataService>();
|
||||
builder.Services.AddScoped<PreloadService>();
|
||||
|
||||
//SessionData
|
||||
builder.Services.AddSingleton<JobSteps>();
|
||||
builder.Services.AddSingleton<UserPageState>();
|
||||
builder.Services.AddSingleton<UserListState>();
|
||||
builder.Services.AddSingleton<FilterUserDTO>();
|
||||
|
||||
//Message
|
||||
builder.Services.AddScoped<IMessenger, WeakReferenceMessenger>();
|
||||
@@ -83,8 +90,8 @@ namespace salesbook.Maui
|
||||
|
||||
builder.Services.AddSingleton<IFormFactor, FormFactor>();
|
||||
builder.Services.AddSingleton<IAttachedService, AttachedService>();
|
||||
builder.Services.AddSingleton<INetworkService, NetworkService>();
|
||||
builder.Services.AddSingleton<LocalDbService>();
|
||||
builder.Services.AddSingleton<FilterUserDTO>();
|
||||
|
||||
return builder.Build();
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
@using System.Globalization
|
||||
@using CommunityToolkit.Mvvm.Messaging
|
||||
@using salesbook.Shared.Core.Interface
|
||||
@using salesbook.Shared.Core.Messages.Back
|
||||
@inherits LayoutComponentBase
|
||||
@inject IJSRuntime JS
|
||||
@inject IMessenger Messenger
|
||||
@inject BackNavigationService BackService
|
||||
@inject INetworkService NetworkService
|
||||
@inject IIntegryApiService IntegryApiService
|
||||
|
||||
<MudThemeProvider Theme="_currentTheme" @ref="@_mudThemeProvider" @bind-IsDarkMode="@IsDarkMode" />
|
||||
<MudPopoverProvider/>
|
||||
@@ -13,13 +14,33 @@
|
||||
|
||||
<div class="page">
|
||||
<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>
|
||||
<article>
|
||||
@Body
|
||||
</article>
|
||||
</main>
|
||||
|
||||
</div>
|
||||
|
||||
@code {
|
||||
@@ -27,6 +48,50 @@
|
||||
private bool IsDarkMode { get; set; }
|
||||
private string _mainContentClass = "";
|
||||
|
||||
//Connection state
|
||||
private bool FirstCheck { get; set; } = true;
|
||||
private bool _isNetworkAvailable;
|
||||
private bool _servicesIsDown;
|
||||
private bool _showWarning;
|
||||
|
||||
private DateTime _lastApiCheck = DateTime.MinValue;
|
||||
private const int DelaySeconds = 60;
|
||||
|
||||
private CancellationTokenSource? _cts;
|
||||
|
||||
private bool ServicesIsDown
|
||||
{
|
||||
get => _servicesIsDown;
|
||||
set
|
||||
{
|
||||
if (_servicesIsDown == value) return;
|
||||
_servicesIsDown = value;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsNetworkAvailable
|
||||
{
|
||||
get => _isNetworkAvailable;
|
||||
set
|
||||
{
|
||||
if (_isNetworkAvailable == value) return;
|
||||
_isNetworkAvailable = value;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private bool ShowWarning
|
||||
{
|
||||
get => _showWarning;
|
||||
set
|
||||
{
|
||||
if (_showWarning == value) return;
|
||||
_showWarning = value;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private readonly MudTheme _currentTheme = new()
|
||||
{
|
||||
PaletteLight = new PaletteLight()
|
||||
@@ -81,6 +146,9 @@
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
_cts = new CancellationTokenSource();
|
||||
_ = CheckConnectionState(_cts.Token);
|
||||
|
||||
BackService.OnHardwareBack += async () => { await JS.InvokeVoidAsync("goBack"); };
|
||||
|
||||
var culture = new CultureInfo("it-IT", false);
|
||||
@@ -89,4 +157,40 @@
|
||||
CultureInfo.CurrentUICulture = culture;
|
||||
}
|
||||
|
||||
private Task CheckConnectionState(CancellationToken token)
|
||||
{
|
||||
return Task.Run(async () =>
|
||||
{
|
||||
while (!token.IsCancellationRequested)
|
||||
{
|
||||
var isNetworkAvailable = NetworkService.IsNetworkAvailable();
|
||||
var servicesDown = ServicesIsDown;
|
||||
|
||||
if (isNetworkAvailable && (DateTime.UtcNow - _lastApiCheck).TotalSeconds >= DelaySeconds)
|
||||
{
|
||||
servicesDown = !await IntegryApiService.SystemOk();
|
||||
_lastApiCheck = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
await InvokeAsync(async () =>
|
||||
{
|
||||
IsNetworkAvailable = isNetworkAvailable;
|
||||
ServicesIsDown = servicesDown;
|
||||
|
||||
await Task.Delay(1500, token);
|
||||
ShowWarning = !(IsNetworkAvailable && !ServicesIsDown);
|
||||
NetworkService.ConnectionAvailable = !ShowWarning;
|
||||
});
|
||||
|
||||
await Task.Delay(500, token);
|
||||
}
|
||||
}, token);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_cts?.Cancel();
|
||||
_cts?.Dispose();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
@using CommunityToolkit.Mvvm.Messaging
|
||||
@using salesbook.Shared.Core.Dto
|
||||
@using salesbook.Shared.Core.Dto.Activity
|
||||
@using salesbook.Shared.Core.Entity
|
||||
@using salesbook.Shared.Core.Messages.Activity.Copy
|
||||
@using salesbook.Shared.Core.Messages.Activity.New
|
||||
@@ -67,10 +68,10 @@
|
||||
{
|
||||
var location = args.Location.Remove(0, NavigationManager.BaseUri.Length);
|
||||
|
||||
var newIsVisible = new List<string> { "Calendar", "Users", "Notifications" }
|
||||
var newIsVisible = new List<string> { "Calendar", "Users", "Notifications", "Commessa" }
|
||||
.Contains(location);
|
||||
|
||||
var newPlusVisible = new List<string> { "Calendar", "Users" }
|
||||
var newPlusVisible = new List<string> { "Calendar", "Users", "Commessa" }
|
||||
.Contains(location);
|
||||
|
||||
if (IsVisible == newIsVisible && PlusVisible == newPlusVisible) return;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
@page "/Calendar"
|
||||
@using salesbook.Shared.Core.Dto
|
||||
@using salesbook.Shared.Core.Interface
|
||||
@using salesbook.Shared.Components.Layout
|
||||
@using salesbook.Shared.Components.SingleElements
|
||||
@using salesbook.Shared.Components.Layout.Spinner
|
||||
@using salesbook.Shared.Components.SingleElements
|
||||
@using salesbook.Shared.Components.SingleElements.BottomSheet
|
||||
@using salesbook.Shared.Core.Dto.Activity
|
||||
@using salesbook.Shared.Core.Interface
|
||||
@using salesbook.Shared.Core.Messages.Activity.New
|
||||
@inject IManageDataService ManageData
|
||||
@inject IJSRuntime JS
|
||||
@@ -471,9 +471,7 @@
|
||||
|
||||
var start = CurrentMonth;
|
||||
var end = start.AddDays(DaysInMonth - 1);
|
||||
var activities = await ManageData.GetActivity(x =>
|
||||
(x.EffectiveDate == null && x.EstimatedDate >= start && x.EstimatedDate <= end) ||
|
||||
(x.EffectiveDate >= start && x.EffectiveDate <= end));
|
||||
var activities = await ManageData.GetActivity(new WhereCondActivity{Start = start, End = end});
|
||||
MonthActivities = activities.OrderBy(x => x.EffectiveDate ?? x.EstimatedDate).ToList();
|
||||
|
||||
PrepareRenderingData();
|
||||
@@ -541,7 +539,7 @@
|
||||
|
||||
await ManageData.DeleteActivity(activity);
|
||||
|
||||
var indexActivity = MonthActivities?.FindIndex(x => x.ActivityId.Equals(activity.ActivityId));
|
||||
var indexActivity = MonthActivities?.FindIndex(x => x.ActivityId!.Equals(activity.ActivityId));
|
||||
|
||||
if (indexActivity != null)
|
||||
{
|
||||
@@ -558,7 +556,7 @@
|
||||
{
|
||||
IsLoading = true;
|
||||
|
||||
var activity = (await ManageData.GetActivity(x => x.ActivityId.Equals(activityId))).LastOrDefault();
|
||||
var activity = (await ManageData.GetActivity(new WhereCondActivity {ActivityId = activityId}, true)).LastOrDefault();
|
||||
|
||||
if (activity == null)
|
||||
{
|
||||
@@ -583,7 +581,7 @@
|
||||
|
||||
private async Task OnActivityChanged(string activityId)
|
||||
{
|
||||
var newActivity = await ManageData.GetActivity(x => x.ActivityId.Equals(activityId));
|
||||
var newActivity = await ManageData.GetActivity(new WhereCondActivity { ActivityId = activityId }, true);
|
||||
var indexActivity = MonthActivities?.FindIndex(x => x.ActivityId.Equals(activityId));
|
||||
|
||||
if (indexActivity != null && !newActivity.IsNullOrEmpty())
|
||||
|
||||
@@ -122,7 +122,7 @@
|
||||
flex-direction: column;
|
||||
-ms-overflow-style: none;
|
||||
scrollbar-width: none;
|
||||
padding-bottom: 70px;
|
||||
padding-bottom: 16vh;
|
||||
height: calc(100% - 130px);
|
||||
}
|
||||
|
||||
|
||||
173
salesbook.Shared/Components/Pages/Commessa.razor
Normal file
173
salesbook.Shared/Components/Pages/Commessa.razor
Normal file
@@ -0,0 +1,173 @@
|
||||
@page "/commessa/{CodJcom}"
|
||||
@page "/commessa/{CodJcom}/{RagSoc}"
|
||||
@attribute [Authorize]
|
||||
@using AutoMapper
|
||||
@using salesbook.Shared.Components.Layout
|
||||
@using salesbook.Shared.Components.Layout.Spinner
|
||||
@using salesbook.Shared.Components.SingleElements
|
||||
@using salesbook.Shared.Core.Dto
|
||||
@using salesbook.Shared.Core.Dto.Activity
|
||||
@using salesbook.Shared.Core.Dto.JobProgress
|
||||
@using salesbook.Shared.Core.Dto.PageState
|
||||
@using salesbook.Shared.Core.Entity
|
||||
@using salesbook.Shared.Core.Interface
|
||||
@inject JobSteps JobSteps
|
||||
@inject IManageDataService ManageData
|
||||
@inject IIntegryApiService IntegryApiService
|
||||
@inject IMapper Mapper
|
||||
|
||||
<HeaderLayout Title="@CodJcom" ShowProfile="false" Back="true" BackTo="Indietro"/>
|
||||
|
||||
@if (IsLoading)
|
||||
{
|
||||
<SpinnerLayout FullScreen="true"/>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="container content">
|
||||
@if (CommessaModel == null)
|
||||
{
|
||||
<NoDataAvailable Text="Nessuna commessa trovata"/>
|
||||
}
|
||||
else
|
||||
{
|
||||
<input type="radio" class="tab-toggle" name="tab-toggle" id="tab1" checked>
|
||||
<input type="radio" class="tab-toggle" name="tab-toggle" id="tab2">
|
||||
<input type="radio" class="tab-toggle" name="tab-toggle" id="tab3">
|
||||
|
||||
<div class="box">
|
||||
<ul class="tab-list">
|
||||
<li class="tab-item"><label class="tab-trigger" for="tab1">Avanzamento</label></li>
|
||||
<li class="tab-item"><label class="tab-trigger" for="tab2">Attività</label></li>
|
||||
<li class="tab-item"><label class="tab-trigger" for="tab3">Allegati</label></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- contenuti -->
|
||||
<div class="tab-container">
|
||||
<div class="tab-content">
|
||||
@if (Steps != null)
|
||||
{
|
||||
<div class="timeline-container">
|
||||
<div class="timeline">
|
||||
@foreach (var step in Steps)
|
||||
{
|
||||
<div class="step">
|
||||
<div class="@(step.Status!.Skip ? "circle skipped" : step.Status!.Progress ? "in-progress" : "circle completed")"></div>
|
||||
<div class="label">
|
||||
<div class="titleStep">@step.StepName</div>
|
||||
@if (step.Date is not null)
|
||||
{
|
||||
<div class="subtitleStep">@($"{step.Date.Value:D}") @(step.Status!.Progress ? "(In corso...)" : "")</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
@if (ActivityIsLoading)
|
||||
{
|
||||
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-7" />
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (ActivityList is { Count: > 0 })
|
||||
{
|
||||
<div class="contentFlex">
|
||||
<Virtualize Items="ActivityList" Context="activity">
|
||||
<ActivityCard ShowDate="true" Activity="activity" />
|
||||
</Virtualize>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<NoDataAvailable Text="Nessuna attività trovata" />
|
||||
}
|
||||
}
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
@if (AttachedIsLoading)
|
||||
{
|
||||
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-7" />
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (ListAttached != null)
|
||||
{
|
||||
<div class="contentFlex">
|
||||
<Virtualize Items="ListAttached" Context="attached">
|
||||
<AttachCard Attached="attached" />
|
||||
</Virtualize>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<NoDataAvailable Text="Nessun allegato presente" />
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter] public string CodJcom { get; set; } = "";
|
||||
[Parameter] public string RagSoc { get; set; } = "";
|
||||
|
||||
private List<CRMJobStepDTO>? Steps { get; set; }
|
||||
private List<ActivityDTO> ActivityList { get; set; } = [];
|
||||
private List<CRMAttachedResponseDTO>? ListAttached { get; set; }
|
||||
private JtbComt? CommessaModel { get; set; }
|
||||
|
||||
private bool IsLoading { get; set; } = true;
|
||||
private bool ActivityIsLoading { get; set; } = true;
|
||||
private bool AttachedIsLoading { get; set; } = true;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await LoadData();
|
||||
}
|
||||
|
||||
private async Task LoadData()
|
||||
{
|
||||
CommessaModel = (await ManageData.GetTable<JtbComt>(x => x.CodJcom.Equals(CodJcom))).LastOrDefault();
|
||||
Steps = JobSteps.Steps;
|
||||
|
||||
_ = LoadActivity();
|
||||
_ = LoadAttached();
|
||||
|
||||
IsLoading = false;
|
||||
}
|
||||
|
||||
private async Task LoadActivity()
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
var activities = await IntegryApiService.RetrieveActivity(new CRMRetrieveActivityRequestDTO { CodJcom = CodJcom });
|
||||
ActivityList = Mapper.Map<List<ActivityDTO>>(activities)
|
||||
.OrderBy(x =>
|
||||
(x.EffectiveTime ?? x.EstimatedTime) ?? x.DataInsAct
|
||||
).ToList();
|
||||
});
|
||||
|
||||
ActivityIsLoading = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task LoadAttached()
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
ListAttached = await IntegryApiService.RetrieveAttached(CodJcom);
|
||||
});
|
||||
|
||||
AttachedIsLoading = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
230
salesbook.Shared/Components/Pages/Commessa.razor.css
Normal file
230
salesbook.Shared/Components/Pages/Commessa.razor.css
Normal file
@@ -0,0 +1,230 @@
|
||||
/* Container scrollabile */
|
||||
|
||||
.timeline-container {
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
.timeline {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
position: relative;
|
||||
padding-left: 40px; /* spazio per linea e cerchi */
|
||||
}
|
||||
|
||||
.step {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 15px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* Linea sopra e sotto ogni step */
|
||||
|
||||
.step::before,
|
||||
.step::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: -31px;
|
||||
width: 2px;
|
||||
background: #ddd;
|
||||
}
|
||||
|
||||
.step::after {
|
||||
top: 30%;
|
||||
bottom: -1.5rem;
|
||||
}
|
||||
|
||||
.step:first-child::before { display: none; }
|
||||
|
||||
.step:last-child::after { display: none; }
|
||||
|
||||
/* Cerchio base */
|
||||
|
||||
.circle,
|
||||
.in-progress {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
z-index: 1;
|
||||
margin-left: -40px;
|
||||
background-color: var(--mud-palette-tertiary);
|
||||
}
|
||||
|
||||
/* Stato skippato */
|
||||
|
||||
.skipped { background: #ccc; }
|
||||
|
||||
/* Stato completato */
|
||||
|
||||
.completed {
|
||||
background: var(--mud-palette-primary);
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* Stato in corso con spinner */
|
||||
|
||||
.in-progress {
|
||||
border: 2px solid var(--mud-palette-primary);
|
||||
border-top: 2px solid transparent;
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% { transform: rotate(0deg); }
|
||||
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
/* Label con titolo + sottotitolo */
|
||||
|
||||
.label {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.titleStep {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 600;
|
||||
color: #111;
|
||||
line-height: normal;
|
||||
}
|
||||
|
||||
.subtitleStep {
|
||||
font-size: .90rem;
|
||||
color: #666;
|
||||
line-height: normal;
|
||||
}
|
||||
|
||||
.timeline-container::-webkit-scrollbar { width: 6px; }
|
||||
|
||||
.timeline-container::-webkit-scrollbar-thumb {
|
||||
background: #bbb;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
/*--------------
|
||||
TabPanel
|
||||
----------------*/
|
||||
|
||||
.box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: -webkit-fill-available;
|
||||
box-shadow: var(--custom-box-shadow);
|
||||
border-radius: 16px;
|
||||
overflow: clip;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
/* nascondo gli input */
|
||||
|
||||
.tab-toggle { display: none; }
|
||||
|
||||
.tab-list {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
display: flex;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
background: var(--mud-palette-surface);
|
||||
}
|
||||
|
||||
/* la lineetta */
|
||||
|
||||
.tab-list::before {
|
||||
content: '';
|
||||
display: block;
|
||||
height: 3px;
|
||||
width: calc(100% / 3);
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
background-color: var(--mud-palette-primary);
|
||||
transition: transform .3s;
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
transition: .3s;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.tab-trigger {
|
||||
display: block;
|
||||
padding: 10px 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* tab attivo */
|
||||
|
||||
#tab1:checked ~ .box .tab-list .tab-item:nth-child(1),
|
||||
#tab2:checked ~ .box .tab-list .tab-item:nth-child(2),
|
||||
#tab3:checked ~ .box .tab-list .tab-item:nth-child(3) {
|
||||
opacity: 1;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* spostamento lineetta */
|
||||
|
||||
#tab1:checked ~ .box .tab-list::before { transform: translateX(0%); }
|
||||
|
||||
#tab2:checked ~ .box .tab-list::before { transform: translateX(100%); }
|
||||
|
||||
#tab3:checked ~ .box .tab-list::before { transform: translateX(200%); }
|
||||
|
||||
.tab-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
width: -webkit-fill-available;
|
||||
}
|
||||
|
||||
.tab-content {
|
||||
display: none;
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
animation: fade .3s ease;
|
||||
padding: .5rem;
|
||||
}
|
||||
|
||||
.contentFlex {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
.tab-content::-webkit-scrollbar { width: 6px; }
|
||||
|
||||
.tab-content::-webkit-scrollbar-thumb {
|
||||
background: #bbb;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.contentFlex ::deep > div:first-child:not(.activity-card) { display: none; }
|
||||
|
||||
#tab1:checked ~ .tab-container .tab-content:nth-child(1),
|
||||
#tab2:checked ~ .tab-container .tab-content:nth-child(2),
|
||||
#tab3:checked ~ .tab-container .tab-content:nth-child(3) { display: block; }
|
||||
|
||||
@keyframes fade {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(5px);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,11 @@
|
||||
@attribute [Authorize]
|
||||
@using salesbook.Shared.Core.Interface
|
||||
@using salesbook.Shared.Components.Layout.Spinner
|
||||
@using salesbook.Shared.Core.Services
|
||||
@inject IFormFactor FormFactor
|
||||
@inject INetworkService NetworkService
|
||||
@inject IFirebaseNotificationService FirebaseNotificationService
|
||||
@inject PreloadService PreloadService
|
||||
|
||||
<SpinnerLayout FullScreen="true" />
|
||||
|
||||
@@ -23,12 +25,21 @@
|
||||
|
||||
var lastSyncDate = LocalStorage.Get<DateTime>("last-sync");
|
||||
|
||||
if (!FormFactor.IsWeb() && NetworkService.IsNetworkAvailable() && lastSyncDate.Equals(DateTime.MinValue))
|
||||
if (!FormFactor.IsWeb() && NetworkService.ConnectionAvailable && lastSyncDate.Equals(DateTime.MinValue))
|
||||
{
|
||||
NavigationManager.NavigateTo("/sync");
|
||||
return;
|
||||
}
|
||||
|
||||
_ = StartSyncUser();
|
||||
NavigationManager.NavigateTo("/Calendar");
|
||||
}
|
||||
|
||||
private Task StartSyncUser()
|
||||
{
|
||||
return Task.Run(() =>
|
||||
{
|
||||
_ = PreloadService.PreloadUsersAsync();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
@page "/login"
|
||||
@using salesbook.Shared.Components.Layout.Spinner
|
||||
@using salesbook.Shared.Core.Interface
|
||||
@using salesbook.Shared.Core.Services
|
||||
@inject IUserAccountService UserAccountService
|
||||
@inject AppAuthenticationStateProvider AuthenticationStateProvider
|
||||
@inject INetworkService NetworkService
|
||||
|
||||
@if (Spinner)
|
||||
{
|
||||
@@ -26,7 +28,7 @@ else
|
||||
<MudTextField @bind-Value="UserData.CodHash" Label="Profilo azienda" Variant="Variant.Outlined"/>
|
||||
</div>
|
||||
|
||||
<MudButton OnClick="SignInUser" Color="Color.Primary" Variant="Variant.Filled">Login</MudButton>
|
||||
<MudButton Disabled="@(!NetworkService.ConnectionAvailable)" OnClick="SignInUser" Color="Color.Primary" Variant="Variant.Filled">Login</MudButton>
|
||||
@if (_attemptFailed)
|
||||
{
|
||||
<MudAlert Class="my-3" Dense="true" Severity="Severity.Error" Variant="Variant.Filled">@ErrorMessage</MudAlert>
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
<div>
|
||||
<span class="info-title">Status</span>
|
||||
@if (NetworkService.IsNetworkAvailable())
|
||||
@if (NetworkService.ConnectionAvailable)
|
||||
{
|
||||
<div class="status online">
|
||||
<i class="ri-wifi-line"></i>
|
||||
@@ -129,7 +129,7 @@
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
Unavailable = FormFactor.IsWeb() || !NetworkService.IsNetworkAvailable();
|
||||
Unavailable = FormFactor.IsWeb() || !NetworkService.ConnectionAvailable;
|
||||
LastSync = LocalStorage.Get<DateTime>("last-sync");
|
||||
});
|
||||
|
||||
|
||||
@@ -17,10 +17,7 @@
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
Elements["Attività"] = false;
|
||||
Elements["Commesse"] = false;
|
||||
Elements["Clienti"] = false;
|
||||
Elements["Prospect"] = false;
|
||||
Elements["Impostazioni"] = false;
|
||||
}
|
||||
|
||||
@@ -36,9 +33,6 @@
|
||||
}
|
||||
|
||||
await Task.WhenAll(
|
||||
RunAndTrack(SetActivity),
|
||||
RunAndTrack(SetClienti),
|
||||
RunAndTrack(SetProspect),
|
||||
RunAndTrack(SetCommesse),
|
||||
RunAndTrack(SetSettings)
|
||||
);
|
||||
@@ -62,30 +56,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SetActivity()
|
||||
{
|
||||
await Task.Run(async () => { await syncDb.GetAndSaveActivity(DateFilter); });
|
||||
|
||||
Elements["Attività"] = true;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task SetClienti()
|
||||
{
|
||||
await Task.Run(async () => { await syncDb.GetAndSaveClienti(DateFilter); });
|
||||
|
||||
Elements["Clienti"] = true;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task SetProspect()
|
||||
{
|
||||
await Task.Run(async () => { await syncDb.GetAndSaveProspect(DateFilter); });
|
||||
|
||||
Elements["Prospect"] = true;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task SetCommesse()
|
||||
{
|
||||
await Task.Run(async () => { await syncDb.GetAndSaveCommesse(DateFilter); });
|
||||
|
||||
@@ -7,20 +7,31 @@
|
||||
@using salesbook.Shared.Components.Layout.Spinner
|
||||
@using salesbook.Shared.Core.Dto
|
||||
@using salesbook.Shared.Components.SingleElements
|
||||
@using salesbook.Shared.Core.Dto.Activity
|
||||
@using salesbook.Shared.Core.Dto.JobProgress
|
||||
@using salesbook.Shared.Core.Dto.PageState
|
||||
@implements IAsyncDisposable
|
||||
@inject IManageDataService ManageData
|
||||
@inject IMapper Mapper
|
||||
@inject IDialogService Dialog
|
||||
@inject INetworkService NetworkService
|
||||
@inject IIntegryApiService IntegryApiService
|
||||
@inject UserPageState UserState
|
||||
|
||||
<HeaderLayout BackTo="Indietro" LabelSave="Modifica" OnSave="() => OpenUserForm(Anag)" Back="true" BackOnTop="true" Title="" ShowProfile="false" />
|
||||
<HeaderLayout BackTo="Indietro"
|
||||
LabelSave="Modifica"
|
||||
OnSave="() => OpenUserForm(Anag)"
|
||||
Back="true"
|
||||
BackOnTop="true"
|
||||
Title=""
|
||||
ShowProfile="false" />
|
||||
|
||||
@if (IsLoading)
|
||||
{
|
||||
<SpinnerLayout FullScreen="true"/>
|
||||
<SpinnerLayout FullScreen="true" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="container content">
|
||||
<div class="container content" style="overflow: auto;" id="topPage">
|
||||
<div class="container-primary-info">
|
||||
<div class="section-primary-info">
|
||||
<MudAvatar Style="height: 70px; width: 70px; font-size: 2rem; font-weight: bold" Color="Color.Secondary">
|
||||
@@ -29,11 +40,11 @@ else
|
||||
|
||||
<div class="personal-info">
|
||||
<span class="info-nome">@Anag.RagSoc</span>
|
||||
@if (Anag.Indirizzo != null)
|
||||
@if (!string.IsNullOrEmpty(Anag.Indirizzo))
|
||||
{
|
||||
<span class="info-section">@Anag.Indirizzo</span>
|
||||
}
|
||||
@if (Anag is { Citta: not null, Cap: not null, Prov: not null })
|
||||
@if (!string.IsNullOrEmpty(Anag.Cap) && !string.IsNullOrEmpty(Anag.Citta) && !string.IsNullOrEmpty(Anag.Prov))
|
||||
{
|
||||
<span class="info-section">@($"{Anag.Cap} - {Anag.Citta} ({Anag.Prov})")</span>
|
||||
}
|
||||
@@ -48,9 +59,7 @@ else
|
||||
{
|
||||
<div>
|
||||
<span class="info-title">Telefono</span>
|
||||
<span class="info-text">
|
||||
@Anag.Telefono
|
||||
</span>
|
||||
<span class="info-text">@Anag.Telefono</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -58,9 +67,7 @@ else
|
||||
{
|
||||
<div>
|
||||
<span class="info-title">P. IVA</span>
|
||||
<span class="info-text">
|
||||
@Anag.PartIva
|
||||
</span>
|
||||
<span class="info-text">@Anag.PartIva</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -70,9 +77,7 @@ else
|
||||
{
|
||||
<div>
|
||||
<span class="info-title">E-mail</span>
|
||||
<span class="info-text">
|
||||
@Anag.EMail
|
||||
</span>
|
||||
<span class="info-text">@Anag.EMail</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -80,31 +85,45 @@ else
|
||||
{
|
||||
<div>
|
||||
<span class="info-title">Agente</span>
|
||||
<span class="info-text">
|
||||
@Agente.FullName
|
||||
</span>
|
||||
<span class="info-text">@Agente.FullName</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<MudTabs TabPanelClass="custom-tab-panel" Elevation="2" Rounded="true" PanelClass="pt-2" Centered="true">
|
||||
<MudTabPanel Text="Contatti">
|
||||
@if (PersRif is { Count: > 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="tab3" checked="@(ActiveTab == 2)">
|
||||
|
||||
<div class="box">
|
||||
<ul class="tab-list">
|
||||
<li class="tab-item">
|
||||
<label class="tab-trigger" for="tab1" @onclick="() => SwitchTab(0)">Contatti</label>
|
||||
</li>
|
||||
<li class="tab-item">
|
||||
<label class="tab-trigger" for="tab2" @onclick="() => SwitchTab(1)">Commesse</label>
|
||||
</li>
|
||||
<li class="tab-item">
|
||||
<label class="tab-trigger" for="tab3" @onclick="() => SwitchTab(2)">Attivit<69></label>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="tab-container">
|
||||
<!-- Tab Contatti -->
|
||||
<div class="tab-content" style="display: @(ActiveTab == 0 ? "block" : "none")">
|
||||
@if (PersRif?.Count > 0)
|
||||
{
|
||||
<div style="margin-top: 1rem;" class="container-pers-rif">
|
||||
<Virtualize Items="PersRif" Context="person">
|
||||
@{
|
||||
var index = PersRif.IndexOf(person);
|
||||
var isLast = index == PersRif.Count - 1;
|
||||
}
|
||||
<ContactCard Contact="person"/>
|
||||
@if (!isLast)
|
||||
<div class="container-pers-rif">
|
||||
@foreach (var person in PersRif)
|
||||
{
|
||||
<ContactCard Contact="person" />
|
||||
@if (person != PersRif.Last())
|
||||
{
|
||||
<div class="divider"></div>
|
||||
}
|
||||
</Virtualize>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -117,92 +136,644 @@ else
|
||||
Aggiungi contatto
|
||||
</MudButton>
|
||||
</div>
|
||||
</MudTabPanel>
|
||||
<MudTabPanel Text="Commesse">
|
||||
@if (Commesse.IsNullOrEmpty())
|
||||
</div>
|
||||
|
||||
<!-- Tab Commesse -->
|
||||
<div class="tab-content" style="display: @(ActiveTab == 1 ? "block" : "none")">
|
||||
@if (IsLoadingCommesse)
|
||||
{
|
||||
<NoDataAvailable Text="Nessuna commessa presente"/>
|
||||
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-7" />
|
||||
}
|
||||
else
|
||||
else if (Commesse?.Count == 0)
|
||||
{
|
||||
<Virtualize Items="Commesse" Context="commessa">
|
||||
<CommessaCard Commessa="commessa"/>
|
||||
</Virtualize>
|
||||
<NoDataAvailable Text="Nessuna commessa presente" />
|
||||
}
|
||||
</MudTabPanel>
|
||||
</MudTabs>
|
||||
else if (Commesse != null)
|
||||
{
|
||||
<!-- Filtri e ricerca -->
|
||||
<div class="input-card clearButton">
|
||||
<MudTextField T="string?"
|
||||
Placeholder="Cerca..."
|
||||
Variant="Variant.Text"
|
||||
@bind-Value="SearchTermCommesse"
|
||||
OnDebounceIntervalElapsed="() => ApplyFiltersCommesse()"
|
||||
DebounceInterval="500" />
|
||||
</div>
|
||||
|
||||
<div class="commesse-container">
|
||||
@if (IsLoadingSteps)
|
||||
{
|
||||
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-3" />
|
||||
}
|
||||
|
||||
@foreach (var commessa in CurrentPageCommesse)
|
||||
{
|
||||
<div class="commessa-wrapper" style="@(IsLoadingStep(commessa.CodJcom) ? "opacity: 0.7;" : "")">
|
||||
@if (Steps.TryGetValue(commessa.CodJcom, out var steps))
|
||||
{
|
||||
<CommessaCard Steps="@steps" RagSoc="@Anag.RagSoc" Commessa="commessa" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<CommessaCard Steps="null" RagSoc="@Anag.RagSoc" Commessa="commessa" />
|
||||
@if (IsLoadingStep(commessa.CodJcom))
|
||||
{
|
||||
<MudProgressLinear Indeterminate="true" Color="Color.Primary" Class="my-1" Style="height: 2px;" />
|
||||
}
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (TotalPagesCommesse > 1)
|
||||
{
|
||||
<div class="custom-pagination">
|
||||
<MudPagination BoundaryCount="1" MiddleCount="1" Count="@TotalPagesCommesse"
|
||||
@bind-Selected="SelectedPageCommesse"
|
||||
Color="Color.Primary" />
|
||||
</div>
|
||||
|
||||
<div class="SelectedPageSize">
|
||||
<MudSelect @bind-Value="SelectedPageSizeCommesse"
|
||||
Variant="Variant.Text"
|
||||
Label="Elementi per pagina"
|
||||
Dense="true"
|
||||
Style="width: 100%;">
|
||||
<MudSelectItem Value="5">5</MudSelectItem>
|
||||
<MudSelectItem Value="10">10</MudSelectItem>
|
||||
<MudSelectItem Value="15">15</MudSelectItem>
|
||||
</MudSelect>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<!-- Tab Attivit<69> -->
|
||||
<div class="tab-content" style="display: @(ActiveTab == 2 ? "block" : "none")">
|
||||
@if (ActivityIsLoading)
|
||||
{
|
||||
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-7" />
|
||||
}
|
||||
else if (ActivityList?.Count == 0)
|
||||
{
|
||||
<NoDataAvailable Text="Nessuna attivit<69> presente" />
|
||||
}
|
||||
else if (ActivityList != null)
|
||||
{
|
||||
<!-- Filtri e ricerca -->
|
||||
<div class="input-card clearButton">
|
||||
<MudTextField T="string?"
|
||||
Placeholder="Cerca..."
|
||||
Variant="Variant.Text"
|
||||
@bind-Value="SearchTermActivity"
|
||||
OnDebounceIntervalElapsed="() => ApplyFiltersActivity()"
|
||||
DebounceInterval="500" />
|
||||
</div>
|
||||
|
||||
<div class="attivita-container">
|
||||
@foreach (var activity in CurrentPageActivity)
|
||||
{
|
||||
<ActivityCard ShowDate="true" Activity="activity" />
|
||||
}
|
||||
|
||||
@if (TotalPagesActivity > 1)
|
||||
{
|
||||
<div class="custom-pagination">
|
||||
<MudPagination BoundaryCount="1" MiddleCount="1" Count="@TotalPagesActivity"
|
||||
@bind-Selected="CurrentPageActivityIndex"
|
||||
Color="Color.Primary" />
|
||||
</div>
|
||||
|
||||
<div class="SelectedPageSize">
|
||||
<MudSelect @bind-Value="SelectedPageSizeActivity"
|
||||
Variant="Variant.Text"
|
||||
Label="Elementi per pagina"
|
||||
Dense="true"
|
||||
Style="width: 100%;">
|
||||
<MudSelectItem Value="5">5</MudSelectItem>
|
||||
<MudSelectItem Value="15">15</MudSelectItem>
|
||||
<MudSelectItem Value="30">30</MudSelectItem>
|
||||
</MudSelect>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<MudScrollToTop Selector="#topPage" VisibleCssClass="visible absolute" TopOffset="100" HiddenCssClass="invisible">
|
||||
<MudFab Size="Size.Small" Color="Color.Primary" StartIcon="@Icons.Material.Rounded.KeyboardArrowUp" />
|
||||
</MudScrollToTop>
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter] public string CodContact { get; set; }
|
||||
[Parameter] public string CodContact { get; set; } = string.Empty;
|
||||
[Parameter] public bool IsContact { get; set; }
|
||||
|
||||
// Dati principali
|
||||
private ContactDTO Anag { get; set; } = new();
|
||||
private List<PersRifDTO>? PersRif { get; set; }
|
||||
private List<JtbComt> Commesse { get; set; }
|
||||
private List<JtbComt>? Commesse { get; set; }
|
||||
private List<ActivityDTO> ActivityList { get; set; } = [];
|
||||
private StbUser? Agente { get; set; }
|
||||
private Dictionary<string, List<CRMJobStepDTO>?> Steps { get; set; } = new();
|
||||
|
||||
// Stati di caricamento
|
||||
private bool IsLoading { get; set; } = true;
|
||||
private bool IsLoadingCommesse { get; set; } = true;
|
||||
private bool ActivityIsLoading { get; set; } = true;
|
||||
private bool IsLoadingSteps { get; set; }
|
||||
private readonly HashSet<string> _loadingSteps = [];
|
||||
|
||||
// Gestione tab
|
||||
private int ActiveTab { get; set; }
|
||||
|
||||
// Paginazione e filtri per COMMESSE
|
||||
private int _selectedPageCommesse = 1;
|
||||
private int _selectedPageSizeCommesse = 5;
|
||||
private string _searchTermCommesse = string.Empty;
|
||||
private List<JtbComt> _filteredCommesse = [];
|
||||
|
||||
// Paginazione e filtri per ATTIVIT<49>
|
||||
private int _currentPageActivity = 1;
|
||||
private int _selectedPageSizeActivity = 5;
|
||||
private string _searchTermActivity = string.Empty;
|
||||
private List<ActivityDTO> _filteredActivity = [];
|
||||
|
||||
// Cancellation tokens per gestire le richieste asincrone
|
||||
private CancellationTokenSource? _loadingCts;
|
||||
private CancellationTokenSource? _stepsCts;
|
||||
|
||||
// Timer per il debounce della ricerca
|
||||
private Timer? _searchTimerCommesse;
|
||||
private Timer? _searchTimerActivity;
|
||||
private const int SearchDelayMs = 300;
|
||||
|
||||
#region Properties per Commesse
|
||||
|
||||
private int SelectedPageCommesse
|
||||
{
|
||||
get => _selectedPageCommesse;
|
||||
set
|
||||
{
|
||||
if (_selectedPageCommesse == value) return;
|
||||
_selectedPageCommesse = value;
|
||||
_ = LoadStepsForCurrentPageAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private int SelectedPageSizeCommesse
|
||||
{
|
||||
get => _selectedPageSizeCommesse;
|
||||
set
|
||||
{
|
||||
if (_selectedPageSizeCommesse == value) return;
|
||||
_selectedPageSizeCommesse = value;
|
||||
_selectedPageCommesse = 1;
|
||||
ApplyFiltersCommesse();
|
||||
_ = LoadStepsForCurrentPageAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private string SearchTermCommesse
|
||||
{
|
||||
get => _searchTermCommesse;
|
||||
set
|
||||
{
|
||||
if (_searchTermCommesse == value) return;
|
||||
_searchTermCommesse = value;
|
||||
|
||||
_searchTimerCommesse?.Dispose();
|
||||
_searchTimerCommesse = new Timer(async _ => await InvokeAsync(ApplyFiltersCommesse), null, SearchDelayMs, Timeout.Infinite);
|
||||
}
|
||||
}
|
||||
|
||||
private List<JtbComt> FilteredCommesse
|
||||
{
|
||||
get => _filteredCommesse;
|
||||
set
|
||||
{
|
||||
_filteredCommesse = value;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private int TotalPagesCommesse =>
|
||||
FilteredCommesse.Count == 0 ? 1 : (int)Math.Ceiling(FilteredCommesse.Count / (double)SelectedPageSizeCommesse);
|
||||
|
||||
private IEnumerable<JtbComt> CurrentPageCommesse =>
|
||||
FilteredCommesse.Skip((SelectedPageCommesse - 1) * SelectedPageSizeCommesse).Take(SelectedPageSizeCommesse);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties per Attivit<69>
|
||||
|
||||
private int CurrentPageActivityIndex
|
||||
{
|
||||
get => _currentPageActivity;
|
||||
set
|
||||
{
|
||||
if (_currentPageActivity == value) return;
|
||||
_currentPageActivity = value;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private int SelectedPageSizeActivity
|
||||
{
|
||||
get => _selectedPageSizeActivity;
|
||||
set
|
||||
{
|
||||
if (_selectedPageSizeActivity == value) return;
|
||||
_selectedPageSizeActivity = value;
|
||||
_currentPageActivity = 1;
|
||||
ApplyFiltersActivity();
|
||||
}
|
||||
}
|
||||
|
||||
private string SearchTermActivity
|
||||
{
|
||||
get => _searchTermActivity;
|
||||
set
|
||||
{
|
||||
if (_searchTermActivity == value) return;
|
||||
_searchTermActivity = value;
|
||||
|
||||
_searchTimerActivity?.Dispose();
|
||||
_searchTimerActivity = new Timer(async _ => await InvokeAsync(ApplyFiltersActivity), null, SearchDelayMs, Timeout.Infinite);
|
||||
}
|
||||
}
|
||||
|
||||
private List<ActivityDTO> FilteredActivity
|
||||
{
|
||||
get => _filteredActivity;
|
||||
set
|
||||
{
|
||||
_filteredActivity = value;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private int TotalPagesActivity =>
|
||||
FilteredActivity.Count == 0 ? 1 : (int)Math.Ceiling(FilteredActivity.Count / (double)SelectedPageSizeActivity);
|
||||
|
||||
private IEnumerable<ActivityDTO> CurrentPageActivity =>
|
||||
FilteredActivity.Skip((CurrentPageActivityIndex - 1) * SelectedPageSizeActivity).Take(SelectedPageSizeActivity);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Lifecycle Methods
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await LoadData();
|
||||
try
|
||||
{
|
||||
_loadingCts = new CancellationTokenSource();
|
||||
|
||||
if (UserState.CodUser?.Equals(CodContact) == true)
|
||||
{
|
||||
LoadDataFromSession();
|
||||
}
|
||||
else
|
||||
{
|
||||
await LoadDataAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Errore in OnInitializedAsync: {ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsLoading = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadData()
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
_loadingCts?.CancelAsync();
|
||||
_loadingCts?.Dispose();
|
||||
_stepsCts?.CancelAsync();
|
||||
_stepsCts?.Dispose();
|
||||
_searchTimerCommesse?.DisposeAsync();
|
||||
_searchTimerActivity?.DisposeAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Data Loading Methods
|
||||
|
||||
private async Task LoadDataAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
await LoadAnagAsync();
|
||||
await LoadPersRifAsync();
|
||||
_ = LoadActivity();
|
||||
|
||||
if (!string.IsNullOrEmpty(Anag.CodVage))
|
||||
{
|
||||
Agente = (await ManageData.GetTable<StbUser>(x => x.UserCode != null && x.UserCode.Equals(Anag.CodVage)))
|
||||
.LastOrDefault();
|
||||
}
|
||||
|
||||
SaveDataToSession();
|
||||
|
||||
_ = Task.Run(async () => await LoadCommesseAsync());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Errore nel caricamento dati: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadAnagAsync()
|
||||
{
|
||||
if (IsContact)
|
||||
{
|
||||
var clie = (await ManageData.GetTable<AnagClie>(x => x.CodAnag.Equals(CodContact))).Last();
|
||||
var clie = (await ManageData.GetTable<AnagClie>(x => x.CodAnag!.Equals(CodContact))).Last();
|
||||
Anag = Mapper.Map<ContactDTO>(clie);
|
||||
}
|
||||
else
|
||||
{
|
||||
var pros = (await ManageData.GetTable<PtbPros>(x => x.CodPpro.Equals(CodContact))).Last();
|
||||
var pros = (await ManageData.GetTable<PtbPros>(x => x.CodPpro!.Equals(CodContact))).Last();
|
||||
Anag = Mapper.Map<ContactDTO>(pros);
|
||||
}
|
||||
|
||||
await LoadPersRif();
|
||||
|
||||
Commesse = await ManageData.GetTable<JtbComt>(x => x.CodAnag != null && x.CodAnag.Equals(CodContact));
|
||||
|
||||
if (Anag.CodVage != null)
|
||||
{
|
||||
Agente = (await ManageData.GetTable<StbUser>(x => x.UserCode != null && x.UserCode.Equals(Anag.CodVage))).LastOrDefault();
|
||||
}
|
||||
|
||||
IsLoading = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task LoadPersRif()
|
||||
private async Task LoadPersRifAsync()
|
||||
{
|
||||
if (IsContact)
|
||||
{
|
||||
var pers = await ManageData.GetTable<VtbCliePersRif>(x => x.CodAnag.Equals(Anag.CodContact));
|
||||
var pers = await ManageData.GetTable<VtbCliePersRif>(x => x.CodAnag!.Equals(Anag.CodContact));
|
||||
PersRif = Mapper.Map<List<PersRifDTO>>(pers);
|
||||
}
|
||||
else
|
||||
{
|
||||
var pers = await ManageData.GetTable<PtbProsRif>(x => x.CodPpro.Equals(Anag.CodContact));
|
||||
var pers = await ManageData.GetTable<PtbProsRif>(x => x.CodPpro!.Equals(Anag.CodContact));
|
||||
PersRif = Mapper.Map<List<PersRifDTO>>(pers);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadActivity()
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
var activities = await IntegryApiService.RetrieveActivity(new CRMRetrieveActivityRequestDTO { CodAnag = Anag.CodContact });
|
||||
ActivityList = Mapper.Map<List<ActivityDTO>>(activities)
|
||||
.OrderByDescending(x =>
|
||||
(x.EffectiveTime ?? x.EstimatedTime) ?? x.DataInsAct
|
||||
).ToList();
|
||||
});
|
||||
|
||||
UserState.Activitys = ActivityList;
|
||||
|
||||
ApplyFiltersActivity();
|
||||
|
||||
ActivityIsLoading = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task LoadCommesseAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
IsLoadingCommesse = true;
|
||||
|
||||
Commesse = await ManageData.GetTable<JtbComt>(x => x.CodAnag != null && x.CodAnag.Equals(CodContact));
|
||||
|
||||
Commesse = Commesse?
|
||||
.OrderByDescending(x => x.CodJcom)
|
||||
.ToList();
|
||||
|
||||
UserState.Commesse = Commesse;
|
||||
|
||||
ApplyFiltersCommesse();
|
||||
|
||||
await LoadStepsForCurrentPageAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Errore nel caricamento commesse: {ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsLoadingCommesse = false;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadDataFromSession()
|
||||
{
|
||||
Anag = UserState.Anag;
|
||||
PersRif = UserState.PersRif;
|
||||
Commesse = UserState.Commesse;
|
||||
Agente = UserState.Agente;
|
||||
Steps = UserState.Steps;
|
||||
ActivityList = UserState.Activitys;
|
||||
|
||||
ApplyFiltersCommesse();
|
||||
ApplyFiltersActivity();
|
||||
|
||||
IsLoadingCommesse = false;
|
||||
ActivityIsLoading = false;
|
||||
}
|
||||
|
||||
private void SaveDataToSession()
|
||||
{
|
||||
UserState.CodUser = CodContact;
|
||||
UserState.Anag = Anag;
|
||||
UserState.PersRif = PersRif;
|
||||
UserState.Agente = Agente;
|
||||
UserState.Steps = Steps;
|
||||
UserState.Activitys = ActivityList;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Steps Loading Methods
|
||||
|
||||
private async Task LoadStepsForCurrentPageAsync()
|
||||
{
|
||||
if (CurrentPageCommesse?.Any() != true) return;
|
||||
|
||||
try
|
||||
{
|
||||
_stepsCts?.Cancel();
|
||||
_stepsCts = new CancellationTokenSource();
|
||||
var token = _stepsCts.Token;
|
||||
|
||||
IsLoadingSteps = true;
|
||||
|
||||
var tasksToLoad = new List<Task>();
|
||||
var semaphore = new SemaphoreSlim(3); // Limita a 3 richieste simultanee
|
||||
|
||||
foreach (var commessa in CurrentPageCommesse.Where(c => !Steps.ContainsKey(c.CodJcom)))
|
||||
{
|
||||
if (token.IsCancellationRequested) break;
|
||||
|
||||
tasksToLoad.Add(LoadStepForCommessaAsync(commessa.CodJcom, semaphore, token));
|
||||
}
|
||||
|
||||
if (tasksToLoad.Any())
|
||||
{
|
||||
await Task.WhenAll(tasksToLoad);
|
||||
UserState.Steps = Steps;
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
// Operazione annullata, non fare nulla
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Errore nel caricamento steps: {ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsLoadingSteps = false;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadStepForCommessaAsync(string codJcom, SemaphoreSlim semaphore, CancellationToken token)
|
||||
{
|
||||
await semaphore.WaitAsync(token);
|
||||
|
||||
try
|
||||
{
|
||||
_loadingSteps.Add(codJcom);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
var jobProgress = await IntegryApiService.RetrieveJobProgress(codJcom);
|
||||
|
||||
if (!token.IsCancellationRequested)
|
||||
{
|
||||
Steps[codJcom] = jobProgress.Steps;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Errore nel caricamento step per {codJcom}: {ex.Message}");
|
||||
if (!token.IsCancellationRequested)
|
||||
{
|
||||
Steps[codJcom] = null;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_loadingSteps.Remove(codJcom);
|
||||
semaphore.Release();
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsLoadingStep(string codJcom) => _loadingSteps.Contains(codJcom);
|
||||
|
||||
#endregion
|
||||
|
||||
#region UI Methods
|
||||
|
||||
private void SwitchTab(int tabIndex)
|
||||
{
|
||||
ActiveTab = tabIndex;
|
||||
|
||||
if (tabIndex == 1 && Commesse == null)
|
||||
{
|
||||
_ = Task.Run(async () => await LoadCommesseAsync());
|
||||
}
|
||||
else if (tabIndex == 1 && Steps.IsNullOrEmpty())
|
||||
{
|
||||
_ = Task.Run(async () => await LoadStepsForCurrentPageAsync());
|
||||
}
|
||||
else if (tabIndex == 2 && ActivityList?.Count == 0)
|
||||
{
|
||||
_ = Task.Run(async () => await LoadActivity());
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyFiltersCommesse()
|
||||
{
|
||||
if (Commesse == null)
|
||||
{
|
||||
FilteredCommesse = [];
|
||||
return;
|
||||
}
|
||||
|
||||
var filtered = Commesse.AsEnumerable();
|
||||
if (!string.IsNullOrWhiteSpace(SearchTermCommesse))
|
||||
{
|
||||
var searchLower = SearchTermCommesse.ToLowerInvariant();
|
||||
filtered = filtered.Where(c =>
|
||||
c.CodJcom?.ToLowerInvariant().Contains(searchLower) == true ||
|
||||
c.Descrizione?.ToLowerInvariant().Contains(searchLower) == true ||
|
||||
c.CodAnag?.ToLowerInvariant().Contains(searchLower) == true);
|
||||
}
|
||||
|
||||
FilteredCommesse = filtered.ToList();
|
||||
if (SelectedPageCommesse > TotalPagesCommesse && TotalPagesCommesse > 0) _selectedPageCommesse = 1;
|
||||
|
||||
_ = LoadStepsForCurrentPageAsync();
|
||||
}
|
||||
|
||||
private void ApplyFiltersActivity()
|
||||
{
|
||||
var filtered = ActivityList.AsEnumerable();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(SearchTermActivity))
|
||||
{
|
||||
var searchLower = SearchTermActivity.ToLowerInvariant();
|
||||
filtered = filtered.Where(a =>
|
||||
a.ActivityDescription?.ToLowerInvariant().Contains(searchLower) == true ||
|
||||
a.ActivityId?.ToLowerInvariant().Contains(searchLower) == true);
|
||||
}
|
||||
|
||||
FilteredActivity = filtered.ToList();
|
||||
if (CurrentPageActivityIndex > TotalPagesActivity && TotalPagesActivity > 0)
|
||||
{
|
||||
_currentPageActivity = 1;
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearSearchCommesse()
|
||||
{
|
||||
SearchTermCommesse = string.Empty;
|
||||
ApplyFiltersCommesse();
|
||||
}
|
||||
|
||||
private void ClearSearchActivity()
|
||||
{
|
||||
SearchTermActivity = string.Empty;
|
||||
ApplyFiltersActivity();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Modal Methods
|
||||
|
||||
private async Task OpenPersRifForm()
|
||||
{
|
||||
var result = await ModalHelpers.OpenPersRifForm(Dialog, null, Anag, PersRif);
|
||||
|
||||
if (result is { Canceled: false, Data: not null } && result.Data.GetType() == typeof(PersRifDTO))
|
||||
{
|
||||
await LoadPersRif();
|
||||
await LoadPersRifAsync();
|
||||
UserState.PersRif = PersRif;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OpenUserForm(ContactDTO anag)
|
||||
{
|
||||
var result = await ModalHelpers.OpenUserForm(Dialog, anag);
|
||||
|
||||
if (result is { Canceled: false })
|
||||
{
|
||||
await LoadAnagAsync();
|
||||
SaveDataToSession();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -87,6 +87,7 @@
|
||||
box-shadow: var(--custom-box-shadow);
|
||||
padding: .25rem 0;
|
||||
border-radius: 16px;
|
||||
margin-bottom: 0 !important;
|
||||
}
|
||||
|
||||
.container-button .divider {
|
||||
@@ -156,4 +157,137 @@
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.commesse-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
.attivita-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
/*--------------
|
||||
TabPanel
|
||||
----------------*/
|
||||
.box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: -webkit-fill-available;
|
||||
box-shadow: var(--custom-box-shadow);
|
||||
border-radius: 16px;
|
||||
overflow: clip;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
/* nascondo gli input */
|
||||
|
||||
.tab-toggle { display: none; }
|
||||
|
||||
.tab-list {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
display: flex;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
background: var(--mud-palette-surface);
|
||||
}
|
||||
|
||||
/* la lineetta */
|
||||
|
||||
.tab-list::before {
|
||||
content: '';
|
||||
display: block;
|
||||
height: 3px;
|
||||
width: calc(100% / 3);
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
background-color: var(--mud-palette-primary);
|
||||
transition: transform .3s;
|
||||
}
|
||||
|
||||
.tab-item {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
transition: .3s;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.tab-trigger {
|
||||
display: block;
|
||||
padding: 10px 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* tab attivo */
|
||||
|
||||
#tab1:checked ~ .box .tab-list .tab-item:nth-child(1),
|
||||
#tab2:checked ~ .box .tab-list .tab-item:nth-child(2),
|
||||
#tab3:checked ~ .box .tab-list .tab-item:nth-child(3) {
|
||||
opacity: 1;
|
||||
font-weight: bold;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* spostamento lineetta */
|
||||
|
||||
#tab1:checked ~ .box .tab-list::before { transform: translateX(0%); }
|
||||
|
||||
#tab2:checked ~ .box .tab-list::before { transform: translateX(100%); }
|
||||
|
||||
#tab3:checked ~ .box .tab-list::before { transform: translateX(200%); }
|
||||
|
||||
.tab-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: -webkit-fill-available;
|
||||
}
|
||||
|
||||
.tab-content {
|
||||
display: none;
|
||||
flex: 1;
|
||||
overflow-y: hidden;
|
||||
animation: fade .3s ease;
|
||||
padding: .5rem;
|
||||
}
|
||||
|
||||
.tab-content::-webkit-scrollbar { width: 3px; }
|
||||
|
||||
.tab-content::-webkit-scrollbar-thumb {
|
||||
background: #bbb;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
#tab1:checked ~ .tab-container .tab-content:nth-child(1),
|
||||
#tab2:checked ~ .tab-container .tab-content:nth-child(2),
|
||||
#tab3:checked ~ .tab-container .tab-content:nth-child(3) {
|
||||
display: block;
|
||||
}
|
||||
|
||||
@keyframes fade {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(5px);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.custom-pagination ::deep ul { padding-left: 0 !important; }
|
||||
|
||||
.SelectedPageSize {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.FilterSection {
|
||||
display: flex;
|
||||
}
|
||||
@@ -6,11 +6,15 @@
|
||||
@using salesbook.Shared.Components.SingleElements.BottomSheet
|
||||
@using salesbook.Shared.Components.Layout.Spinner
|
||||
@using salesbook.Shared.Components.SingleElements
|
||||
@using salesbook.Shared.Core.Dto.PageState
|
||||
@using salesbook.Shared.Core.Dto.Users
|
||||
@using salesbook.Shared.Core.Entity
|
||||
@using salesbook.Shared.Core.Messages.Contact
|
||||
@inject IManageDataService ManageData
|
||||
@inject NewContactService NewContact
|
||||
@inject FilterUserDTO Filter
|
||||
@inject UserListState UserState
|
||||
@implements IDisposable
|
||||
|
||||
<HeaderLayout Title="Contatti"/>
|
||||
|
||||
@@ -67,25 +71,47 @@
|
||||
private bool OpenFilter { get; set; }
|
||||
private string TypeUser { get; set; } = "all";
|
||||
|
||||
protected override void OnInitialized()
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
NewContact.OnContactCreated += async response => await OnUserCreated(response);
|
||||
Console.WriteLine($"Filter HashCode: {Filter.GetHashCode()} - IsInitialized: {Filter.IsInitialized}");
|
||||
}
|
||||
IsLoading = true;
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender)
|
||||
if (!UserState.IsLoaded)
|
||||
{
|
||||
UserState.OnUsersLoaded += OnUsersLoaded;
|
||||
}
|
||||
else
|
||||
{
|
||||
await LoadData();
|
||||
LoadFromSession();
|
||||
FilterUsers();
|
||||
}
|
||||
|
||||
NewContact.OnContactCreated += async response => await OnUserCreated(response);
|
||||
}
|
||||
|
||||
private void OnUsersLoaded()
|
||||
{
|
||||
InvokeAsync(async () =>
|
||||
{
|
||||
await LoadData();
|
||||
LoadFromSession();
|
||||
FilterUsers();
|
||||
});
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
UserState.OnUsersLoaded -= OnUsersLoaded;
|
||||
}
|
||||
|
||||
private void LoadFromSession()
|
||||
{
|
||||
GroupedUserList = UserState.GroupedUserList!;
|
||||
FilteredGroupedUserList = UserState.FilteredGroupedUserList!;
|
||||
}
|
||||
|
||||
private async Task LoadData()
|
||||
{
|
||||
IsLoading = true;
|
||||
StateHasChanged();
|
||||
|
||||
if (!Filter.IsInitialized)
|
||||
{
|
||||
var loggedUser = (await ManageData.GetTable<StbUser>(x => x.UserName.Equals(UserSession.User.Username))).Last();
|
||||
@@ -95,50 +121,6 @@
|
||||
|
||||
Filter.IsInitialized = true;
|
||||
}
|
||||
|
||||
var users = await ManageData.GetContact();
|
||||
|
||||
var sortedUsers = users
|
||||
.Where(u => !string.IsNullOrWhiteSpace(u.RagSoc))
|
||||
.OrderBy(u =>
|
||||
{
|
||||
var firstChar = char.ToUpper(u.RagSoc[0]);
|
||||
return char.IsLetter(firstChar) ? firstChar.ToString() : "ZZZ";
|
||||
})
|
||||
.ThenBy(u => u.RagSoc)
|
||||
.ToList();
|
||||
|
||||
GroupedUserList = [];
|
||||
|
||||
string? lastHeader = null;
|
||||
foreach (var user in sortedUsers)
|
||||
{
|
||||
var firstChar = char.ToUpper(user.RagSoc[0]);
|
||||
var currentLetter = char.IsLetter(firstChar) ? firstChar.ToString() : "#";
|
||||
|
||||
var showHeader = currentLetter != lastHeader;
|
||||
lastHeader = currentLetter;
|
||||
|
||||
GroupedUserList.Add(new UserDisplayItem
|
||||
{
|
||||
User = user,
|
||||
ShowHeader = showHeader,
|
||||
HeaderLetter = currentLetter
|
||||
});
|
||||
}
|
||||
|
||||
FilterUsers();
|
||||
|
||||
IsLoading = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
|
||||
private class UserDisplayItem
|
||||
{
|
||||
public required ContactDTO User { get; set; }
|
||||
public bool ShowHeader { get; set; }
|
||||
public string? HeaderLetter { get; set; }
|
||||
}
|
||||
|
||||
private void FilterUsers() => FilterUsers(false);
|
||||
@@ -205,6 +187,9 @@
|
||||
}
|
||||
|
||||
FilteredGroupedUserList = result;
|
||||
|
||||
IsLoading = false;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task OnUserCreated(CRMCreateContactResponseDTO response)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
@using salesbook.Shared.Core.Dto
|
||||
@using salesbook.Shared.Core.Dto.Activity
|
||||
@using salesbook.Shared.Core.Entity
|
||||
@using salesbook.Shared.Core.Helpers.Enum
|
||||
@using salesbook.Shared.Core.Interface
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
@using salesbook.Shared.Core.Dto
|
||||
@using salesbook.Shared.Core.Dto.Activity
|
||||
@using salesbook.Shared.Core.Entity
|
||||
@using salesbook.Shared.Core.Interface
|
||||
@inject IManageDataService ManageData
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
@using salesbook.Shared.Core.Dto
|
||||
@using salesbook.Shared.Core.Dto.Activity
|
||||
@using salesbook.Shared.Core.Entity
|
||||
@using salesbook.Shared.Core.Helpers.Enum
|
||||
@inject IDialogService Dialog
|
||||
@@ -28,11 +29,25 @@
|
||||
<span class="activity-hours">
|
||||
@if (Activity.EffectiveTime is null)
|
||||
{
|
||||
@($"{Activity.EstimatedTime:t}")
|
||||
if (ShowDate)
|
||||
{
|
||||
@($"{Activity.EstimatedTime:g}")
|
||||
}
|
||||
else
|
||||
{
|
||||
@($"{Activity.EstimatedTime:t}")
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@($"{Activity.EffectiveTime:t}")
|
||||
if (ShowDate)
|
||||
{
|
||||
@($"{Activity.EffectiveTime:g}")
|
||||
}
|
||||
else
|
||||
{
|
||||
@($"{Activity.EffectiveTime:t}")
|
||||
}
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
@@ -67,6 +82,8 @@
|
||||
[Parameter] public EventCallback<string> ActivityChanged { get; set; }
|
||||
[Parameter] public EventCallback<ActivityDTO> ActivityDeleted { get; set; }
|
||||
|
||||
[Parameter] public bool ShowDate { get; set; }
|
||||
|
||||
private TimeSpan? Durata { get; set; }
|
||||
|
||||
protected override void OnParametersSet()
|
||||
@@ -81,7 +98,7 @@
|
||||
|
||||
private async Task OpenActivity()
|
||||
{
|
||||
var result = await ModalHelpers.OpenActivityForm(Dialog, null, Activity.ActivityId);
|
||||
var result = await ModalHelpers.OpenActivityForm(Dialog, Activity, null);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
@using salesbook.Shared.Core.Dto
|
||||
@using salesbook.Shared.Core.Interface
|
||||
@inject IIntegryApiService IntegryApiService
|
||||
@inject IAttachedService AttachedService
|
||||
|
||||
<div @onclick="OpenAttached" class="activity-card">
|
||||
<div class="activity-left-section">
|
||||
<div class="activity-body-section">
|
||||
<div class="title-section">
|
||||
<MudText Class="activity-title" Typo="Typo.body1" HtmlTag="h3">
|
||||
@(Attached.Description.IsNullOrEmpty() ? Attached.FileName : Attached.Description)
|
||||
</MudText>
|
||||
<div class="activity-hours-section">
|
||||
<span class="activity-hours">@($"{Attached.DateAttached:g}")</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="activity-info-section">
|
||||
@if (Attached.IsActivity)
|
||||
{
|
||||
<MudChip T="string" Color="Color.Primary" Variant="Variant.Outlined" Icon="@IconConstants.Chip.Tag" Size="Size.Small">
|
||||
@Attached.RefAttached
|
||||
</MudChip>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudChip T="string" Color="Color.Warning" Variant="Variant.Outlined" Icon="@IconConstants.Chip.FileTextLine" Size="Size.Small">
|
||||
@Attached.RefAttached
|
||||
</MudChip>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public CRMAttachedResponseDTO Attached { get; set; } = new();
|
||||
|
||||
private async Task OpenAttached()
|
||||
{
|
||||
var bytes = await IntegryApiService.DownloadFileFromRefUuid(Attached.RefUuid, Attached.FileName);
|
||||
await AttachedService.OpenFile(bytes, Attached.FileName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
.activity-card {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: .5rem .5rem;
|
||||
border-radius: 12px;
|
||||
line-height: normal;
|
||||
box-shadow: var(--custom-box-shadow);
|
||||
}
|
||||
|
||||
.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 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.title-section {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.activity-hours {
|
||||
color: var(--mud-palette-gray-darker);
|
||||
font-weight: 600;
|
||||
font-size: .8rem;
|
||||
}
|
||||
|
||||
.activity-hours-section ::deep .mud-chip { margin: 5px 0 0 !important; }
|
||||
|
||||
.activity-body-section {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.title-section ::deep > .activity-title {
|
||||
font-weight: 700 !important;
|
||||
margin: 0 !important;
|
||||
line-height: normal !important;
|
||||
color: var(--mud-palette-text-primary);
|
||||
}
|
||||
|
||||
.activity-body-section ::deep > .activity-subtitle {
|
||||
color: var(--mud-palette-gray-darker);
|
||||
margin: .2rem 0 !important;
|
||||
line-height: normal !important;
|
||||
}
|
||||
|
||||
.activity-info-section {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: .25rem;
|
||||
}
|
||||
@@ -1,24 +1,68 @@
|
||||
@using salesbook.Shared.Core.Dto.JobProgress
|
||||
@using salesbook.Shared.Core.Dto.PageState
|
||||
@using salesbook.Shared.Core.Entity
|
||||
@inject JobSteps JobSteps
|
||||
|
||||
<div style="margin-top: 1rem;" class="activity-card">
|
||||
<div @onclick="OpenPageCommessa" class="activity-card">
|
||||
<div class="activity-left-section">
|
||||
<div class="activity-body-section">
|
||||
<div class="title-section">
|
||||
<MudText Class="activity-title" Typo="Typo.body1" HtmlTag="h3">@Commessa.Descrizione</MudText>
|
||||
<MudText Class="activity-title" Typo="Typo.body1" HtmlTag="h3">@Commessa.CodJcom</MudText>
|
||||
<div class="activity-hours-section">
|
||||
<span class="activity-hours">
|
||||
@Commessa.CodJcom
|
||||
</span>
|
||||
@if (LastUpd is not null)
|
||||
{
|
||||
<span class="activity-hours">Aggiornato il @($"{LastUpd:d}")</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<span class="activity-title">@Commessa.Descrizione</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="activity-info-section">
|
||||
<MudChip T="string" Icon="@IconConstants.Chip.User" Size="Size.Small">Stato</MudChip>
|
||||
@if (Stato is not null)
|
||||
{
|
||||
<MudChip T="string" Variant="Variant.Outlined" Icon="@IconConstants.Chip.Stato" Size="Size.Small">@Stato</MudChip>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter] public JtbComt Commessa { get; set; } = new();
|
||||
[Parameter] public string RagSoc { get; set; } = "";
|
||||
[Parameter] public List<CRMJobStepDTO>? Steps { get; set; }
|
||||
|
||||
private string? Stato { get; set; }
|
||||
private DateTime? LastUpd { get; set; }
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
GetStepInfo();
|
||||
}
|
||||
|
||||
private void GetStepInfo()
|
||||
{
|
||||
if (Steps is null) return;
|
||||
|
||||
var lastBeforeSkip = Steps
|
||||
.TakeWhile(s => s.Status is { Skip: false })
|
||||
.LastOrDefault();
|
||||
|
||||
if (lastBeforeSkip is not null) Stato = lastBeforeSkip.StepName;
|
||||
|
||||
LastUpd = Steps
|
||||
.Where(s => s.Date.HasValue)
|
||||
.Select(s => s.Date!.Value)
|
||||
.DefaultIfEmpty()
|
||||
.Max();
|
||||
|
||||
if (LastUpd.Equals(DateTime.MinValue)) LastUpd = null;
|
||||
}
|
||||
|
||||
private void OpenPageCommessa()
|
||||
{
|
||||
JobSteps.Steps = Steps;
|
||||
NavigationManager.NavigateTo($"commessa/{Commessa.CodJcom}/{RagSoc}");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,8 +28,9 @@
|
||||
}
|
||||
|
||||
.activity-hours {
|
||||
font-weight: 700;
|
||||
color: var(--mud-palette-text-primary);
|
||||
color: var(--mud-palette-gray-darker);
|
||||
font-weight: 600;
|
||||
font-size: .8rem;
|
||||
}
|
||||
|
||||
.activity-hours-section ::deep .mud-chip { margin: 5px 0 0 !important; }
|
||||
@@ -40,13 +41,18 @@
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.title-section ::deep > .activity-title {
|
||||
.activity-title {
|
||||
font-weight: 800 !important;
|
||||
margin: 0 !important;
|
||||
line-height: normal !important;
|
||||
color: var(--mud-palette-text-primary);
|
||||
}
|
||||
|
||||
.title-section ::deep > .activity-title {
|
||||
font-weight: 600;
|
||||
color: var(--mud-palette-text-primary);
|
||||
}
|
||||
|
||||
.activity-body-section ::deep > .activity-subtitle {
|
||||
color: var(--mud-palette-gray-darker);
|
||||
margin: .2rem 0 !important;
|
||||
@@ -55,5 +61,7 @@
|
||||
|
||||
.activity-info-section {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: .25rem;
|
||||
}
|
||||
@@ -25,11 +25,23 @@
|
||||
@if (!Commesse.IsNullOrEmpty())
|
||||
{
|
||||
<div @onclick="OpenUser" class="container-commesse">
|
||||
@foreach (var commessa in Commesse!)
|
||||
|
||||
@for (var i = 0; i < Commesse!.Count; i++)
|
||||
{
|
||||
var commessa = Commesse[i];
|
||||
|
||||
<div class="commessa">
|
||||
<span>@($"{commessa.CodJcom} - {commessa.Descrizione}")</span>
|
||||
@if (i > 5 && Commesse.Count - i > 1)
|
||||
{
|
||||
<span>@($"E altre {Commesse.Count - i} commesse")</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>@($"{commessa.CodJcom} - {commessa.Descrizione}")</span>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (i > 5 && Commesse.Count - i > 1) break;
|
||||
}
|
||||
</div>
|
||||
}
|
||||
@@ -63,7 +75,8 @@
|
||||
|
||||
if (ShowSectionCommesse)
|
||||
{
|
||||
Commesse = await ManageData.GetTable<JtbComt>(x => x.CodAnag.Equals(User.CodContact));
|
||||
Commesse = (await ManageData.GetTable<JtbComt>(x => x.CodAnag.Equals(User.CodContact)))
|
||||
.OrderByDescending(x => x.CodJcom).ToList();
|
||||
IsLoading = false;
|
||||
StateHasChanged();
|
||||
return;
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
@using System.Globalization
|
||||
@using System.Text.RegularExpressions
|
||||
@using CommunityToolkit.Mvvm.Messaging
|
||||
@using salesbook.Shared.Core.Dto
|
||||
@using salesbook.Shared.Components.Layout
|
||||
@using salesbook.Shared.Core.Entity
|
||||
@using salesbook.Shared.Core.Interface
|
||||
@using salesbook.Shared.Components.Layout.Overlay
|
||||
@using salesbook.Shared.Components.SingleElements.BottomSheet
|
||||
@using salesbook.Shared.Core.Dto
|
||||
@using salesbook.Shared.Core.Dto.Activity
|
||||
@using salesbook.Shared.Core.Dto.Contact
|
||||
@using salesbook.Shared.Core.Entity
|
||||
@using salesbook.Shared.Core.Interface
|
||||
@using salesbook.Shared.Core.Messages.Activity.Copy
|
||||
@inject IManageDataService ManageData
|
||||
@inject INetworkService NetworkService
|
||||
@inject IIntegryApiService IntegryApiService
|
||||
@inject IMessenger Messenger
|
||||
@inject IDialogService Dialog
|
||||
@inject IAttachedService AttachedService
|
||||
|
||||
<MudDialog Class="customDialog-form">
|
||||
<DialogContent>
|
||||
@@ -142,7 +145,7 @@
|
||||
{
|
||||
foreach (var file in ActivityFileList)
|
||||
{
|
||||
<MudChip T="string" Color="Color.Default">
|
||||
<MudChip T="string" OnClick="() => OpenAttached(file.Id, file.FileName)" Color="Color.Default">
|
||||
@file.FileName
|
||||
</MudChip>
|
||||
}
|
||||
@@ -240,15 +243,15 @@
|
||||
private ActivityDTO ActivityModel { get; set; } = new();
|
||||
|
||||
private List<StbActivityResult> ActivityResult { get; set; } = [];
|
||||
private List<StbActivityType> ActivityType { get; set; } = [];
|
||||
private List<SrlActivityTypeUser> ActivityType { get; set; } = [];
|
||||
private List<StbUser> Users { get; set; } = [];
|
||||
private List<JtbComt> Commesse { get; set; } = [];
|
||||
private List<AnagClie> Clienti { get; set; } = [];
|
||||
private List<PtbPros> Pros { get; set; } = [];
|
||||
private List<ActivityFileDto>? ActivityFileList { get; set; }
|
||||
|
||||
private bool IsNew => Id.IsNullOrEmpty();
|
||||
private bool IsView => !NetworkService.IsNetworkAvailable();
|
||||
private bool IsNew { get; set; }
|
||||
private bool IsView => !NetworkService.ConnectionAvailable;
|
||||
|
||||
private string? LabelSave { get; set; }
|
||||
|
||||
@@ -273,18 +276,18 @@
|
||||
{
|
||||
Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter;
|
||||
|
||||
_ = LoadData();
|
||||
|
||||
LabelSave = IsNew ? "Aggiungi" : null;
|
||||
|
||||
if (!Id.IsNullOrEmpty())
|
||||
ActivityModel = (await ManageData.GetActivity(x => x.ActivityId.Equals(Id))).Last();
|
||||
|
||||
if (ActivityCopied != null)
|
||||
{
|
||||
ActivityModel = ActivityCopied.Clone();
|
||||
}
|
||||
else if (!Id.IsNullOrEmpty())
|
||||
ActivityModel = (await ManageData.GetActivity(new WhereCondActivity { ActivityId = Id }, true)).Last();
|
||||
|
||||
if (Id.IsNullOrEmpty()) Id = ActivityModel.ActivityId;
|
||||
IsNew = Id.IsNullOrEmpty();
|
||||
LabelSave = IsNew ? "Aggiungi" : null;
|
||||
|
||||
_ = LoadData();
|
||||
await LoadCommesse();
|
||||
|
||||
if (IsNew)
|
||||
@@ -294,6 +297,8 @@
|
||||
ActivityModel.UserName = UserSession.User.Username;
|
||||
}
|
||||
|
||||
await LoadActivityType();
|
||||
|
||||
OriginalModel = ActivityModel.Clone();
|
||||
}
|
||||
|
||||
@@ -315,7 +320,7 @@
|
||||
|
||||
await ManageData.InsertOrUpdate(newActivity);
|
||||
|
||||
await SaveAttached(newActivity.ActivityId);
|
||||
await SaveAttached(newActivity.ActivityId!);
|
||||
|
||||
SuccessAnimation = true;
|
||||
StateHasChanged();
|
||||
@@ -353,7 +358,7 @@
|
||||
{
|
||||
if (attached.FileContent is not null && attached.Type != AttachedDTO.TypeAttached.Position)
|
||||
{
|
||||
await IntegryApiService.UploadFile(activityId, attached.FileContent, attached.Name);
|
||||
await IntegryApiService.UploadFile(activityId, attached.FileBytes, attached.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -378,9 +383,17 @@
|
||||
|
||||
Users = await ManageData.GetTable<StbUser>();
|
||||
ActivityResult = await ManageData.GetTable<StbActivityResult>();
|
||||
Clienti = await ManageData.GetTable<AnagClie>(x => x.FlagStato.Equals("A"));
|
||||
Pros = await ManageData.GetTable<PtbPros>();
|
||||
ActivityType = await ManageData.GetTable<StbActivityType>(x => x.FlagTipologia.Equals("A"));
|
||||
Clienti = await ManageData.GetClienti(new WhereCondContact {FlagStato = "A"});
|
||||
Pros = await ManageData.GetProspect();
|
||||
}
|
||||
|
||||
private async Task LoadActivityType()
|
||||
{
|
||||
if (ActivityModel.UserName is null) ActivityType = [];
|
||||
|
||||
ActivityType = await ManageData.GetTable<SrlActivityTypeUser>(x =>
|
||||
x.UserName != null && x.UserName.Equals(ActivityModel.UserName)
|
||||
);
|
||||
}
|
||||
|
||||
private async Task LoadCommesse() =>
|
||||
@@ -427,6 +440,12 @@
|
||||
OnAfterChangeValue();
|
||||
}
|
||||
|
||||
private async Task OnUserChanged()
|
||||
{
|
||||
await LoadActivityType();
|
||||
OnAfterChangeValue();
|
||||
}
|
||||
|
||||
private void OnAfterChangeValue()
|
||||
{
|
||||
if (!IsNew)
|
||||
@@ -541,12 +560,26 @@
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task OpenAttached(string idAttached, string fileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
var bytes = await IntegryApiService.DownloadFile(ActivityModel.ActivityId!, fileName);
|
||||
await AttachedService.OpenFile(bytes, fileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Clear();
|
||||
Snackbar.Add("Impossibile aprire il file", Severity.Error);
|
||||
Console.WriteLine($"Errore durante l'apertura del file: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task OpenAttached(AttachedDTO attached)
|
||||
{
|
||||
if (attached is { FileContent: not null, MimeType: not null })
|
||||
{
|
||||
var fileViewerUrl = $"data:{attached.MimeType};base64,{Convert.ToBase64String(attached.FileContent)}";
|
||||
await ModalHelpers.OpenViewAttach(Dialog, fileViewerUrl);
|
||||
await AttachedService.OpenFile(attached.FileContent!, attached.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
@using salesbook.Shared.Components.Layout.Overlay
|
||||
@using salesbook.Shared.Core.Entity
|
||||
@using salesbook.Shared.Components.SingleElements.BottomSheet
|
||||
@using salesbook.Shared.Core.Dto.Contact
|
||||
@inject IManageDataService ManageData
|
||||
@inject INetworkService NetworkService
|
||||
@inject IIntegryApiService IntegryApiService
|
||||
@@ -279,7 +280,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (NetworkService.IsNetworkAvailable() && !ContactModel.IsContact)
|
||||
@if (NetworkService.ConnectionAvailable && !ContactModel.IsContact)
|
||||
{
|
||||
<MudButton Class="button-settings blue-icon"
|
||||
FullWidth="true"
|
||||
@@ -331,7 +332,7 @@
|
||||
private List<StbUser> Users { get; set; } = [];
|
||||
|
||||
private bool IsNew => OriginalModel is null;
|
||||
private bool IsView => !NetworkService.IsNetworkAvailable();
|
||||
private bool IsView => !NetworkService.ConnectionAvailable;
|
||||
|
||||
private string? LabelSave { get; set; }
|
||||
|
||||
@@ -473,11 +474,11 @@
|
||||
|
||||
var pIva = ContactModel.PartIva.Trim();
|
||||
|
||||
var clie = (await ManageData.GetTable<AnagClie>(x => x.PartIva.Equals(pIva))).LastOrDefault();
|
||||
var clie = (await ManageData.GetClienti(new WhereCondContact {PartIva = pIva})).LastOrDefault();
|
||||
|
||||
if (clie == null)
|
||||
{
|
||||
var pros = (await ManageData.GetTable<PtbPros>(x => x.PartIva.Equals(pIva))).LastOrDefault();
|
||||
var pros = (await ManageData.GetProspect(new WhereCondContact {PartIva = pIva})).LastOrDefault();
|
||||
|
||||
if (pros == null)
|
||||
{
|
||||
|
||||
@@ -118,7 +118,7 @@
|
||||
private PersRifDTO PersRifModel { get; set; } = new();
|
||||
|
||||
private bool IsNew => OriginalModel is null;
|
||||
private bool IsView => !NetworkService.IsNetworkAvailable();
|
||||
private bool IsView => !NetworkService.ConnectionAvailable;
|
||||
|
||||
private string? LabelSave { get; set; }
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
<MudDialog Class="customDialog-form">
|
||||
<DialogContent>
|
||||
@if (!string.IsNullOrEmpty(FileViewerUrl))
|
||||
{
|
||||
<iframe src="@FileViewerUrl" style="width:100%; height:80vh; border:none;"></iframe>
|
||||
}
|
||||
</DialogContent>
|
||||
</MudDialog>
|
||||
|
||||
@code {
|
||||
[CascadingParameter] private IMudDialogInstance MudDialog { get; set; }
|
||||
|
||||
[Parameter] public string? FileViewerUrl { get; set; }
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
.content.attached {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2rem;
|
||||
padding: 1rem;
|
||||
height: unset;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using salesbook.Shared.Core.Entity;
|
||||
using salesbook.Shared.Core.Helpers.Enum;
|
||||
|
||||
namespace salesbook.Shared.Core.Dto;
|
||||
namespace salesbook.Shared.Core.Dto.Activity;
|
||||
|
||||
public class ActivityDTO : StbActivity
|
||||
{
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace salesbook.Shared.Core.Dto.Activity;
|
||||
|
||||
public class CRMRetrieveActivityRequestDTO
|
||||
{
|
||||
[JsonPropertyName("dateFilter")]
|
||||
public string? DateFilter { get; set; }
|
||||
|
||||
[JsonPropertyName("activityId")]
|
||||
public string? ActivityId { get; set; }
|
||||
|
||||
[JsonPropertyName("codAnag")]
|
||||
public string? CodAnag { get; set; }
|
||||
|
||||
[JsonPropertyName("codJcom")]
|
||||
public string? CodJcom { get; set; }
|
||||
|
||||
[JsonPropertyName("startDate")]
|
||||
public DateTime? StarDate { get; set; }
|
||||
|
||||
[JsonPropertyName("endDate")]
|
||||
public DateTime? EndDate { get; set; }
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using salesbook.Shared.Core.Helpers;
|
||||
using salesbook.Shared.Core.Helpers.Enum;
|
||||
|
||||
namespace salesbook.Shared.Core.Dto;
|
||||
namespace salesbook.Shared.Core.Dto.Activity;
|
||||
|
||||
public class FilterActivityDTO
|
||||
{
|
||||
11
salesbook.Shared/Core/Dto/Activity/WhereCondActivity.cs
Normal file
11
salesbook.Shared/Core/Dto/Activity/WhereCondActivity.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace salesbook.Shared.Core.Dto.Activity;
|
||||
|
||||
public class WhereCondActivity
|
||||
{
|
||||
public DateTime? Start { get; set; }
|
||||
public DateTime? End { get; set; }
|
||||
|
||||
public string? ActivityId { get; set; }
|
||||
}
|
||||
@@ -8,8 +8,12 @@ public class AttachedDTO
|
||||
public string? MimeType { get; set; }
|
||||
public long? DimensionBytes { get; set; }
|
||||
public string? Path { get; set; }
|
||||
public byte[]? FileContent { get; set; }
|
||||
|
||||
|
||||
public byte[]? FileBytes { get; set; }
|
||||
|
||||
public Stream? FileContent =>
|
||||
FileBytes is null ? null : new MemoryStream(FileBytes);
|
||||
|
||||
public double? Lat { get; set; }
|
||||
public double? Lng { get; set; }
|
||||
|
||||
|
||||
27
salesbook.Shared/Core/Dto/CRMAttachedResponseDTO.cs
Normal file
27
salesbook.Shared/Core/Dto/CRMAttachedResponseDTO.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace salesbook.Shared.Core.Dto;
|
||||
|
||||
public class CRMAttachedResponseDTO
|
||||
{
|
||||
[JsonPropertyName("fileName")]
|
||||
public string FileName { get; set; }
|
||||
|
||||
[JsonPropertyName("description")]
|
||||
public string? Description { get; set; }
|
||||
|
||||
[JsonPropertyName("dateAttached")]
|
||||
public DateTime DateAttached { get; set; }
|
||||
|
||||
[JsonPropertyName("fileSize")]
|
||||
public decimal FileSize { get; set; }
|
||||
|
||||
[JsonPropertyName("refUuid")]
|
||||
public string RefUuid { get; set; }
|
||||
|
||||
[JsonPropertyName("refAttached")]
|
||||
public string RefAttached { get; set; }
|
||||
|
||||
[JsonPropertyName("activity")]
|
||||
public bool IsActivity { get; set; }
|
||||
}
|
||||
19
salesbook.Shared/Core/Dto/Contact/CRMAnagRequestDTO.cs
Normal file
19
salesbook.Shared/Core/Dto/Contact/CRMAnagRequestDTO.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace salesbook.Shared.Core.Dto.Contact;
|
||||
|
||||
public class CRMAnagRequestDTO
|
||||
{
|
||||
[JsonPropertyName("filterDate")]
|
||||
public DateTime? FilterDate { get; set; }
|
||||
|
||||
[JsonPropertyName("flagStato")]
|
||||
public string? FlagStato { get; set; }
|
||||
[JsonPropertyName("partitaIva")]
|
||||
public string? PartIva { get; set; }
|
||||
[JsonPropertyName("codAnag")]
|
||||
public string? CodAnag { get; set; }
|
||||
|
||||
[JsonPropertyName("returnPersRif")]
|
||||
public bool ReturnPersRif { get; set; }
|
||||
}
|
||||
17
salesbook.Shared/Core/Dto/Contact/CRMProspectRequestDTO.cs
Normal file
17
salesbook.Shared/Core/Dto/Contact/CRMProspectRequestDTO.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace salesbook.Shared.Core.Dto.Contact;
|
||||
|
||||
public class CRMProspectRequestDTO
|
||||
{
|
||||
[JsonPropertyName("filterDate")]
|
||||
public DateTime? FilterDate { get; set; }
|
||||
|
||||
[JsonPropertyName("partitaIva")]
|
||||
public string? PartIva { get; set; }
|
||||
[JsonPropertyName("codPpro")]
|
||||
public string? CodPpro { get; set; }
|
||||
|
||||
[JsonPropertyName("returnPersRif")]
|
||||
public bool ReturnPersRif { get; set; }
|
||||
}
|
||||
10
salesbook.Shared/Core/Dto/Contact/WhereCondContact.cs
Normal file
10
salesbook.Shared/Core/Dto/Contact/WhereCondContact.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace salesbook.Shared.Core.Dto.Contact;
|
||||
|
||||
public class WhereCondContact
|
||||
{
|
||||
public string? FlagStato { get; set; }
|
||||
public string? PartIva { get; set; }
|
||||
public string? CodAnag { get; set; }
|
||||
|
||||
public bool OnlyContact { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace salesbook.Shared.Core.Dto.JobProgress;
|
||||
|
||||
public class CRMJobProgressResponseDTO
|
||||
{
|
||||
[JsonPropertyName("steps")]
|
||||
public List<CRMJobStepDTO> Steps { get; set; }
|
||||
}
|
||||
15
salesbook.Shared/Core/Dto/JobProgress/CRMJobStatusDTO.cs
Normal file
15
salesbook.Shared/Core/Dto/JobProgress/CRMJobStatusDTO.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace salesbook.Shared.Core.Dto.JobProgress;
|
||||
|
||||
public class CRMJobStatusDTO
|
||||
{
|
||||
[JsonPropertyName("completed")]
|
||||
public bool Completed { get; set; }
|
||||
|
||||
[JsonPropertyName("progress")]
|
||||
public bool Progress { get; set; }
|
||||
|
||||
[JsonPropertyName("skip")]
|
||||
public bool Skip { get; set; }
|
||||
}
|
||||
15
salesbook.Shared/Core/Dto/JobProgress/CRMJobStepDTO.cs
Normal file
15
salesbook.Shared/Core/Dto/JobProgress/CRMJobStepDTO.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace salesbook.Shared.Core.Dto.JobProgress;
|
||||
|
||||
public class CRMJobStepDTO
|
||||
{
|
||||
[JsonPropertyName("stepName")]
|
||||
public string? StepName { get; set; }
|
||||
|
||||
[JsonPropertyName("status")]
|
||||
public CRMJobStatusDTO? Status { get; set; }
|
||||
|
||||
[JsonPropertyName("date")]
|
||||
public DateTime? Date { get; set; }
|
||||
}
|
||||
8
salesbook.Shared/Core/Dto/PageState/JobSteps.cs
Normal file
8
salesbook.Shared/Core/Dto/PageState/JobSteps.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using salesbook.Shared.Core.Dto.JobProgress;
|
||||
|
||||
namespace salesbook.Shared.Core.Dto.PageState;
|
||||
|
||||
public class JobSteps
|
||||
{
|
||||
public List<CRMJobStepDTO>? Steps { get; set; }
|
||||
}
|
||||
21
salesbook.Shared/Core/Dto/PageState/UserListState.cs
Normal file
21
salesbook.Shared/Core/Dto/PageState/UserListState.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using salesbook.Shared.Core.Dto.Users;
|
||||
|
||||
namespace salesbook.Shared.Core.Dto.PageState;
|
||||
|
||||
public class UserListState
|
||||
{
|
||||
public List<UserDisplayItem>? GroupedUserList { get; set; }
|
||||
public List<UserDisplayItem>? FilteredGroupedUserList { get; set; }
|
||||
|
||||
public bool IsLoaded { get; set; }
|
||||
public bool IsLoading { get; set; }
|
||||
|
||||
public event Action? OnUsersLoaded;
|
||||
|
||||
public void NotifyUsersLoaded()
|
||||
{
|
||||
IsLoaded = true;
|
||||
IsLoading = false;
|
||||
OnUsersLoaded?.Invoke();
|
||||
}
|
||||
}
|
||||
17
salesbook.Shared/Core/Dto/PageState/UserPageState.cs
Normal file
17
salesbook.Shared/Core/Dto/PageState/UserPageState.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using salesbook.Shared.Core.Dto.Activity;
|
||||
using salesbook.Shared.Core.Dto.JobProgress;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
|
||||
namespace salesbook.Shared.Core.Dto.PageState;
|
||||
|
||||
public class UserPageState
|
||||
{
|
||||
public string? CodUser { get; set; }
|
||||
|
||||
public ContactDTO Anag { get; set; }
|
||||
public List<PersRifDTO>? PersRif { get; set; }
|
||||
public List<JtbComt> Commesse { get; set; }
|
||||
public StbUser? Agente { get; set; }
|
||||
public Dictionary<string, List<CRMJobStepDTO>?> Steps { get; set; }
|
||||
public List<ActivityDTO> Activitys { get; set; }
|
||||
}
|
||||
@@ -8,6 +8,9 @@ public class SettingsResponseDTO
|
||||
[JsonPropertyName("activityTypes")]
|
||||
public List<StbActivityType>? ActivityTypes { get; set; }
|
||||
|
||||
[JsonPropertyName("activityTypeUsers")]
|
||||
public List<SrlActivityTypeUser>? ActivityTypeUsers { get; set; }
|
||||
|
||||
[JsonPropertyName("activityResults")]
|
||||
public List<StbActivityResult>? ActivityResults { get; set; }
|
||||
|
||||
|
||||
8
salesbook.Shared/Core/Dto/Users/UserDisplayItem.cs
Normal file
8
salesbook.Shared/Core/Dto/Users/UserDisplayItem.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace salesbook.Shared.Core.Dto.Users;
|
||||
|
||||
public class UserDisplayItem
|
||||
{
|
||||
public required ContactDTO User { get; set; }
|
||||
public bool ShowHeader { get; set; }
|
||||
public string? HeaderLetter { get; set; }
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using salesbook.Shared.Core.Entity;
|
||||
|
||||
namespace salesbook.Shared.Core.Dto;
|
||||
|
||||
public class TaskSyncResponseDTO
|
||||
public class UsersSyncResponseDTO
|
||||
{
|
||||
[JsonPropertyName("anagClie")]
|
||||
public List<AnagClie>? AnagClie { get; set; }
|
||||
@@ -107,4 +107,7 @@ public class JtbComt
|
||||
|
||||
[Column("note_tecniche"), JsonPropertyName("noteTecniche")]
|
||||
public string NoteTecniche { get; set; }
|
||||
|
||||
[Ignore, JsonIgnore]
|
||||
public DateTime? LastUpd { get; set; }
|
||||
}
|
||||
56
salesbook.Shared/Core/Entity/SrlActivityTypeUser.cs
Normal file
56
salesbook.Shared/Core/Entity/SrlActivityTypeUser.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using SQLite;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace salesbook.Shared.Core.Entity;
|
||||
|
||||
[Table("srl_activity_type_user")]
|
||||
public class SrlActivityTypeUser
|
||||
{
|
||||
[PrimaryKey, Column("composite_key")]
|
||||
public string CompositeKey { get; set; }
|
||||
|
||||
private string? _activityTypeId;
|
||||
|
||||
[Column("activity_type_id"), JsonPropertyName("activityTypeId"), Indexed(Name = "ActivityTypePK", Order = 1, Unique = true)]
|
||||
public string? ActivityTypeId
|
||||
{
|
||||
get => _activityTypeId;
|
||||
set
|
||||
{
|
||||
_activityTypeId = value;
|
||||
if (_activityTypeId != null && _flagTipologia != null && _userName != null)
|
||||
UpdateCompositeKey();
|
||||
}
|
||||
}
|
||||
|
||||
private string? _flagTipologia;
|
||||
|
||||
[Column("flag_tipologia"), JsonPropertyName("flagTipologia"), Indexed(Name = "ActivityTypePK", Order = 2, Unique = true)]
|
||||
public string? FlagTipologia
|
||||
{
|
||||
get => _flagTipologia;
|
||||
set
|
||||
{
|
||||
_flagTipologia = value;
|
||||
if (_activityTypeId != null && _flagTipologia != null && _userName != null)
|
||||
UpdateCompositeKey();
|
||||
}
|
||||
}
|
||||
|
||||
private string? _userName;
|
||||
|
||||
[Column("user_name"), JsonPropertyName("userName"), Indexed(Name = "ActivityTypePK", Order = 3, Unique = true)]
|
||||
public string? UserName
|
||||
{
|
||||
get => _userName;
|
||||
set
|
||||
{
|
||||
_userName = value;
|
||||
if (_activityTypeId != null && _flagTipologia != null && _userName != null)
|
||||
UpdateCompositeKey();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateCompositeKey() =>
|
||||
CompositeKey = $"{ActivityTypeId}::{FlagTipologia}::{UserName}";
|
||||
}
|
||||
@@ -7,5 +7,7 @@ class IconConstants
|
||||
public const string Stato = "ri-list-check-3 fa-fw fa-chip";
|
||||
public const string User = "ri-user-fill fa-fw fa-chip";
|
||||
public const string Time = "ri-time-line fa-fw fa-chip";
|
||||
public const string FileTextLine = "ri-file-text-line fa-fw fa-chip";
|
||||
public const string Tag = "ri-price-tag-3-fill fa-fw fa-chip";
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using AutoMapper;
|
||||
using salesbook.Shared.Core.Dto;
|
||||
using salesbook.Shared.Core.Dto.Activity;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
|
||||
namespace salesbook.Shared.Core.Helpers;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using MudBlazor;
|
||||
using salesbook.Shared.Components.SingleElements.Modal;
|
||||
using salesbook.Shared.Core.Dto;
|
||||
using salesbook.Shared.Core.Dto.Activity;
|
||||
|
||||
namespace salesbook.Shared.Core.Helpers;
|
||||
|
||||
@@ -85,23 +86,4 @@ public class ModalHelpers
|
||||
|
||||
return await modal.Result;
|
||||
}
|
||||
|
||||
public static async Task<DialogResult?> OpenViewAttach(IDialogService dialog, string? fileViewUrl)
|
||||
{
|
||||
var modal = await dialog.ShowAsync<ViewAttached>(
|
||||
"View attached",
|
||||
new DialogParameters<ViewAttached>
|
||||
{
|
||||
{ x => x.FileViewerUrl, fileViewUrl }
|
||||
},
|
||||
new DialogOptions
|
||||
{
|
||||
FullScreen = true,
|
||||
CloseButton = true,
|
||||
NoHeader = true
|
||||
}
|
||||
);
|
||||
|
||||
return await modal.Result;
|
||||
}
|
||||
}
|
||||
@@ -7,4 +7,5 @@ public interface IAttachedService
|
||||
Task<AttachedDTO?> SelectImage();
|
||||
Task<AttachedDTO?> SelectFile();
|
||||
Task<AttachedDTO?> SelectPosition();
|
||||
Task OpenFile(Stream file, string fileName);
|
||||
}
|
||||
@@ -1,15 +1,21 @@
|
||||
using salesbook.Shared.Core.Dto;
|
||||
using salesbook.Shared.Core.Dto.Activity;
|
||||
using salesbook.Shared.Core.Dto.Contact;
|
||||
using salesbook.Shared.Core.Dto.JobProgress;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
|
||||
namespace salesbook.Shared.Core.Interface;
|
||||
|
||||
public interface IIntegryApiService
|
||||
{
|
||||
Task<List<StbActivity>?> RetrieveActivity(string? dateFilter = null);
|
||||
Task<bool> SystemOk();
|
||||
|
||||
Task<List<StbActivity>?> RetrieveActivity(CRMRetrieveActivityRequestDTO activityRequest);
|
||||
Task<List<JtbComt>?> RetrieveAllCommesse(string? dateFilter = null);
|
||||
Task<TaskSyncResponseDTO> RetrieveAnagClie(string? dateFilter = null);
|
||||
Task<TaskSyncResponseDTO> RetrieveProspect(string? dateFilter = null);
|
||||
Task<UsersSyncResponseDTO> RetrieveAnagClie(CRMAnagRequestDTO request);
|
||||
Task<UsersSyncResponseDTO> RetrieveProspect(CRMProspectRequestDTO request);
|
||||
Task<SettingsResponseDTO> RetrieveSettings();
|
||||
Task<List<CRMAttachedResponseDTO>?> RetrieveAttached(string codJcom);
|
||||
|
||||
Task DeleteActivity(string activityId);
|
||||
|
||||
@@ -21,6 +27,9 @@ public interface IIntegryApiService
|
||||
Task UploadFile(string id, byte[] file, string fileName);
|
||||
Task<List<ActivityFileDto>> GetActivityFile(string activityId);
|
||||
Task<Stream> DownloadFile(string activityId, string fileName);
|
||||
Task<Stream> DownloadFileFromRefUuid(string refUuid, string fileName);
|
||||
|
||||
Task<CRMJobProgressResponseDTO> RetrieveJobProgress(string codJcom);
|
||||
|
||||
//Position
|
||||
Task<PositionDTO> SavePosition(PositionDTO position);
|
||||
|
||||
@@ -1,17 +1,22 @@
|
||||
using System.Linq.Expressions;
|
||||
using salesbook.Shared.Core.Dto;
|
||||
using salesbook.Shared.Core.Dto;
|
||||
using salesbook.Shared.Core.Dto.Activity;
|
||||
using salesbook.Shared.Core.Dto.Contact;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace salesbook.Shared.Core.Interface;
|
||||
|
||||
public interface IManageDataService
|
||||
{
|
||||
Task<List<T>> GetTable<T>(Expression<Func<T, bool>>? whereCond = null) where T : new();
|
||||
|
||||
Task<List<ActivityDTO>> GetActivity(Expression<Func<StbActivity, bool>>? whereCond = null);
|
||||
Task<List<ContactDTO>> GetContact();
|
||||
|
||||
Task<List<AnagClie>> GetClienti(WhereCondContact? whereCond = null);
|
||||
Task<List<PtbPros>> GetProspect(WhereCondContact? whereCond = null);
|
||||
Task<List<ContactDTO>> GetContact(WhereCondContact whereCond);
|
||||
Task<ContactDTO?> GetSpecificContact(string codAnag, bool IsContact);
|
||||
|
||||
Task<List<ActivityDTO>> GetActivity(WhereCondActivity whereCond, bool useLocalDb = false);
|
||||
|
||||
Task InsertOrUpdate<T>(T objectToSave);
|
||||
Task InsertOrUpdate<T>(List<T> listToSave);
|
||||
|
||||
|
||||
@@ -2,5 +2,7 @@
|
||||
|
||||
public interface INetworkService
|
||||
{
|
||||
public bool ConnectionAvailable { get; set; }
|
||||
|
||||
public bool IsNetworkAvailable();
|
||||
}
|
||||
@@ -2,9 +2,6 @@
|
||||
|
||||
public interface ISyncDbService
|
||||
{
|
||||
Task GetAndSaveActivity(string? dateFilter = null);
|
||||
Task GetAndSaveCommesse(string? dateFilter = null);
|
||||
Task GetAndSaveProspect(string? dateFilter = null);
|
||||
Task GetAndSaveClienti(string? dateFilter = null);
|
||||
Task GetAndSaveSettings(string? dateFilter = null);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using CommunityToolkit.Mvvm.Messaging.Messages;
|
||||
using salesbook.Shared.Core.Dto;
|
||||
using salesbook.Shared.Core.Dto.Activity;
|
||||
|
||||
namespace salesbook.Shared.Core.Messages.Activity.Copy;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using salesbook.Shared.Core.Dto;
|
||||
using salesbook.Shared.Core.Dto.Activity;
|
||||
|
||||
namespace salesbook.Shared.Core.Messages.Activity.Copy;
|
||||
|
||||
|
||||
@@ -1,21 +1,33 @@
|
||||
using IntegryApiClient.Core.Domain.Abstraction.Contracts.Account;
|
||||
using IntegryApiClient.Core.Domain.RestClient.Contacts;
|
||||
using salesbook.Shared.Core.Dto;
|
||||
using salesbook.Shared.Core.Dto.Activity;
|
||||
using salesbook.Shared.Core.Dto.JobProgress;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
using salesbook.Shared.Core.Interface;
|
||||
using System.Net.Http.Headers;
|
||||
using salesbook.Shared.Core.Dto.Contact;
|
||||
|
||||
namespace salesbook.Shared.Core.Services;
|
||||
|
||||
public class IntegryApiService(IIntegryApiRestClient integryApiRestClient, IUserSession userSession)
|
||||
: IIntegryApiService
|
||||
{
|
||||
public Task<List<StbActivity>?> RetrieveActivity(string? dateFilter)
|
||||
public async Task<bool> SystemOk()
|
||||
{
|
||||
var queryParams = new Dictionary<string, object> { { "dateFilter", dateFilter ?? "2020-01-01" } };
|
||||
|
||||
return integryApiRestClient.AuthorizedGet<List<StbActivity>?>("crm/retrieveActivity", queryParams);
|
||||
try
|
||||
{
|
||||
await integryApiRestClient.Get<object>("system/ok");
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<List<StbActivity>?> RetrieveActivity(CRMRetrieveActivityRequestDTO activityRequest) =>
|
||||
integryApiRestClient.AuthorizedPost<List<StbActivity>?>("crm/retrieveActivity", activityRequest);
|
||||
|
||||
public Task<List<JtbComt>?> RetrieveAllCommesse(string? dateFilter)
|
||||
{
|
||||
@@ -29,33 +41,26 @@ public class IntegryApiService(IIntegryApiRestClient integryApiRestClient, IUser
|
||||
return integryApiRestClient.AuthorizedGet<List<JtbComt>?>("crm/retrieveCommesse", queryParams);
|
||||
}
|
||||
|
||||
public Task<TaskSyncResponseDTO> RetrieveAnagClie(string? dateFilter)
|
||||
{
|
||||
var queryParams = new Dictionary<string, object>();
|
||||
public Task<UsersSyncResponseDTO> RetrieveAnagClie(CRMAnagRequestDTO request) =>
|
||||
integryApiRestClient.AuthorizedPost<UsersSyncResponseDTO>("crm/retrieveClienti", request)!;
|
||||
|
||||
if (dateFilter != null)
|
||||
{
|
||||
queryParams.Add("dateFilter", dateFilter);
|
||||
}
|
||||
|
||||
return integryApiRestClient.AuthorizedGet<TaskSyncResponseDTO>("crm/retrieveClienti", queryParams)!;
|
||||
}
|
||||
|
||||
public Task<TaskSyncResponseDTO> RetrieveProspect(string? dateFilter)
|
||||
{
|
||||
var queryParams = new Dictionary<string, object>();
|
||||
|
||||
if (dateFilter != null)
|
||||
{
|
||||
queryParams.Add("dateFilter", dateFilter);
|
||||
}
|
||||
|
||||
return integryApiRestClient.AuthorizedGet<TaskSyncResponseDTO>("crm/retrieveProspect", queryParams)!;
|
||||
}
|
||||
public Task<UsersSyncResponseDTO> RetrieveProspect(CRMProspectRequestDTO request) =>
|
||||
integryApiRestClient.AuthorizedPost<UsersSyncResponseDTO>("crm/retrieveProspect", request)!;
|
||||
|
||||
public Task<SettingsResponseDTO> RetrieveSettings() =>
|
||||
integryApiRestClient.AuthorizedGet<SettingsResponseDTO>("crm/retrieveSettings")!;
|
||||
|
||||
public Task<List<CRMAttachedResponseDTO>?> RetrieveAttached(string codJcom)
|
||||
{
|
||||
var queryParams = new Dictionary<string, object>
|
||||
{
|
||||
{ "codJcom", codJcom }
|
||||
};
|
||||
|
||||
return integryApiRestClient.AuthorizedGet<List<CRMAttachedResponseDTO>?>("crm/retrieveAttachedForCodJcom",
|
||||
queryParams);
|
||||
}
|
||||
|
||||
public Task DeleteActivity(string activityId)
|
||||
{
|
||||
var queryParams = new Dictionary<string, object>
|
||||
@@ -137,6 +142,17 @@ public class IntegryApiService(IIntegryApiRestClient integryApiRestClient, IUser
|
||||
public Task<Stream> DownloadFile(string activityId, string fileName) =>
|
||||
integryApiRestClient.Download($"downloadStbFileAttachment/{activityId}/{fileName}")!;
|
||||
|
||||
public Task<Stream> DownloadFileFromRefUuid(string refUuid, string fileName)
|
||||
{
|
||||
var queryParams = new Dictionary<string, object>
|
||||
{
|
||||
{ "refUuid", refUuid },
|
||||
{ "fileName", fileName }
|
||||
};
|
||||
|
||||
return integryApiRestClient.Download("downloadFileFromRefUuid", queryParams);
|
||||
}
|
||||
|
||||
public Task<PositionDTO> SavePosition(PositionDTO position) =>
|
||||
integryApiRestClient.Post<PositionDTO>("savePosition", position)!;
|
||||
|
||||
@@ -146,4 +162,11 @@ public class IntegryApiService(IIntegryApiRestClient integryApiRestClient, IUser
|
||||
|
||||
return integryApiRestClient.Get<PositionDTO>("retrievePosition", queryParams)!;
|
||||
}
|
||||
|
||||
public Task<CRMJobProgressResponseDTO> RetrieveJobProgress(string codJcom)
|
||||
{
|
||||
var queryParams = new Dictionary<string, object> { { "codJcom", codJcom } };
|
||||
|
||||
return integryApiRestClient.Get<CRMJobProgressResponseDTO>("crm/retrieveJobProgress", queryParams)!;
|
||||
}
|
||||
}
|
||||
55
salesbook.Shared/Core/Services/PreloadService.cs
Normal file
55
salesbook.Shared/Core/Services/PreloadService.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using salesbook.Shared.Core.Dto;
|
||||
using salesbook.Shared.Core.Dto.Contact;
|
||||
using salesbook.Shared.Core.Dto.PageState;
|
||||
using salesbook.Shared.Core.Dto.Users;
|
||||
using salesbook.Shared.Core.Interface;
|
||||
|
||||
namespace salesbook.Shared.Core.Services;
|
||||
|
||||
public class PreloadService(IManageDataService manageData, UserListState userState)
|
||||
{
|
||||
public async Task PreloadUsersAsync()
|
||||
{
|
||||
if (userState.IsLoaded || userState.IsLoading)
|
||||
return;
|
||||
|
||||
userState.IsLoading = true;
|
||||
|
||||
var users = await manageData.GetContact(new WhereCondContact { FlagStato = "A" });
|
||||
|
||||
var sorted = users
|
||||
.Where(u => !string.IsNullOrWhiteSpace(u.RagSoc))
|
||||
.OrderBy(u => char.IsLetter(char.ToUpper(u.RagSoc[0])) ? char.ToUpper(u.RagSoc[0]).ToString() : "ZZZ")
|
||||
.ThenBy(u => u.RagSoc)
|
||||
.ToList();
|
||||
|
||||
userState.GroupedUserList = BuildGroupedList(sorted);
|
||||
userState.FilteredGroupedUserList = userState.GroupedUserList;
|
||||
|
||||
userState.NotifyUsersLoaded();
|
||||
}
|
||||
|
||||
private static List<UserDisplayItem> BuildGroupedList(List<ContactDTO> users)
|
||||
{
|
||||
var grouped = new List<UserDisplayItem>();
|
||||
string? lastHeader = null;
|
||||
|
||||
foreach (var user in users)
|
||||
{
|
||||
var firstChar = char.ToUpper(user.RagSoc[0]);
|
||||
var currentLetter = char.IsLetter(firstChar) ? firstChar.ToString() : "#";
|
||||
|
||||
var showHeader = currentLetter != lastHeader;
|
||||
lastHeader = currentLetter;
|
||||
|
||||
grouped.Add(new UserDisplayItem
|
||||
{
|
||||
User = user,
|
||||
ShowHeader = showHeader,
|
||||
HeaderLetter = currentLetter
|
||||
});
|
||||
}
|
||||
|
||||
return grouped;
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,42 @@ a, .btn-link {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
/*ServicesIsDown" : "SystemOk" : "NetworkKo*/
|
||||
|
||||
.Connection {
|
||||
padding: 0 .75rem;
|
||||
font-weight: 700;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 1rem;
|
||||
font-size: larger;
|
||||
transition: all 0.5s ease;
|
||||
opacity: 0;
|
||||
transform: translateY(-35px);
|
||||
min-height: 35px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.Connection.ServicesIsDown, .Connection.NetworkKo {
|
||||
background-color: var(--mud-palette-error);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.Connection.SystemOk {
|
||||
background-color: var(--mud-palette-success);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.Connection.Show {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
.page > .Connection.Hide ~ main {
|
||||
transition: all 0.5s ease;
|
||||
transform: translateY(-35px);
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
color: #fff;
|
||||
background-color: var(--primary-color);
|
||||
@@ -31,11 +67,18 @@ a, .btn-link {
|
||||
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus { box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb; }
|
||||
|
||||
.content {
|
||||
/*padding-top: 1.1rem;*/
|
||||
padding-top: 1rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
height: 84vh;
|
||||
height: 90vh;
|
||||
}
|
||||
|
||||
.content::-webkit-scrollbar { width: 3px; }
|
||||
|
||||
.content::-webkit-scrollbar-thumb {
|
||||
background: #bbb;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
h1:focus { outline: none; }
|
||||
@@ -97,9 +140,7 @@ h1:focus { outline: none; }
|
||||
color: var(--mud-palette-text-primary) !important;
|
||||
}
|
||||
|
||||
.custom_popover .mud-divider {
|
||||
border-color: var(--mud-palette-text-primary) !important;
|
||||
}
|
||||
.custom_popover .mud-divider { border-color: var(--mud-palette-text-primary) !important; }
|
||||
|
||||
.custom_popover .mud-list-padding { padding: 3px 0px 3px 0px !important; }
|
||||
|
||||
@@ -196,9 +237,7 @@ h1:focus { outline: none; }
|
||||
padding-left: calc(var(--m-page-x) * 0.5) !important;
|
||||
}
|
||||
|
||||
.mud-message-box > .mud-dialog-title > h6 {
|
||||
font-weight: 800 !important;
|
||||
}
|
||||
.mud-message-box > .mud-dialog-title > h6 { font-weight: 800 !important; }
|
||||
|
||||
.mud-dialog-actions button {
|
||||
margin-left: .5rem !important;
|
||||
|
||||
@@ -38,16 +38,41 @@ function monitorExpandedClass(mutations) {
|
||||
});
|
||||
}
|
||||
|
||||
// Funzione per monitorare bottom-sheet-container e gestire la navbar
|
||||
function monitorBottomSheetClass(mutations) {
|
||||
const bottomSheet = document.querySelector(".bottom-sheet-container");
|
||||
const navbar = document.querySelector(".animated-navbar");
|
||||
|
||||
if (!bottomSheet || !navbar) return;
|
||||
|
||||
mutations.forEach(function (mutation) {
|
||||
if (mutation.type === 'attributes' && mutation.attributeName === 'class' && mutation.target === bottomSheet) {
|
||||
if (bottomSheet.classList.contains("show")) {
|
||||
navbar.classList.remove("show-nav");
|
||||
navbar.classList.add("hide-nav");
|
||||
console.log("Navbar nascosta (hide-nav)");
|
||||
} else {
|
||||
navbar.classList.remove("hide-nav");
|
||||
navbar.classList.add("show-nav");
|
||||
console.log("Navbar mostrata (show-nav)");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Esegui la funzione tabindex inizialmente
|
||||
addTabindexToButtons();
|
||||
|
||||
// Observer combinato per entrambe le funzionalità
|
||||
// Observer combinato per tutte le funzionalità
|
||||
const observer = new MutationObserver((mutations) => {
|
||||
// Aggiungi tabindex ai nuovi bottoni
|
||||
addTabindexToButtons();
|
||||
|
||||
// Monitora le classi expanded
|
||||
monitorExpandedClass(mutations);
|
||||
|
||||
// Monitora bottom-sheet-container
|
||||
monitorBottomSheetClass(mutations);
|
||||
});
|
||||
|
||||
// Osserva sia i cambiamenti nel DOM che gli attributi
|
||||
@@ -56,4 +81,20 @@ observer.observe(document.body, {
|
||||
subtree: true,
|
||||
attributes: true,
|
||||
attributeFilter: ['class']
|
||||
});
|
||||
});
|
||||
|
||||
// Sync iniziale per la navbar (nel caso la pagina parte già con .show)
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const bottomSheet = document.querySelector(".bottom-sheet-container");
|
||||
const navbar = document.querySelector(".animated-navbar");
|
||||
|
||||
if (bottomSheet && navbar) {
|
||||
if (bottomSheet.classList.contains("show")) {
|
||||
navbar.classList.remove("show-nav");
|
||||
navbar.classList.add("hide-nav");
|
||||
} else {
|
||||
navbar.classList.remove("hide-nav");
|
||||
navbar.classList.add("show-nav");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System.Linq.Expressions;
|
||||
using salesbook.Shared.Core.Dto;
|
||||
using salesbook.Shared.Core.Dto.Activity;
|
||||
using salesbook.Shared.Core.Dto.Contact;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
using salesbook.Shared.Core.Interface;
|
||||
|
||||
@@ -12,17 +14,27 @@ public class ManageDataService : IManageDataService
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<List<ActivityDTO>> GetActivity(Expression<Func<StbActivity, bool>>? whereCond = null)
|
||||
public Task<List<AnagClie>> GetClienti(WhereCondContact? whereCond)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<List<ContactDTO>> GetContact()
|
||||
public Task<List<PtbPros>> GetProspect(WhereCondContact? whereCond)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<ContactDTO> GetSpecificContact(string codAnag, bool IsContact)
|
||||
public Task<List<ContactDTO>> GetContact(WhereCondContact whereCond)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<ContactDTO?> GetSpecificContact(string codAnag, bool IsContact)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<List<ActivityDTO>> GetActivity(WhereCondActivity whereCond, bool useLocalDb = false)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace salesbook.Web.Core.Services;
|
||||
|
||||
public class NetworkService : INetworkService
|
||||
{
|
||||
public bool ConnectionAvailable { get; set; }
|
||||
|
||||
public bool IsNetworkAvailable()
|
||||
{
|
||||
return true;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
using salesbook.Shared.Core.Interface;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
using salesbook.Shared.Core.Interface;
|
||||
|
||||
namespace salesbook.Web.Core.Services;
|
||||
|
||||
public class SyncDbService : ISyncDbService
|
||||
{
|
||||
public Task GetAndSaveActivity(string? dateFilter = null)
|
||||
public Task GetAndSaveActivity(List<StbActivity>? allActivity)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user