Stores scheduler page display preferences per user

This commit is contained in:
BinaryAlley committed 2026-09-03 14:06:01 -07:00
1 parent ab8ab51397
commit 237be9e2c8
50 files changed
+3144 -60

No files matched your search

@@ -23,6 +23,12 @@
- [Fire Scheduled Job](#fire-scheduled-job)
- [Fire Scheduled Job Request](#fire-scheduled-job-request)
- [Fire Scheduled Job Response](#fire-scheduled-job-response)
- [Get Scheduler Display Preferences](#get-scheduler-display-preferences)
- [Get Scheduler Display Preferences Request](#get-scheduler-display-preferences-request)
- [Get Scheduler Display Preferences Response](#get-scheduler-display-preferences-response)
- [Update Scheduler Display Preferences](#update-scheduler-display-preferences)
- [Update Scheduler Display Preferences Request](#update-scheduler-display-preferences-request)
- [Update Scheduler Display Preferences Response](#update-scheduler-display-preferences-response)
## Scheduled Jobs
@@ -60,12 +66,57 @@ POST api/v1/scheduled-jobs
"intervalMinutes": null,
"hour": 3,
"minute": 0,
"status": "Added",
"status": "Active",
"lastStartedOnUtc": null,
"lastCompletedOnUtc": null
}
```
### Get Scheduler Display Preferences
#### Get Scheduler Display Preferences Request
```js
GET api/v1/scheduled-jobs/display-preferences
```
#### Get Scheduler Display Preferences Response
```js
200 Ok
```
```json
{
"userId": "2cff0c0f-3a67-4e30-b94f-f4e948a3b64f",
"jobTypeFilter": "ScanMediaLibraries",
"displayTimeSpan": 10,
"displayTimeUnit": "Minutes"
}
```
### Update Scheduler Display Preferences
#### Update Scheduler Display Preferences Request
```js
PUT api/v1/scheduled-jobs/display-preferences
```
```json
{
"jobTypeFilter": "ScanMediaLibraries",
"displayTimeSpan": 10,
"displayTimeUnit": "Minutes"
}
```
#### Update Scheduler Display Preferences Response
```js
200 Ok
```
### Get Scheduled Jobs
#### Get Scheduled Jobs Request
@@ -0,0 +1,2 @@
GET {{host}}/api/v1/scheduled-jobs/display-preferences
Authorization: Bearer {{ACCESS_TOKEN}}
@@ -0,0 +1,9 @@
PUT {{host}}/api/v1/scheduled-jobs/display-preferences
Authorization: Bearer {{ACCESS_TOKEN}}
Content-Type: application/json
{
"jobTypeFilter": "ScanMediaLibraries",
"displayTimeSpan": 10,
"displayTimeUnit": "Minutes"
}
@@ -0,0 +1,60 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Common;
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Application.Common.DataAccess.Entities.Scheduling;
/// <summary>
/// Repository entity for the display preferences of the scheduler page of a user.
/// </summary>
[DebuggerDisplay("UserId: {UserId}, DisplayTimeSpan: {DisplayTimeSpan}")]
public class SchedulerDisplayPreferencesEntity : IStorageEntity, IAuditableEntity
{
/// <summary>
/// Gets or sets the Id of the display preferences.
/// </summary>
public required Guid Id { get; init; }
/// <summary>
/// Gets or sets the Id of the user that owns the display preferences.
/// </summary>
public required Guid UserId { get; set; }
/// <summary>
/// Gets or sets the type of the scheduled job tasks whose executions are shown on the scheduler page, or <see langword="null"/> when all of them are shown.
/// </summary>
public ScheduledTaskType? JobTypeFilter { get; set; }
/// <summary>
/// Gets or sets the time span, expressed in <see cref="DisplayTimeUnit"/>, that the scheduler page shows.
/// </summary>
public required int DisplayTimeSpan { get; set; }
/// <summary>
/// Gets or sets the unit in which the displayed time span of the scheduler page is expressed.
/// </summary>
public required SchedulerDisplayTimeUnit DisplayTimeUnit { get; set; }
/// <summary>
/// Gets or sets the time and date when the entity was added.
/// </summary>
public required DateTime CreatedOnUtc { get; set; }
/// <summary>
/// Gets or sets the Id of the user that created the entity.
/// </summary>
public required Guid CreatedBy { get; set; }
/// <summary>
/// Gets or sets the optional time and date when the entity was updated.
/// </summary>
public DateTime? UpdatedOnUtc { get; set; }
/// <summary>
/// Gets or sets the optional Id of the user that updated the entity.
/// </summary>
public required Guid? UpdatedBy { get; set; }
}
@@ -0,0 +1,32 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
using Lumina.Application.Common.DataAccess.Repositories.Common.Base;
using Lumina.Domain.Common.Primitives;
using System;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Application.Common.DataAccess.Repositories.Scheduling;
/// <summary>
/// Interface for the repository for the display preferences of the scheduler page.
/// </summary>
public interface ISchedulerDisplayPreferencesRepository : IRepository<SchedulerDisplayPreferencesEntity>
{
/// <summary>
/// Gets the display preferences of the scheduler page of the user identified by <paramref name="userId"/>, if they exist.
/// </summary>
/// <param name="userId">The Id of the user whose display preferences are retrieved.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either the display preferences of the user, or an error.</returns>
Task<Result<SchedulerDisplayPreferencesEntity?>> GetByUserIdAsync(Guid userId, CancellationToken cancellationToken);
/// <summary>
/// Inserts the display preferences of the scheduler page of a user, or updates them when they already exist.
/// </summary>
/// <param name="preferences">The display preferences to insert or update.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Updated>> UpsertAsync(SchedulerDisplayPreferencesEntity preferences, CancellationToken cancellationToken);
}
@@ -98,6 +98,11 @@ public interface IUnitOfWork
/// </summary>
IScheduledJobExecutionRepository ScheduledJobExecutionRepository { get; }
/// <summary>
/// Gets the scheduler display preferences repository.
/// </summary>
ISchedulerDisplayPreferencesRepository SchedulerDisplayPreferencesRepository { get; }
/// <summary>
/// Gets the plugin repository.
/// </summary>
@@ -0,0 +1,48 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
using Lumina.Contracts.Responses.Scheduling;
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
using System;
#endregion
namespace Lumina.Application.Common.Mapping.Scheduling;
/// <summary>
/// Extension methods for converting <see cref="SchedulerDisplayPreferencesEntity"/>.
/// </summary>
public static class SchedulerDisplayPreferencesEntityMapping
{
private const int DEFAULT_DISPLAY_TIME_SPAN = 10;
private const SchedulerDisplayTimeUnit DEFAULT_DISPLAY_TIME_UNIT = SchedulerDisplayTimeUnit.Minutes;
/// <summary>
/// Converts <paramref name="repositoryEntity"/> to <see cref="SchedulerDisplayPreferencesResponse"/>.
/// </summary>
/// <param name="repositoryEntity">The repository entity to be converted.</param>
/// <returns>The converted response.</returns>
public static SchedulerDisplayPreferencesResponse ToResponse(this SchedulerDisplayPreferencesEntity repositoryEntity)
{
return new SchedulerDisplayPreferencesResponse(
repositoryEntity.UserId,
repositoryEntity.JobTypeFilter,
repositoryEntity.DisplayTimeSpan,
repositoryEntity.DisplayTimeUnit
);
}
/// <summary>
/// Converts the lack of stored display preferences to the default <see cref="SchedulerDisplayPreferencesResponse"/> of the user identified by <paramref name="userId"/>.
/// </summary>
/// <param name="repositoryEntity">The missing repository entity, which is <see langword="null"/>.</param>
/// <param name="userId">The Id of the user that owns the display preferences.</param>
/// <returns>The converted response with the default display preferences.</returns>
public static SchedulerDisplayPreferencesResponse ToDefaultResponse(this SchedulerDisplayPreferencesEntity? repositoryEntity, Guid userId)
{
return new SchedulerDisplayPreferencesResponse(
userId,
null,
DEFAULT_DISPLAY_TIME_SPAN,
DEFAULT_DISPLAY_TIME_UNIT
);
}
}
@@ -0,0 +1,26 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Core.Scheduling.Commands.UpdateSchedulerDisplayPreferences;
using Lumina.Contracts.Requests.Scheduling;
#endregion
namespace Lumina.Application.Common.Mapping.Scheduling;
/// <summary>
/// Extension methods for converting <see cref="UpdateSchedulerDisplayPreferencesRequest"/>.
/// </summary>
public static class UpdateSchedulerDisplayPreferencesRequestMapping
{
/// <summary>
/// Converts <paramref name="request"/> to <see cref="UpdateSchedulerDisplayPreferencesCommand"/>.
/// </summary>
/// <param name="request">The request to be converted.</param>
/// <returns>The converted command.</returns>
public static UpdateSchedulerDisplayPreferencesCommand ToCommand(this UpdateSchedulerDisplayPreferencesRequest request)
{
return new UpdateSchedulerDisplayPreferencesCommand(
request.JobTypeFilter,
request.DisplayTimeSpan,
request.DisplayTimeUnit
);
}
}
@@ -0,0 +1,20 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.CQRS;
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
using System.Diagnostics;
#endregion
namespace Lumina.Application.Core.Scheduling.Commands.UpdateSchedulerDisplayPreferences;
/// <summary>
/// Command for updating the display preferences of the scheduler page of the current user.
/// </summary>
/// <param name="JobTypeFilter">The type of the scheduled job tasks whose executions are shown on the scheduler page, or <see langword="null"/> when all of them are shown.</param>
/// <param name="DisplayTimeSpan">The time span, expressed in <paramref name="DisplayTimeUnit"/>, that the scheduler page shows.</param>
/// <param name="DisplayTimeUnit">The unit in which the displayed time span of the scheduler page is expressed.</param>
[DebuggerDisplay("DisplayTimeSpan: {DisplayTimeSpan} {DisplayTimeUnit}")]
public record UpdateSchedulerDisplayPreferencesCommand(
ScheduledTaskType? JobTypeFilter,
int DisplayTimeSpan,
SchedulerDisplayTimeUnit DisplayTimeUnit
) : ICommand;
@@ -0,0 +1,86 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.CQRS;
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
using Lumina.Application.Common.DataAccess.UoW;
using Lumina.Application.Common.Infrastructure.Authentication;
using Lumina.Application.Common.Infrastructure.Authorization;
using Lumina.Application.Common.Infrastructure.Validation;
using Lumina.Domain.Common.Primitives;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
#endregion
namespace Lumina.Application.Core.Scheduling.Commands.UpdateSchedulerDisplayPreferences;
/// <summary>
/// Handler for the command to update the display preferences of the scheduler page of the current user.
/// </summary>
public class UpdateSchedulerDisplayPreferencesCommandHandler : ICommandHandler<UpdateSchedulerDisplayPreferencesCommand, Result<Updated>>
{
private readonly ICurrentUserService _currentUserService;
private readonly IAuthorizationService _authorizationService;
private readonly IUnitOfWork _unitOfWork;
private readonly IValidator<UpdateSchedulerDisplayPreferencesCommand> _validator;
/// <summary>
/// Initializes a new instance of the <see cref="UpdateSchedulerDisplayPreferencesCommandHandler"/> class.
/// </summary>
/// <param name="authorizationService">Injected service for authorization related functionality.</param>
/// <param name="currentUserService">Injected service to retrieve the current user information.</param>
/// <param name="unitOfWork">Injected unit of work for interacting with the data access layer repositories.</param>
/// <param name="validator">Injected validator for application validation rules.</param>
public UpdateSchedulerDisplayPreferencesCommandHandler(IAuthorizationService authorizationService, ICurrentUserService currentUserService, IUnitOfWork unitOfWork, IValidator<UpdateSchedulerDisplayPreferencesCommand> validator)
{
_authorizationService = authorizationService;
_currentUserService = currentUserService;
_unitOfWork = unitOfWork;
_validator = validator;
}
/// <summary>
/// Handles the command to update the display preferences of the scheduler page of the current user.
/// </summary>
/// <param name="command">The command to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>
/// An <see cref="Result{TValue}"/> representing either a successful update, or an error.
/// </returns>
public async Task<Result<Updated>> HandleAsync(UpdateSchedulerDisplayPreferencesCommand command, CancellationToken cancellationToken)
{
List<Error> validationResult = _validator.Validate(command);
if (validationResult.Count > 0)
return validationResult;
// An authenticated request must always carry a user identity.
Guid? currentUserId = _currentUserService.UserId;
if (currentUserId is null)
return ApplicationErrors.Authorization.NotAuthorized;
Guid userId = currentUserId.Value;
// Only administrators can use the scheduler page.
if (!await _authorizationService.IsInRoleAsync(userId, "Admin", cancellationToken).ConfigureAwait(false))
return ApplicationErrors.Authorization.NotAuthorized;
// Upsert the display preferences of the scheduler page of the current user.
SchedulerDisplayPreferencesEntity displayPreferences = new()
{
Id = Guid.NewGuid(),
UserId = userId,
JobTypeFilter = command.JobTypeFilter,
DisplayTimeSpan = command.DisplayTimeSpan,
DisplayTimeUnit = command.DisplayTimeUnit,
CreatedOnUtc = default,
CreatedBy = default,
UpdatedOnUtc = null,
UpdatedBy = null
};
Result<Updated> upsertResult = await _unitOfWork.SchedulerDisplayPreferencesRepository.UpsertAsync(displayPreferences, cancellationToken).ConfigureAwait(false);
if (upsertResult.IsFailure)
return upsertResult.Errors;
await _unitOfWork.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
return Result.Updated;
}
}
@@ -0,0 +1,23 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.Infrastructure.Validation;
using Lumina.Application.Common.Utilities;
using Lumina.Domain.Common.Errors;
#endregion
namespace Lumina.Application.Core.Scheduling.Commands.UpdateSchedulerDisplayPreferences;
/// <summary>
/// Validates the needed validation rules for <see cref="UpdateSchedulerDisplayPreferencesCommand"/>.
/// </summary>
public class UpdateSchedulerDisplayPreferencesCommandValidator : AbstractValidator<UpdateSchedulerDisplayPreferencesCommand>
{
/// <summary>
/// Initializes a new instance of the <see cref="UpdateSchedulerDisplayPreferencesCommandValidator"/> class.
/// </summary>
public UpdateSchedulerDisplayPreferencesCommandValidator()
{
RuleFor(command => command.DisplayTimeSpan)
.GreaterThan(0)
.WithError(Errors.Scheduling.SchedulerDisplayTimeSpanMustBePositive);
}
}
@@ -0,0 +1,10 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.CQRS;
#endregion
namespace Lumina.Application.Core.Scheduling.Queries.GetSchedulerDisplayPreferences;
/// <summary>
/// Query for getting the display preferences of the scheduler page of the current user.
/// </summary>
public record GetSchedulerDisplayPreferencesQuery : IQuery;
@@ -0,0 +1,72 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.CQRS;
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
using Lumina.Application.Common.DataAccess.UoW;
using Lumina.Application.Common.Errors;
using Lumina.Application.Common.Infrastructure.Authentication;
using Lumina.Application.Common.Infrastructure.Authorization;
using Lumina.Application.Common.Mapping.Scheduling;
using Lumina.Contracts.Responses.Scheduling;
using Lumina.Domain.Common.Primitives;
using System;
using System.Threading;
using System.Threading.Tasks;
using ApplicationErrors = Lumina.Application.Common.Errors.Errors;
#endregion
namespace Lumina.Application.Core.Scheduling.Queries.GetSchedulerDisplayPreferences;
/// <summary>
/// Handler for the query to get the display preferences of the scheduler page of the current user.
/// </summary>
public class GetSchedulerDisplayPreferencesQueryHandler : IQueryHandler<GetSchedulerDisplayPreferencesQuery, Result<SchedulerDisplayPreferencesResponse>>
{
private readonly ICurrentUserService _currentUserService;
private readonly IAuthorizationService _authorizationService;
private readonly IUnitOfWork _unitOfWork;
/// <summary>
/// Initializes a new instance of the <see cref="GetSchedulerDisplayPreferencesQueryHandler"/> class.
/// </summary>
/// <param name="authorizationService">Injected service for authorization related functionality.</param>
/// <param name="currentUserService">Injected service to retrieve the current user information.</param>
/// <param name="unitOfWork">Injected unit of work for interacting with the data access layer repositories.</param>
public GetSchedulerDisplayPreferencesQueryHandler(IAuthorizationService authorizationService, ICurrentUserService currentUserService, IUnitOfWork unitOfWork)
{
_authorizationService = authorizationService;
_currentUserService = currentUserService;
_unitOfWork = unitOfWork;
}
/// <summary>
/// Handles the query to get the display preferences of the scheduler page of the current user.
/// </summary>
/// <param name="query">The query to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>
/// An <see cref="Result{TValue}"/> containing either the display preferences of the scheduler page of the current user, or an error.
/// </returns>
public async Task<Result<SchedulerDisplayPreferencesResponse>> HandleAsync(GetSchedulerDisplayPreferencesQuery query, CancellationToken cancellationToken)
{
// An authenticated request must always carry a user identity.
Guid? currentUserId = _currentUserService.UserId;
if (currentUserId is null)
return ApplicationErrors.Authorization.NotAuthorized;
Guid userId = currentUserId.Value;
// Only administrators can view the scheduler page.
if (!await _authorizationService.IsInRoleAsync(userId, "Admin", cancellationToken).ConfigureAwait(false))
return ApplicationErrors.Authorization.NotAuthorized;
// Get the display preferences of the scheduler page of the current user from the repository.
Result<SchedulerDisplayPreferencesEntity?> getDisplayPreferencesResult = await _unitOfWork.SchedulerDisplayPreferencesRepository.GetByUserIdAsync(userId, cancellationToken).ConfigureAwait(false);
if (getDisplayPreferencesResult.IsFailure)
return getDisplayPreferencesResult.Errors;
// When no display preferences are stored for the current user yet, return the default display preferences.
if (getDisplayPreferencesResult.Value is null)
return getDisplayPreferencesResult.Value.ToDefaultResponse(userId);
return getDisplayPreferencesResult.Value.ToResponse();
}
}
@@ -0,0 +1,19 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Requests.Scheduling;
/// <summary>
/// Represents a request to update the display preferences of the scheduler page of the current user.
/// </summary>
/// <param name="JobTypeFilter">The type of the scheduled job tasks whose executions are shown on the scheduler page, or <see langword="null"/> when all of them are shown.</param>
/// <param name="DisplayTimeSpan">The time span, expressed in <paramref name="DisplayTimeUnit"/>, that the scheduler page shows. Required.</param>
/// <param name="DisplayTimeUnit">The unit in which the displayed time span of the scheduler page is expressed. Required.</param>
[DebuggerDisplay("DisplayTimeSpan: {DisplayTimeSpan} {DisplayTimeUnit}")]
public sealed record UpdateSchedulerDisplayPreferencesRequest(
ScheduledTaskType? JobTypeFilter,
int DisplayTimeSpan,
SchedulerDisplayTimeUnit DisplayTimeUnit
);
@@ -0,0 +1,22 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Responses.Scheduling;
/// <summary>
/// Represents the display preferences of the scheduler page of a user.
/// </summary>
/// <param name="UserId">The unique identifier of the user that owns the display preferences.</param>
/// <param name="JobTypeFilter">The type of the scheduled job tasks whose executions are shown on the scheduler page, or <see langword="null"/> when all of them are shown.</param>
/// <param name="DisplayTimeSpan">The time span, expressed in <paramref name="DisplayTimeUnit"/>, that the scheduler page shows.</param>
/// <param name="DisplayTimeUnit">The unit in which the displayed time span of the scheduler page is expressed.</param>
[DebuggerDisplay("UserId: {UserId}, DisplayTimeSpan: {DisplayTimeSpan} {DisplayTimeUnit}")]
public sealed record SchedulerDisplayPreferencesResponse(
Guid UserId,
ScheduledTaskType? JobTypeFilter,
int DisplayTimeSpan,
SchedulerDisplayTimeUnit DisplayTimeUnit
);
@@ -0,0 +1,65 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
#endregion
namespace Lumina.DataAccess.Common.Configuration;
/// <summary>
/// Configures the entity mapping for the <see cref="SchedulerDisplayPreferencesEntity"/> entity.
/// </summary>
public class SchedulerDisplayPreferencesConfiguration : IEntityTypeConfiguration<SchedulerDisplayPreferencesEntity>
{
/// <summary>
/// Configures the <see cref="SchedulerDisplayPreferencesEntity"/> entity.
/// </summary>
/// <param name="builder">The builder to be used to configure the entity.</param>
public void Configure(EntityTypeBuilder<SchedulerDisplayPreferencesEntity> builder)
{
builder.ToTable("SchedulerDisplayPreferences");
builder.HasKey(preferences => preferences.Id);
builder.Property(preferences => preferences.Id)
.ValueGeneratedNever() // because EF always tries to generate the value for the Id, and because we generate it as part of the aggregate root, we need to tell EF not to generate it
.HasColumnOrder(0);
builder.Property(preferences => preferences.UserId)
.IsRequired()
.HasColumnOrder(1);
builder.Property(preferences => preferences.JobTypeFilter)
.HasConversion<string>()
.HasColumnOrder(2);
builder.Property(preferences => preferences.DisplayTimeSpan)
.IsRequired()
.HasColumnOrder(3);
builder.Property(preferences => preferences.DisplayTimeUnit)
.IsRequired()
.HasConversion<string>()
.HasColumnOrder(4);
// Audit.
builder.Property(preferences => preferences.CreatedOnUtc)
.IsRequired()
.HasColumnOrder(5);
builder.Property(preferences => preferences.CreatedBy)
.IsRequired()
.HasColumnOrder(6);
builder.Property(preferences => preferences.UpdatedOnUtc)
.HasDefaultValue(null)
.HasColumnOrder(7);
builder.Property(preferences => preferences.UpdatedBy)
.HasDefaultValue(null)
.HasColumnOrder(8);
// One user has at most one set of scheduler page display preferences.
builder.HasIndex(preferences => preferences.UserId)
.IsUnique();
}
}
@@ -0,0 +1,47 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Lumina.DataAccess.Common.Migrations
{
/// <inheritdoc />
public partial class AddsSchedulerDisplayPreferences : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "SchedulerDisplayPreferences",
columns: table => new
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
UserId = table.Column<Guid>(type: "TEXT", nullable: false),
JobTypeFilter = table.Column<string>(type: "TEXT", nullable: true),
DisplayTimeSpan = table.Column<int>(type: "INTEGER", nullable: false),
DisplayTimeUnit = table.Column<string>(type: "TEXT", nullable: false),
CreatedOnUtc = table.Column<DateTime>(type: "TEXT", nullable: false),
CreatedBy = table.Column<Guid>(type: "TEXT", nullable: false),
UpdatedOnUtc = table.Column<DateTime>(type: "TEXT", nullable: true),
UpdatedBy = table.Column<Guid>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_SchedulerDisplayPreferences", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_SchedulerDisplayPreferences_UserId",
table: "SchedulerDisplayPreferences",
column: "UserId",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "SchedulerDisplayPreferences");
}
}
}
@@ -1,4 +1,4 @@
// <auto-generated />.
// <auto-generated />
using System;
using Lumina.DataAccess.Core.UoW;
using Microsoft.EntityFrameworkCore;
@@ -1207,6 +1207,53 @@ namespace Lumina.DataAccess.Common.Migrations
b.ToTable("ScheduledJobExecutions", (string)null);
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Scheduling.SchedulerDisplayPreferencesEntity", b =>
{
b.Property<Guid>("Id")
.HasColumnType("TEXT")
.HasColumnOrder(0);
b.Property<Guid>("CreatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(6);
b.Property<DateTime>("CreatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(5);
b.Property<int>("DisplayTimeSpan")
.HasColumnType("INTEGER")
.HasColumnOrder(3);
b.Property<string>("DisplayTimeUnit")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnOrder(4);
b.Property<string>("JobTypeFilter")
.HasColumnType("TEXT")
.HasColumnOrder(2);
b.Property<Guid?>("UpdatedBy")
.HasColumnType("TEXT")
.HasColumnOrder(8);
b.Property<DateTime?>("UpdatedOnUtc")
.HasColumnType("TEXT")
.HasColumnOrder(7);
b.Property<Guid>("UserId")
.HasColumnType("TEXT")
.HasColumnOrder(1);
b.HasKey("Id");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("SchedulerDisplayPreferences", (string)null);
});
modelBuilder.Entity("Lumina.Application.Common.DataAccess.Entities.Themes.ThemeEntity", b =>
{
b.Property<Guid>("Id")
@@ -0,0 +1,63 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.DataAccess.Entities.Scheduling;
using Lumina.Application.Common.DataAccess.Repositories.Scheduling;
using Lumina.DataAccess.Core.UoW;
using Lumina.Domain.Common.Primitives;
using Microsoft.EntityFrameworkCore;
using System;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.DataAccess.Core.Repositories.Scheduling;
/// <summary>
/// Repository for the display preferences of the scheduler page.
/// </summary>
internal sealed class SchedulerDisplayPreferencesRepository : ISchedulerDisplayPreferencesRepository
{
private readonly LuminaDbContext _luminaDbContext;
/// <summary>
/// Initializes a new instance of the <see cref="SchedulerDisplayPreferencesRepository"/> class.
/// </summary>
/// <param name="luminaDbContext">Injected Entity Framework DbContext.</param>
public SchedulerDisplayPreferencesRepository(LuminaDbContext luminaDbContext)
{
_luminaDbContext = luminaDbContext;
}
/// <summary>
/// Gets the display preferences of the scheduler page of the user identified by <paramref name="userId"/>, if they exist.
/// </summary>
/// <param name="userId">The Id of the user whose display preferences are retrieved.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> containing either the display preferences of the user, or an error.</returns>
public async Task<Result<SchedulerDisplayPreferencesEntity?>> GetByUserIdAsync(Guid userId, CancellationToken cancellationToken)
{
return await _luminaDbContext.SchedulerDisplayPreferences
.FirstOrDefaultAsync(preferences => preferences.UserId == userId, cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// Inserts the display preferences of the scheduler page of a user, or updates them when they already exist.
/// </summary>
/// <param name="preferences">The display preferences to insert or update.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
public async Task<Result<Updated>> UpsertAsync(SchedulerDisplayPreferencesEntity preferences, CancellationToken cancellationToken)
{
SchedulerDisplayPreferencesEntity? existingPreferences = await _luminaDbContext.SchedulerDisplayPreferences
.FirstOrDefaultAsync(repositoryPreferences => repositoryPreferences.UserId == preferences.UserId, cancellationToken).ConfigureAwait(false);
if (existingPreferences is null)
_luminaDbContext.SchedulerDisplayPreferences.Add(preferences);
else
{
// Update only the mutable fields, preserving the Id and the ownership of the existing preferences.
existingPreferences.JobTypeFilter = preferences.JobTypeFilter;
existingPreferences.DisplayTimeSpan = preferences.DisplayTimeSpan;
existingPreferences.DisplayTimeUnit = preferences.DisplayTimeUnit;
}
return Result.Updated;
}
}
@@ -42,6 +42,7 @@ public class LuminaDbContext : DbContext
public virtual DbSet<BookContributorEntity> BookContributors { get; set; } = null!;
public virtual DbSet<ScheduledJobEntity> ScheduledJobs { get; set; } = null!;
public virtual DbSet<ScheduledJobExecutionEntity> ScheduledJobExecutions { get; set; } = null!;
public virtual DbSet<SchedulerDisplayPreferencesEntity> SchedulerDisplayPreferences { get; set; } = null!;
/// <summary>
/// Initializes a new instance of the <see cref="LuminaDbContext"/> class.
@@ -48,6 +48,7 @@ public class UnitOfWork : IUnitOfWork, IDisposable
private ILibraryBookReaderConfigurationRepository? _libraryBookReaderConfigurationRepository;
private IScheduledJobRepository? _scheduledJobRepository;
private IScheduledJobExecutionRepository? _scheduledJobExecutionRepository;
private ISchedulerDisplayPreferencesRepository? _schedulerDisplayPreferencesRepository;
private IPluginRepository? _pluginRepository;
private IThemeRepository? _themeRepository;
private IUserRepository? _userRepository;
@@ -242,6 +243,18 @@ public class UnitOfWork : IUnitOfWork, IDisposable
}
}
/// <summary>
/// Gets the scheduler display preferences repository.
/// </summary>
public ISchedulerDisplayPreferencesRepository SchedulerDisplayPreferencesRepository
{
get
{
_schedulerDisplayPreferencesRepository ??= new SchedulerDisplayPreferencesRepository(_luminaDbContext);
return _schedulerDisplayPreferencesRepository;
}
}
/// <summary>
/// Gets the plugin repository.
/// </summary>
@@ -0,0 +1,22 @@
namespace Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
/// <summary>
/// Enumeration for the units in which the display time span of the scheduler page is expressed.
/// </summary>
public enum SchedulerDisplayTimeUnit
{
/// <summary>
/// The display time span is expressed in minutes.
/// </summary>
Minutes,
/// <summary>
/// The display time span is expressed in hours.
/// </summary>
Hours,
/// <summary>
/// The display time span is expressed in days.
/// </summary>
Days
}
@@ -24,5 +24,6 @@ public static partial class Errors
public static Error ScheduledJobAlreadyRunning => Error.Forbidden(description: nameof(ScheduledJobAlreadyRunning));
public static Error CanOnlyCompleteRunningScheduledJob => Error.Forbidden(description: nameof(CanOnlyCompleteRunningScheduledJob));
public static Error InvalidScheduleType => Error.Validation(description: nameof(InvalidScheduleType));
public static Error SchedulerDisplayTimeSpanMustBePositive => Error.Validation(description: nameof(SchedulerDisplayTimeSpanMustBePositive));
}
}
@@ -14,5 +14,7 @@ public static partial class ApiRoutes
public const string START_SCHEDULED_JOB = "/scheduled-jobs/{scheduledJobId}/start";
public const string STOP_SCHEDULED_JOB = "/scheduled-jobs/{scheduledJobId}/stop";
public const string FIRE_SCHEDULED_JOB = "/scheduled-jobs/{scheduledJobId}/fire";
public const string GET_DISPLAY_PREFERENCES = "/scheduled-jobs/display-preferences";
public const string UPDATE_DISPLAY_PREFERENCES = "/scheduled-jobs/display-preferences";
}
}
@@ -0,0 +1,51 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.CQRS;
using Lumina.Application.Core.Scheduling.Queries.GetSchedulerDisplayPreferences;
using Lumina.Contracts.Responses.Scheduling;
using Lumina.Domain.Common.Primitives;
using Lumina.Presentation.Api.Common.Routes.Scheduling;
using Lumina.Presentation.Api.Core.Endpoints.Common;
using Microsoft.AspNetCore.Http;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.Scheduling.GetSchedulerDisplayPreferences;
/// <summary>
/// API endpoint for the <c>/scheduled-jobs/display-preferences</c> route.
/// </summary>
public class GetSchedulerDisplayPreferencesEndpoint : BaseEndpoint<FastEndpoints.EmptyRequest, IResult>
{
private readonly IQueryHandler<GetSchedulerDisplayPreferencesQuery, Result<SchedulerDisplayPreferencesResponse>> _getSchedulerDisplayPreferencesQueryHandler;
/// <summary>
/// Initializes a new instance of the <see cref="GetSchedulerDisplayPreferencesEndpoint"/> class.
/// </summary>
/// <param name="getSchedulerDisplayPreferencesQueryHandler">Injected service for handling get scheduler display preferences queries.</param>
public GetSchedulerDisplayPreferencesEndpoint(IQueryHandler<GetSchedulerDisplayPreferencesQuery, Result<SchedulerDisplayPreferencesResponse>> getSchedulerDisplayPreferencesQueryHandler)
{
_getSchedulerDisplayPreferencesQueryHandler = getSchedulerDisplayPreferencesQueryHandler;
}
/// <summary>
/// Configures the API endpoint.
/// </summary>
public override void Configure()
{
Verbs(FastEndpoints.Http.GET);
Routes(ApiRoutes.ScheduledJobs.GET_DISPLAY_PREFERENCES);
Version(1);
DontCatchExceptions();
}
/// <summary>
/// Gets the display preferences of the scheduler page of the current user.
/// </summary>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public override async Task<IResult> ExecuteAsync(FastEndpoints.EmptyRequest request, CancellationToken cancellationToken)
{
Result<SchedulerDisplayPreferencesResponse> result = await _getSchedulerDisplayPreferencesQueryHandler.HandleAsync(new GetSchedulerDisplayPreferencesQuery(), cancellationToken).ConfigureAwait(false);
return result.Match(success => TypedResults.Ok(success), Problem);
}
}
@@ -0,0 +1,75 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Responses.Scheduling;
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.Scheduling.GetSchedulerDisplayPreferences;
/// <summary>
/// Class used for providing a textual description for the <see cref="GetSchedulerDisplayPreferencesEndpoint"/> API endpoint, for OpenAPI.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetSchedulerDisplayPreferencesEndpointSummary : Summary<GetSchedulerDisplayPreferencesEndpoint, EmptyRequest>
{
/// <summary>
/// Initializes a new instance of the <see cref="GetSchedulerDisplayPreferencesEndpointSummary"/> class.
/// </summary>
public GetSchedulerDisplayPreferencesEndpointSummary()
{
Summary = "Gets the display preferences of the scheduler page of the current user.";
Description = "Gets the display preferences of the scheduler page of the current user. When no display preferences are stored for the user yet, the default display preferences are returned. Only administrators can use the scheduler page.";
Response(200, "The display preferences of the scheduler page of the current user are returned.",
example: new SchedulerDisplayPreferencesResponse(
UserId: Guid.NewGuid(),
JobTypeFilter: ScheduledTaskType.ScanMediaLibraries,
DisplayTimeSpan: 10,
DisplayTimeUnit: SchedulerDisplayTimeUnit.Minutes
));
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/scheduled-jobs/display-preferences"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/scheduled-jobs/display-preferences"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/scheduled-jobs/display-preferences"
}
}
);
Response(403, "The request failed because the user making the request is not an administrator.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
title = "General.Failure",
status = 403,
detail = "NotAuthorized",
instance = "/api/v1/scheduled-jobs/display-preferences",
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
}
);
}
}
@@ -0,0 +1,53 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Application.Common.CQRS;
using Lumina.Application.Common.Mapping.Scheduling;
using Lumina.Application.Core.Scheduling.Commands.UpdateSchedulerDisplayPreferences;
using Lumina.Contracts.Requests.Scheduling;
using Lumina.Domain.Common.Primitives;
using Lumina.Presentation.Api.Common.Routes.Scheduling;
using Lumina.Presentation.Api.Core.Endpoints.Common;
using Microsoft.AspNetCore.Http;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.Scheduling.UpdateSchedulerDisplayPreferences;
/// <summary>
/// API endpoint for the <c>/scheduled-jobs/display-preferences</c> route.
/// </summary>
public class UpdateSchedulerDisplayPreferencesEndpoint : BaseEndpoint<UpdateSchedulerDisplayPreferencesRequest, IResult>
{
private readonly ICommandHandler<UpdateSchedulerDisplayPreferencesCommand, Result<Updated>> _updateSchedulerDisplayPreferencesCommandHandler;
/// <summary>
/// Initializes a new instance of the <see cref="UpdateSchedulerDisplayPreferencesEndpoint"/> class.
/// </summary>
/// <param name="updateSchedulerDisplayPreferencesCommandHandler">Injected service for handling update scheduler display preferences commands.</param>
public UpdateSchedulerDisplayPreferencesEndpoint(ICommandHandler<UpdateSchedulerDisplayPreferencesCommand, Result<Updated>> updateSchedulerDisplayPreferencesCommandHandler)
{
_updateSchedulerDisplayPreferencesCommandHandler = updateSchedulerDisplayPreferencesCommandHandler;
}
/// <summary>
/// Configures the API endpoint.
/// </summary>
public override void Configure()
{
Verbs(FastEndpoints.Http.PUT);
Routes(ApiRoutes.ScheduledJobs.UPDATE_DISPLAY_PREFERENCES);
Version(1);
DontCatchExceptions();
}
/// <summary>
/// Updates the display preferences of the scheduler page of the current user.
/// </summary>
/// <param name="request">The request containing the display preferences of the scheduler page of the current user.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public override async Task<IResult> ExecuteAsync(UpdateSchedulerDisplayPreferencesRequest request, CancellationToken cancellationToken)
{
Result<Updated> result = await _updateSchedulerDisplayPreferencesCommandHandler.HandleAsync(request.ToCommand(), cancellationToken).ConfigureAwait(false);
return result.Match(success => TypedResults.Ok(success), Problem);
}
}
@@ -0,0 +1,100 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Contracts.Requests.Scheduling;
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Api.Core.Endpoints.Scheduling.UpdateSchedulerDisplayPreferences;
/// <summary>
/// Class used for providing a textual description for the <see cref="UpdateSchedulerDisplayPreferencesEndpoint"/> API endpoint, for OpenAPI.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateSchedulerDisplayPreferencesEndpointSummary : Summary<UpdateSchedulerDisplayPreferencesEndpoint, UpdateSchedulerDisplayPreferencesRequest>
{
/// <summary>
/// Initializes a new instance of the <see cref="UpdateSchedulerDisplayPreferencesEndpointSummary"/> class.
/// </summary>
public UpdateSchedulerDisplayPreferencesEndpointSummary()
{
Summary = "Updates the display preferences of the scheduler page of the current user.";
Description = "Updates the display preferences of the scheduler page of the current user. Only administrators can use the scheduler page.";
ExampleRequest = new UpdateSchedulerDisplayPreferencesRequest(
JobTypeFilter: ScheduledTaskType.ScanMediaLibraries,
DisplayTimeSpan: 10,
DisplayTimeUnit: SchedulerDisplayTimeUnit.Minutes
);
RequestParam(request => request.JobTypeFilter, "The type of the scheduled job tasks whose executions are shown on the scheduler page, or null when all of them are shown.");
RequestParam(request => request.DisplayTimeSpan, "The time span, expressed in the display time unit, that the scheduler page shows. Required.");
RequestParam(request => request.DisplayTimeUnit, "The unit in which the displayed time span of the scheduler page is expressed. Required.");
Response(200, "The display preferences of the scheduler page of the current user were successfully updated.");
Response(401, "Authentication required.", "application/problem+json",
example: new[]
{
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "You are not authorized",
instance = "/api/v1/scheduled-jobs/display-preferences"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "Invalid token: The token expired at '01/01/2024 01:00:00'",
instance = "/api/v1/scheduled-jobs/display-preferences"
},
new
{
type = "https://tools.ietf.org/html/rfc7235#section-3.1",
status = 401,
title = "Unauthorized",
detail = "The token is invalid",
instance = "/api/v1/scheduled-jobs/display-preferences"
}
}
);
Response(403, "The request failed because the user making the request is not an administrator.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc9110#section-15.5.4",
title = "General.Failure",
status = 403,
detail = "NotAuthorized",
instance = "/api/v1/scheduled-jobs/display-preferences",
traceId = "00-a712bbf99ca8ab485f86a762ae5ae74d-b3a2eb78813b0a5d-00"
}
);
Response(422, "The request did not pass validation checks.", "application/problem+json",
example: new
{
type = "https://tools.ietf.org/html/rfc4918#section-11.2",
title = "General.Validation",
status = 422,
detail = "OneOrMoreValidationErrorsOccurred",
instance = "/api/v1/scheduled-jobs/display-preferences",
errors = new Dictionary<string, string[]>
{
{
"General.Validation", new[]
{
"SchedulerDisplayTimeSpanMustBePositive"
}
}
},
traceId = "00-2470be4248a2a5a0c6f70579975a6954-b9c3ba9544a03500-00"
}
);
}
}
@@ -0,0 +1,22 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.Scheduling;
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.DTO.Scheduling;
/// <summary>
/// Data transfer object for the display preferences of the scheduler page.
/// </summary>
/// <param name="UserId">The unique identifier of the user that owns the display preferences.</param>
/// <param name="JobTypeFilter">The type of the scheduled job tasks whose executions are shown on the scheduler page, or <see langword="null"/> when all of them are shown.</param>
/// <param name="DisplayTimeSpan">The time span, expressed in <paramref name="DisplayTimeUnit"/>, that the scheduler page shows.</param>
/// <param name="DisplayTimeUnit">The unit in which the displayed time span of the scheduler page is expressed.</param>
[DebuggerDisplay("UserId: {UserId}, DisplayTimeSpan: {DisplayTimeSpan} {DisplayTimeUnit}")]
public record SchedulerDisplayPreferencesDto(
Guid UserId,
ScheduledTaskType? JobTypeFilter,
int DisplayTimeSpan,
SchedulerDisplayTimeUnit DisplayTimeUnit
);
@@ -0,0 +1,22 @@
namespace Lumina.Presentation.Web.Common.Enums.Scheduling;
/// <summary>
/// Enumeration for the units in which the display time span of the scheduler page is expressed.
/// </summary>
public enum SchedulerDisplayTimeUnit
{
/// <summary>
/// The display time span is expressed in minutes.
/// </summary>
Minutes,
/// <summary>
/// The display time span is expressed in hours.
/// </summary>
Hours,
/// <summary>
/// The display time span is expressed in days.
/// </summary>
Days
}
@@ -0,0 +1,19 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Presentation.Web.Common.Enums.Scheduling;
using System.Diagnostics;
#endregion
namespace Lumina.Presentation.Web.Common.Requests.Scheduling;
/// <summary>
/// Request for updating the display preferences of the scheduler page of the current user.
/// </summary>
/// <param name="JobTypeFilter">The type of the scheduled job tasks whose executions are shown on the scheduler page, or <see langword="null"/> when all of them are shown.</param>
/// <param name="DisplayTimeSpan">The time span, expressed in <paramref name="DisplayTimeUnit"/>, that the scheduler page shows. Required.</param>
/// <param name="DisplayTimeUnit">The unit in which the displayed time span of the scheduler page is expressed. Required.</param>
[DebuggerDisplay("DisplayTimeSpan: {DisplayTimeSpan} {DisplayTimeUnit}")]
public record UpdateSchedulerDisplayPreferencesRequest(
ScheduledTaskType? JobTypeFilter,
int DisplayTimeSpan,
SchedulerDisplayTimeUnit DisplayTimeUnit
);
@@ -17,5 +17,7 @@ public static partial class ApiRoutes
public const string START_SCHEDULED_JOB = "scheduled-jobs/{scheduledJobId}/start";
public const string STOP_SCHEDULED_JOB = "scheduled-jobs/{scheduledJobId}/stop";
public const string FIRE_SCHEDULED_JOB = "scheduled-jobs/{scheduledJobId}/fire";
public const string GET_DISPLAY_PREFERENCES = "scheduled-jobs/display-preferences";
public const string UPDATE_DISPLAY_PREFERENCES = "scheduled-jobs/display-preferences";
}
}
@@ -18,5 +18,7 @@ public static partial class WebRoutes
public const string START_SCHEDULED_JOB = "{culture}/admin/api-scheduled-jobs/{scheduledJobId}/start";
public const string STOP_SCHEDULED_JOB = "{culture}/admin/api-scheduled-jobs/{scheduledJobId}/stop";
public const string FIRE_SCHEDULED_JOB = "{culture}/admin/api-scheduled-jobs/{scheduledJobId}/fire";
public const string GET_DISPLAY_PREFERENCES = "{culture}/admin/api-scheduled-jobs/display-preferences";
public const string UPDATE_DISPLAY_PREFERENCES = "{culture}/admin/api-scheduled-jobs/display-preferences";
}
}
@@ -0,0 +1,55 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Presentation.Web.Common.Api;
using Lumina.Presentation.Web.Common.Authorization;
using Lumina.Presentation.Web.Common.DTO.Scheduling;
using Lumina.Presentation.Web.Common.Routes;
using Lumina.Presentation.Web.Core.Endpoints.Common;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Web.Core.Endpoints.Admin.Scheduler.GetSchedulerDisplayPreferences;
/// <summary>
/// API endpoint for the <c>/{culture}/admin/api-scheduled-jobs/display-preferences</c> route.
/// </summary>
public class GetSchedulerDisplayPreferencesEndpoint : BaseEndpoint<EmptyRequest, IResult>
{
private readonly IApiHttpClient _apiHttpClient;
/// <summary>
/// Initializes a new instance of the <see cref="GetSchedulerDisplayPreferencesEndpoint"/> class.
/// </summary>
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
public GetSchedulerDisplayPreferencesEndpoint(IApiHttpClient apiHttpClient)
{
_apiHttpClient = apiHttpClient;
}
/// <summary>
/// Configures the endpoint.
/// </summary>
public override void Configure()
{
base.Configure();
Verbs(Http.GET);
Routes(WebRoutes.Scheduler.GET_DISPLAY_PREFERENCES);
DontAutoTag();
Options(options => options.WithTags("Admin"));
Policies(AuthorizationPolicies.REQUIRE_ADMIN_ROLE);
}
/// <summary>
/// Gets the display preferences of the scheduler page of the current user.
/// </summary>
/// <param name="request">The request object.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public override async Task<IResult> ExecuteAsync(EmptyRequest request, CancellationToken cancellationToken)
{
SchedulerDisplayPreferencesDto displayPreferences = await _apiHttpClient.GetAsync<SchedulerDisplayPreferencesDto>(ApiRoutes.ScheduledJobs.GET_DISPLAY_PREFERENCES, cancellationToken).ConfigureAwait(false);
return JsonSuccess(displayPreferences);
}
}
@@ -0,0 +1,33 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Presentation.Web.Common.DTO.Common;
using Lumina.Presentation.Web.Common.DTO.Scheduling;
using Lumina.Presentation.Web.Common.Enums.Scheduling;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Web.Core.Endpoints.Admin.Scheduler.GetSchedulerDisplayPreferences;
/// <summary>
/// Class used for providing a textual description for the <see cref="GetSchedulerDisplayPreferencesEndpoint"/> endpoint, for OpenAPI.
/// </summary>
[ExcludeFromCodeCoverage]
public class GetSchedulerDisplayPreferencesEndpointSummary : Summary<GetSchedulerDisplayPreferencesEndpoint, EmptyRequest>
{
/// <summary>
/// Initializes a new instance of the <see cref="GetSchedulerDisplayPreferencesEndpointSummary"/> class.
/// </summary>
public GetSchedulerDisplayPreferencesEndpointSummary()
{
Summary = "Gets the display preferences of the scheduler page.";
Description = "Retrieves the display preferences of the scheduler page of the current user, or the default display preferences when none are stored yet.";
Response(200, "The display preferences of the scheduler page are returned.", example: new SuccessResponse<SchedulerDisplayPreferencesDto>(true, new SchedulerDisplayPreferencesDto(
UserId: Guid.NewGuid(),
JobTypeFilter: ScheduledTaskType.ScanMediaLibraries,
DisplayTimeSpan: 10,
DisplayTimeUnit: SchedulerDisplayTimeUnit.Minutes
)));
}
}
@@ -0,0 +1,55 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Presentation.Web.Common.Api;
using Lumina.Presentation.Web.Common.Authorization;
using Lumina.Presentation.Web.Common.Requests.Scheduling;
using Lumina.Presentation.Web.Common.Routes;
using Lumina.Presentation.Web.Core.Endpoints.Common;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using System.Threading;
using System.Threading.Tasks;
#endregion
namespace Lumina.Presentation.Web.Core.Endpoints.Admin.Scheduler.UpdateSchedulerDisplayPreferences;
/// <summary>
/// API endpoint for the <c>/{culture}/admin/api-scheduled-jobs/display-preferences</c> route.
/// </summary>
public class UpdateSchedulerDisplayPreferencesEndpoint : BaseEndpoint<UpdateSchedulerDisplayPreferencesRequest, IResult>
{
private readonly IApiHttpClient _apiHttpClient;
/// <summary>
/// Initializes a new instance of the <see cref="UpdateSchedulerDisplayPreferencesEndpoint"/> class.
/// </summary>
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
public UpdateSchedulerDisplayPreferencesEndpoint(IApiHttpClient apiHttpClient)
{
_apiHttpClient = apiHttpClient;
}
/// <summary>
/// Configures the endpoint.
/// </summary>
public override void Configure()
{
base.Configure();
Verbs(Http.PUT);
Routes(WebRoutes.Scheduler.UPDATE_DISPLAY_PREFERENCES);
DontAutoTag();
Options(options => options.WithTags("Admin"));
Policies(AuthorizationPolicies.REQUIRE_ADMIN_ROLE);
}
/// <summary>
/// Updates the display preferences of the scheduler page of the current user.
/// </summary>
/// <param name="request">The request containing the display preferences of the scheduler page of the current user.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
public override async Task<IResult> ExecuteAsync(UpdateSchedulerDisplayPreferencesRequest request, CancellationToken cancellationToken)
{
await _apiHttpClient.PutAsync<Web.Common.Requests.Common.EmptyRequest, UpdateSchedulerDisplayPreferencesRequest>(ApiRoutes.ScheduledJobs.UPDATE_DISPLAY_PREFERENCES, request, cancellationToken).ConfigureAwait(false);
return JsonSuccess();
}
}
@@ -0,0 +1,38 @@
#region ========================================================================= USING =====================================================================================
using FastEndpoints;
using Lumina.Presentation.Web.Common.DTO.Common;
using Lumina.Presentation.Web.Common.Enums.Scheduling;
using Lumina.Presentation.Web.Common.Requests.Scheduling;
using System;
using System.Diagnostics.CodeAnalysis;
#endregion
namespace Lumina.Presentation.Web.Core.Endpoints.Admin.Scheduler.UpdateSchedulerDisplayPreferences;
/// <summary>
/// Class used for providing a textual description for the <see cref="UpdateSchedulerDisplayPreferencesEndpoint"/> endpoint, for OpenAPI.
/// </summary>
[ExcludeFromCodeCoverage]
public class UpdateSchedulerDisplayPreferencesEndpointSummary : Summary<UpdateSchedulerDisplayPreferencesEndpoint, UpdateSchedulerDisplayPreferencesRequest>
{
/// <summary>
/// Initializes a new instance of the <see cref="UpdateSchedulerDisplayPreferencesEndpointSummary"/> class.
/// </summary>
public UpdateSchedulerDisplayPreferencesEndpointSummary()
{
Summary = "Updates the display preferences of the scheduler page.";
Description = "Stores the display preferences of the scheduler page of the current user, so that they are restored on every client the user signs in from.";
RequestParam(r => r.JobTypeFilter, "The type of the scheduled job tasks whose executions are shown on the scheduler page, or null when all of them are shown.");
RequestParam(r => r.DisplayTimeSpan, "The time span, expressed in the display time unit, that the scheduler page shows. Required.");
RequestParam(r => r.DisplayTimeUnit, "The unit in which the displayed time span of the scheduler page is expressed. Required.");
ExampleRequest = new UpdateSchedulerDisplayPreferencesRequest(
JobTypeFilter: ScheduledTaskType.ScanMediaLibraries,
DisplayTimeSpan: 10,
DisplayTimeUnit: SchedulerDisplayTimeUnit.Minutes
);
Response(200, "The display preferences of the scheduler page were successfully updated.", example: new SuccessResponse(true));
}
}
@@ -757,7 +757,7 @@
<value>المهمة المجدولة بهذا الاسم موجودة بالفعل!</value>
</data>
<data name="ScheduledJobExecutionAlreadyExists" xml:space="preserve">
<value>The execution of the scheduled job already exists!</value>
<value>تنفيذ المهمة المجدولة موجود بالفعل!</value>
</data>
<data name="ScheduledJobExecutionNotFound" xml:space="preserve">
<value>لم يتم العثور على تنفيذ المهمة المجدولة!</value>
@@ -774,6 +774,9 @@
<data name="CanOnlyCompleteRunningScheduledJob" xml:space="preserve">
<value>يمكن إكمال المهمة المجدولة قيد التشغيل فقط!</value>
</data>
<data name="SchedulerDisplayTimeSpanMustBePositive" xml:space="preserve">
<value>يجب أن تكون الفترة الزمنية للعرض في صفحة الجدولة رقمًا موجبًا!</value>
</data>
<data name="InvalidScheduleType" xml:space="preserve">
<value>نوع الجدول غير صالح!</value>
</data>
@@ -757,7 +757,7 @@
<value>Ein geplanter Auftrag mit diesem Namen ist bereits vorhanden!</value>
</data>
<data name="ScheduledJobExecutionAlreadyExists" xml:space="preserve">
<value>The execution of the scheduled job already exists!</value>
<value>Die Ausführung des geplanten Auftrags existiert bereits!</value>
</data>
<data name="ScheduledJobExecutionNotFound" xml:space="preserve">
<value>Die Ausführung des geplanten Auftrags wurde nicht gefunden!</value>
@@ -774,6 +774,9 @@
<data name="CanOnlyCompleteRunningScheduledJob" xml:space="preserve">
<value>Nur ein laufender geplanter Auftrag kann abgeschlossen werden!</value>
</data>
<data name="SchedulerDisplayTimeSpanMustBePositive" xml:space="preserve">
<value>Der Anzeigezeitraum der Scheduler-Seite muss eine positive Zahl sein!</value>
</data>
<data name="InvalidScheduleType" xml:space="preserve">
<value>Der Zeitplantyp ist ungültig!</value>
</data>
@@ -774,6 +774,9 @@
<data name="CanOnlyCompleteRunningScheduledJob" xml:space="preserve">
<value>Only a running scheduled job can be completed!</value>
</data>
<data name="SchedulerDisplayTimeSpanMustBePositive" xml:space="preserve">
<value>The display time span of the scheduler page must be a positive number!</value>
</data>
<data name="InvalidScheduleType" xml:space="preserve">
<value>The schedule type is invalid!</value>
</data>
@@ -757,7 +757,7 @@
<value>Ya existe una tarea programada con este nombre!</value>
</data>
<data name="ScheduledJobExecutionAlreadyExists" xml:space="preserve">
<value>The execution of the scheduled job already exists!</value>
<value>La ejecución de la tarea programada ya existe!</value>
</data>
<data name="ScheduledJobExecutionNotFound" xml:space="preserve">
<value>No se encontró la ejecución de la tarea programada!</value>
@@ -774,6 +774,9 @@
<data name="CanOnlyCompleteRunningScheduledJob" xml:space="preserve">
<value>Solo se puede completar una tarea programada en ejecución!</value>
</data>
<data name="SchedulerDisplayTimeSpanMustBePositive" xml:space="preserve">
<value>El intervalo de visualización de la página de tareas programadas debe ser un número positivo!</value>
</data>
<data name="InvalidScheduleType" xml:space="preserve">
<value>El tipo de programación no es válido!</value>
</data>
@@ -757,7 +757,7 @@
<value>Un travail planifié portant ce nom existe déjà !</value>
</data>
<data name="ScheduledJobExecutionAlreadyExists" xml:space="preserve">
<value>The execution of the scheduled job already exists!</value>
<value>L'exécution du travail planifié existe déjà !</value>
</data>
<data name="ScheduledJobExecutionNotFound" xml:space="preserve">
<value>L'exécution du travail planifié est introuvable !</value>
@@ -774,6 +774,9 @@
<data name="CanOnlyCompleteRunningScheduledJob" xml:space="preserve">
<value>Seul un travail planifié en cours d'exécution peut être terminé !</value>
</data>
<data name="SchedulerDisplayTimeSpanMustBePositive" xml:space="preserve">
<value>La durée d'affichage de la page des travaux planifiés doit être un nombre positif !</value>
</data>
<data name="InvalidScheduleType" xml:space="preserve">
<value>Le type de planification n'est pas valide !</value>
</data>
@@ -757,7 +757,7 @@
<value>Esiste già un processo pianificato con questo nome!</value>
</data>
<data name="ScheduledJobExecutionAlreadyExists" xml:space="preserve">
<value>The execution of the scheduled job already exists!</value>
<value>L'esecuzione del processo pianificato esiste già!</value>
</data>
<data name="ScheduledJobExecutionNotFound" xml:space="preserve">
<value>L'esecuzione del processo pianificato non è stata trovata!</value>
@@ -774,6 +774,9 @@
<data name="CanOnlyCompleteRunningScheduledJob" xml:space="preserve">
<value>Solo un processo pianificato in esecuzione può essere completato!</value>
</data>
<data name="SchedulerDisplayTimeSpanMustBePositive" xml:space="preserve">
<value>L'intervallo di visualizzazione della pagina dei processi pianificati deve essere un numero positivo!</value>
</data>
<data name="InvalidScheduleType" xml:space="preserve">
<value>Il tipo di pianificazione non è valido!</value>
</data>
@@ -757,7 +757,7 @@
<value>この名前のスケジュールされたジョブは既に存在します!</value>
</data>
<data name="ScheduledJobExecutionAlreadyExists" xml:space="preserve">
<value>The execution of the scheduled job already exists!</value>
<value>スケジュールされたジョブの実行は既に存在します!</value>
</data>
<data name="ScheduledJobExecutionNotFound" xml:space="preserve">
<value>スケジュールされたジョブの実行が見つかりません!</value>
@@ -774,6 +774,9 @@
<data name="CanOnlyCompleteRunningScheduledJob" xml:space="preserve">
<value>実行中のスケジュールされたジョブのみ完了できます!</value>
</data>
<data name="SchedulerDisplayTimeSpanMustBePositive" xml:space="preserve">
<value>スケジューラーページの表示期間は正の数である必要があります!</value>
</data>
<data name="InvalidScheduleType" xml:space="preserve">
<value>スケジュールタイプが無効です!</value>
</data>
@@ -774,6 +774,9 @@
<data name="CanOnlyCompleteRunningScheduledJob" xml:space="preserve">
<value>Only a running scheduled job can be completed!</value>
</data>
<data name="SchedulerDisplayTimeSpanMustBePositive" xml:space="preserve">
<value>The display time span of the scheduler page must be a positive number!</value>
</data>
<data name="InvalidScheduleType" xml:space="preserve">
<value>The schedule type is invalid!</value>
</data>
@@ -757,7 +757,7 @@
<value>Există deja un job programat cu acest nume!</value>
</data>
<data name="ScheduledJobExecutionAlreadyExists" xml:space="preserve">
<value>The execution of the scheduled job already exists!</value>
<value>Execuția jobului programat există deja!</value>
</data>
<data name="ScheduledJobExecutionNotFound" xml:space="preserve">
<value>Execuția jobului programat nu a fost găsită!</value>
@@ -774,6 +774,9 @@
<data name="CanOnlyCompleteRunningScheduledJob" xml:space="preserve">
<value>Doar un job programat în execuție poate fi finalizat!</value>
</data>
<data name="SchedulerDisplayTimeSpanMustBePositive" xml:space="preserve">
<value>Durata de afișare a paginii joburilor programate trebuie să fie un număr pozitiv!</value>
</data>
<data name="InvalidScheduleType" xml:space="preserve">
<value>Tipul de programare este invalid!</value>
</data>
@@ -757,7 +757,7 @@
<value>Плановане завдання з таким ім'ям вже існує!</value>
</data>
<data name="ScheduledJobExecutionAlreadyExists" xml:space="preserve">
<value>The execution of the scheduled job already exists!</value>
<value>Виконання планованого завдання вже існує!</value>
</data>
<data name="ScheduledJobExecutionNotFound" xml:space="preserve">
<value>Виконання планованого завдання не знайдено!</value>
@@ -774,6 +774,9 @@
<data name="CanOnlyCompleteRunningScheduledJob" xml:space="preserve">
<value>Завершити можна лише плановане завдання, що виконується!</value>
</data>
<data name="SchedulerDisplayTimeSpanMustBePositive" xml:space="preserve">
<value>Період відображення сторінки планувальника має бути додатним числом!</value>
</data>
<data name="InvalidScheduleType" xml:space="preserve">
<value>Тип розкладу недійсний!</value>
</data>
@@ -757,7 +757,7 @@
<value>已存在同名计划任务!</value>
</data>
<data name="ScheduledJobExecutionAlreadyExists" xml:space="preserve">
<value>The execution of the scheduled job already exists!</value>
<value>计划任务的执行记录已存在!</value>
</data>
<data name="ScheduledJobExecutionNotFound" xml:space="preserve">
<value>未找到计划任务的执行记录!</value>
@@ -774,6 +774,9 @@
<data name="CanOnlyCompleteRunningScheduledJob" xml:space="preserve">
<value>只有运行中的计划任务才能完成!</value>
</data>
<data name="SchedulerDisplayTimeSpanMustBePositive" xml:space="preserve">
<value>计划任务页面的显示时长必须是正数!</value>
</data>
<data name="InvalidScheduleType" xml:space="preserve">
<value>调度类型无效!</value>
</data>
@@ -214,6 +214,8 @@
const removeJobUrlTemplate = '@_urlService.GetAbsoluteUrl(WebRoutes.Scheduler.REMOVE_SCHEDULED_JOB, new { scheduledJobId = default(Guid) })';
const accessTokenUrl = '@_urlService.GetAbsoluteUrl(WebRoutes.Authentication.GET_API_ACCESS_TOKEN)';
const schedulerHubUrl = '@scheduledJobsHubUrl';
const getDisplayPreferencesUrl = '@_urlService.GetAbsoluteUrl(WebRoutes.Scheduler.GET_DISPLAY_PREFERENCES)';
const updateDisplayPreferencesUrl = '@_urlService.GetAbsoluteUrl(WebRoutes.Scheduler.UPDATE_DISPLAY_PREFERENCES)';
function getComboboxValue(combobox) {
const selected = combobox.querySelector('.enlightenment-selected-text');
@@ -238,26 +240,33 @@
return () => combobox.removeEventListener('click', handler);
}
// Persists the display preferences of the scheduler page (the job type filter, the time span and its unit) in the
// browser, so that they are restored when the page is reloaded, and the graph and the jobs list respect them.
const schedulerSettingsKey = 'luminaSchedulerSettings';
function readSchedulerSettings() {
try {
const storedSettings = localStorage.getItem(schedulerSettingsKey);
return storedSettings ? JSON.parse(storedSettings) : {};
} catch (error) {
console.error('Failed to read the scheduler settings:', error);
return {};
}
// Reads the display preferences of the scheduler page from its controls, as the payload sent to the update endpoint.
function getDisplayPreferencesPayload() {
const selectedJobType = getComboboxValue(jobTypeFilter) || 'All';
return {
jobTypeFilter: selectedJobType === 'All' ? null : selectedJobType,
displayTimeSpan: Number(timespanInput.value),
displayTimeUnit: getComboboxValue(timeunitSelect)
};
}
function writeSchedulerSettings(settings) {
try {
localStorage.setItem(schedulerSettingsKey, JSON.stringify(settings));
} catch (error) {
console.error('Failed to store the scheduler settings:', error);
}
// Persists the display preferences of the scheduler page (the job type filter, the time span and its unit) on the
// server, so that they are shared by every client the current user signs in from, not only by the browser that changed them.
async function persistDisplayPreferences() {
await callApiPutAsync(updateDisplayPreferencesUrl, getDisplayPreferencesPayload());
}
// Loads the display preferences of the current user from the server, and applies them to the controls, before the graph and
// the jobs list are loaded; the server returns the default display preferences when none are stored for the user yet.
async function applyDisplayPreferences() {
const displayPreferences = await callApiGetAsync(getDisplayPreferencesUrl);
if (!displayPreferences)
return;
setComboboxValue(jobTypeFilter, displayPreferences.jobTypeFilter || 'All');
setComboboxValue(timeunitSelect, displayPreferences.displayTimeUnit || 'Minutes');
const storedTimeSpan = Number(displayPreferences.displayTimeSpan);
if (Number.isFinite(storedTimeSpan) && storedTimeSpan >= 1)
timespanInput.value = storedTimeSpan;
}
function setComboboxValue(combobox, value) {
@@ -271,27 +280,6 @@
}
}
function persistDisplayPreferences() {
const settings = {
jobType: getComboboxValue(jobTypeFilter) || 'All',
timespan: timespanInput.value,
timeUnit: getComboboxValue(timeunitSelect)
};
writeSchedulerSettings(settings);
}
// Restores the stored display preferences on the controls, before the graph and the jobs list are loaded.
function applyDisplayPreferences() {
const settings = readSchedulerSettings();
if (settings.jobType)
setComboboxValue(jobTypeFilter, settings.jobType);
if (settings.timeUnit)
setComboboxValue(timeunitSelect, settings.timeUnit);
const storedTimespan = Number(settings.timespan);
if (Number.isFinite(storedTimespan) && storedTimespan >= 1)
timespanInput.value = storedTimespan;
}
// Graph state.
const taskTypeOrder = ['ScanMediaLibraries', 'CleanTemporaryFiles'];
const graphState = {
@@ -640,7 +628,7 @@
async function updateTimeSpanAsync() {
adjustTimeScale();
graphState.dataPoints = [];
persistDisplayPreferences();
await persistDisplayPreferences();
await loadHistoryAsync();
}
@@ -744,7 +732,7 @@
//+----------------------------------------------------------------------------------------+
async function initialize() {
applyDisplayPreferences();
await applyDisplayPreferences();
renderLegend();
graphState.startTime = new Date();
graphState.startTime.setMinutes(0, 0, 0);
@@ -767,16 +755,19 @@
toggleScheduleFields();
// Persist the display preferences when they change, and reload the history when the job type filter changes,
// so that the graph and the jobs list always respect the selected filter.
const handleJobTypeFilterChange = () => {
persistDisplayPreferences();
// so that the graph and the jobs list always respect the selected filter, on every client of the current user.
const handleJobTypeFilterChange = async () => {
renderJobsTable();
updateTimeSpanAsync();
await updateTimeSpanAsync();
};
const unbindJobTypeFilterChange = bindComboboxChange(jobTypeFilter, handleJobTypeFilterChange);
const unbindTimeUnitChange = bindComboboxChange(timeunitSelect, persistDisplayPreferences);
const handleTimespanChange = () => persistDisplayPreferences();
timespanInput.addEventListener('input', handleTimespanChange);
const handleTimeUnitChange = async () => {
await persistDisplayPreferences();
};
const unbindTimeUnitChange = bindComboboxChange(timeunitSelect, handleTimeUnitChange);
const handleTimespanChange = async () => {
await persistDisplayPreferences();
};
timespanInput.addEventListener('change', handleTimespanChange);
updateTimespanButton.addEventListener('click', updateTimeSpanAsync);
addJobButton.addEventListener('click', addJobAsync);
@@ -790,7 +781,6 @@
unbindScheduleTypeChange();
unbindJobTypeFilterChange();
unbindTimeUnitChange();
timespanInput.removeEventListener('input', handleTimespanChange);
timespanInput.removeEventListener('change', handleTimespanChange);
updateTimespanButton.removeEventListener('click', updateTimeSpanAsync);
addJobButton.removeEventListener('click', addJobAsync);