-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: raise event on encode outputs and subscribe via encode dialog
- Loading branch information
1 parent
944757e
commit 4a0f235
Showing
7 changed files
with
112 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react' | ||
|
||
type ScrollAnchorProps = React.PropsWithChildren | ||
|
||
const ScrollAnchor: React.FC<ScrollAnchorProps> = ({ children }) => { | ||
const ref = React.useRef<HTMLDivElement | null>(null) | ||
|
||
React.useEffect(() => ref.current?.scrollIntoView({ behavior: 'smooth' })) | ||
|
||
return ( | ||
<> | ||
{children} | ||
<div ref={ref} id="anchor" /> | ||
</> | ||
) | ||
} | ||
|
||
export default ScrollAnchor |
25 changes: 25 additions & 0 deletions
25
src/Service.Dashboard/src/Application.Components/Encodes/Events/RaiseEncodeOutputtedTopic.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Giantnodes.Service.Dashboard.Application.Contracts.Encodes.Events; | ||
using Giantnodes.Service.Dashboard.Domain.Aggregates.Encodes.Repositories; | ||
using HotChocolate.Subscriptions; | ||
using MassTransit; | ||
|
||
namespace Giantnodes.Service.Dashboard.Application.Components.Encodes.Events; | ||
|
||
public class RaiseEncodeOutputtedTopic : IConsumer<EncodeProgressedEvent> | ||
{ | ||
private readonly IEncodeRepository _repository; | ||
private readonly ITopicEventSender _sender; | ||
|
||
public RaiseEncodeOutputtedTopic(IEncodeRepository repository, ITopicEventSender sender) | ||
{ | ||
_repository = repository; | ||
_sender = sender; | ||
} | ||
|
||
public async Task Consume(ConsumeContext<EncodeProgressedEvent> context) | ||
{ | ||
var encode = await _repository.SingleAsync(x => x.Id == context.Message.EncodeId); | ||
|
||
await _sender.SendAsync(nameof(EncodeOutputtedEvent), encode, context.CancellationToken); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Service.Dashboard/src/Application.Contracts/Encodes/Events/EncodeOutputtedEvent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Giantnodes.Infrastructure.Domain.Events; | ||
|
||
namespace Giantnodes.Service.Dashboard.Application.Contracts.Encodes.Events; | ||
|
||
public sealed record EncodeOutputtedEvent : DomainEvent | ||
{ | ||
public required Guid EncodeId { get; init; } | ||
|
||
public required string Output { get; init; } | ||
|
||
public required string FullOutput { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...vice.Dashboard/src/HttpApi/Resolvers/Encodes/Subscriptions/EncodeOutputtedSubscription.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Giantnodes.Service.Dashboard.Application.Contracts.Encodes.Events; | ||
using Giantnodes.Service.Dashboard.Domain.Aggregates.Encodes; | ||
using Giantnodes.Service.Dashboard.Persistence.DbContexts; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace Giantnodes.Service.Dashboard.HttpApi.Resolvers.Encodes.Subscriptions; | ||
|
||
[ExtendObjectType(OperationTypeNames.Subscription)] | ||
public class EncodeOutputtedSubscription | ||
{ | ||
[Subscribe] | ||
[Topic(nameof(EncodeOutputtedEvent))] | ||
[UseSingleOrDefault] | ||
[UseProjection] | ||
[UseFiltering] | ||
[UseSorting] | ||
public IQueryable<Encode> EncodeOutputted( | ||
[Service] ApplicationDbContext database, | ||
[EventMessage] Encode encode) | ||
{ | ||
return database.Encodes.Where(x => x.Id == encode.Id).AsNoTracking(); | ||
} | ||
} |