Compare commits
3 Commits
24f5f91704
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| dffbc31432 | |||
| 151ecaa98f | |||
| b917aa5077 |
@@ -5,6 +5,30 @@
|
|||||||
|
|
||||||
## RECENT CHANGES (This Session)
|
## RECENT CHANGES (This Session)
|
||||||
|
|
||||||
|
**Job Scheduler Race Condition Fix (Dec 8, 2025):**
|
||||||
|
- ✅ **In-Memory Deduplication** - Added `HashSet<Guid>` to track LayerIds scheduled within the same batch
|
||||||
|
- ✅ **Prevents Duplicate Jobs** - Fixed race condition where same layer could be scheduled multiple times during single "Run All Jobs" operation
|
||||||
|
- ✅ **Two-Level Protection** - In-memory check (HashSet) runs before database check for O(1) performance
|
||||||
|
- ✅ **Applied to Both Methods** - Fixed both ScheduleImportJobsAsync and ScheduleProcessJobsAsync
|
||||||
|
- ✅ **Better Logging** - Added debug log message "Job already scheduled in this batch" for transparency
|
||||||
|
- Root cause: When multiple layers had same ID in query results or import plugins created new layers during scheduling loop, database check couldn't detect duplicates added in same batch before SaveChangesAsync()
|
||||||
|
- Solution: Track scheduled LayerIds in HashSet during loop iteration to prevent within-batch duplicates
|
||||||
|
- Files modified: [JobSchedulerService.cs](DiunaBI.Infrastructure/Services/JobSchedulerService.cs)
|
||||||
|
- Status: Race condition resolved, duplicate job creation prevented
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Blazor Server Reconnection UI Customization (Dec 8, 2025):**
|
||||||
|
- ✅ **Custom Reconnection Modal** - Replaced default Blazor "Rejoin failed..." dialog with custom-styled modal
|
||||||
|
- ✅ **Theme-Matched Styling** - Changed loader and button colors from blue to app's primary red (#e7163d) matching navbar
|
||||||
|
- ✅ **Timer with Elapsed Seconds** - Added real-time timer showing elapsed reconnection time (0s, 1s, 2s...)
|
||||||
|
- ✅ **CSS Classes Integration** - Used Blazor's built-in `.components-reconnect-show/failed/rejected` classes for state management
|
||||||
|
- ✅ **MutationObserver Timer** - JavaScript watches for CSS class changes to start/stop elapsed time counter
|
||||||
|
- ✅ **Professional Design** - Modal backdrop blur, spinner animation, red reload button with hover effects
|
||||||
|
- Files modified: [App.razor](DiunaBI.UI.Web/Components/App.razor), [app.css](DiunaBI.UI.Web/wwwroot/app.css)
|
||||||
|
- Files created: [reconnect.js](DiunaBI.UI.Web/wwwroot/js/reconnect.js)
|
||||||
|
- Status: Blazor reconnection UI now matches app theme with timer indicator
|
||||||
|
|
||||||
**Jobs List Sorting and Multi-Select Filtering (Dec 8, 2025):**
|
**Jobs List Sorting and Multi-Select Filtering (Dec 8, 2025):**
|
||||||
- ✅ **Fixed Job Sorting** - Changed from single CreatedAt DESC to Priority ASC → JobType → CreatedAt DESC
|
- ✅ **Fixed Job Sorting** - Changed from single CreatedAt DESC to Priority ASC → JobType → CreatedAt DESC
|
||||||
- ✅ **Multi-Select Status Filter** - Replaced single status dropdown with multi-select supporting multiple JobStatus values
|
- ✅ **Multi-Select Status Filter** - Replaced single status dropdown with multi-select supporting multiple JobStatus values
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
DECLARE @JustForDebug TINYINT = 0;
|
DECLARE @JustForDebug TINYINT = 0;
|
||||||
|
|
||||||
|
-- FIX DATAINBOX!
|
||||||
|
|
||||||
-- SETUP VARIABLES
|
-- SETUP VARIABLES
|
||||||
DECLARE @Year INT = 2024;
|
DECLARE @Year INT = 2025;
|
||||||
DECLARE @Type NVARCHAR(5) = 'B3';
|
DECLARE @Type NVARCHAR(5) = 'B3';
|
||||||
DECLARE @StartDate NVARCHAR(10) = '2025.01.02';
|
DECLARE @StartDate NVARCHAR(10) = '2025.01.02';
|
||||||
DECLARE @EndDate NVARCHAR(10) = '2026.12.31'
|
DECLARE @EndDate NVARCHAR(10) = '2026.12.31'
|
||||||
@@ -22,7 +24,7 @@ SET @Plugin =
|
|||||||
DECLARE @DataInboxName NVARCHAR(100);
|
DECLARE @DataInboxName NVARCHAR(100);
|
||||||
SET @DataInboxName =
|
SET @DataInboxName =
|
||||||
CASE @Type
|
CASE @Type
|
||||||
WHEN 'B3' THEN 'B3_2024'
|
WHEN 'B3' THEN 'P2_2025'
|
||||||
ELSE NULL -- If @Type doesn't match, set it to NULL
|
ELSE NULL -- If @Type doesn't match, set it to NULL
|
||||||
END;
|
END;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
DECLARE @JustForDebug TINYINT = 0;
|
DECLARE @JustForDebug TINYINT = 0;
|
||||||
|
|
||||||
-- SETUP VARIABLES
|
-- SETUP VARIABLES
|
||||||
DECLARE @Year INT = 2024;
|
DECLARE @Year INT = 2025;
|
||||||
|
|
||||||
DECLARE @Number INT = (SELECT COUNT(id) + 1 FROM [DiunaBI-PedrolloPL].[dbo].[Layers]);
|
DECLARE @Number INT = (SELECT COUNT(id) + 1 FROM [DiunaBI-PedrolloPL].[dbo].[Layers]);
|
||||||
DECLARE @CurrentTimestamp NVARCHAR(14) = FORMAT(GETDATE(), 'yyyyMMddHHmm');
|
DECLARE @CurrentTimestamp NVARCHAR(14) = FORMAT(GETDATE(), 'yyyyMMddHHmm');
|
||||||
@@ -56,3 +56,16 @@ VALUES ((SELECT NEWID()), 'Plugin', 'PedrolloPL.Process.P2', GETDATE(), GETDATE(
|
|||||||
INSERT INTO [DiunaBI-PedrolloPL].[dbo].[Records]
|
INSERT INTO [DiunaBI-PedrolloPL].[dbo].[Records]
|
||||||
([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId])
|
([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId])
|
||||||
VALUES ((SELECT NEWID()), 'Priority', '110', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, @LayerId);
|
VALUES ((SELECT NEWID()), 'Priority', '110', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, @LayerId);
|
||||||
|
--
|
||||||
|
INSERT INTO [DiunaBI-PedrolloPL].[dbo].[Records]
|
||||||
|
([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId])
|
||||||
|
VALUES ((SELECT NEWID()), 'GoogleSheetId', '1jI-3QrlBADm5slEl2Balf29cKmHwkYi4pboaHY-gRqc', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, @LayerId);
|
||||||
|
|
||||||
|
INSERT INTO [DiunaBI-PedrolloPL].[dbo].[Records]
|
||||||
|
([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId])
|
||||||
|
VALUES ((SELECT NEWID()), 'GoogleSheetTab', 'P2_Export_DiunaBI', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, @LayerId);
|
||||||
|
|
||||||
|
INSERT INTO [DiunaBI-PedrolloPL].[dbo].[Records]
|
||||||
|
([Id], [Code], [Desc1], [CreatedAt], [ModifiedAt], [CreatedById], [ModifiedById], [IsDeleted], [LayerId])
|
||||||
|
VALUES ((SELECT NEWID()), 'GoogleSheetRange', 'C32:O48', GETDATE(), GETDATE(), '117be4f0-b5d1-41a1-a962-39dc30cce368', '117be4f0-b5d1-41a1-a962-39dc30cce368', 0, @LayerId);
|
||||||
|
|
||||||
@@ -71,11 +71,10 @@ public class JobsController : Controller
|
|||||||
|
|
||||||
var totalCount = await query.CountAsync();
|
var totalCount = await query.CountAsync();
|
||||||
|
|
||||||
// Sort by: Priority ASC (0=highest), JobType, then CreatedAt DESC
|
// Sort by: CreatedAt DESC (newest first), then Priority ASC (0=highest)
|
||||||
var items = await query
|
var items = await query
|
||||||
.OrderBy(j => j.Priority)
|
.OrderByDescending(j => j.CreatedAt)
|
||||||
.ThenBy(j => j.JobType)
|
.ThenBy(j => j.Priority)
|
||||||
.ThenByDescending(j => j.CreatedAt)
|
|
||||||
.Skip(start)
|
.Skip(start)
|
||||||
.Take(limit)
|
.Take(limit)
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ public class JobSchedulerService
|
|||||||
_logger.LogInformation("JobScheduler: Found {Count} import workers to schedule", importWorkers.Count);
|
_logger.LogInformation("JobScheduler: Found {Count} import workers to schedule", importWorkers.Count);
|
||||||
|
|
||||||
var jobsCreated = 0;
|
var jobsCreated = 0;
|
||||||
|
var scheduledLayerIds = new HashSet<Guid>(); // Track LayerIds scheduled in this batch
|
||||||
|
|
||||||
foreach (var worker in importWorkers)
|
foreach (var worker in importWorkers)
|
||||||
{
|
{
|
||||||
@@ -61,7 +62,15 @@ public class JobSchedulerService
|
|||||||
var maxRetriesStr = worker.Records?.FirstOrDefault(r => r.Code == "MaxRetries")?.Desc1;
|
var maxRetriesStr = worker.Records?.FirstOrDefault(r => r.Code == "MaxRetries")?.Desc1;
|
||||||
var maxRetries = int.TryParse(maxRetriesStr, out var mr) ? mr : 3;
|
var maxRetries = int.TryParse(maxRetriesStr, out var mr) ? mr : 3;
|
||||||
|
|
||||||
// Check if there's already a pending/running job for this layer
|
// Check in-memory: already scheduled in this batch?
|
||||||
|
if (scheduledLayerIds.Contains(worker.Id))
|
||||||
|
{
|
||||||
|
_logger.LogDebug("JobScheduler: Job already scheduled in this batch for {LayerName} ({LayerId})",
|
||||||
|
worker.Name, worker.Id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if there's already a pending/running job for this layer in database
|
||||||
var existingJob = await _db.QueueJobs
|
var existingJob = await _db.QueueJobs
|
||||||
.Where(j => j.LayerId == worker.Id &&
|
.Where(j => j.LayerId == worker.Id &&
|
||||||
(j.Status == JobStatus.Pending || j.Status == JobStatus.Running))
|
(j.Status == JobStatus.Pending || j.Status == JobStatus.Running))
|
||||||
@@ -91,6 +100,7 @@ public class JobSchedulerService
|
|||||||
};
|
};
|
||||||
|
|
||||||
_db.QueueJobs.Add(job);
|
_db.QueueJobs.Add(job);
|
||||||
|
scheduledLayerIds.Add(worker.Id); // Track that we've scheduled this layer
|
||||||
jobsCreated++;
|
jobsCreated++;
|
||||||
|
|
||||||
_logger.LogInformation("JobScheduler: Created import job for {LayerName} ({LayerId}) with priority {Priority}",
|
_logger.LogInformation("JobScheduler: Created import job for {LayerName} ({LayerId}) with priority {Priority}",
|
||||||
@@ -129,6 +139,7 @@ public class JobSchedulerService
|
|||||||
_logger.LogInformation("JobScheduler: Found {Count} process workers to schedule", processWorkers.Count);
|
_logger.LogInformation("JobScheduler: Found {Count} process workers to schedule", processWorkers.Count);
|
||||||
|
|
||||||
var jobsCreated = 0;
|
var jobsCreated = 0;
|
||||||
|
var scheduledLayerIds = new HashSet<Guid>(); // Track LayerIds scheduled in this batch
|
||||||
|
|
||||||
foreach (var worker in processWorkers)
|
foreach (var worker in processWorkers)
|
||||||
{
|
{
|
||||||
@@ -150,7 +161,15 @@ public class JobSchedulerService
|
|||||||
var maxRetriesStr = worker.Records?.FirstOrDefault(r => r.Code == "MaxRetries")?.Desc1;
|
var maxRetriesStr = worker.Records?.FirstOrDefault(r => r.Code == "MaxRetries")?.Desc1;
|
||||||
var maxRetries = int.TryParse(maxRetriesStr, out var mr) ? mr : 3;
|
var maxRetries = int.TryParse(maxRetriesStr, out var mr) ? mr : 3;
|
||||||
|
|
||||||
// Check if there's already a pending/running job for this layer
|
// Check in-memory: already scheduled in this batch?
|
||||||
|
if (scheduledLayerIds.Contains(worker.Id))
|
||||||
|
{
|
||||||
|
_logger.LogDebug("JobScheduler: Job already scheduled in this batch for {LayerName} ({LayerId})",
|
||||||
|
worker.Name, worker.Id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if there's already a pending/running job for this layer in database
|
||||||
var existingJob = await _db.QueueJobs
|
var existingJob = await _db.QueueJobs
|
||||||
.Where(j => j.LayerId == worker.Id &&
|
.Where(j => j.LayerId == worker.Id &&
|
||||||
(j.Status == JobStatus.Pending || j.Status == JobStatus.Running))
|
(j.Status == JobStatus.Pending || j.Status == JobStatus.Running))
|
||||||
@@ -180,6 +199,7 @@ public class JobSchedulerService
|
|||||||
};
|
};
|
||||||
|
|
||||||
_db.QueueJobs.Add(job);
|
_db.QueueJobs.Add(job);
|
||||||
|
scheduledLayerIds.Add(worker.Id); // Track that we've scheduled this layer
|
||||||
jobsCreated++;
|
jobsCreated++;
|
||||||
|
|
||||||
_logger.LogInformation("JobScheduler: Created process job for {LayerName} ({LayerId}) with priority {Priority}",
|
_logger.LogInformation("JobScheduler: Created process job for {LayerName} ({LayerId}) with priority {Priority}",
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public class JobWorkerService : BackgroundService
|
|||||||
{
|
{
|
||||||
private readonly IServiceProvider _serviceProvider;
|
private readonly IServiceProvider _serviceProvider;
|
||||||
private readonly ILogger<JobWorkerService> _logger;
|
private readonly ILogger<JobWorkerService> _logger;
|
||||||
private readonly TimeSpan _pollInterval = TimeSpan.FromSeconds(10);
|
private readonly TimeSpan _pollInterval = TimeSpan.FromSeconds(5);
|
||||||
private readonly TimeSpan _rateLimitDelay = TimeSpan.FromSeconds(5);
|
private readonly TimeSpan _rateLimitDelay = TimeSpan.FromSeconds(5);
|
||||||
|
|
||||||
public JobWorkerService(IServiceProvider serviceProvider, ILogger<JobWorkerService> logger)
|
public JobWorkerService(IServiceProvider serviceProvider, ILogger<JobWorkerService> logger)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
@page "/datainbox"
|
@page "/datainbox"
|
||||||
@using MudBlazor.Internal
|
@using MudBlazor.Internal
|
||||||
@using DiunaBI.Application.DTOModels
|
@using DiunaBI.Application.DTOModels
|
||||||
|
@implements IDisposable
|
||||||
|
|
||||||
<PageTitle>Data Inbox</PageTitle>
|
<PageTitle>Data Inbox</PageTitle>
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,10 @@ using Microsoft.JSInterop;
|
|||||||
|
|
||||||
namespace DiunaBI.UI.Shared.Pages.DataInbox;
|
namespace DiunaBI.UI.Shared.Pages.DataInbox;
|
||||||
|
|
||||||
public partial class Index : ComponentBase
|
public partial class Index : ComponentBase, IDisposable
|
||||||
{
|
{
|
||||||
[Inject] private DataInboxService DataInboxService { get; set; } = default!;
|
[Inject] private DataInboxService DataInboxService { get; set; } = default!;
|
||||||
|
[Inject] private EntityChangeHubService HubService { get; set; } = default!;
|
||||||
[Inject] private ISnackbar Snackbar { get; set; } = default!;
|
[Inject] private ISnackbar Snackbar { get; set; } = default!;
|
||||||
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
|
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
|
||||||
[Inject] private DataInboxFilterStateService FilterStateService { get; set; } = default!;
|
[Inject] private DataInboxFilterStateService FilterStateService { get; set; } = default!;
|
||||||
@@ -27,6 +28,22 @@ public partial class Index : ComponentBase
|
|||||||
await DateTimeHelper.InitializeAsync();
|
await DateTimeHelper.InitializeAsync();
|
||||||
filterRequest = FilterStateService.FilterRequest;
|
filterRequest = FilterStateService.FilterRequest;
|
||||||
await LoadDataInbox();
|
await LoadDataInbox();
|
||||||
|
|
||||||
|
// Subscribe to SignalR entity changes
|
||||||
|
HubService.EntityChanged += OnEntityChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnEntityChanged(string module, string id, string operation)
|
||||||
|
{
|
||||||
|
// Only react if it's a DataInbox change
|
||||||
|
if (module.Equals("DataInbox", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
await InvokeAsync(async () =>
|
||||||
|
{
|
||||||
|
await LoadDataInbox();
|
||||||
|
StateHasChanged();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task LoadDataInbox()
|
private async Task LoadDataInbox()
|
||||||
@@ -77,4 +94,9 @@ public partial class Index : ComponentBase
|
|||||||
var url = NavigationManager.ToAbsoluteUri($"/datainbox/{dataInboxItem.Id}").ToString();
|
var url = NavigationManager.ToAbsoluteUri($"/datainbox/{dataInboxItem.Id}").ToString();
|
||||||
await JSRuntime.InvokeVoidAsync("open", url, "_blank");
|
await JSRuntime.InvokeVoidAsync("open", url, "_blank");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
HubService.EntityChanged -= OnEntityChanged;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,11 +69,6 @@
|
|||||||
</MudMenuItem>
|
</MudMenuItem>
|
||||||
</MudMenu>
|
</MudMenu>
|
||||||
|
|
||||||
<MudIconButton Icon="@Icons.Material.Filled.Refresh"
|
|
||||||
OnClick="LoadJobs"
|
|
||||||
Color="Color.Primary"
|
|
||||||
Size="Size.Medium"
|
|
||||||
Title="Refresh"/>
|
|
||||||
<MudIconButton Icon="@Icons.Material.Filled.Clear"
|
<MudIconButton Icon="@Icons.Material.Filled.Clear"
|
||||||
OnClick="ClearFilters"
|
OnClick="ClearFilters"
|
||||||
Color="Color.Default"
|
Color="Color.Default"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
@using DiunaBI.UI.Shared.Services
|
@using DiunaBI.UI.Shared.Services
|
||||||
@using DiunaBI.Application.DTOModels
|
@using DiunaBI.Application.DTOModels
|
||||||
@using MudBlazor
|
@using MudBlazor
|
||||||
|
@implements IDisposable
|
||||||
|
|
||||||
<MudCard>
|
<MudCard>
|
||||||
<MudCardHeader>
|
<MudCardHeader>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ using System.Reflection;
|
|||||||
|
|
||||||
namespace DiunaBI.UI.Shared.Pages.Layers;
|
namespace DiunaBI.UI.Shared.Pages.Layers;
|
||||||
|
|
||||||
public partial class Details : ComponentBase
|
public partial class Details : ComponentBase, IDisposable
|
||||||
{
|
{
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
@@ -20,6 +20,9 @@ public partial class Details : ComponentBase
|
|||||||
[Inject]
|
[Inject]
|
||||||
private JobService JobService { get; set; } = null!;
|
private JobService JobService { get; set; } = null!;
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
private EntityChangeHubService HubService { get; set; } = null!;
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
private NavigationManager NavigationManager { get; set; } = null!;
|
private NavigationManager NavigationManager { get; set; } = null!;
|
||||||
|
|
||||||
@@ -57,6 +60,39 @@ public partial class Details : ComponentBase
|
|||||||
{
|
{
|
||||||
await DateTimeHelper.InitializeAsync();
|
await DateTimeHelper.InitializeAsync();
|
||||||
await LoadLayer();
|
await LoadLayer();
|
||||||
|
|
||||||
|
// Subscribe to SignalR entity changes
|
||||||
|
HubService.EntityChanged += OnEntityChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnEntityChanged(string module, string id, string operation)
|
||||||
|
{
|
||||||
|
// React to Layers or Records changes for this layer
|
||||||
|
if (module.Equals("Layers", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
module.Equals("Records", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
// Check if it's this layer or its records that changed
|
||||||
|
if (Guid.TryParse(id, out var changedId))
|
||||||
|
{
|
||||||
|
if (module.Equals("Layers", StringComparison.OrdinalIgnoreCase) && changedId == Id)
|
||||||
|
{
|
||||||
|
await InvokeAsync(async () =>
|
||||||
|
{
|
||||||
|
await LoadLayer();
|
||||||
|
StateHasChanged();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (module.Equals("Records", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
// For records, we reload to get the latest data
|
||||||
|
await InvokeAsync(async () =>
|
||||||
|
{
|
||||||
|
await LoadLayer();
|
||||||
|
StateHasChanged();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
protected override async Task OnParametersSetAsync()
|
||||||
@@ -495,4 +531,9 @@ public partial class Details : ComponentBase
|
|||||||
isRunningJob = false;
|
isRunningJob = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
HubService.EntityChanged -= OnEntityChanged;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
@page "/layers"
|
@page "/layers"
|
||||||
@using MudBlazor.Internal
|
@using MudBlazor.Internal
|
||||||
@using DiunaBI.Application.DTOModels
|
@using DiunaBI.Application.DTOModels
|
||||||
|
@implements IDisposable
|
||||||
|
|
||||||
<PageTitle>Layers</PageTitle>
|
<PageTitle>Layers</PageTitle>
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,10 @@ using Microsoft.JSInterop;
|
|||||||
|
|
||||||
namespace DiunaBI.UI.Shared.Pages.Layers;
|
namespace DiunaBI.UI.Shared.Pages.Layers;
|
||||||
|
|
||||||
public partial class Index : ComponentBase
|
public partial class Index : ComponentBase, IDisposable
|
||||||
{
|
{
|
||||||
[Inject] private LayerService LayerService { get; set; } = default!;
|
[Inject] private LayerService LayerService { get; set; } = default!;
|
||||||
|
[Inject] private EntityChangeHubService HubService { get; set; } = default!;
|
||||||
[Inject] private ISnackbar Snackbar { get; set; } = default!;
|
[Inject] private ISnackbar Snackbar { get; set; } = default!;
|
||||||
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
|
[Inject] private NavigationManager NavigationManager { get; set; } = default!;
|
||||||
[Inject] private LayerFilterStateService FilterStateService { get; set; } = default!;
|
[Inject] private LayerFilterStateService FilterStateService { get; set; } = default!;
|
||||||
@@ -25,6 +26,22 @@ public partial class Index : ComponentBase
|
|||||||
{
|
{
|
||||||
filterRequest = FilterStateService.FilterRequest;
|
filterRequest = FilterStateService.FilterRequest;
|
||||||
await LoadLayers();
|
await LoadLayers();
|
||||||
|
|
||||||
|
// Subscribe to SignalR entity changes
|
||||||
|
HubService.EntityChanged += OnEntityChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async void OnEntityChanged(string module, string id, string operation)
|
||||||
|
{
|
||||||
|
// Only react if it's a Layers change
|
||||||
|
if (module.Equals("Layers", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
await InvokeAsync(async () =>
|
||||||
|
{
|
||||||
|
await LoadLayers();
|
||||||
|
StateHasChanged();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task LoadLayers()
|
private async Task LoadLayers()
|
||||||
@@ -89,4 +106,9 @@ public partial class Index : ComponentBase
|
|||||||
var url = NavigationManager.ToAbsoluteUri($"/layers/{layer.Id}").ToString();
|
var url = NavigationManager.ToAbsoluteUri($"/layers/{layer.Id}").ToString();
|
||||||
await JSRuntime.InvokeVoidAsync("open", url, "_blank");
|
await JSRuntime.InvokeVoidAsync("open", url, "_blank");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
HubService.EntityChanged -= OnEntityChanged;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,9 +31,24 @@
|
|||||||
<a class="dismiss">🗙</a>
|
<a class="dismiss">🗙</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="components-reconnect-modal" data-nosnippet>
|
||||||
|
<div class="reconnect-content">
|
||||||
|
<div class="reconnect-spinner"></div>
|
||||||
|
<h5>Connection Lost</h5>
|
||||||
|
<div class="reconnect-message">
|
||||||
|
Attempting to reconnect to the server...
|
||||||
|
</div>
|
||||||
|
<div class="reconnect-timer">
|
||||||
|
<span id="reconnect-elapsed-time">0s</span>
|
||||||
|
</div>
|
||||||
|
<button onclick="location.reload()">Reload Page</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script src="_framework/blazor.web.js"></script>
|
<script src="_framework/blazor.web.js"></script>
|
||||||
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
|
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
|
||||||
<script src="_content/DiunaBI.UI.Shared/js/auth.js"></script>
|
<script src="_content/DiunaBI.UI.Shared/js/auth.js"></script>
|
||||||
|
<script src="js/reconnect.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
@@ -58,3 +58,93 @@ h1:focus {
|
|||||||
.mud-pagination li::marker {
|
.mud-pagination li::marker {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Blazor Server Reconnection UI Customization */
|
||||||
|
#components-reconnect-modal {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background: rgba(0, 0, 0, 0.5);
|
||||||
|
backdrop-filter: blur(4px);
|
||||||
|
z-index: 9999;
|
||||||
|
font-family: 'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
||||||
|
display: none !important;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Show modal when Blazor applies these classes */
|
||||||
|
#components-reconnect-modal.components-reconnect-show,
|
||||||
|
#components-reconnect-modal.components-reconnect-failed,
|
||||||
|
#components-reconnect-modal.components-reconnect-rejected {
|
||||||
|
display: flex !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#components-reconnect-modal .reconnect-content {
|
||||||
|
background: white;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 32px;
|
||||||
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
|
||||||
|
max-width: 400px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#components-reconnect-modal h5 {
|
||||||
|
margin: 0 0 16px 0;
|
||||||
|
color: #424242;
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
#components-reconnect-modal .reconnect-message {
|
||||||
|
color: #666;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
#components-reconnect-modal .reconnect-spinner {
|
||||||
|
width: 48px;
|
||||||
|
height: 48px;
|
||||||
|
border: 4px solid #f3f3f3;
|
||||||
|
border-top: 4px solid #e7163d;
|
||||||
|
border-radius: 50%;
|
||||||
|
animation: spin 1s linear infinite;
|
||||||
|
margin: 0 auto 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
0% { transform: rotate(0deg); }
|
||||||
|
100% { transform: rotate(360deg); }
|
||||||
|
}
|
||||||
|
|
||||||
|
#components-reconnect-modal .reconnect-timer {
|
||||||
|
color: #e7163d;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 500;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#components-reconnect-modal button {
|
||||||
|
background-color: #e7163d;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 10px 24px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#components-reconnect-modal button:hover {
|
||||||
|
background-color: #c01234;
|
||||||
|
}
|
||||||
|
|
||||||
|
#components-reconnect-modal button:active {
|
||||||
|
background-color: #a01028;
|
||||||
|
}
|
||||||
|
|||||||
82
DiunaBI.UI.Web/wwwroot/js/reconnect.js
Normal file
82
DiunaBI.UI.Web/wwwroot/js/reconnect.js
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
// Blazor Server Reconnection Timer
|
||||||
|
(function() {
|
||||||
|
let reconnectTimer = null;
|
||||||
|
let startTime = null;
|
||||||
|
|
||||||
|
function startTimer() {
|
||||||
|
if (reconnectTimer) return; // Already running
|
||||||
|
|
||||||
|
console.log('Blazor reconnection started, timer running...');
|
||||||
|
startTime = Date.now();
|
||||||
|
|
||||||
|
reconnectTimer = setInterval(() => {
|
||||||
|
const elapsedSeconds = Math.floor((Date.now() - startTime) / 1000);
|
||||||
|
const timerElement = document.getElementById('reconnect-elapsed-time');
|
||||||
|
|
||||||
|
if (timerElement) {
|
||||||
|
timerElement.textContent = `${elapsedSeconds}s`;
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopTimer() {
|
||||||
|
if (reconnectTimer) {
|
||||||
|
console.log('Blazor reconnection ended, stopping timer');
|
||||||
|
clearInterval(reconnectTimer);
|
||||||
|
reconnectTimer = null;
|
||||||
|
|
||||||
|
// Reset timer display
|
||||||
|
const timerElement = document.getElementById('reconnect-elapsed-time');
|
||||||
|
if (timerElement) {
|
||||||
|
timerElement.textContent = '0s';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkReconnectionState() {
|
||||||
|
const modal = document.getElementById('components-reconnect-modal');
|
||||||
|
|
||||||
|
if (!modal) return;
|
||||||
|
|
||||||
|
// Check if modal has the "show" class (Blazor applies this when reconnecting)
|
||||||
|
if (modal.classList.contains('components-reconnect-show')) {
|
||||||
|
startTimer();
|
||||||
|
} else {
|
||||||
|
stopTimer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MutationObserver to watch for class changes on the modal
|
||||||
|
const observer = new MutationObserver((mutations) => {
|
||||||
|
mutations.forEach((mutation) => {
|
||||||
|
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
|
||||||
|
checkReconnectionState();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Start observing when DOM is ready
|
||||||
|
function init() {
|
||||||
|
const modal = document.getElementById('components-reconnect-modal');
|
||||||
|
|
||||||
|
if (modal) {
|
||||||
|
observer.observe(modal, {
|
||||||
|
attributes: true,
|
||||||
|
attributeFilter: ['class']
|
||||||
|
});
|
||||||
|
|
||||||
|
// Check initial state
|
||||||
|
checkReconnectionState();
|
||||||
|
console.log('Blazor reconnection timer initialized');
|
||||||
|
} else {
|
||||||
|
console.warn('components-reconnect-modal not found, retrying...');
|
||||||
|
setTimeout(init, 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.readyState === 'loading') {
|
||||||
|
document.addEventListener('DOMContentLoaded', init);
|
||||||
|
} else {
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
})();
|
||||||
Reference in New Issue
Block a user