Skip to content

Commit

Permalink
Merge pull request #23 from dyatlov-a/add-main-page
Browse files Browse the repository at this point in the history
Add main page
  • Loading branch information
dyatlov-a authored Oct 3, 2023
2 parents 8ea2eda + 4d48417 commit 8634368
Show file tree
Hide file tree
Showing 75 changed files with 488 additions and 435 deletions.
14 changes: 7 additions & 7 deletions build/Build.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Nuke.Common;
using Nuke.Common.CI;
using Nuke.Common.IO;
Expand All @@ -11,7 +12,6 @@
using Nuke.Common.Tools.GitVersion;
using Nuke.Common.Utilities.Collections;
using Renci.SshNet;
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.Tools.Docker.DockerTasks;
using static Nuke.Common.Tools.DotNet.DotNetTasks;

Expand Down Expand Up @@ -52,16 +52,16 @@ public sealed class Build : NukeBuild
[Solution]
private readonly Solution Solution;

[GitVersion(Framework = "net6.0")]
[GitVersion(Framework = "net7.0")]
private readonly GitVersion GitVersion;

Target Clean => _ => _
.Before(Restore)
.Executes(() =>
{
SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory);
TestsDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory);
EnsureCleanDirectory(OutputDirectory);
SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(x => x.DeleteDirectory());
TestsDirectory.GlobDirectories("**/bin", "**/obj").ForEach(x => x.DeleteDirectory());
OutputDirectory.CreateOrCleanDirectory();
});

Target Restore => _ => _
Expand Down Expand Up @@ -95,7 +95,7 @@ public sealed class Build : NukeBuild
.When(IsServerBuild, c => c.EnableUseSourceLink())
.EnableNoRestore()
.EnableNoBuild()
.CombineWith(Solution.GetProjects("*Tests"), (_, p) => _
.CombineWith(Solution.GetAllProjects("*Tests"), (_, p) => _
.SetProjectFile(p)
.SetLoggers($"junit;LogFileName={p.Name}-results.xml;MethodFormat=Class;FailureBodyFormat=Verbose")));
});
Expand All @@ -109,7 +109,7 @@ public sealed class Build : NukeBuild
.EnableNoBuild()
.EnableNoRestore()
.CombineWith(ProjectsForPublish, (ss, p) => ss
.SetProject(Solution.GetProject(p))
.SetProject(Solution.GetAllProjects(p).SingleOrDefault())
.SetOutput(OutputDirectory / p)));
});

Expand Down
5 changes: 1 addition & 4 deletions build/_build.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
Expand All @@ -9,11 +8,9 @@
<NukeScriptDirectory>..</NukeScriptDirectory>
<NukeTelemetryVersion>1</NukeTelemetryVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nuke.Common" Version="6.3.0" />
<PackageReference Include="Nuke.Common" Version="7.0.6" />
<PackageDownload Include="GitVersion.Tool" Version="[5.10.3]" />
<PackageReference Include="SSH.NET" Version="2020.0.2" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,27 @@ public Task<ConnectToAssessmentSessionResult> Handle(
{
if (command is null)
throw new ArgumentNullException(nameof(command));

var existSessionAssessmentSession = _repository.Find(command.AppraiserId);
if (existSessionAssessmentSession?.Participants.Any(p => p.Id == command.AppraiserId) == true)
if (existSessionAssessmentSession is not null)
{
var messageId = existSessionAssessmentSession.Id == command.AssessmentSessionId
? Messages.AppraiserConnectWithError
: Messages.AppraiserConnectedToOtherSession;
if (existSessionAssessmentSession.Participants.Any(p => p.Id == command.AppraiserId))
{
var messageId = existSessionAssessmentSession.Id == command.AssessmentSessionId
? Messages.AppraiserConnectWithError
: Messages.AppraiserConnectedToOtherSession;

throw new AppraiserUserException(messageId, command.AppraiserName, existSessionAssessmentSession.Title);
}
throw new AppraiserUserException(messageId, command.AppraiserName, existSessionAssessmentSession.Title);
}

if (existSessionAssessmentSession.Moderator.Id == command.AppraiserId
&& existSessionAssessmentSession.Id != command.AssessmentSessionId)
throw new AppraiserUserException(Messages.AppraiserConnectedToOtherSession, command.AppraiserName, existSessionAssessmentSession.Title);
}

// TODO: remove nullable check
if (command.AssessmentSessionId is null)
throw new ApplicationException("AssessmentSessionId is empty.");

var assessmentSession = _repository
.Find(command.AssessmentSessionId)
.EnsureForAppraiser(command.AppraiserName);
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ namespace Inc.TeamAssistant.Appraiser.Application.Contracts;

public interface IQuickResponseCodeGenerator
{
string Generate(string data, int width, int height, bool drawQuietZones);
string Generate(string data);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
<ProjectReference Include="..\Inc.TeamAssistant.Appraiser.Model\Inc.TeamAssistant.Appraiser.Model.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.4.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.1" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.7.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.4" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
</ItemGroup>
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
Expand Down
1 change: 0 additions & 1 deletion src/Inc.TeamAssistant.Appraiser.Application/Messages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ internal static class Messages
public static readonly MessageId ExitFromAssessmentSessionHelp = new(nameof(ExitFromAssessmentSessionHelp));
public static readonly MessageId CreateAssessmentSessionHelp = new(nameof(CreateAssessmentSessionHelp));
public static readonly MessageId AllowUseNameHelp = new(nameof(AllowUseNameHelp));
public static readonly MessageId ConnectToDashboardHelp = new(nameof(ConnectToDashboardHelp));
public static readonly MessageId ShowParticipantsHelp = new(nameof(ShowParticipantsHelp));
public static readonly MessageId AddStoryToAssessmentSessionHelp = new(nameof(AddStoryToAssessmentSessionHelp));
public static readonly MessageId ChangeLanguageHelp = new(nameof(ChangeLanguageHelp));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public Task<GetLinkForConnectResult> Handle(GetLinkForConnectQuery query, Cancel
throw new ArgumentNullException(nameof(query));

var link = _linkBuilder.BuildLinkMoveToBot();
var code = _codeGenerator.Generate(link, query.Width, query.Height, query.DrawQuietZones);
var code = _codeGenerator.Generate(link);

return Task.FromResult(new GetLinkForConnectResult(code));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,18 @@ public GetStoryDetailsQueryHandler(
throw new ArgumentNullException(nameof(query));

var assessmentSession = _repository.Find(query.AssessmentSessionId);

var result = assessmentSession is not null
? Get(assessmentSession, query.Width, query.Height, query.DrawQuietZones)
: null;

var result = assessmentSession is not null ? Get(assessmentSession) : null;
return Task.FromResult(result);
}

private GetStoryDetailsResult Get(AssessmentSession assessmentSession, int width, int height, bool drawQuietZones)
private GetStoryDetailsResult Get(AssessmentSession assessmentSession)
{
if (assessmentSession is null)
throw new ArgumentNullException(nameof(assessmentSession));

var estimateEnded = assessmentSession.EstimateEnded();
var link = _linkBuilder.BuildLinkForConnect(assessmentSession.Id);
var code = _codeGenerator.Generate(link, width, height, drawQuietZones);
var code = _codeGenerator.Generate(link);

var items = assessmentSession.CurrentStory.StoryForEstimates
.Select(e => new StoryForEstimateDto(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Inc.TeamAssistant.Appraiser.Model.Commands.AddStoryToAssessmentSession;
using Inc.TeamAssistant.Appraiser.Model.Commands.AllowUseName;
using Inc.TeamAssistant.Appraiser.Model.Commands.ChangeLanguage;
using Inc.TeamAssistant.Appraiser.Model.Commands.ConnectToDashboard;
using Inc.TeamAssistant.Appraiser.Model.Commands.CreateAssessmentSession;
using Inc.TeamAssistant.Appraiser.Model.Commands.ExitFromAssessmentSession;
using Inc.TeamAssistant.Appraiser.Model.Commands.FinishAssessmentSession;
Expand Down Expand Up @@ -60,12 +59,6 @@ public async Task<ShowHelpResult> Handle(ShowHelpQuery query, CancellationToken
languageInfo.LanguageId.Value));
}

var connectToDashboardCommand = _commandProvider.GetCommand(typeof(ConnectToDashboardCommand));
commandsHelp.Add(await _messageBuilder.Build(
Messages.ConnectToDashboardHelp,
query.LanguageId,
connectToDashboardCommand));

var addStoryToAssessmentSessionCommand = _commandProvider.GetCommand(typeof(AddStoryToAssessmentSessionCommand));
commandsHelp.Add(await _messageBuilder.Build(
Messages.AddStoryToAssessmentSessionHelp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ public static IServiceCollection AddApplication(this IServiceCollection services

services
.AddSingleton(addStoryOptions)
.AddMediatR(c => c.AsScoped(), typeof(AddStoryToAssessmentSessionCommandHandler))
.AddMediatR(c =>
{
c.Lifetime = ServiceLifetime.Scoped;
c.RegisterServicesFromAssemblyContaining<AddStoryToAssessmentSessionCommandHandler>();
})
.AddValidatorsFromAssemblyContaining<AddStoryToAssessmentSessionCommandValidator>(
ServiceLifetime.Scoped,
includeInternalTypes: true)
Expand Down
1 change: 0 additions & 1 deletion src/Inc.TeamAssistant.Appraiser.Backend/CommandList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ internal static class CommandList
public const string AllowUseName = "/allow_use_name";
public const string CreateAssessmentSession = "/new";
public const string ChangeLanguageForAssessmentSession = "/{0}";
public const string ConnectToDashboard = "/dashboard";
public const string ShowParticipants = "/users";
public const string AddStoryToAssessmentSession = "/add";
public const string AcceptEstimate = "/accept";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,10 @@ public AssessmentSessionsController(IAssessmentSessionsService service)
}

[HttpGet("story/{assessmentSessionId}")]
public async Task<IActionResult> GetStoryDetails(
Guid assessmentSessionId,
int width,
int height,
bool drawQuietZones,
CancellationToken cancellationToken)
=> Ok(await _service.GetStoryDetails(new(assessmentSessionId), width, height, drawQuietZones, cancellationToken));
public async Task<IActionResult> GetStoryDetails(Guid assessmentSessionId, CancellationToken cancellationToken)
=> Ok(await _service.GetStoryDetails(new(assessmentSessionId), cancellationToken));

[HttpGet("link-for-connect")]
public async Task<IActionResult> LinkForConnect(
int width,
int height,
bool drawQuietZones,
CancellationToken cancellationToken)
=> Ok(await _service.GetLinkForConnect(width, height, drawQuietZones, cancellationToken));
public async Task<IActionResult> LinkForConnect(CancellationToken cancellationToken)
=> Ok(await _service.GetLinkForConnect(cancellationToken));
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@
<ProjectReference Include="..\Inc.TeamAssistant.Reviewer.All\Inc.TeamAssistant.Reviewer.All.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="GeoTimeZone" Version="5.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="7.0.1" />
<PackageReference Include="QRCoder" Version="1.4.1" />
<PackageReference Include="Telegram.Bot" Version="18.0.0" />
<PackageReference Include="prometheus-net.AspNetCore" Version="7.0.0" />
<PackageReference Include="prometheus-net.AspNetCore.HealthChecks" Version="7.0.0" />
<PackageReference Include="GeoTimeZone" Version="5.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="7.0.11" />
<PackageReference Include="Net.Codecrete.QrCodeGenerator" Version="2.0.3" />
<PackageReference Include="QRCoder" Version="1.4.3" />
<PackageReference Include="Telegram.Bot" Version="19.0.0" />
<PackageReference Include="prometheus-net.AspNetCore" Version="8.0.1" />
<PackageReference Include="prometheus-net.AspNetCore.HealthChecks" Version="8.0.1" />
<PackageReference Include="prometheus-net.DotNetRuntime" Version="4.4.0" />
</ItemGroup>
</Project>
5 changes: 4 additions & 1 deletion src/Inc.TeamAssistant.Appraiser.Backend/Pages/_Host.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@
<body>
<component type="typeof(WebUI.App)" render-mode="WebAssemblyPrerendered"/>

<script src="~/_framework/blazor.webassembly.js?v=@Model.AppVersion"></script>
<script src="~/_framework/blazor.webassembly.js?v=@Model.AppVersion" autostart="false"></script>
<script>
Blazor.start();
</script>
</body>

</html>
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@ public AssessmentSessionsService(IMediator mediator)

public async Task<ServiceResult<GetStoryDetailsResult?>> GetStoryDetails(
AssessmentSessionId assessmentSessionId,
int width,
int height,
bool drawQuietZones,
CancellationToken cancellationToken)
{
try
{
var result = await _mediator.Send(
new GetStoryDetailsQuery(assessmentSessionId, width, height, drawQuietZones),
new GetStoryDetailsQuery(assessmentSessionId),
cancellationToken);

return result is null
Expand All @@ -37,16 +34,12 @@ public AssessmentSessionsService(IMediator mediator)
}
}

public async Task<ServiceResult<GetLinkForConnectResult>> GetLinkForConnect(
int width,
int height,
bool drawQuietZones,
CancellationToken cancellationToken)
public async Task<ServiceResult<GetLinkForConnectResult>> GetLinkForConnect(CancellationToken cancellationToken)
{
try
{
var result = await _mediator.Send(
new GetLinkForConnectQuery(width, height, drawQuietZones),
new GetLinkForConnectQuery(),
cancellationToken);

return ServiceResult.Success(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Inc.TeamAssistant.Appraiser.Model.Commands.AddStoryToAssessmentSession;
using Inc.TeamAssistant.Appraiser.Model.Commands.AllowUseName;
using Inc.TeamAssistant.Appraiser.Model.Commands.ChangeLanguage;
using Inc.TeamAssistant.Appraiser.Model.Commands.ConnectToDashboard;
using Inc.TeamAssistant.Appraiser.Model.Commands.CreateAssessmentSession;
using Inc.TeamAssistant.Appraiser.Model.Commands.ExitFromAssessmentSession;
using Inc.TeamAssistant.Appraiser.Model.Commands.FinishAssessmentSession;
Expand All @@ -21,7 +20,6 @@ internal sealed class CommandProvider : ICommandProvider
[typeof(CreateAssessmentSessionCommand)] = CommandList.CreateAssessmentSession,
[typeof(AllowUseNameCommand)] = CommandList.AllowUseName,
[typeof(ChangeLanguageCommand)] = CommandList.ChangeLanguageForAssessmentSession,
[typeof(ConnectToDashboardCommand)] = CommandList.ConnectToDashboard,
[typeof(AddStoryToAssessmentSessionCommand)] = CommandList.AddStoryToAssessmentSession,
[typeof(ReVoteEstimateCommand)] = CommandList.ReVoteEstimate,
[typeof(AcceptEstimateCommand)] = CommandList.AcceptEstimate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Inc.TeamAssistant.Appraiser.Model.Commands.AllowUseName;
using Inc.TeamAssistant.Appraiser.Model.Commands.ChangeLanguage;
using Inc.TeamAssistant.Appraiser.Model.Commands.ConnectToAssessmentSession;
using Inc.TeamAssistant.Appraiser.Model.Commands.ConnectToDashboard;
using Inc.TeamAssistant.Appraiser.Model.Commands.CreateAssessmentSession;
using Inc.TeamAssistant.Appraiser.Model.Commands.ExitFromAssessmentSession;
using Inc.TeamAssistant.Appraiser.Model.Commands.FinishAssessmentSession;
Expand Down Expand Up @@ -51,7 +50,6 @@ public StaticCommandFactory()
[CommandList.AllowUseName] = c => new AllowUseNameCommand(c.UserId, c.RealUserName),
[CommandList.ExitFromAssessmentSession] = c => new ExitFromAssessmentSessionCommand(c.UserId, c.UserName),
[CommandList.CreateAssessmentSession] = c => new CreateAssessmentSessionCommand(c.ChatId, c.UserId, c.UserName, c.LanguageId),
[CommandList.ConnectToDashboard] = c => new ConnectToDashboardCommand(c.UserId, c.UserName),
[CommandList.ShowParticipants] = c => new ShowParticipantsQuery(c.UserId, c.UserName),
[CommandList.AddStoryToAssessmentSession] = CreateStartStorySelectionCommand
};
Expand Down
Loading

0 comments on commit 8634368

Please sign in to comment.