Enhance documentation with new features: added dark/light/system theme support, instructions page, and application catalog. Updated API and domain model for app management and automatic migrations on startup. Improved frontend structure with new routes and features for user instructions and app management.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PnvPanel.Application.Common.Interfaces;
|
||||
using PnvPanel.Application.Common.Messaging;
|
||||
using PnvPanel.Application.Common.Models;
|
||||
using PnvPanel.Domain.Nodes;
|
||||
|
||||
namespace PnvPanel.Application.Admin.Nodes;
|
||||
|
||||
public sealed class UpdateNodeCommandHandler(IAppDbContext dbContext, IXuiPanelGateway gateway, ISecretProtector secretProtector)
|
||||
: ICommandHandler<UpdateNodeCommand, Result<NodeDto>>
|
||||
{
|
||||
public async Task<Result<NodeDto>> Handle(UpdateNodeCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
var node = await dbContext.Nodes.FirstOrDefaultAsync(n => n.Id == command.NodeId, cancellationToken);
|
||||
if (node is null)
|
||||
return Result.Failure<NodeDto>(NodeErrors.NotFound);
|
||||
|
||||
node.UpdateDetails(command.Name, command.Location);
|
||||
|
||||
if (command.IsEnabled)
|
||||
node.Enable();
|
||||
else
|
||||
node.Disable();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(command.Username) && !string.IsNullOrWhiteSpace(command.Password))
|
||||
{
|
||||
node.UpdateCredentials(new NodeCredentials(command.Username, secretProtector.Protect(command.Password)));
|
||||
gateway.InvalidateClient(node.Id);
|
||||
}
|
||||
|
||||
return Result.Success(NodeDto.FromDomain(node));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user