mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-01 18:57:24 +00:00
feat: adds FastEndpoints endpoints, views and resources to the web project
This commit is contained in:
1 parent
733e174cac
commit
d3b1c681dc
341 files changed
+44018
-113
No files matched your search
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.Authorization;
|
||||
using Lumina.Presentation.Web.Common.DTO.Authorization;
|
||||
using Lumina.Presentation.Web.Common.Requests.Authorization;
|
||||
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.Authorization.Roles.AddRole;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/admin/api-create-role</c> route.
|
||||
/// </summary>
|
||||
public class AddRoleEndpoint : BaseEndpoint<AddRoleRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AddRoleEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public AddRoleEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.POST);
|
||||
Routes(WebRoutes.Admin.CREATE_ROLE);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Admin"));
|
||||
Policies(AuthorizationPolicies.REQUIRE_ADMIN_ROLE);
|
||||
EnableAntiforgery();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an authorization role.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the details of the authorization role to add.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(AddRoleRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
RolePermissionsDto response = await _apiHttpClient.PostAsync<RolePermissionsDto, AddRoleRequest>(ApiRoutes.Roles.CREATE_ROLE, request, cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(response);
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Authorization;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.Requests.Authorization;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Admin.Authorization.Roles.AddRole;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="AddRoleEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AddRoleEndpointSummary : Summary<AddRoleEndpoint, AddRoleRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AddRoleEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public AddRoleEndpointSummary()
|
||||
{
|
||||
Summary = "Adds a new role.";
|
||||
Description = "Creates a new authorization role with the specified permissions.";
|
||||
RequestParam(r => r.RoleName, "The name of the role. Required.");
|
||||
RequestParam(r => r.Permissions, "The collection of Ids of the permissions of the role. Required.");
|
||||
|
||||
ExampleRequest = new AddRoleRequest(
|
||||
RoleName: "Editor",
|
||||
Permissions: [
|
||||
Guid.NewGuid(),
|
||||
Guid.NewGuid(),
|
||||
]
|
||||
);
|
||||
|
||||
Response(200, "The role is created.", example: new SuccessResponse<RolePermissionsDto>(true, default));
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.Authorization;
|
||||
using Lumina.Presentation.Web.Common.Requests.Authorization;
|
||||
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.Authorization.Roles.DeleteRole;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/admin/api-delete-role/{roleId}</c> route.
|
||||
/// </summary>
|
||||
public class DeleteRoleEndpoint : BaseEndpoint<DeleteRoleRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DeleteRoleEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public DeleteRoleEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.DELETE);
|
||||
Routes(WebRoutes.Admin.DELETE_ROLE);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Admin"));
|
||||
Policies(AuthorizationPolicies.REQUIRE_ADMIN_ROLE);
|
||||
EnableAntiforgery();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the authorization role identified by the request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the unique identifier of the authorization role to delete.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(DeleteRoleRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
await _apiHttpClient.DeleteAsync(ApiRoutes.Roles.DELETE_ROLE.Replace("{roleId}", request.RoleId.ToString()), cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess();
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.Requests.Authorization;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Admin.Authorization.Roles.DeleteRole;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="DeleteRoleEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DeleteRoleEndpointSummary : Summary<DeleteRoleEndpoint, DeleteRoleRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DeleteRoleEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public DeleteRoleEndpointSummary()
|
||||
{
|
||||
Summary = "Deletes a role.";
|
||||
Description = "Deletes an existing authorization role identified by its unique identifier.";
|
||||
|
||||
RequestParam(r => r.RoleId, "The unique identifier of the role to delete.");
|
||||
|
||||
Response(200, "The role is deleted.", example: new SuccessResponse(true));
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.Authorization;
|
||||
using Lumina.Presentation.Web.Common.DTO.Authorization;
|
||||
using Lumina.Presentation.Web.Common.Requests.Authorization;
|
||||
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.Authorization.Roles.GetRolePermissions;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/admin/api-get-permissions-by-role-id/{roleId}</c> route.
|
||||
/// </summary>
|
||||
public class GetRolePermissionsEndpoint : BaseEndpoint<GetRolePermissionsRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetRolePermissionsEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public GetRolePermissionsEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Admin.GET_PERMISSIONS_BY_ROLE_ID);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Admin"));
|
||||
Policies(AuthorizationPolicies.REQUIRE_ADMIN_ROLE);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the permissions of the authorization role identified by the request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the unique identifier of the role whose permissions are retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetRolePermissionsRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
RolePermissionsDto response = await _apiHttpClient.GetAsync<RolePermissionsDto>(ApiRoutes.Roles.GET_ROLE_PERMISSIONS_BY_ROLE_ID.Replace("{roleId}", request.RoleId.ToString()), cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(response);
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Authorization;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.Requests.Authorization;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Admin.Authorization.Roles.GetRolePermissions;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetRolePermissionsEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetRolePermissionsEndpointSummary : Summary<GetRolePermissionsEndpoint, GetRolePermissionsRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetRolePermissionsEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetRolePermissionsEndpointSummary()
|
||||
{
|
||||
Summary = "Gets the permissions of a role.";
|
||||
Description = "Retrieves the permissions of an existing authorization role identified by its unique identifier.";
|
||||
|
||||
RequestParam(r => r.RoleId, "The unique identifier of the role whose permissions are retrieved.");
|
||||
|
||||
Response(200, "The permissions of the role are returned.", example: new SuccessResponse<RolePermissionsDto>(true, default));
|
||||
}
|
||||
}
|
||||
+55
@@ -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.Authorization;
|
||||
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.Authorization.Roles.GetRoles;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/admin/api-get-roles</c> route.
|
||||
/// </summary>
|
||||
public class GetRolesEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetRolesEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public GetRolesEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Admin.GET_ROLES);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Admin"));
|
||||
Policies(AuthorizationPolicies.REQUIRE_ADMIN_ROLE);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the authorization roles.
|
||||
/// </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)
|
||||
{
|
||||
RoleDto[] roles = await _apiHttpClient.GetAsync<RoleDto[]>(ApiRoutes.Roles.GET_ROLES, cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(roles);
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Authorization;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Admin.Authorization.Roles.GetRoles;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetRolesEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetRolesEndpointSummary : Summary<GetRolesEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetRolesEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetRolesEndpointSummary()
|
||||
{
|
||||
Summary = "Gets all roles.";
|
||||
Description = "Retrieves the collection of existing authorization roles.";
|
||||
|
||||
Response(200, "The collection of authorization roles is returned.", example: new SuccessResponse<RoleDto[]>(true, default));
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.Authorization;
|
||||
using Lumina.Presentation.Web.Common.DTO.Authorization;
|
||||
using Lumina.Presentation.Web.Common.Requests.Authorization;
|
||||
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.Authorization.Roles.UpdateRole;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/admin/api-update-role</c> route.
|
||||
/// </summary>
|
||||
public class UpdateRoleEndpoint : BaseEndpoint<UpdateRoleRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UpdateRoleEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public UpdateRoleEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.PUT);
|
||||
Routes(WebRoutes.Admin.UPDATE_ROLE);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Admin"));
|
||||
Policies(AuthorizationPolicies.REQUIRE_ADMIN_ROLE);
|
||||
EnableAntiforgery();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates an existing authorization role.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the updated details of the authorization role.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(UpdateRoleRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
RolePermissionsDto response = await _apiHttpClient.PutAsync<RolePermissionsDto, UpdateRoleRequest>(ApiRoutes.Roles.UPDATE_ROLE, request, cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(response);
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Authorization;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.Requests.Authorization;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Admin.Authorization.Roles.UpdateRole;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="UpdateRoleEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UpdateRoleEndpointSummary : Summary<UpdateRoleEndpoint, UpdateRoleRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UpdateRoleEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public UpdateRoleEndpointSummary()
|
||||
{
|
||||
Summary = "Updates a role.";
|
||||
Description = "Updates the name and the permissions of an existing authorization role.";
|
||||
RequestParam(r => r.RoleId, "The unique identifier of the role. Required.");
|
||||
RequestParam(r => r.RoleName, "The name of the role. Required.");
|
||||
RequestParam(r => r.Permissions, "The collection of Ids of the permissions of the role. Required.");
|
||||
|
||||
ExampleRequest = new UpdateRoleRequest(
|
||||
RoleId: Guid.NewGuid(),
|
||||
RoleName: "Editor",
|
||||
Permissions: [
|
||||
Guid.NewGuid(),
|
||||
Guid.NewGuid(),
|
||||
]
|
||||
);
|
||||
|
||||
Response(200, "The role is updated.", example: new SuccessResponse<RolePermissionsDto>(true, default));
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.Authorization;
|
||||
using Lumina.Presentation.Web.Common.DTO.Authorization;
|
||||
using Lumina.Presentation.Web.Common.DTO.UsersManagement;
|
||||
using Lumina.Presentation.Web.Common.Routes;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Admin.ManagePermissions;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/admin/manage-permissions</c> route.
|
||||
/// </summary>
|
||||
public class ManagePermissionsViewEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ManagePermissionsViewEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public ManagePermissionsViewEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Admin.MANAGE_PERMISSIONS);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Admin"));
|
||||
Policies(AuthorizationPolicies.REQUIRE_ADMIN_ROLE);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays the authorization permissions management view.
|
||||
/// </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)
|
||||
{
|
||||
UserDto[] users = await _apiHttpClient.GetAsync<UserDto[]>(ApiRoutes.Authentication.USERS, cancellationToken).ConfigureAwait(false);
|
||||
RoleDto[] roles = await _apiHttpClient.GetAsync<RoleDto[]>(ApiRoutes.Roles.GET_ROLES, cancellationToken).ConfigureAwait(false);
|
||||
PermissionDto[] permissions = await _apiHttpClient.GetAsync<PermissionDto[]>(ApiRoutes.Permissions.GET_PERMISSIONS, cancellationToken).ConfigureAwait(false);
|
||||
Dictionary<string, object?> viewData = new() { ["users"] = users, ["roles"] = roles, ["permissions"] = permissions };
|
||||
return View("/Core/Views/Admin/ManagePermissions.cshtml", viewData: viewData);
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Admin.ManagePermissions;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="ManagePermissionsViewEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ManagePermissionsViewEndpointSummary : Summary<ManagePermissionsViewEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ManagePermissionsViewEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public ManagePermissionsViewEndpointSummary()
|
||||
{
|
||||
Summary = "Renders the manage permissions view.";
|
||||
Description = "Renders the view for managing the authorization permissions.";
|
||||
|
||||
Response(200, "The view for managing the authorization permissions is rendered.");
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.Authorization;
|
||||
using Lumina.Presentation.Web.Common.DTO.Authorization;
|
||||
using Lumina.Presentation.Web.Common.Routes;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Admin.ManageRoles;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/admin/manage-roles</c> route.
|
||||
/// </summary>
|
||||
public class ManageRolesViewEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ManageRolesViewEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public ManageRolesViewEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Admin.MANAGE_ROLES);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Admin"));
|
||||
Policies(AuthorizationPolicies.REQUIRE_ADMIN_ROLE);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays the authorization roles management view.
|
||||
/// </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)
|
||||
{
|
||||
RoleDto[] roles = await _apiHttpClient.GetAsync<RoleDto[]>(ApiRoutes.Roles.GET_ROLES, cancellationToken).ConfigureAwait(false);
|
||||
PermissionDto[] permissions = await _apiHttpClient.GetAsync<PermissionDto[]>(ApiRoutes.Permissions.GET_PERMISSIONS, cancellationToken).ConfigureAwait(false);
|
||||
Dictionary<string, object?> viewData = new() { ["roles"] = roles, ["permissions"] = permissions };
|
||||
return View("/Core/Views/Admin/ManageRoles.cshtml", viewData: viewData);
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Admin.ManageRoles;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="ManageRolesViewEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ManageRolesViewEndpointSummary : Summary<ManageRolesViewEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ManageRolesViewEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public ManageRolesViewEndpointSummary()
|
||||
{
|
||||
Summary = "Renders the manage roles view.";
|
||||
Description = "Renders the view for managing the authorization roles.";
|
||||
|
||||
Response(200, "The view for managing the authorization roles is rendered.");
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.Authorization;
|
||||
using Lumina.Presentation.Web.Common.DTO.Authorization;
|
||||
using Lumina.Presentation.Web.Common.Requests.Authorization;
|
||||
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.UsersManagement.Authorization.GetUserPermissions;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/admin/api-get-permissions-by-user-id/{userId}</c> route.
|
||||
/// </summary>
|
||||
public class GetUserPermissionsEndpoint : BaseEndpoint<GetUserPermissionsRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetUserPermissionsEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public GetUserPermissionsEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Admin.GET_PERMISSIONS_BY_USER_ID);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Admin"));
|
||||
Policies(AuthorizationPolicies.REQUIRE_ADMIN_ROLE);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the permissions of the user identified by the request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the unique identifier of the user whose permissions are retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetUserPermissionsRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
PermissionDto[] response = await _apiHttpClient.GetAsync<PermissionDto[]>(ApiRoutes.Authorization.GET_USER_PERMISSIONS_BY_USER_ID.Replace("{userId}", request.UserId.ToString()), cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(response);
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Authorization;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.Requests.Authorization;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Admin.UsersManagement.Authorization.GetUserPermissions;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetUserPermissionsEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetUserPermissionsEndpointSummary : Summary<GetUserPermissionsEndpoint, GetUserPermissionsRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetUserPermissionsEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetUserPermissionsEndpointSummary()
|
||||
{
|
||||
Summary = "Gets the permissions of a user.";
|
||||
Description = "Retrieves the authorization permissions of a user identified by its unique identifier.";
|
||||
|
||||
RequestParam(r => r.UserId, "The unique identifier of the user for whom to get the authorization permissions.");
|
||||
|
||||
Response(200, "The permissions of the user are returned.", example: new SuccessResponse<PermissionDto[]>(true, default));
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.Authorization;
|
||||
using Lumina.Presentation.Web.Common.DTO.Authorization;
|
||||
using Lumina.Presentation.Web.Common.Requests.Authorization;
|
||||
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.UsersManagement.Authorization.GetUserRole;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/admin/api-get-role-by-user-id/{userId}</c> route.
|
||||
/// </summary>
|
||||
public class GetUserRoleEndpoint : BaseEndpoint<GetUserRoleRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetUserRoleEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public GetUserRoleEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Admin.GET_ROLE_BY_USER_ID);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Admin"));
|
||||
Policies(AuthorizationPolicies.REQUIRE_ADMIN_ROLE);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the authorization role of the user identified by the request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the unique identifier of the user whose authorization role is retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetUserRoleRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
RoleDto? response = await _apiHttpClient.GetAsync<RoleDto?>(ApiRoutes.Authorization.GET_USER_ROLE_BY_USER_ID.Replace("{userId}", request.UserId.ToString()), cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(response);
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Authorization;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.Requests.Authorization;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Admin.UsersManagement.Authorization.GetUserRole;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetUserRoleEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetUserRoleEndpointSummary : Summary<GetUserRoleEndpoint, GetUserRoleRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetUserRoleEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetUserRoleEndpointSummary()
|
||||
{
|
||||
Summary = "Gets the role of a user.";
|
||||
Description = "Retrieves the authorization role of a user identified by its unique identifier.";
|
||||
|
||||
RequestParam(r => r.UserId, "The unique identifier of the user for whom to get the authorization role.");
|
||||
|
||||
Response(200, "The role of the user is returned.", example: new SuccessResponse<RoleDto?>(true, default));
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.Authorization;
|
||||
using Lumina.Presentation.Web.Common.Requests.Authorization;
|
||||
using Lumina.Presentation.Web.Common.Responses.Authorization;
|
||||
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.UsersManagement.Authorization.UpdateUserRoleAndPermissions;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/admin/api-update-user-authorization</c> route.
|
||||
/// </summary>
|
||||
public class UpdateUserRoleAndPermissionsEndpoint : BaseEndpoint<UpdateUserRoleAndPermissionsRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UpdateUserRoleAndPermissionsEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public UpdateUserRoleAndPermissionsEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.PUT);
|
||||
Routes(WebRoutes.Admin.UPDATE_USER_AUTHORIZATION);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Admin"));
|
||||
Policies(AuthorizationPolicies.REQUIRE_ADMIN_ROLE);
|
||||
EnableAntiforgery();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the authorization role and permissions of the user identified by the request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the updated authorization role and permissions of the user.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(UpdateUserRoleAndPermissionsRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
GetAuthorizationResponse response = await _apiHttpClient.PutAsync<GetAuthorizationResponse, UpdateUserRoleAndPermissionsRequest>(ApiRoutes.Authorization.UPDATE_USER_ROLE_AND_PERMISSIONS_BY_USER_ID.Replace("{userId}", request.UserId.ToString()), request, cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(response);
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.Requests.Authorization;
|
||||
using Lumina.Presentation.Web.Common.Responses.Authorization;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Admin.UsersManagement.Authorization.UpdateUserRoleAndPermissions;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="UpdateUserRoleAndPermissionsEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UpdateUserRoleAndPermissionsEndpointSummary : Summary<UpdateUserRoleAndPermissionsEndpoint, UpdateUserRoleAndPermissionsRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UpdateUserRoleAndPermissionsEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public UpdateUserRoleAndPermissionsEndpointSummary()
|
||||
{
|
||||
Summary = "Updates the role and the permissions of a user.";
|
||||
Description = "Updates the authorization role and the permissions of a user identified by its unique identifier.";
|
||||
RequestParam(r => r.UserId, "The unique identifier of the user. Required.");
|
||||
RequestParam(r => r.RoleId, "The unique identifier of the role. Optional.");
|
||||
RequestParam(r => r.Permissions, "The collection of Ids of the permissions of the role. Optional.");
|
||||
|
||||
ExampleRequest = new UpdateUserRoleAndPermissionsRequest(
|
||||
UserId: Guid.NewGuid(),
|
||||
RoleId: Guid.NewGuid(),
|
||||
Permissions: [
|
||||
Guid.NewGuid(),
|
||||
Guid.NewGuid(),
|
||||
]
|
||||
);
|
||||
|
||||
Response(200, "The role and the permissions of the user are updated.", example: new SuccessResponse<GetAuthorizationResponse>(true, default));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Http;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Common;
|
||||
|
||||
/// <summary>
|
||||
/// Base class for Web endpoints.
|
||||
/// </summary>
|
||||
/// <typeparam name="TRequest">The type of the request object.</typeparam>
|
||||
/// <typeparam name="TResponse">The type of the response object.</typeparam>
|
||||
public abstract class BaseEndpoint<TRequest, TResponse> : Endpoint<TRequest, TResponse> where TRequest : notnull
|
||||
where TResponse : notnull
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the current culture taken from the <c>culture</c> route value.
|
||||
/// </summary>
|
||||
protected string Culture => HttpContext.Request.RouteValues["culture"]?.ToString() ?? "en-US";
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// All exceptions are propagated to the application's exception handling middleware instead of being converted to error responses by the library.
|
||||
/// </remarks>
|
||||
public override void Configure()
|
||||
{
|
||||
DontCatchExceptions();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders a Razor view to the response.
|
||||
/// </summary>
|
||||
/// <param name="viewName">The name or path of the view to render.</param>
|
||||
/// <param name="model">The model to pass to the view.</param>
|
||||
/// <param name="viewData">Optional additional view data entries made available to the view via <c>ViewData</c>.</param>
|
||||
/// <returns>An <see cref="IResult"/> that renders the view.</returns>
|
||||
protected IResult View(string viewName, object? model = null, IReadOnlyDictionary<string, object?>? viewData = null)
|
||||
{
|
||||
// store the path of the displayed view in the session, so that the login redirect after the JWT token expires points to it; ignore the login endpoint,
|
||||
// because it is incorrect to be redirected to the login URL, with the login URL as the return URL
|
||||
if (HttpContext.Request.Path != "/en-us/auth/login")
|
||||
HttpContext.Session.SetString(HttpContextItemKeys.LAST_DISPLAYED_VIEW, $"{HttpContext.Request.PathBase}{HttpContext.Request.Path}{HttpContext.Request.QueryString}");
|
||||
return new RazorViewResult(viewName, model, viewData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a JSON response indicating a successful operation, optionally wrapping <paramref name="data"/>.
|
||||
/// </summary>
|
||||
/// <param name="data">The payload of the successful response.</param>
|
||||
/// <returns>An <see cref="IResult"/> containing the success JSON payload.</returns>
|
||||
protected IResult JsonSuccess(object? data)
|
||||
{
|
||||
return Results.Json(new { success = true, data });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a JSON response indicating a successful operation without a payload.
|
||||
/// </summary>
|
||||
/// <returns>An <see cref="IResult"/> containing the success JSON payload.</returns>
|
||||
protected IResult JsonSuccess()
|
||||
{
|
||||
return Results.Json(new { success = true });
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Directories;
|
||||
using Lumina.Presentation.Web.Common.Routes;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Directories.GetDirectories;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/directories/api-get-directories</c> route.
|
||||
/// </summary>
|
||||
public class GetDirectoriesEndpoint : BaseEndpoint<GetDirectoriesRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetDirectoriesEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public GetDirectoriesEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Directories.GET_DIRECTORIES);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Directories"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the directories of the file system path identified by the request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the file system path whose directories are retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetDirectoriesRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
DirectoryDto[] response = await _apiHttpClient.GetAsync<DirectoryDto[]>($"{ApiRoutes.Directories.GET_DIRECTORIES}?path={Uri.EscapeDataString(request.Path!)}&includeHiddenElements={request.IncludeHiddenElements}", cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(response);
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Directories;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Directories.GetDirectories;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetDirectoriesEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetDirectoriesEndpointSummary : Summary<GetDirectoriesEndpoint, GetDirectoriesRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetDirectoriesEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetDirectoriesEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the directories of a file system path.";
|
||||
Description = "Retrieves the directories of the file system path identified by the request.";
|
||||
|
||||
RequestParam(r => r.Path, "The file system path for which to get the directories.");
|
||||
RequestParam(r => r.IncludeHiddenElements, "Whether to include hidden file system elements or not.");
|
||||
|
||||
Response(200, "The directories of the file system path are returned.", example: new SuccessResponse<DirectoryDto[]>(true, default));
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
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.FileSystemManagement.Drives.GetDrives;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/drives/api-get-drives</c> route.
|
||||
/// </summary>
|
||||
public class GetDrivesEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetDrivesEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public GetDrivesEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Drives.GET_DRIVES);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Drives"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the file system drives.
|
||||
/// </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)
|
||||
{
|
||||
FileSystemTreeNodeDto[] response = await _apiHttpClient.GetAsync<FileSystemTreeNodeDto[]>(ApiRoutes.Drives.GET_DRIVES, cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(new { drives = response });
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Drives.GetDrives;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetDrivesEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetDrivesEndpointSummary : Summary<GetDrivesEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetDrivesEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetDrivesEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the file system drives.";
|
||||
Description = "Retrieves the list of file system drives of the machine.";
|
||||
|
||||
Response(200, "The list of file system drives is returned.", example: new { success = true, data = new { drives = new FileSystemTreeNodeDto[] { } } });
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
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.FileSystemManagement.FileSystem.GetType;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/file-system/api-get-type</c> route.
|
||||
/// </summary>
|
||||
public class GetTypeEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetTypeEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public GetTypeEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.FileSystem.GET_TYPE);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("FileSystem"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the file system platform type.
|
||||
/// </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)
|
||||
{
|
||||
FileSystemTypeDto response = await _apiHttpClient.GetAsync<FileSystemTypeDto>(ApiRoutes.FileSystem.GET_TYPES, cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(new { platformType = response.PlatformType.ToString() });
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.FileSystem.GetType;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetTypeEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetTypeEndpointSummary : Summary<GetTypeEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetTypeEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetTypeEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the file system platform type.";
|
||||
Description = "Retrieves the platform type of the file system of the machine.";
|
||||
|
||||
Response(200, "The type of the file system is returned.", example: new { success = true, data = new { platformType = "Windows" } });
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Files;
|
||||
using Lumina.Presentation.Web.Common.Routes;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Files.GetFiles;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/files/api-get-files</c> route.
|
||||
/// </summary>
|
||||
public class GetFilesEndpoint : BaseEndpoint<GetFilesRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetFilesEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public GetFilesEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Files.GET_FILES);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Files"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the files of the file system path identified by the request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the file system path whose files are retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetFilesRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
FileDto[] response = await _apiHttpClient.GetAsync<FileDto[]>($"{ApiRoutes.Files.GET_FILES}?path={Uri.EscapeDataString(request.Path!)}&includeHiddenElements={request.IncludeHiddenElements}", cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(response);
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Files;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Files.GetFiles;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetFilesEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetFilesEndpointSummary : Summary<GetFilesEndpoint, GetFilesRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetFilesEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetFilesEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the files of a file system path.";
|
||||
Description = "Retrieves the files of the file system path identified by the request.";
|
||||
|
||||
RequestParam(r => r.Path, "The file system path for which to get the files.");
|
||||
RequestParam(r => r.IncludeHiddenElements, "Whether to include hidden file system elements or not.");
|
||||
|
||||
Response(200, "The files of the file system path are returned.", example: new SuccessResponse<FileDto[]>(true, default));
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Files;
|
||||
using Lumina.Presentation.Web.Common.Routes;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Files.GetTreeFiles;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/files/api-get-tree-files</c> route.
|
||||
/// </summary>
|
||||
public class GetTreeFilesEndpoint : BaseEndpoint<GetTreeFilesRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetTreeFilesEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public GetTreeFilesEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Files.GET_TREE_FILES);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Files"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the file system tree of the file system path identified by the request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the file system path whose file system tree is retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetTreeFilesRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
FileSystemTreeNodeDto[] response = await _apiHttpClient.GetAsync<FileSystemTreeNodeDto[]>($"{ApiRoutes.Files.GET_TREE_FILES}?path={Uri.EscapeDataString(request.Path!)}&includeHiddenElements={request.IncludeHiddenElements}", cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(response);
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Files;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Files.GetTreeFiles;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetTreeFilesEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetTreeFilesEndpointSummary : Summary<GetTreeFilesEndpoint, GetTreeFilesRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetTreeFilesEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetTreeFilesEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the file system tree of a file system path.";
|
||||
Description = "Retrieves the file system tree of the file system path identified by the request.";
|
||||
|
||||
RequestParam(r => r.Path, "The file system path for which to get the tree files.");
|
||||
RequestParam(r => r.IncludeHiddenElements, "Whether to include hidden file system elements or not.");
|
||||
|
||||
Response(200, "The file system tree of the file system path is returned.", example: new SuccessResponse<FileSystemTreeNodeDto[]>(true, default));
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Path;
|
||||
using Lumina.Presentation.Web.Common.Routes;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Path.CheckPathExists;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/path/api-check-path-exists</c> route.
|
||||
/// </summary>
|
||||
public class CheckPathExistsEndpoint : BaseEndpoint<CheckPathExistsRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CheckPathExistsEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public CheckPathExistsEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Path.CHECK_PATH_EXISTS);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Path"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the file system path identified by the request exists.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the file system path whose existence is checked.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(CheckPathExistsRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
PathExistsDto response = await _apiHttpClient.GetAsync<PathExistsDto>($"{ApiRoutes.Path.CHECK_PATH_EXISTS}?path={Uri.EscapeDataString(request.Path!)}&includeHiddenElements={request.IncludeHiddenElements}", cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(new { exists = response.Exists });
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Path;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Path.CheckPathExists;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="CheckPathExistsEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class CheckPathExistsEndpointSummary : Summary<CheckPathExistsEndpoint, CheckPathExistsRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CheckPathExistsEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public CheckPathExistsEndpointSummary()
|
||||
{
|
||||
Summary = "Checks the existence of a file system path.";
|
||||
Description = "Checks whether the file system path identified by the request exists.";
|
||||
|
||||
RequestParam(r => r.Path, "The file system path to check the existence of.");
|
||||
RequestParam(r => r.IncludeHiddenElements, "Whether to include hidden elements in the search results, or not.");
|
||||
|
||||
Response(200, "Whether the file system path exists is returned.", example: new { success = true, data = new { exists = true } });
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Path;
|
||||
using Lumina.Presentation.Web.Common.Routes;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Path.GetPathParent;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/path/api-get-path-parent</c> route.
|
||||
/// </summary>
|
||||
public class GetPathParentEndpoint : BaseEndpoint<GetPathParentRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetPathParentEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public GetPathParentEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Path.GET_PATH_PARENT);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Path"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the parent path of the file system path identified by the request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the file system path whose parent path is retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetPathParentRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
PathSegmentDto[] response = await _apiHttpClient.GetAsync<PathSegmentDto[]>($"{ApiRoutes.Path.GET_PATH_PARENT}?path={Uri.EscapeDataString(request.Path!)}", cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(new { pathSegments = response });
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Path;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Path.GetPathParent;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetPathParentEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetPathParentEndpointSummary : Summary<GetPathParentEndpoint, GetPathParentRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetPathParentEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetPathParentEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the parent path of a file system path.";
|
||||
Description = "Retrieves the path segments of the parent path of the file system path identified by the request.";
|
||||
|
||||
RequestParam(r => r.Path, "The path for which the parent path is retrieved.");
|
||||
|
||||
Response(200, "The path segments of the parent path are returned.", example: new { success = true, data = new { pathSegments = new PathSegmentDto[] { } } });
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Path;
|
||||
using Lumina.Presentation.Web.Common.Routes;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Path.GetPathRoot;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/path/api-get-path-root</c> route.
|
||||
/// </summary>
|
||||
public class GetPathRootEndpoint : BaseEndpoint<GetPathRootRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetPathRootEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public GetPathRootEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Path.GET_PATH_ROOT);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Path"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the root of the file system path identified by the request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the file system path whose root is retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetPathRootRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
PathSegmentDto response = await _apiHttpClient.GetAsync<PathSegmentDto>($"{ApiRoutes.Path.GET_PATH_ROOT}?path={Uri.EscapeDataString(request.Path!)}", cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(new { root = response });
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Path;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Path.GetPathRoot;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetPathRootEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetPathRootEndpointSummary : Summary<GetPathRootEndpoint, GetPathRootRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetPathRootEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetPathRootEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the root of a file system path.";
|
||||
Description = "Retrieves the root of the file system path identified by the request.";
|
||||
|
||||
RequestParam(r => r.Path, "The file system path for which to get the root.");
|
||||
|
||||
Response(200, "The root of the file system path is returned.", example: new { success = true, data = new { root = new PathSegmentDto() } });
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
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.FileSystemManagement.Path.GetPathSeparator;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/path/api-get-path-separator</c> route.
|
||||
/// </summary>
|
||||
public class GetPathSeparatorEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetPathSeparatorEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public GetPathSeparatorEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Path.GET_PATH_SEPARATOR);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Path"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the file system path separator.
|
||||
/// </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)
|
||||
{
|
||||
PathSeparatorDto response = await _apiHttpClient.GetAsync<PathSeparatorDto>(ApiRoutes.Path.GET_PATH_SEPARATOR, cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(new { pathSeparator = response.Separator });
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Path.GetPathSeparator;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetPathSeparatorEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetPathSeparatorEndpointSummary : Summary<GetPathSeparatorEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetPathSeparatorEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetPathSeparatorEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the file system path separator.";
|
||||
Description = "Retrieves the path separator of the file system of the machine.";
|
||||
|
||||
Response(200, "The file system path separator is returned.", example: new { success = true, data = new { pathSeparator = "\\" } });
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Path;
|
||||
using Lumina.Presentation.Web.Common.Routes;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Path.SplitPath;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/path/api-split</c> route.
|
||||
/// </summary>
|
||||
public class SplitPathEndpoint : BaseEndpoint<SplitPathRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SplitPathEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public SplitPathEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Path.SPLIT_PATH);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Path"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Splits the file system path identified by the request into its segments.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the file system path to split.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(SplitPathRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
PathSegmentDto[] response = await _apiHttpClient.GetAsync<PathSegmentDto[]>($"{ApiRoutes.Path.SPLIT}?path={Uri.EscapeDataString(request.Path!)}", cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(new { pathSegments = response });
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Path;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Path.SplitPath;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="SplitPathEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SplitPathEndpointSummary : Summary<SplitPathEndpoint, SplitPathRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SplitPathEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public SplitPathEndpointSummary()
|
||||
{
|
||||
Summary = "Splits a file system path into its segments.";
|
||||
Description = "Splits the file system path identified by the request into its path segments.";
|
||||
|
||||
RequestParam(r => r.Path, "The file system path for which to get the path segments.");
|
||||
|
||||
Response(200, "The path segments of the file system path are returned.", example: new { success = true, data = new { pathSegments = new PathSegmentDto[] { } } });
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.FileSystemManagement;
|
||||
using Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Path;
|
||||
using Lumina.Presentation.Web.Common.Routes;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Path.ValidatePath;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/path/api-validate</c> route.
|
||||
/// </summary>
|
||||
public class ValidatePathEndpoint : BaseEndpoint<ValidatePathRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ValidatePathEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public ValidatePathEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Path.VALIDATE_PATH);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Path"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates the file system path identified by the request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the file system path to validate.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(ValidatePathRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
PathValidDto response = await _apiHttpClient.GetAsync<PathValidDto>($"{ApiRoutes.Path.VALIDATE}?path={Uri.EscapeDataString(request.Path!)}", cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(new { isValid = response.IsValid });
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Requests.FileSystemManagement.Path;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.FileSystemManagement.Path.ValidatePath;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="ValidatePathEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ValidatePathEndpointSummary : Summary<ValidatePathEndpoint, ValidatePathRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ValidatePathEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public ValidatePathEndpointSummary()
|
||||
{
|
||||
Summary = "Validates a file system path.";
|
||||
Description = "Validates the file system path identified by the request.";
|
||||
|
||||
RequestParam(r => r.Path, "The file system path to validate.");
|
||||
|
||||
Response(200, "Whether the file system path is valid is returned.", example: new { success = true, data = new { isValid = true } });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.Routes;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Home;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/error</c> route.
|
||||
/// </summary>
|
||||
public class HomeErrorEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Home.ERROR);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Home"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays the error page.
|
||||
/// </summary>
|
||||
/// <param name="request">The request object.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override Task<IResult> ExecuteAsync(EmptyRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
ErrorViewDto errorViewDto = new() { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier };
|
||||
return Task.FromResult(View("/Core/Views/Shared/Error.cshtml", errorViewDto));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Home;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="HomeErrorEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class HomeErrorEndpointSummary : Summary<HomeErrorEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HomeErrorEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public HomeErrorEndpointSummary()
|
||||
{
|
||||
Summary = "Renders the error view.";
|
||||
Description = "Renders the error page of the application.";
|
||||
|
||||
Response(200, "The error view is rendered.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
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.Home;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/</c> and <c>/{culture}</c> routes.
|
||||
/// </summary>
|
||||
public class HomeIndexEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Home.INDEX, WebRoutes.Home.INDEX_CULTURED);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Home"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays the home page.
|
||||
/// </summary>
|
||||
/// <param name="request">The request object.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override Task<IResult> ExecuteAsync(EmptyRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult(View("/Core/Views/Home/Index.cshtml"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Home;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="HomeIndexEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class HomeIndexEndpointSummary : Summary<HomeIndexEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HomeIndexEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public HomeIndexEndpointSummary()
|
||||
{
|
||||
Summary = "Renders the home page.";
|
||||
Description = "Renders the home page of the application.";
|
||||
|
||||
Response(200, "The home page is rendered.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
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.Home;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/not-found</c> route.
|
||||
/// </summary>
|
||||
public class HomeNotFoundViewEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Home.NOT_FOUND);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Home"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays the not-found page.
|
||||
/// </summary>
|
||||
/// <param name="request">The request object.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override Task<IResult> ExecuteAsync(EmptyRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult(View("/Core/Views/Shared/NotFound.cshtml"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Home;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="HomeNotFoundViewEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class HomeNotFoundViewEndpointSummary : Summary<HomeNotFoundViewEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HomeNotFoundViewEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public HomeNotFoundViewEndpointSummary()
|
||||
{
|
||||
Summary = "Renders the not-found view.";
|
||||
Description = "Renders the page displayed when a requested resource is not found.";
|
||||
|
||||
Response(200, "The not-found view is rendered.");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
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.Home;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/privacy</c> route.
|
||||
/// </summary>
|
||||
public class HomePrivacyEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Home.PRIVACY);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Home"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays the privacy page.
|
||||
/// </summary>
|
||||
/// <param name="request">The request object.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override Task<IResult> ExecuteAsync(EmptyRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult(View("/Core/Views/Home/Privacy.cshtml"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Home;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="HomePrivacyEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class HomePrivacyEndpointSummary : Summary<HomePrivacyEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="HomePrivacyEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public HomePrivacyEndpointSummary()
|
||||
{
|
||||
Summary = "Renders the privacy view.";
|
||||
Description = "Renders the privacy policy page of the application.";
|
||||
|
||||
Response(200, "The privacy view is rendered.");
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
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.Library.Management.AddLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/libraries/manage/item</c> route.
|
||||
/// </summary>
|
||||
public class AddLibraryViewEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.LibraryManagement.ADD_LIBRARY);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Libraries"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays the media library adding view.
|
||||
/// </summary>
|
||||
/// <param name="request">The request object.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override Task<IResult> ExecuteAsync(EmptyRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
LibraryDto library = new();
|
||||
return Task.FromResult(View("/Core/Views/Library/Management/Item.cshtml", library));
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Library.Management.AddLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="AddLibraryViewEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class AddLibraryViewEndpointSummary : Summary<AddLibraryViewEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AddLibraryViewEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public AddLibraryViewEndpointSummary()
|
||||
{
|
||||
Summary = "Renders the add library view.";
|
||||
Description = "Renders the view for adding a media library.";
|
||||
|
||||
Response(200, "The view for adding a media library is rendered.");
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
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.Library.Management.CancelLibrariesScan;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/libraries/manage/api-cancel-libraries-scan</c> route.
|
||||
/// </summary>
|
||||
public class CancelLibrariesScanEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CancelLibrariesScanEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public CancelLibrariesScanEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.POST);
|
||||
Routes(WebRoutes.LibraryManagement.CANCEL_LIBRARIES_SCAN);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Libraries"));
|
||||
EnableAntiforgery();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancels the running scans of all the media libraries.
|
||||
/// </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)
|
||||
{
|
||||
await _apiHttpClient.PostAsync<Web.Common.Requests.Common.EmptyRequest, Web.Common.Requests.Common.EmptyRequest>(ApiRoutes.Libraries.CANCEL_LIBRARIES_SCAN, new Web.Common.Requests.Common.EmptyRequest(), cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess();
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Library.Management.CancelLibrariesScan;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="CancelLibrariesScanEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class CancelLibrariesScanEndpointSummary : Summary<CancelLibrariesScanEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CancelLibrariesScanEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public CancelLibrariesScanEndpointSummary()
|
||||
{
|
||||
Summary = "Cancels the scan of all the media libraries.";
|
||||
Description = "Cancels the running scans of all the media libraries.";
|
||||
|
||||
Response(200, "The scan of all media libraries is cancelled.", example: new SuccessResponse(true));
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.Management;
|
||||
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.Library.Management.CancelLibraryScan;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/libraries/manage/{libraryId}/api-cancel-library-scan/{scanId}</c> route.
|
||||
/// </summary>
|
||||
public class CancelLibraryScanEndpoint : BaseEndpoint<CancelLibraryScanRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CancelLibraryScanEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public CancelLibraryScanEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.POST);
|
||||
Routes(WebRoutes.LibraryManagement.CANCEL_LIBRARY_SCAN);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Libraries"));
|
||||
EnableAntiforgery();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cancels a running scan of a media library.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the Ids of the media library and of the scan to cancel.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(CancelLibraryScanRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
await _apiHttpClient.PostAsync<Web.Common.Requests.Common.EmptyRequest, Lumina.Presentation.Web.Common.Requests.Common.EmptyRequest>(ApiRoutes.Libraries.CANCEL_LIBRARY_SCAN.Replace("{libraryId}", request.LibraryId.ToString()).Replace("{scanId}", request.ScanId.ToString()), new Lumina.Presentation.Web.Common.Requests.Common.EmptyRequest(), cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess();
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.Management;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Library.Management.CancelLibraryScan;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="CancelLibraryScanEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class CancelLibraryScanEndpointSummary : Summary<CancelLibraryScanEndpoint, CancelLibraryScanRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CancelLibraryScanEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public CancelLibraryScanEndpointSummary()
|
||||
{
|
||||
Summary = "Cancels the scan of a media library.";
|
||||
Description = "Cancels a running scan of the media library identified by the request.";
|
||||
|
||||
RequestParam(r => r.LibraryId, "The unique identifier of the media library whose scan is cancelled.");
|
||||
RequestParam(r => r.ScanId, "The Id of the scan to cancel.");
|
||||
|
||||
Response(200, "The scan of the media library is cancelled.", example: new SuccessResponse(true));
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.Management;
|
||||
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.Library.Management.DeleteLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/libraries/manage/api-item/{id}</c> route.
|
||||
/// </summary>
|
||||
public class DeleteLibraryEndpoint : BaseEndpoint<DeleteLibraryRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DeleteLibraryEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public DeleteLibraryEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.DELETE);
|
||||
Routes(WebRoutes.LibraryManagement.DELETE_LIBRARY);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Libraries"));
|
||||
EnableAntiforgery();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a media library.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the Id of the media library to delete.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(DeleteLibraryRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
await _apiHttpClient.DeleteAsync(ApiRoutes.Libraries.DELETE_LIBRARY.Replace("{id}", request.Id.ToString()), cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess();
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.Management;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Library.Management.DeleteLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="DeleteLibraryEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class DeleteLibraryEndpointSummary : Summary<DeleteLibraryEndpoint, DeleteLibraryRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DeleteLibraryEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public DeleteLibraryEndpointSummary()
|
||||
{
|
||||
Summary = "Deletes a media library.";
|
||||
Description = "Deletes the media library identified by the request.";
|
||||
|
||||
RequestParam(r => r.Id, "The unique identifier of the media library to delete.");
|
||||
|
||||
Response(200, "The media library is deleted.", example: new SuccessResponse(true));
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.Management;
|
||||
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.Library.Management.EditLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/libraries/manage/item/{id}</c> route.
|
||||
/// </summary>
|
||||
public class EditLibraryViewEndpoint : BaseEndpoint<EditLibraryRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EditLibraryViewEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public EditLibraryViewEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.LibraryManagement.EDIT_LIBRARY);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Libraries"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays the media library editing view.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the Id of the media library to edit.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(EditLibraryRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
LibraryDto library = await _apiHttpClient.GetAsync<LibraryDto>(ApiRoutes.Libraries.GET_LIBRARY_BY_ID.Replace("{id}", request.Id.ToString()), cancellationToken).ConfigureAwait(false);
|
||||
return View("/Core/Views/Library/Management/Item.cshtml", library);
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.Management;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Library.Management.EditLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="EditLibraryViewEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class EditLibraryViewEndpointSummary : Summary<EditLibraryViewEndpoint, EditLibraryRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EditLibraryViewEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public EditLibraryViewEndpointSummary()
|
||||
{
|
||||
Summary = "Renders the edit library view.";
|
||||
Description = "Renders the view for editing the media library identified by the request.";
|
||||
|
||||
RequestParam(r => r.Id, "The unique identifier of the media library to edit.");
|
||||
|
||||
Response(200, "The view for editing the media library is rendered.");
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
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.Library.Management.GetEnabledLibraries;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/libraries/manage/api-get-enabled-libraries</c> route.
|
||||
/// </summary>
|
||||
public class GetEnabledLibrariesEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetEnabledLibrariesEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public GetEnabledLibrariesEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.LibraryManagement.GET_ENABLED_LIBRARIES);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Libraries"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the enabled media libraries.
|
||||
/// </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)
|
||||
{
|
||||
LibraryDto[] response = await _apiHttpClient.GetAsync<LibraryDto[]>(ApiRoutes.Libraries.GET_ENABLED_LIBRARIES, cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(response);
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Library.Management.GetEnabledLibraries;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetEnabledLibrariesEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetEnabledLibrariesEndpointSummary : Summary<GetEnabledLibrariesEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetEnabledLibrariesEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetEnabledLibrariesEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the enabled media libraries.";
|
||||
Description = "Retrieves the collection of enabled media libraries.";
|
||||
|
||||
Response(200, "The collection of enabled media libraries is returned.", example: new SuccessResponse<LibraryDto[]>(true, default));
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
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.Library.Management.GetLibraries;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/libraries/manage/api-get-libraries</c> route.
|
||||
/// </summary>
|
||||
public class GetLibrariesEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetLibrariesEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public GetLibrariesEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.LibraryManagement.GET_LIBRARIES);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Libraries"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the media libraries.
|
||||
/// </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)
|
||||
{
|
||||
LibraryDto[] response = await _apiHttpClient.GetAsync<LibraryDto[]>(ApiRoutes.Libraries.GET_LIBRARIES, cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(response);
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Library.Management.GetLibraries;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetLibrariesEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetLibrariesEndpointSummary : Summary<GetLibrariesEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetLibrariesEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetLibrariesEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the media libraries.";
|
||||
Description = "Retrieves the collection of media libraries.";
|
||||
|
||||
Response(200, "The collection of media libraries is returned.", example: new SuccessResponse<LibraryDto[]>(true, default));
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.Plugins;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.Management;
|
||||
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.Library.Management.GetMetadataProviders;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/libraries/manage/api-get-metadata-providers/{libraryId}</c> route.
|
||||
/// </summary>
|
||||
public class GetMetadataProvidersEndpoint : BaseEndpoint<GetMetadataProvidersRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetMetadataProvidersEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public GetMetadataProvidersEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.LibraryManagement.GET_METADATA_PROVIDERS);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Libraries"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the metadata providers of a media library.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the Id of the media library whose metadata providers are retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetMetadataProvidersRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
LibraryMetadataProviderDto[] response = await _apiHttpClient.GetAsync<LibraryMetadataProviderDto[]>(ApiRoutes.Libraries.GET_LIBRARY_METADATA_PROVIDERS.Replace("{libraryId}", request.LibraryId.ToString()), cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(response);
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.DTO.Plugins;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.Management;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Library.Management.GetMetadataProviders;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetMetadataProvidersEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetMetadataProvidersEndpointSummary : Summary<GetMetadataProvidersEndpoint, GetMetadataProvidersRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetMetadataProvidersEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetMetadataProvidersEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the metadata providers of a media library.";
|
||||
Description = "Retrieves the metadata providers of the media library identified by the request.";
|
||||
|
||||
RequestParam(r => r.LibraryId, "The unique identifier of the media library whose metadata providers are retrieved.");
|
||||
|
||||
Response(200, "The metadata providers of the media library are returned.", example: new SuccessResponse<LibraryMetadataProviderDto[]>(true, default));
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
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.Library.Management.GetRunningLibraryScans;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/libraries/manage/api-get-running-library-scans</c> route.
|
||||
/// </summary>
|
||||
public class GetRunningLibraryScansEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetRunningLibraryScansEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public GetRunningLibraryScansEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.LibraryManagement.GET_RUNNING_LIBRARY_SCANS);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Libraries"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the running media library scans.
|
||||
/// </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)
|
||||
{
|
||||
LibraryScanProgressDto[] response = await _apiHttpClient.GetAsync<LibraryScanProgressDto[]>(ApiRoutes.Libraries.GET_RUNNING_LIBRARIES_SCAN, cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(response);
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Library.Management.GetRunningLibraryScans;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetRunningLibraryScansEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetRunningLibraryScansEndpointSummary : Summary<GetRunningLibraryScansEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetRunningLibraryScansEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetRunningLibraryScansEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the running media library scans.";
|
||||
Description = "Retrieves the collection of ongoing media library scans.";
|
||||
|
||||
Response(200, "The collection of ongoing media library scans is returned.", example: new SuccessResponse<LibraryScanProgressDto[]>(true, default));
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
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.Library.Management.Index;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/libraries/manage</c> route.
|
||||
/// </summary>
|
||||
public class LibrariesIndexViewEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.LibraryManagement.INDEX);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Libraries"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays the media libraries management view.
|
||||
/// </summary>
|
||||
/// <param name="request">The request object.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override Task<IResult> ExecuteAsync(EmptyRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult(View("/Core/Views/Library/Management/Index.cshtml"));
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Library.Management.Index;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="LibrariesIndexViewEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class LibrariesIndexViewEndpointSummary : Summary<LibrariesIndexViewEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibrariesIndexViewEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public LibrariesIndexViewEndpointSummary()
|
||||
{
|
||||
Summary = "Renders the libraries management view.";
|
||||
Description = "Renders the view for managing the media libraries.";
|
||||
|
||||
Response(200, "The view for managing the media libraries is rendered.");
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.Requests.Plugins;
|
||||
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.Library.Management.ReorderMetadataProviders;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/libraries/manage/api-reorder-metadata-providers</c> route.
|
||||
/// </summary>
|
||||
public class ReorderMetadataProvidersEndpoint : BaseEndpoint<ReorderLibraryMetadataProvidersRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ReorderMetadataProvidersEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public ReorderMetadataProvidersEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.PUT);
|
||||
Routes(WebRoutes.LibraryManagement.REORDER_METADATA_PROVIDERS);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Libraries"));
|
||||
EnableAntiforgery();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reorders the metadata providers of a media library.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the Id of the media library and the plugin Ids in the new order.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(ReorderLibraryMetadataProvidersRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
await _apiHttpClient.PutAsync<Web.Common.Requests.Common.EmptyRequest, ReorderLibraryMetadataProvidersRequest>(ApiRoutes.Libraries.REORDER_LIBRARY_METADATA_PROVIDERS.Replace("{libraryId}", request.LibraryId.ToString()), request, cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess();
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.Requests.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Library.Management.ReorderMetadataProviders;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="ReorderMetadataProvidersEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ReorderMetadataProvidersEndpointSummary : Summary<ReorderMetadataProvidersEndpoint, ReorderLibraryMetadataProvidersRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ReorderMetadataProvidersEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public ReorderMetadataProvidersEndpointSummary()
|
||||
{
|
||||
Summary = "Reorders the metadata providers of a media library.";
|
||||
Description = "Reorders the metadata providers of the media library identified by the request.";
|
||||
RequestParam(r => r.LibraryId, "The Id of the media library whose metadata providers are reordered. Required.");
|
||||
RequestParam(r => r.PluginIds, "The plugin Ids in the new order, from highest to lowest rank. Required.");
|
||||
|
||||
ExampleRequest = new ReorderLibraryMetadataProvidersRequest
|
||||
{
|
||||
LibraryId = Guid.NewGuid(),
|
||||
PluginIds = [
|
||||
Guid.NewGuid(),
|
||||
Guid.NewGuid(),
|
||||
]
|
||||
};
|
||||
|
||||
Response(200, "The metadata providers of the media library are reordered.", example: new SuccessResponse(true));
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.Authorization;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
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.Library.Management.SaveLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/libraries/manage/api-item</c> route.
|
||||
/// </summary>
|
||||
public class SaveLibraryEndpoint : BaseEndpoint<LibraryDto, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SaveLibraryEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public SaveLibraryEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.POST);
|
||||
Routes(WebRoutes.LibraryManagement.SAVE_LIBRARY);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Libraries"));
|
||||
EnableAntiforgery();
|
||||
Policies(AuthorizationPolicies.REQUIRE_CREATE_LIBRARIES_PERMISSION);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates or updates a media library.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the details of the media library to create or update.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(LibraryDto request, CancellationToken cancellationToken)
|
||||
{
|
||||
LibraryDto response = request.Id.HasValue
|
||||
? await _apiHttpClient.PutAsync<LibraryDto, LibraryDto>(ApiRoutes.Libraries.UPDATE_LIBRARY.Replace("{id}", request.Id.Value.ToString()), request, cancellationToken).ConfigureAwait(false)
|
||||
: await _apiHttpClient.PostAsync<LibraryDto, LibraryDto>(ApiRoutes.Libraries.ADD_LIBRARY, request, cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(response);
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Library.Management.SaveLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="SaveLibraryEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SaveLibraryEndpointSummary : Summary<SaveLibraryEndpoint, LibraryDto>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SaveLibraryEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public SaveLibraryEndpointSummary()
|
||||
{
|
||||
Summary = "Creates or updates a media library.";
|
||||
Description = "Creates or updates the media library provided in the request.";
|
||||
RequestParam(r => r.Id, "The unique identifier of the media library. Optional, when creating a new media library.");
|
||||
RequestParam(r => r.UserId, "The unique identifier of the user owning the media library. Optional.");
|
||||
RequestParam(r => r.Title, "The title of the media library. Required.");
|
||||
RequestParam(r => r.LibraryType, "The type of the media library. Required.");
|
||||
RequestParam(r => r.CoverImage, "The path of the image file used as the cover of the media library. Optional.");
|
||||
RequestParam(r => r.ContentLocations, "The collection of directories that contain the media library files. Required.");
|
||||
RequestParam(r => r.IsEnabled, "Whether the media library is enabled or not. Optional.");
|
||||
RequestParam(r => r.IsLocked, "Whether the media library is locked or not. Optional.");
|
||||
RequestParam(r => r.DownloadMetadataFromWeb, "Whether the metadata of the media library items should be downloaded from the web, or not. Optional.");
|
||||
RequestParam(r => r.ShouldSaveMetadataInMediaDirectories, "Whether the downloaded metadata should be copied into the media library content locations, or not. Optional.");
|
||||
RequestParam(r => r.ShouldSkipUnchangedDirectoriesDuringScan, "Whether the directories whose contents have not changed since the last scan should be skipped during the scan, or not. Optional.");
|
||||
|
||||
ExampleRequest = new LibraryDto();
|
||||
|
||||
Response(200, "The media library is created or updated.", example: new SuccessResponse<LibraryDto>(true, default));
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
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.Library.Management.ScanLibraries;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/libraries/manage/api-scan-libraries</c> route.
|
||||
/// </summary>
|
||||
public class ScanLibrariesEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ScanLibrariesEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public ScanLibrariesEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.POST);
|
||||
Routes(WebRoutes.LibraryManagement.SCAN_LIBRARIES);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Libraries"));
|
||||
EnableAntiforgery();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initiates the scan of all the media libraries.
|
||||
/// </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)
|
||||
{
|
||||
ScanLibraryDto[] response = await _apiHttpClient.PostAsync<ScanLibraryDto[], Lumina.Presentation.Web.Common.Requests.Common.EmptyRequest>(ApiRoutes.Libraries.SCAN_LIBRARIES, new Lumina.Presentation.Web.Common.Requests.Common.EmptyRequest(), cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(response);
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Library.Management.ScanLibraries;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="ScanLibrariesEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ScanLibrariesEndpointSummary : Summary<ScanLibrariesEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ScanLibrariesEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public ScanLibrariesEndpointSummary()
|
||||
{
|
||||
Summary = "Starts the scan of all the media libraries.";
|
||||
Description = "Initiates the scan of all the media libraries.";
|
||||
|
||||
Response(200, "The scan of all media libraries is started.", example: new SuccessResponse<ScanLibraryDto[]>(true, default));
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.Management;
|
||||
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.Library.Management.ScanLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/libraries/manage/api-scan-library/{id}</c> route.
|
||||
/// </summary>
|
||||
public class ScanLibraryEndpoint : BaseEndpoint<ScanLibraryRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ScanLibraryEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public ScanLibraryEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.POST);
|
||||
Routes(WebRoutes.LibraryManagement.SCAN_LIBRARY);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Libraries"));
|
||||
EnableAntiforgery();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initiates the scan of a media library.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the Id of the media library to scan.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(ScanLibraryRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
ScanLibraryDto response = await _apiHttpClient.PostAsync<ScanLibraryDto, Lumina.Presentation.Web.Common.Requests.Common.EmptyRequest>(ApiRoutes.Libraries.SCAN_LIBRARY.Replace("{id}", request.Id.ToString()), new Lumina.Presentation.Web.Common.Requests.Common.EmptyRequest(), cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(response);
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.Management;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Library.Management.ScanLibrary;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="ScanLibraryEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class ScanLibraryEndpointSummary : Summary<ScanLibraryEndpoint, ScanLibraryRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ScanLibraryEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public ScanLibraryEndpointSummary()
|
||||
{
|
||||
Summary = "Starts the scan of a media library.";
|
||||
Description = "Initiates the scan of the media library identified by the request.";
|
||||
|
||||
RequestParam(r => r.Id, "The unique identifier of the media library to scan.");
|
||||
|
||||
Response(200, "The scan of the media library is started.", example: new SuccessResponse<ScanLibraryDto>(true, default));
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.Requests.Plugins;
|
||||
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.Library.Management.SetMetadataProviderEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/libraries/manage/api-set-metadata-provider-enabled</c> route.
|
||||
/// </summary>
|
||||
public class SetMetadataProviderEnabledEndpoint : BaseEndpoint<SetLibraryMetadataProviderEnabledRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SetMetadataProviderEnabledEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public SetMetadataProviderEnabledEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.PUT);
|
||||
Routes(WebRoutes.LibraryManagement.SET_METADATA_PROVIDER_ENABLED);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Libraries"));
|
||||
EnableAntiforgery();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables or disables a metadata provider of a media library.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the Ids of the media library and of the plugin, and whether the provider is enabled.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(SetLibraryMetadataProviderEnabledRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
await _apiHttpClient.PutAsync<Web.Common.Requests.Common.EmptyRequest, SetLibraryMetadataProviderEnabledRequest>(ApiRoutes.Libraries.SET_LIBRARY_METADATA_PROVIDER_ENABLED.Replace("{libraryId}", request.LibraryId.ToString()).Replace("{pluginId}", request.PluginId.ToString()), request, cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess();
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.Requests.Plugins;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Library.Management.SetMetadataProviderEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="SetMetadataProviderEnabledEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SetMetadataProviderEnabledEndpointSummary : Summary<SetMetadataProviderEnabledEndpoint, SetLibraryMetadataProviderEnabledRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SetMetadataProviderEnabledEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public SetMetadataProviderEnabledEndpointSummary()
|
||||
{
|
||||
Summary = "Enables or disables a metadata provider of a media library.";
|
||||
Description = "Enables or disables the metadata provider of the media library identified by the request.";
|
||||
RequestParam(r => r.LibraryId, "The Id of the media library whose metadata provider is enabled or disabled. Required.");
|
||||
RequestParam(r => r.PluginId, "The unique identifier of the plugin providing the metadata. Required.");
|
||||
RequestParam(r => r.IsEnabled, "Whether the metadata provider should be enabled for the media library, or not. Required.");
|
||||
|
||||
ExampleRequest = new SetLibraryMetadataProviderEnabledRequest
|
||||
{
|
||||
LibraryId = Guid.NewGuid(),
|
||||
PluginId = Guid.NewGuid(),
|
||||
IsEnabled = true
|
||||
};
|
||||
|
||||
Response(200, "The metadata provider of the media library is enabled or disabled.", example: new SuccessResponse(true));
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books;
|
||||
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.Library.WrittenContentLibrary.BookLibrary.Books.EditBook;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/library/written-content-library/books-library/books/{id}</c> route.
|
||||
/// </summary>
|
||||
public class EditBookViewEndpoint : BaseEndpoint<GetBookRequest, IResult>
|
||||
{
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Books.EDIT_BOOK);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Books"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays the book editing view.
|
||||
/// </summary>
|
||||
/// <param name="request">The request object.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override Task<IResult> ExecuteAsync(GetBookRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.FromResult(View("/Core/Views/Library/WrittenContentLibrary/BookLibrary/Books/Item.cshtml"));
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.EditBook;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="EditBookViewEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class EditBookViewEndpointSummary : Summary<EditBookViewEndpoint, GetBookRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EditBookViewEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public EditBookViewEndpointSummary()
|
||||
{
|
||||
Summary = "Renders the edit book view.";
|
||||
Description = "Renders the view for editing the book identified by the request.";
|
||||
|
||||
RequestParam(r => r.Id, "The unique identifier of the book to edit.");
|
||||
|
||||
Response(200, "The view for editing the book is rendered.");
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using Lumina.Presentation.Web.Common.Requests.Libraries;
|
||||
using Lumina.Presentation.Web.Common.Routes;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.GetLibraryItems;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/library/written-content-library/books-library/books/api-get-library-items</c> route.
|
||||
/// </summary>
|
||||
public class GetLibraryItemsEndpoint : BaseEndpoint<GetBooksLiteRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetLibraryItemsEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public GetLibraryItemsEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Books.GET_LIBRARY_ITEMS);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Books"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the lightweight details of the books of a media library.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the parameters used to retrieve the books.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetBooksLiteRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
PaginatedBookLiteDto response = await _apiHttpClient.GetAsync<PaginatedBookLiteDto>(BuildItemsEndpoint(request), cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(response);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds the API endpoint used to retrieve the lightweight details of the books of a media library, from the provided <paramref name="query"/>.
|
||||
/// </summary>
|
||||
/// <param name="query">The request containing the parameters used to retrieve the books.</param>
|
||||
/// <returns>The API endpoint to which the retrieval request is sent.</returns>
|
||||
private static string BuildItemsEndpoint(GetBooksLiteRequest query)
|
||||
{
|
||||
StringBuilder endpoint = new(ApiRoutes.Books.GET_BOOKS_LITE);
|
||||
endpoint.Append($"?libraryId={query.LibraryId}");
|
||||
if (query.CurrentPage is not null)
|
||||
endpoint.Append($"¤tPage={query.CurrentPage}");
|
||||
if (query.PerPage is not null)
|
||||
endpoint.Append($"&perPage={query.PerPage}");
|
||||
if (!string.IsNullOrWhiteSpace(query.SearchTerm))
|
||||
endpoint.Append($"&searchTerm={Uri.EscapeDataString(query.SearchTerm)}");
|
||||
if (!string.IsNullOrWhiteSpace(query.FilterAlphaKey))
|
||||
endpoint.Append($"&filterAlphaKey={Uri.EscapeDataString(query.FilterAlphaKey)}");
|
||||
endpoint.Append($"&ignoreThePrefixForAlphaPicker={query.IgnoreThePrefixForAlphaPicker}");
|
||||
if (!string.IsNullOrWhiteSpace(query.SortBy))
|
||||
endpoint.Append($"&sortBy={Uri.EscapeDataString(query.SortBy)}");
|
||||
if (query.SortOrder is not null)
|
||||
endpoint.Append($"&sortOrder={query.SortOrder}");
|
||||
return endpoint.ToString();
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using Lumina.Presentation.Web.Common.Requests.Libraries;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.GetLibraryItems;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetLibraryItemsEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetLibraryItemsEndpointSummary : Summary<GetLibraryItemsEndpoint, GetBooksLiteRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetLibraryItemsEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetLibraryItemsEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the lightweight details of the books of a media library.";
|
||||
Description = "Retrieves the lightweight details of the books of the media library identified by the request.";
|
||||
|
||||
RequestParam(r => r.LibraryId, "The Id of the media library whose books are retrieved.");
|
||||
RequestParam(r => r.CurrentPage, "Optional. The page of results to retrieve.");
|
||||
RequestParam(r => r.PerPage, "Optional. The maximum number of books to retrieve per page.");
|
||||
RequestParam(r => r.SearchTerm, "Optional. The search term used to filter results.");
|
||||
RequestParam(r => r.FilterAlphaKey, "Optional. The alpha key used to filter the results by the first character of their title, for the alpha picker.");
|
||||
RequestParam(r => r.IgnoreThePrefixForAlphaPicker, "Whether the leading The prefix of a title is ignored when computing the alpha key, or not.");
|
||||
RequestParam(r => r.SortBy, "Optional. The name of the field by which to sort the results.");
|
||||
RequestParam(r => r.SortOrder, "Optional. The direction in which to sort the results.");
|
||||
|
||||
Response(200, "The lightweight details of the books of the media library are returned.", example: new SuccessResponse<PaginatedBookLiteDto>(true, default));
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.Libraries;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books;
|
||||
using Lumina.Presentation.Web.Common.Routes;
|
||||
using Lumina.Presentation.Web.Common.Services;
|
||||
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.Library.WrittenContentLibrary.BookLibrary.Books.Index;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/library/written-content-library/books-library/books</c> route.
|
||||
/// </summary>
|
||||
public class BooksIndexViewEndpoint : BaseEndpoint<GetBooksViewRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
private readonly IUrlService _urlService;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BooksIndexViewEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
/// <param name="urlService">Injected service for generating URLs from action and controller names, with localization.</param>
|
||||
public BooksIndexViewEndpoint(IApiHttpClient apiHttpClient, IUrlService urlService)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
_urlService = urlService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Books.INDEX);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Books"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays the books browsing view.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the Id of the media library whose books are browsed.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetBooksViewRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (request.LibraryId is null)
|
||||
return Results.Redirect(_urlService.GetAbsoluteUrl(WebRoutes.Home.INDEX_CULTURED)!);
|
||||
LibraryDto library = await _apiHttpClient.GetAsync<LibraryDto>(ApiRoutes.Libraries.GET_LIBRARY_BY_ID.Replace("{id}", request.LibraryId.Value.ToString()), cancellationToken).ConfigureAwait(false);
|
||||
return View("/Core/Views/Library/WrittenContentLibrary/BookLibrary/Books/Index.cshtml", library);
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Requests.Library.WrittenContentLibrary.BookLibrary.Books;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Library.WrittenContentLibrary.BookLibrary.Books.Index;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="BooksIndexViewEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class BooksIndexViewEndpointSummary : Summary<BooksIndexViewEndpoint, GetBooksViewRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BooksIndexViewEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public BooksIndexViewEndpointSummary()
|
||||
{
|
||||
Summary = "Renders the books browsing view.";
|
||||
Description = "Renders the view for browsing the books of the media library identified by the request.";
|
||||
|
||||
RequestParam(r => r.LibraryId, "Optional. The unique identifier of the media library whose books are browsed.");
|
||||
|
||||
Response(200, "The view for browsing the books of the media library is rendered.");
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.Authorization;
|
||||
using Lumina.Presentation.Web.Common.DTO.Plugins;
|
||||
using Lumina.Presentation.Web.Common.Requests.Plugins;
|
||||
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.Plugins.GetPluginSettings;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/plugins/api-get-plugin-settings/{pluginId}</c> route.
|
||||
/// </summary>
|
||||
public class GetPluginSettingsEndpoint : BaseEndpoint<GetPluginSettingsRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetPluginSettingsEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public GetPluginSettingsEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Plugins.GET_PLUGIN_SETTINGS);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Plugins"));
|
||||
Policies(AuthorizationPolicies.REQUIRE_ADMIN_ROLE);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the settings of the plugin identified by the request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the unique identifier of the plugin whose settings are retrieved.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(GetPluginSettingsRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
PluginSettingsDto response = await _apiHttpClient.GetAsync<PluginSettingsDto>(ApiRoutes.Plugins.GET_PLUGIN_SETTINGS.Replace("{pluginId}", request.PluginId.ToString()), cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(response);
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.DTO.Plugins;
|
||||
using Lumina.Presentation.Web.Common.Requests.Plugins;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Plugins.GetPluginSettings;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetPluginSettingsEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetPluginSettingsEndpointSummary : Summary<GetPluginSettingsEndpoint, GetPluginSettingsRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetPluginSettingsEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetPluginSettingsEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the settings of a plugin and their schema.";
|
||||
Description = "Retrieves the settings and their schema of the plugin identified by the request.";
|
||||
|
||||
RequestParam(r => r.PluginId, "The unique identifier of the plugin whose settings are retrieved.");
|
||||
|
||||
Response(200, "The settings and their schema of the plugin are returned.", example: new SuccessResponse<PluginSettingsDto>(true, default));
|
||||
}
|
||||
}
|
||||
@@ -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.Plugins;
|
||||
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.Plugins.GetPlugins;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/plugins/api-get-plugins</c> route.
|
||||
/// </summary>
|
||||
public class GetPluginsEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetPluginsEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public GetPluginsEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Plugins.GET_PLUGINS);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Plugins"));
|
||||
Policies(AuthorizationPolicies.REQUIRE_ADMIN_ROLE);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the plugins.
|
||||
/// </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)
|
||||
{
|
||||
PluginDto[] response = await _apiHttpClient.GetAsync<PluginDto[]>(ApiRoutes.Plugins.GET_PLUGINS, cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(response);
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.DTO.Plugins;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Plugins.GetPlugins;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetPluginsEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetPluginsEndpointSummary : Summary<GetPluginsEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetPluginsEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetPluginsEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the plugins.";
|
||||
Description = "Retrieves the collection of detected plugins.";
|
||||
|
||||
Response(200, "The collection of detected plugins is returned.", example: new SuccessResponse<PluginDto[]>(true, default));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.Authorization;
|
||||
using Lumina.Presentation.Web.Common.DTO.Plugins;
|
||||
using Lumina.Presentation.Web.Common.Routes;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Plugins.Index;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/plugins</c> route.
|
||||
/// </summary>
|
||||
public class PluginsIndexViewEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PluginsIndexViewEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public PluginsIndexViewEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Plugins.INDEX);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Plugins"));
|
||||
Policies(AuthorizationPolicies.REQUIRE_ADMIN_ROLE);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays the plugins index view.
|
||||
/// </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)
|
||||
{
|
||||
PluginDto[] plugins = await _apiHttpClient.GetAsync<PluginDto[]>(ApiRoutes.Plugins.GET_PLUGINS, cancellationToken).ConfigureAwait(false);
|
||||
Dictionary<Guid, PluginSettingsDto> settingsByPluginId = [];
|
||||
foreach (PluginDto plugin in plugins)
|
||||
if (plugin.LoadStatus == Lumina.Presentation.Web.Common.Enums.Plugins.PluginLoadStatus.Loaded)
|
||||
settingsByPluginId[plugin.Id] = await _apiHttpClient.GetAsync<PluginSettingsDto>(ApiRoutes.Plugins.GET_PLUGIN_SETTINGS.Replace("{pluginId}", plugin.Id.ToString()), cancellationToken).ConfigureAwait(false);
|
||||
Dictionary<string, object?> viewData = new() { ["pluginSettings"] = settingsByPluginId };
|
||||
return View("/Core/Views/Plugins/Index.cshtml", plugins, viewData);
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Plugins.Index;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="PluginsIndexViewEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class PluginsIndexViewEndpointSummary : Summary<PluginsIndexViewEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="PluginsIndexViewEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public PluginsIndexViewEndpointSummary()
|
||||
{
|
||||
Summary = "Renders the plugins management view.";
|
||||
Description = "Renders the view for managing the plugins and their settings.";
|
||||
|
||||
Response(200, "The view for managing the plugins and their settings is rendered.");
|
||||
}
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.Authorization;
|
||||
using Lumina.Presentation.Web.Common.Requests.Plugins;
|
||||
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.Plugins.UpdatePluginSettings;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/plugins/api-update-plugin-settings</c> route.
|
||||
/// </summary>
|
||||
public class UpdatePluginSettingsEndpoint : BaseEndpoint<UpdatePluginSettingsRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UpdatePluginSettingsEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public UpdatePluginSettingsEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.PUT);
|
||||
Routes(WebRoutes.Plugins.UPDATE_PLUGIN_SETTINGS);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Plugins"));
|
||||
Policies(AuthorizationPolicies.REQUIRE_ADMIN_ROLE);
|
||||
EnableAntiforgery();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the settings of the plugin identified by the request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the updated settings of the plugin.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(UpdatePluginSettingsRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
await _apiHttpClient.PutAsync<Web.Common.Requests.Common.EmptyRequest, UpdatePluginSettingsRequest>(ApiRoutes.Plugins.UPDATE_PLUGIN_SETTINGS.Replace("{pluginId}", request.PluginId.ToString()), request, cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess();
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.Requests.Plugins;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Plugins.UpdatePluginSettings;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="UpdatePluginSettingsEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class UpdatePluginSettingsEndpointSummary : Summary<UpdatePluginSettingsEndpoint, UpdatePluginSettingsRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UpdatePluginSettingsEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public UpdatePluginSettingsEndpointSummary()
|
||||
{
|
||||
Summary = "Updates the settings of a plugin.";
|
||||
Description = "Updates the settings of the plugin identified by the request.";
|
||||
RequestParam(r => r.PluginId, "The unique identifier of the plugin. Required.");
|
||||
RequestParam(r => r.Settings, "The settings of the plugin. Optional.");
|
||||
|
||||
ExampleRequest = new UpdatePluginSettingsRequest
|
||||
{
|
||||
PluginId = Guid.NewGuid(),
|
||||
Settings = new Dictionary<string, string>
|
||||
{
|
||||
{ "preferredLanguage", "fr" },
|
||||
{ "selectionStrategy", "first" }
|
||||
}
|
||||
};
|
||||
|
||||
Response(200, "The settings of the plugin are updated.", example: new SuccessResponse(true));
|
||||
}
|
||||
}
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Requests.Tools;
|
||||
using Lumina.Presentation.Web.Common.Routes;
|
||||
using Lumina.Presentation.Web.Common.Services;
|
||||
using Lumina.Presentation.Web.Core.Endpoints.Common;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Tools.Language.SetLanguage;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/tools/language/set-language</c> route.
|
||||
/// </summary>
|
||||
public class SetLanguageEndpoint : BaseEndpoint<SetLanguageRequest, IResult>
|
||||
{
|
||||
private readonly IUrlService _urlService;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SetLanguageEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="urlService">Injected service for generating URLs from action and controller names, with localization.</param>
|
||||
public SetLanguageEndpoint(IUrlService urlService)
|
||||
{
|
||||
_urlService = urlService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Language.SET_LANGUAGE);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Language"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the culture used by the application.
|
||||
/// </summary>
|
||||
/// <param name="request">The request containing the new culture to set and the URL to return to.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override async Task<IResult> ExecuteAsync(SetLanguageRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
// store the culture preference in a cookie
|
||||
HttpContext.Response.Cookies.Append(
|
||||
CookieRequestCultureProvider.DefaultCookieName,
|
||||
CookieRequestCultureProvider.MakeCookieValue(new RequestCulture(request.NewCulture!)),
|
||||
new CookieOptions
|
||||
{
|
||||
Expires = DateTimeOffset.UtcNow.AddYears(1),
|
||||
IsEssential = true,
|
||||
SameSite = SameSiteMode.Lax,
|
||||
Path = "/" // ensure the cookie works across all paths
|
||||
}
|
||||
);
|
||||
// ensure the return URL includes the correct culture
|
||||
string returnUrl = string.IsNullOrEmpty(request.ReturnUrl) ? _urlService.GetAbsoluteUrl(WebRoutes.Home.INDEX_CULTURED)! : request.ReturnUrl;
|
||||
// handle the culture replacement in the return URL
|
||||
string currentCulture = Culture;
|
||||
string culturePath = $"/{currentCulture.ToLower()}/";
|
||||
string newCulturePath = $"/{request.NewCulture!.ToLower()}/";
|
||||
|
||||
// handle the base path if present
|
||||
if (!string.IsNullOrEmpty(HttpContext.Request.PathBase))
|
||||
returnUrl = returnUrl.Replace(HttpContext.Request.PathBase.Value!, string.Empty, StringComparison.OrdinalIgnoreCase);
|
||||
// replace the culture in the URL
|
||||
returnUrl = returnUrl.Replace(culturePath, newCulturePath, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
// re-apply the base path if present
|
||||
if (!string.IsNullOrEmpty(HttpContext.Request.PathBase))
|
||||
returnUrl = HttpContext.Request.PathBase.Value + returnUrl;
|
||||
|
||||
// redirect to the original page
|
||||
return Results.LocalRedirect(returnUrl);
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Requests.Tools;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Tools.Language.SetLanguage;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="SetLanguageEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class SetLanguageEndpointSummary : Summary<SetLanguageEndpoint, SetLanguageRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SetLanguageEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public SetLanguageEndpointSummary()
|
||||
{
|
||||
Summary = "Sets the culture of the application.";
|
||||
Description = "Sets the culture used by the application, storing the preference in a cookie, and redirects the browser back.";
|
||||
|
||||
RequestParam(r => r.NewCulture, "The new culture to set.");
|
||||
RequestParam(r => r.ReturnUrl, "The URL to return to, after setting the new culture.");
|
||||
|
||||
Response(200, "The culture preference is stored in a cookie, and the browser is redirected back.");
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.Api;
|
||||
using Lumina.Presentation.Web.Common.DTO.UsersManagement;
|
||||
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.Tools.Settings.GetUserSettings;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/tools/settings/api-get-user-settings</c> route.
|
||||
/// </summary>
|
||||
public class GetUserSettingsEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
private readonly IApiHttpClient _apiHttpClient;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetUserSettingsEndpoint"/> class.
|
||||
/// </summary>
|
||||
/// <param name="apiHttpClient">Injected service for interactions with the API.</param>
|
||||
public GetUserSettingsEndpoint(IApiHttpClient apiHttpClient)
|
||||
{
|
||||
_apiHttpClient = apiHttpClient;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Settings.GET_USER_SETTINGS);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Settings"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the settings 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)
|
||||
{
|
||||
UserSettingsDto response = await _apiHttpClient.GetAsync<UserSettingsDto>(ApiRoutes.Users.GET_USER_SETTINGS, cancellationToken).ConfigureAwait(false);
|
||||
return JsonSuccess(response);
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.Common;
|
||||
using Lumina.Presentation.Web.Common.DTO.UsersManagement;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Presentation.Web.Core.Endpoints.Tools.Settings.GetUserSettings;
|
||||
|
||||
/// <summary>
|
||||
/// Class used for providing a textual description for the <see cref="GetUserSettingsEndpoint"/> endpoint, for OpenAPI.
|
||||
/// </summary>
|
||||
[ExcludeFromCodeCoverage]
|
||||
public class GetUserSettingsEndpointSummary : Summary<GetUserSettingsEndpoint, EmptyRequest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetUserSettingsEndpointSummary"/> class.
|
||||
/// </summary>
|
||||
public GetUserSettingsEndpointSummary()
|
||||
{
|
||||
Summary = "Retrieves the settings of the current user.";
|
||||
Description = "Retrieves the settings of the current user.";
|
||||
|
||||
Response(200, "The settings of the current user are returned.", example: new SuccessResponse<UserSettingsDto>(true, default));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using FastEndpoints;
|
||||
using Lumina.Presentation.Web.Common.DTO.UsersManagement;
|
||||
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.Tools.Settings;
|
||||
|
||||
/// <summary>
|
||||
/// API endpoint for the <c>/{culture}/tools/settings</c> route.
|
||||
/// </summary>
|
||||
public class SettingsViewEndpoint : BaseEndpoint<EmptyRequest, IResult>
|
||||
{
|
||||
/// <summary>
|
||||
/// Configures the endpoint.
|
||||
/// </summary>
|
||||
public override void Configure()
|
||||
{
|
||||
base.Configure();
|
||||
Verbs(Http.GET);
|
||||
Routes(WebRoutes.Settings.INDEX);
|
||||
DontAutoTag();
|
||||
Options(options => options.WithTags("Settings"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays the user settings view.
|
||||
/// </summary>
|
||||
/// <param name="request">The request object.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
public override Task<IResult> ExecuteAsync(EmptyRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
UserSettingsDto settings = new();
|
||||
return Task.FromResult(View("/Core/Views/Tools/Settings.cshtml", settings));
|
||||
}
|
||||
}
|
||||
Loaded 100 of 341 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user