Compare commits
2 Commits
8508820350
...
82d268d9f8
| Author | SHA1 | Date | |
|---|---|---|---|
| 82d268d9f8 | |||
| 014e2ffc41 |
@@ -26,7 +26,7 @@ public class ManageDataService(
|
||||
whereCond ??= new WhereCondContact();
|
||||
whereCond.OnlyContact = true;
|
||||
|
||||
if (networkService.IsNetworkAvailable())
|
||||
if (networkService.ConnectionAvailable)
|
||||
{
|
||||
var response = await integryApiService.RetrieveAnagClie(
|
||||
new CRMAnagRequestDTO
|
||||
@@ -58,7 +58,7 @@ public class ManageDataService(
|
||||
whereCond ??= new WhereCondContact();
|
||||
whereCond.OnlyContact = true;
|
||||
|
||||
if (networkService.IsNetworkAvailable())
|
||||
if (networkService.ConnectionAvailable)
|
||||
{
|
||||
var response = await integryApiService.RetrieveProspect(
|
||||
new CRMProspectRequestDTO
|
||||
@@ -88,7 +88,7 @@ public class ManageDataService(
|
||||
List<PtbPros>? prospectList;
|
||||
whereCond ??= new WhereCondContact();
|
||||
|
||||
if (networkService.IsNetworkAvailable())
|
||||
if (networkService.ConnectionAvailable)
|
||||
{
|
||||
var clienti = await integryApiService.RetrieveAnagClie(
|
||||
new CRMAnagRequestDTO
|
||||
@@ -160,7 +160,7 @@ public class ManageDataService(
|
||||
{
|
||||
List<StbActivity>? activities;
|
||||
|
||||
if (networkService.IsNetworkAvailable() && !useLocalDb)
|
||||
if (networkService.ConnectionAvailable && !useLocalDb)
|
||||
{
|
||||
activities = await integryApiService.RetrieveActivity(
|
||||
new CRMRetrieveActivityRequestDTO
|
||||
|
||||
@@ -4,8 +4,11 @@ namespace salesbook.Maui.Core.Services;
|
||||
|
||||
public class NetworkService : INetworkService
|
||||
{
|
||||
public bool ConnectionAvailable { get; set; }
|
||||
|
||||
public bool IsNetworkAvailable()
|
||||
{
|
||||
//return false;
|
||||
return Connectivity.Current.NetworkAccess == NetworkAccess.Internet;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,6 @@ 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>();
|
||||
@@ -80,6 +79,7 @@ namespace salesbook.Maui
|
||||
|
||||
builder.Services.AddSingleton<IFormFactor, FormFactor>();
|
||||
builder.Services.AddSingleton<IAttachedService, AttachedService>();
|
||||
builder.Services.AddSingleton<INetworkService, NetworkService>();
|
||||
builder.Services.AddSingleton<LocalDbService>();
|
||||
|
||||
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/>
|
||||
@@ -14,12 +15,32 @@
|
||||
<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 int _delaySeconds = 3;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -78,7 +78,7 @@ else
|
||||
{
|
||||
<div class="contentFlex">
|
||||
<Virtualize Items="ActivityList" Context="activity">
|
||||
<ActivityCard Activity="activity" />
|
||||
<ActivityCard ShowDate="true" Activity="activity" />
|
||||
</Virtualize>
|
||||
</div>
|
||||
}
|
||||
@@ -148,7 +148,10 @@ else
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
var activities = await IntegryApiService.RetrieveActivity(new CRMRetrieveActivityRequestDTO { CodJcom = CodJcom });
|
||||
ActivityList = Mapper.Map<List<ActivityDTO>>(activities);
|
||||
ActivityList = Mapper.Map<List<ActivityDTO>>(activities)
|
||||
.OrderBy(x =>
|
||||
(x.EffectiveTime ?? x.EstimatedTime) ?? x.DataInsAct
|
||||
).ToList();
|
||||
});
|
||||
|
||||
ActivityIsLoading = false;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
{
|
||||
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;
|
||||
|
||||
@@ -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");
|
||||
});
|
||||
|
||||
|
||||
@@ -7,23 +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 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">
|
||||
@@ -32,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>
|
||||
}
|
||||
@@ -51,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>
|
||||
}
|
||||
|
||||
@@ -61,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>
|
||||
@@ -73,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>
|
||||
}
|
||||
|
||||
@@ -83,47 +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>
|
||||
|
||||
<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="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">Contatti</label>
|
||||
<label class="tab-trigger" for="tab1" @onclick="() => SwitchTab(0)">Contatti</label>
|
||||
</li>
|
||||
<li class="tab-item">
|
||||
<label class="tab-trigger" for="tab2">Commesse</label>
|
||||
<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>
|
||||
|
||||
<!-- contenuti -->
|
||||
<div class="tab-container">
|
||||
<div class="tab-content">
|
||||
<!-- Contatti -->
|
||||
@if (PersRif is { Count: > 0 })
|
||||
<!-- Tab Contatti -->
|
||||
<div class="tab-content" style="display: @(ActiveTab == 0 ? "block" : "none")">
|
||||
@if (PersRif?.Count > 0)
|
||||
{
|
||||
<div 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)
|
||||
@foreach (var person in PersRif)
|
||||
{
|
||||
<ContactCard Contact="person" />
|
||||
@if (person != PersRif.Last())
|
||||
{
|
||||
<div class="divider"></div>
|
||||
}
|
||||
</Virtualize>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -137,82 +137,432 @@ else
|
||||
</MudButton>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
<!-- Commesse -->
|
||||
@if (LoadCommessa)
|
||||
|
||||
<!-- Tab Commesse -->
|
||||
<div class="tab-content" style="display: @(ActiveTab == 1 ? "block" : "none")">
|
||||
@if (IsLoadingCommesse)
|
||||
{
|
||||
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-7"/>
|
||||
<MudProgressLinear Color="Color.Primary" Indeterminate="true" Class="my-7" />
|
||||
}
|
||||
else
|
||||
else if (Commesse?.Count == 0)
|
||||
{
|
||||
@if (Commesse.IsNullOrEmpty())
|
||||
{
|
||||
<NoDataAvailable Text="Nessuna commessa presente"/>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="commesse-container">
|
||||
<Virtualize Items="Commesse" Context="commessa">
|
||||
<CommessaCard Steps="@Steps[commessa.CodJcom]" RagSoc="@Anag.RagSoc" Commessa="commessa"/>
|
||||
</Virtualize>
|
||||
</div>
|
||||
}
|
||||
<NoDataAvailable Text="Nessuna commessa presente" />
|
||||
}
|
||||
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<ActivityDTO> ActivityList { get; set; } = [];
|
||||
private StbUser? Agente { get; set; }
|
||||
private Dictionary<string, List<CRMJobStepDTO>?> Steps { get; set; } = [];
|
||||
private Dictionary<string, List<CRMJobStepDTO>?> Steps { get; set; } = new();
|
||||
|
||||
// Stati di caricamento
|
||||
private bool IsLoading { get; set; } = true;
|
||||
private bool LoadCommessa { 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()
|
||||
{
|
||||
if (UserState.CodUser != null && UserState.CodUser.Equals(CodContact))
|
||||
try
|
||||
{
|
||||
LoadDataFromSession();
|
||||
}
|
||||
else
|
||||
{
|
||||
await LoadData();
|
||||
}
|
||||
_loadingCts = new CancellationTokenSource();
|
||||
|
||||
IsLoading = false;
|
||||
StateHasChanged();
|
||||
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();
|
||||
_ = LoadCommesse();
|
||||
|
||||
if (Anag.CodVage != null)
|
||||
private async Task LoadPersRifAsync()
|
||||
{
|
||||
if (IsContact)
|
||||
{
|
||||
Agente = (await ManageData.GetTable<StbUser>(x => x.UserCode != null && x.UserCode.Equals(Anag.CodVage))).LastOrDefault();
|
||||
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));
|
||||
PersRif = Mapper.Map<List<PersRifDTO>>(pers);
|
||||
}
|
||||
}
|
||||
|
||||
SetDataSession();
|
||||
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()
|
||||
@@ -222,74 +572,208 @@ else
|
||||
Commesse = UserState.Commesse;
|
||||
Agente = UserState.Agente;
|
||||
Steps = UserState.Steps;
|
||||
ActivityList = UserState.Activitys;
|
||||
|
||||
SortCommesse();
|
||||
ApplyFiltersCommesse();
|
||||
ApplyFiltersActivity();
|
||||
|
||||
LoadCommessa = false;
|
||||
StateHasChanged();
|
||||
IsLoadingCommesse = false;
|
||||
ActivityIsLoading = false;
|
||||
}
|
||||
|
||||
private void SetDataSession()
|
||||
private void SaveDataToSession()
|
||||
{
|
||||
UserState.CodUser = CodContact;
|
||||
UserState.Anag = Anag;
|
||||
UserState.PersRif = PersRif;
|
||||
UserState.Agente = Agente;
|
||||
UserState.Steps = Steps;
|
||||
UserState.Activitys = ActivityList;
|
||||
}
|
||||
|
||||
private async Task LoadCommesse()
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
Commesse = await ManageData.GetTable<JtbComt>(x => x.CodAnag != null && x.CodAnag.Equals(CodContact));
|
||||
UserState.Commesse = Commesse;
|
||||
#endregion
|
||||
|
||||
foreach (var commessa in Commesse)
|
||||
#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)))
|
||||
{
|
||||
var steps = (await IntegryApiService.RetrieveJobProgress(commessa.CodJcom)).Steps;
|
||||
Steps.Add(commessa.CodJcom, steps);
|
||||
if (token.IsCancellationRequested) break;
|
||||
|
||||
tasksToLoad.Add(LoadStepForCommessaAsync(commessa.CodJcom, semaphore, token));
|
||||
}
|
||||
|
||||
LoadCommessa = false;
|
||||
});
|
||||
|
||||
SortCommesse();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private void SortCommesse()
|
||||
{
|
||||
Commesse = Commesse?.OrderBy(x => x.LastUpd.HasValue).ThenBy(x => x.LastUpd).ToList();
|
||||
}
|
||||
|
||||
private async Task LoadPersRif()
|
||||
{
|
||||
if (IsContact)
|
||||
{
|
||||
var pers = await ManageData.GetTable<VtbCliePersRif>(x => x.CodAnag.Equals(Anag.CodContact));
|
||||
PersRif = Mapper.Map<List<PersRifDTO>>(pers);
|
||||
if (tasksToLoad.Any())
|
||||
{
|
||||
await Task.WhenAll(tasksToLoad);
|
||||
UserState.Steps = Steps;
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
var pers = await ManageData.GetTable<PtbProsRif>(x => x.CodPpro.Equals(Anag.CodContact));
|
||||
PersRif = Mapper.Map<List<PersRifDTO>>(pers);
|
||||
// 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
|
||||
}
|
||||
@@ -165,14 +165,15 @@
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
.commesse-container ::deep > div:first-child:not(.activity-card) {
|
||||
display: none;
|
||||
.attivita-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
/*--------------
|
||||
TabPanel
|
||||
----------------*/
|
||||
|
||||
.box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -203,7 +204,7 @@
|
||||
content: '';
|
||||
display: block;
|
||||
height: 3px;
|
||||
width: calc(100% / 2);
|
||||
width: calc(100% / 3);
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
@@ -227,7 +228,8 @@
|
||||
/* tab attivo */
|
||||
|
||||
#tab1:checked ~ .box .tab-list .tab-item:nth-child(1),
|
||||
#tab2:checked ~ .box .tab-list .tab-item:nth-child(2) {
|
||||
#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;
|
||||
@@ -239,17 +241,18 @@
|
||||
|
||||
#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;
|
||||
overflow-y: hidden;
|
||||
animation: fade .3s ease;
|
||||
padding: .5rem;
|
||||
}
|
||||
@@ -262,7 +265,10 @@
|
||||
}
|
||||
|
||||
#tab1:checked ~ .tab-container .tab-content:nth-child(1),
|
||||
#tab2:checked ~ .tab-container .tab-content:nth-child(2) { display: block; }
|
||||
#tab2:checked ~ .tab-container .tab-content:nth-child(2),
|
||||
#tab3:checked ~ .tab-container .tab-content:nth-child(3) {
|
||||
display: block;
|
||||
}
|
||||
|
||||
@keyframes fade {
|
||||
from {
|
||||
@@ -275,3 +281,13 @@
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
.custom-pagination ::deep ul { padding-left: 0 !important; }
|
||||
|
||||
.SelectedPageSize {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.FilterSection {
|
||||
display: flex;
|
||||
}
|
||||
@@ -29,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>
|
||||
@@ -68,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()
|
||||
@@ -82,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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -250,8 +250,8 @@
|
||||
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; }
|
||||
|
||||
@@ -276,18 +276,18 @@
|
||||
{
|
||||
Snackbar.Configuration.PositionClass = Defaults.Classes.Position.TopCenter;
|
||||
|
||||
_ = LoadData();
|
||||
|
||||
LabelSave = IsNew ? "Aggiungi" : null;
|
||||
|
||||
if (!Id.IsNullOrEmpty())
|
||||
ActivityModel = (await ManageData.GetActivity(new WhereCondActivity { ActivityId = Id }, true)).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)
|
||||
|
||||
@@ -280,7 +280,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (NetworkService.IsNetworkAvailable() && !ContactModel.IsContact)
|
||||
@if (NetworkService.ConnectionAvailable && !ContactModel.IsContact)
|
||||
{
|
||||
<MudButton Class="button-settings blue-icon"
|
||||
FullWidth="true"
|
||||
@@ -332,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; }
|
||||
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -10,6 +10,9 @@ public class CRMRetrieveActivityRequestDTO
|
||||
[JsonPropertyName("activityId")]
|
||||
public string? ActivityId { get; set; }
|
||||
|
||||
[JsonPropertyName("codAnag")]
|
||||
public string? CodAnag { get; set; }
|
||||
|
||||
[JsonPropertyName("codJcom")]
|
||||
public string? CodJcom { get; set; }
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using salesbook.Shared.Core.Dto.JobProgress;
|
||||
using salesbook.Shared.Core.Dto.Activity;
|
||||
using salesbook.Shared.Core.Dto.JobProgress;
|
||||
using salesbook.Shared.Core.Entity;
|
||||
|
||||
namespace salesbook.Shared.Core.Dto.PageState;
|
||||
@@ -12,4 +13,5 @@ public class UserPageState
|
||||
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,8 @@ namespace salesbook.Shared.Core.Interface;
|
||||
|
||||
public interface IIntegryApiService
|
||||
{
|
||||
Task<bool> SystemOk();
|
||||
|
||||
Task<List<StbActivity>?> RetrieveActivity(CRMRetrieveActivityRequestDTO activityRequest);
|
||||
Task<List<JtbComt>?> RetrieveAllCommesse(string? dateFilter = null);
|
||||
Task<UsersSyncResponseDTO> RetrieveAnagClie(CRMAnagRequestDTO request);
|
||||
|
||||
@@ -2,5 +2,7 @@
|
||||
|
||||
public interface INetworkService
|
||||
{
|
||||
public bool ConnectionAvailable { get; set; }
|
||||
|
||||
public bool IsNetworkAvailable();
|
||||
}
|
||||
@@ -13,6 +13,19 @@ namespace salesbook.Shared.Core.Services;
|
||||
public class IntegryApiService(IIntegryApiRestClient integryApiRestClient, IUserSession userSession)
|
||||
: IIntegryApiService
|
||||
{
|
||||
public async Task<bool> SystemOk()
|
||||
{
|
||||
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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
@@ -38,6 +74,13 @@ a, .btn-link {
|
||||
height: 90vh;
|
||||
}
|
||||
|
||||
.content::-webkit-scrollbar { width: 3px; }
|
||||
|
||||
.content::-webkit-scrollbar-thumb {
|
||||
background: #bbb;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
h1:focus { outline: none; }
|
||||
|
||||
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
|
||||
@@ -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
|
||||
@@ -57,3 +82,19 @@ observer.observe(document.body, {
|
||||
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");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace salesbook.Web.Core.Services;
|
||||
|
||||
public class NetworkService : INetworkService
|
||||
{
|
||||
public bool ConnectionAvailable { get; set; }
|
||||
|
||||
public bool IsNetworkAvailable()
|
||||
{
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user