Implementato controllo conessione dispositivo e servizi. Completata pagination commesse e attività per cliente
This commit is contained in:
@@ -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,9 +4,11 @@ namespace salesbook.Maui.Core.Services;
|
||||
|
||||
public class NetworkService : INetworkService
|
||||
{
|
||||
public bool ConnectionAvailable { get; set; }
|
||||
|
||||
public bool IsNetworkAvailable()
|
||||
{
|
||||
return false;
|
||||
//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,6 +7,7 @@
|
||||
@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
|
||||
@@ -93,6 +94,7 @@ else
|
||||
|
||||
<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">
|
||||
@@ -102,6 +104,9 @@ else
|
||||
<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>
|
||||
|
||||
@@ -150,8 +155,8 @@ else
|
||||
<MudTextField T="string?"
|
||||
Placeholder="Cerca..."
|
||||
Variant="Variant.Text"
|
||||
@bind-Value="SearchTerm"
|
||||
OnDebounceIntervalElapsed="() => ApplyFilters()"
|
||||
@bind-Value="SearchTermCommesse"
|
||||
OnDebounceIntervalElapsed="() => ApplyFiltersCommesse()"
|
||||
DebounceInterval="500" />
|
||||
</div>
|
||||
|
||||
@@ -179,46 +184,86 @@ else
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (TotalPages > 1)
|
||||
@if (TotalPagesCommesse > 1)
|
||||
{
|
||||
<div class="custom-pagination">
|
||||
<MudPagination BoundaryCount="1" MiddleCount="1" Count="@TotalPages"
|
||||
@bind-Selected="CurrentPage"
|
||||
Color="Color.Primary"/>
|
||||
<MudPagination BoundaryCount="1" MiddleCount="1" Count="@TotalPagesCommesse"
|
||||
@bind-Selected="SelectedPageCommesse"
|
||||
Color="Color.Primary" />
|
||||
</div>
|
||||
|
||||
<div class="SelectedPageSize">
|
||||
<MudSelect @bind-Value="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="20">15</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 class="commesse-stats mt-4">
|
||||
<MudChip T="string" Size="Size.Small" Color="Color.Info">
|
||||
Visualizzate: @CurrentPageCommesse.Count() / @FilteredCommesse.Count()
|
||||
</MudChip>
|
||||
@if (!string.IsNullOrEmpty(SearchTerm))
|
||||
{
|
||||
<MudChip T="string" Size="Size.Small" Color="Color.Warning" OnClose="ClearSearch">
|
||||
Filtro: "@SearchTerm"
|
||||
</MudChip>
|
||||
}
|
||||
</div> *@
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -230,75 +275,77 @@ else
|
||||
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; } = new();
|
||||
|
||||
// Stati di caricamento
|
||||
private bool IsLoading { get; set; } = true;
|
||||
private bool IsLoadingCommesse { get; set; } = true;
|
||||
private bool IsLoadingSteps { get; set; } = false;
|
||||
private readonly HashSet<string> _loadingSteps = new();
|
||||
private bool ActivityIsLoading { get; set; } = true;
|
||||
private bool IsLoadingSteps { get; set; }
|
||||
private readonly HashSet<string> _loadingSteps = [];
|
||||
|
||||
// Gestione tab
|
||||
private int ActiveTab { get; set; } = 0;
|
||||
private int ActiveTab { get; set; }
|
||||
|
||||
// Paginazione e filtri
|
||||
private int _currentPage = 1;
|
||||
private int _selectedPageSize = 5;
|
||||
private string _searchTerm = string.Empty;
|
||||
private List<JtbComt> _filteredCommesse = new();
|
||||
// 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? _searchTimer;
|
||||
private Timer? _searchTimerCommesse;
|
||||
private Timer? _searchTimerActivity;
|
||||
private const int SearchDelayMs = 300;
|
||||
|
||||
#region Properties
|
||||
#region Properties per Commesse
|
||||
|
||||
private int CurrentPage
|
||||
private int SelectedPageCommesse
|
||||
{
|
||||
get => _currentPage;
|
||||
get => _selectedPageCommesse;
|
||||
set
|
||||
{
|
||||
if (_currentPage != value)
|
||||
{
|
||||
_currentPage = value;
|
||||
if (_selectedPageCommesse == value) return;
|
||||
_selectedPageCommesse = value;
|
||||
_ = LoadStepsForCurrentPageAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int SelectedPageSize
|
||||
private int SelectedPageSizeCommesse
|
||||
{
|
||||
get => _selectedPageSize;
|
||||
get => _selectedPageSizeCommesse;
|
||||
set
|
||||
{
|
||||
if (_selectedPageSize != value)
|
||||
{
|
||||
_selectedPageSize = value;
|
||||
_currentPage = 1;
|
||||
ApplyFilters();
|
||||
if (_selectedPageSizeCommesse == value) return;
|
||||
_selectedPageSizeCommesse = value;
|
||||
_selectedPageCommesse = 1;
|
||||
ApplyFiltersCommesse();
|
||||
_ = LoadStepsForCurrentPageAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string SearchTerm
|
||||
private string SearchTermCommesse
|
||||
{
|
||||
get => _searchTerm;
|
||||
get => _searchTermCommesse;
|
||||
set
|
||||
{
|
||||
if (_searchTerm != value)
|
||||
{
|
||||
_searchTerm = value;
|
||||
if (_searchTermCommesse == value) return;
|
||||
_searchTermCommesse = value;
|
||||
|
||||
// Debounce della ricerca
|
||||
_searchTimer?.Dispose();
|
||||
_searchTimer = new Timer(async _ => await InvokeAsync(ApplyFilters), null, SearchDelayMs, Timeout.Infinite);
|
||||
}
|
||||
_searchTimerCommesse?.Dispose();
|
||||
_searchTimerCommesse = new Timer(async _ => await InvokeAsync(ApplyFiltersCommesse), null, SearchDelayMs, Timeout.Infinite);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,11 +359,67 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
private int TotalPages =>
|
||||
FilteredCommesse.Count == 0 ? 1 : (int)Math.Ceiling(FilteredCommesse.Count / (double)SelectedPageSize);
|
||||
private int TotalPagesCommesse =>
|
||||
FilteredCommesse.Count == 0 ? 1 : (int)Math.Ceiling(FilteredCommesse.Count / (double)SelectedPageSizeCommesse);
|
||||
|
||||
private IEnumerable<JtbComt> CurrentPageCommesse =>
|
||||
FilteredCommesse.Skip((CurrentPage - 1) * SelectedPageSize).Take(SelectedPageSize);
|
||||
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
|
||||
|
||||
@@ -339,7 +442,6 @@ else
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Log dell'errore
|
||||
Console.WriteLine($"Errore in OnInitializedAsync: {ex.Message}");
|
||||
}
|
||||
finally
|
||||
@@ -351,11 +453,12 @@ else
|
||||
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
_loadingCts?.Cancel();
|
||||
_loadingCts?.CancelAsync();
|
||||
_loadingCts?.Dispose();
|
||||
_stepsCts?.Cancel();
|
||||
_stepsCts?.CancelAsync();
|
||||
_stepsCts?.Dispose();
|
||||
_searchTimer?.Dispose();
|
||||
_searchTimerCommesse?.DisposeAsync();
|
||||
_searchTimerActivity?.DisposeAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -366,21 +469,18 @@ else
|
||||
{
|
||||
try
|
||||
{
|
||||
// Caricamento dati principali
|
||||
await LoadAnagAsync();
|
||||
await LoadPersRifAsync();
|
||||
_ = LoadActivity();
|
||||
|
||||
// Caricamento agente
|
||||
if (!string.IsNullOrEmpty(Anag.CodVage))
|
||||
{
|
||||
Agente = (await ManageData.GetTable<StbUser>(x => x.UserCode != null && x.UserCode.Equals(Anag.CodVage)))
|
||||
.LastOrDefault();
|
||||
}
|
||||
|
||||
// Salvataggio in sessione
|
||||
SaveDataToSession();
|
||||
|
||||
// Caricamento commesse in background
|
||||
_ = Task.Run(async () => await LoadCommesseAsync());
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -393,12 +493,12 @@ else
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -407,16 +507,35 @@ else
|
||||
{
|
||||
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
|
||||
@@ -425,17 +544,14 @@ else
|
||||
|
||||
Commesse = await ManageData.GetTable<JtbComt>(x => x.CodAnag != null && x.CodAnag.Equals(CodContact));
|
||||
|
||||
// Ordinamento ottimizzato
|
||||
Commesse = Commesse?
|
||||
.OrderByDescending(x => x.LastUpd ?? DateTime.MinValue)
|
||||
.ThenByDescending(x => x.CodJcom)
|
||||
.OrderByDescending(x => x.CodJcom)
|
||||
.ToList();
|
||||
|
||||
UserState.Commesse = Commesse;
|
||||
|
||||
ApplyFilters();
|
||||
ApplyFiltersCommesse();
|
||||
|
||||
// Caricamento steps per la prima pagina
|
||||
await LoadStepsForCurrentPageAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -455,11 +571,14 @@ else
|
||||
PersRif = UserState.PersRif;
|
||||
Commesse = UserState.Commesse;
|
||||
Agente = UserState.Agente;
|
||||
Steps = UserState.Steps ?? new Dictionary<string, List<CRMJobStepDTO>?>();
|
||||
Steps = UserState.Steps;
|
||||
ActivityList = UserState.Activitys;
|
||||
|
||||
ApplyFilters();
|
||||
ApplyFiltersCommesse();
|
||||
ApplyFiltersActivity();
|
||||
|
||||
IsLoadingCommesse = false;
|
||||
ActivityIsLoading = false;
|
||||
}
|
||||
|
||||
private void SaveDataToSession()
|
||||
@@ -469,6 +588,7 @@ else
|
||||
UserState.PersRif = PersRif;
|
||||
UserState.Agente = Agente;
|
||||
UserState.Steps = Steps;
|
||||
UserState.Activitys = ActivityList;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -560,30 +680,32 @@ else
|
||||
{
|
||||
ActiveTab = tabIndex;
|
||||
|
||||
// Se si passa alle commesse e non sono ancora state caricate
|
||||
if (tabIndex == 1 && Commesse == null)
|
||||
{
|
||||
_ = Task.Run(async () => await LoadCommesseAsync());
|
||||
} else if (tabIndex == 1 && Steps.IsNullOrEmpty())
|
||||
}
|
||||
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 ApplyFilters()
|
||||
private void ApplyFiltersCommesse()
|
||||
{
|
||||
if (Commesse == null)
|
||||
{
|
||||
FilteredCommesse = new List<JtbComt>();
|
||||
FilteredCommesse = [];
|
||||
return;
|
||||
}
|
||||
|
||||
var filtered = Commesse.AsEnumerable();
|
||||
|
||||
// Filtro per testo di ricerca
|
||||
if (!string.IsNullOrWhiteSpace(SearchTerm))
|
||||
if (!string.IsNullOrWhiteSpace(SearchTermCommesse))
|
||||
{
|
||||
var searchLower = SearchTerm.ToLowerInvariant();
|
||||
var searchLower = SearchTermCommesse.ToLowerInvariant();
|
||||
filtered = filtered.Where(c =>
|
||||
c.CodJcom?.ToLowerInvariant().Contains(searchLower) == true ||
|
||||
c.Descrizione?.ToLowerInvariant().Contains(searchLower) == true ||
|
||||
@@ -591,21 +713,40 @@ else
|
||||
}
|
||||
|
||||
FilteredCommesse = filtered.ToList();
|
||||
if (SelectedPageCommesse > TotalPagesCommesse && TotalPagesCommesse > 0) _selectedPageCommesse = 1;
|
||||
|
||||
// Reset della pagina se necessario
|
||||
if (CurrentPage > TotalPages && TotalPages > 0)
|
||||
{
|
||||
_currentPage = 1;
|
||||
}
|
||||
|
||||
// Carica gli steps per la pagina corrente
|
||||
_ = LoadStepsForCurrentPageAsync();
|
||||
}
|
||||
|
||||
private void ClearSearch()
|
||||
private void ApplyFiltersActivity()
|
||||
{
|
||||
SearchTerm = string.Empty;
|
||||
ApplyFilters();
|
||||
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
|
||||
@@ -629,12 +770,10 @@ else
|
||||
|
||||
if (result is { Canceled: false })
|
||||
{
|
||||
// Aggiorna i dati se necessario
|
||||
await LoadAnagAsync();
|
||||
SaveDataToSession();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -165,10 +165,15 @@
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
.attivita-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
/*--------------
|
||||
TabPanel
|
||||
----------------*/
|
||||
|
||||
.box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -199,7 +204,7 @@
|
||||
content: '';
|
||||
display: block;
|
||||
height: 3px;
|
||||
width: calc(100% / 2);
|
||||
width: calc(100% / 3);
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
@@ -223,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;
|
||||
@@ -235,6 +241,8 @@
|
||||
|
||||
#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;
|
||||
@@ -257,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 {
|
||||
|
||||
@@ -28,13 +28,27 @@
|
||||
<div class="activity-hours-section">
|
||||
<span class="activity-hours">
|
||||
@if (Activity.EffectiveTime is null)
|
||||
{
|
||||
if (ShowDate)
|
||||
{
|
||||
@($"{Activity.EstimatedTime:g}")
|
||||
}
|
||||
else
|
||||
{
|
||||
@($"{Activity.EstimatedTime:t}")
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ShowDate)
|
||||
{
|
||||
@($"{Activity.EffectiveTime:g}")
|
||||
}
|
||||
else
|
||||
{
|
||||
@($"{Activity.EffectiveTime:t}")
|
||||
}
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
</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">
|
||||
@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,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