Skip to content

Commit

Permalink
Use new angular project format in visual studio (#115)
Browse files Browse the repository at this point in the history
* move angular project

* more reorg

* dockerfile fixup

* workflow fixes

* get back end test results

* try a different folder

* now report it

* keep 2 comments

* different wildcard

* path fixes

* these also

* send the auth also

* more
  • Loading branch information
mlapaglia authored Jan 29, 2024
1 parent 09c3f22 commit 6de0272
Show file tree
Hide file tree
Showing 496 changed files with 3,831 additions and 3,425 deletions.
8 changes: 6 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
**/.angular
**/config
LICENSE
README.md
README.md
!**/.gitignore
!.git/HEAD
!.git/config
!.git/packed-refs
!.git/refs/heads/**
59 changes: 31 additions & 28 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Run build
run: docker build . --file ./OpenAlprWebhookProcessor/Dockerfile
run: docker build . --file ./OpenAlprWebhookProcessor.Server/Dockerfile

back-end-tests:
runs-on: ubuntu-latest
Expand All @@ -37,7 +37,7 @@ jobs:
- name: Test
run: dotnet test --configuration Release --no-build --collect:"XPlat Code Coverage" --results-directory ./coverage

- name: Code Coverage Report
- name: Back End Code Coverage Report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: coverage/**/coverage.cobertura.xml
Expand All @@ -54,6 +54,7 @@ jobs:
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
header: Back End Coverage
recreate: true
path: code-coverage-results.md

Expand All @@ -62,12 +63,33 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Run frontend tests
working-directory: ./OpenAlprWebhookProcessor/angularapp
working-directory: ./openalprwebhookprocessor.client
run: |
npm ci
npm run test:prod
npm run lint
- name: Front End Code Coverage Report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: ./openalprwebhookprocessor.client/coverage/cobertura-coverage.xml
badge: true
fail_below_min: true
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '0 80'

- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
header: Front End Coverage
recreate: true
path: code-coverage-results.md

windows-build-push:
needs: build
runs-on: ubuntu-latest
Expand All @@ -86,25 +108,16 @@ jobs:
run: |
tag=$(git describe --tags --abbrev=0)
release_name="OpenAlprWebHookProcessor-${tag}-windows64"
dotnet restore "OpenAlprWebhookProcessor/OpenAlprWebhookProcessor.csproj"
dotnet build "OpenAlprWebhookProcessor/OpenAlprWebhookProcessor.csproj" -c Release
dotnet publish "OpenAlprWebhookProcessor/OpenAlprWebhookProcessor.csproj" -c Release -o "$release_name"
dotnet restore "OpenAlprWebhookProcessor.Server/OpenAlprWebhookProcessor.Server.csproj"
dotnet build "OpenAlprWebhookProcessor.Server/OpenAlprWebhookProcessor.Server.csproj" -c Release
dotnet publish "OpenAlprWebhookProcessor.Server/OpenAlprWebhookProcessor.Server.csproj" -c Release -o "$release_name"
tar czvf "${release_name}.tar.gz" "$release_name"
- name: Publish
uses: softprops/action-gh-release@v1
if: contains(github.ref, 'alpha') != true
with:
files: "OpenAlprWebHookProcessor*"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish
uses: softprops/action-gh-release@v1
if: contains(github.ref, 'alpha')
with:
files: "OpenAlprWebHookProcessor*"
prerelease: true
prerelease: ${{ contains(github.ref, 'alpha') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -130,20 +143,10 @@ jobs:
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}

- name: Push to Docker Hub
if: contains(github.ref, 'alpha') != true
uses: docker/build-push-action@v2
with:
file: ./OpenAlprWebhookProcessor/Dockerfile
file: ./OpenAlprWebhookProcessor.Server/Dockerfile
push: true
tags: |
mlapaglia/openalprwebhookprocessor:${{ steps.get_version.outputs.VERSION }}
mlapaglia/openalprwebhookprocessor:latest
- name: Push alpha build to Docker Hub
if: contains(github.ref, 'alpha')
uses: docker/build-push-action@v2
with:
file: ./OpenAlprWebhookProcessor/Dockerfile
push: true
tags: |
mlapaglia/openalprwebhookprocessor:${{ steps.get_version.outputs.VERSION }}
${{ contains(github.ref, 'alpha') && 'mlapaglia/openalprwebhookprocessor:alpha' || 'mlapaglia/openalprwebhookprocessor:latest' }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -356,4 +356,4 @@ dist/
**/log*.txt
*db-shm
*db-wal
OpenAlprWebhookProcessor/angularapp/.angular/*
openalprwebhookprocessor.client/.angular/*
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace OpenAlprWebhookProcessor.Alerts
{
[Authorize]
[ApiController]
[Route("alerts")]
[Route("api/alerts")]
public class AlertsController : Controller
{
private readonly GetAlertsRequestHandler _getAlertsRequestHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ await _alertClient.SendAlertAsync(new AlertUpdateRequest()
IsUrgent = true,
PlateId = testPlateGroup.Id,
PlateJpeg = testPlateGroup.PlateImage.Jpeg,
PlateJpegUrl = $"/images/crop/{testPlateGroup.OpenAlprUuid}",
PlateJpegUrl = $"/api/images/crop/{testPlateGroup.OpenAlprUuid}",
PlateNumber = testPlateGroup.BestNumber,
ReceivedOn = DateTimeOffset.UtcNow,
}, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ await _alertClient.SendAlertAsync(new AlertUpdateRequest()
PlateId = testPlateGroup.Id,
PlateNumber = testPlateGroup.BestNumber,
PlateJpeg = testPlateGroup.PlateImage.Jpeg,
PlateJpegUrl = $"/images/crop/{testPlateGroup.OpenAlprUuid}",
PlateJpegUrl = $"/api/images/crop/{testPlateGroup.OpenAlprUuid}",
ReceivedOn = DateTimeOffset.UtcNow,
}, cancellationToken);
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace OpenAlprWebhookProcessor.Cameras
{
[Authorize]
[ApiController]
[Route("cameras")]
[Route("api/cameras")]
public class CameraController : Controller
{
private readonly GetCameraRequestHandler _getCameraHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,15 @@ private async Task<string> CreateSampleImageUrlAsync(
return null;
}

return Flurl.Url.Combine($"/images/{camera.LatestProcessedPlateUuid}");
return Flurl.Url.Combine($"/api/images/{camera.LatestProcessedPlateUuid}");
}
else
{
return Flurl.Url.Combine($"/images/{camera.Id}/snapshot");
return Flurl.Url.Combine($"/api/images/{camera.Id}/snapshot");
}
}

private DateTimeOffset? GetNextScheduledExecutionDate(
private static DateTimeOffset? GetNextScheduledExecutionDate(
Agent agent,
Data.Camera camera,
JobDetailsDto dateToEnqueueAt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task<List<string>> HandleAsync(
.Take(10)
.ToListAsync(cancellationToken);

return capturedPlates.Select(x => Flurl.Url.Combine($"/images/{x}")).ToList();
return capturedPlates.Select(x => Flurl.Url.Combine($"/api/images/{x}")).ToList();
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
34 changes: 34 additions & 0 deletions OpenAlprWebhookProcessor.Server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src

RUN apt-get update && apt-get install -y ca-certificates curl gnupg \
&& mkdir -p /etc/apt/keyrings \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& NODE_MAJOR=20 \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list \
&& apt-get update && apt-get install nodejs -y

COPY ["openalprwebhookprocessor.client/nuget.config", "openalprwebhookprocessor.client/"]
COPY ["OpenAlprWebhookProcessor.Server/OpenAlprWebhookProcessor.Server.csproj", "OpenAlprWebhookProcessor.Server/"]
COPY ["openalprwebhookprocessor.client/openalprwebhookprocessor.client.esproj", "openalprwebhookprocessor.client/"]
RUN dotnet restore "./OpenAlprWebhookProcessor.Server/./OpenAlprWebhookProcessor.Server.csproj"
COPY . .
WORKDIR "/src/OpenAlprWebhookProcessor.Server"
RUN dotnet build "./OpenAlprWebhookProcessor.Server.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./OpenAlprWebhookProcessor.Server.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "OpenAlprWebhookProcessor.Server.dll"]
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace OpenAlprWebhookProcessor.ImageRelay
{
[Authorize]
[ApiController]
[Route("images")]
[Route("api/images")]
public class ImageRelayController : ControllerBase
{
private readonly GetSnapshotHandler _getSnapshotHandler;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace OpenAlprWebhookProcessor.LicensePlates
{
[Authorize]
[ApiController]
[Route("licensePlates")]
[Route("/api/licensePlates")]
public class LicensePlatesController : ControllerBase
{
private readonly SearchLicensePlateHandler _searchLicensePlateHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public static LicensePlate MapPlate(
{
AlertDescription = plate.AlertDescription,
Direction = plate.Direction,
ImageUrl = new Uri($"/images/{plate.OpenAlprUuid}", UriKind.Relative),
ImageUrl = new Uri($"/api/images/{plate.OpenAlprUuid}", UriKind.Relative),
CanBeEnriched = !plate.IsEnriched,
CropImageUrl = new Uri($"/images/crop/{plate.OpenAlprUuid}", UriKind.Relative),
CropImageUrl = new Uri($"/api/images/crop/{plate.OpenAlprUuid}", UriKind.Relative),
Id = plate.Id,
IsAlert = platesToAlert?.Contains(plate.BestNumber) ?? false,
IsIgnore = platesToIgnore?.Contains(plate.BestNumber) ?? false,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
<SpaRoot>..\openalprwebhookprocessor.client</SpaRoot>
<SpaProxyLaunchCommand>npm start</SpaProxyLaunchCommand>
<SpaProxyServerUrl>https://localhost:4200</SpaProxyServerUrl>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AutoMapper" Version="12.0.1" />
<PackageReference Include="Bogus" Version="35.4.0" />
<PackageReference Include="BouncyCastle.Cryptography" Version="2.2.1" />
<PackageReference Include="CoordinateSharp" Version="2.21.1.1" />
<PackageReference Include="Flurl" Version="4.0.0" />
<PackageReference Include="Hangfire" Version="1.8.9" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.9" />
<PackageReference Include="Hangfire.InMemory" Version="0.7.0" />
<PackageReference Include="Lib.AspNetCore.WebPush" Version="2.2.1" />
<PackageReference Include="Magick.NET-Q8-x64" Version="13.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.SpaProxy" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
<PackageReference Include="NUnit" Version="4.0.1" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.1" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.2.0" />
</ItemGroup>

<ItemGroup>
<Folder Include="config\" />
</ItemGroup>

<ItemGroup>
<None Include="E:\code\OpenAlprWebhookProcessor\OpenAlprWebhookProcessor\.editorconfig" />
<EditorConfigFiles Remove="E:\code\OpenAlprWebhookProcessor\OpenAlprWebhookProcessor\.editorconfig" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\openalprwebhookprocessor.client\openalprwebhookprocessor.client.esproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@AngularApp1.Server_HostAddress = https://localhost:5001

GET {{AngularApp1.Server_HostAddress}}/plates/
Accept: application/json

###
File renamed without changes.
42 changes: 42 additions & 0 deletions OpenAlprWebhookProcessor.Server/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "plates",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:5001"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "plates",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy"
}
},
"Docker": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/plates",
"environmentVariables": {
"ASPNETCORE_HTTP_PORTS": "8080"
},
"publishAllPorts": true
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:2686",
"sslPort": 0
}
}
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace OpenAlprWebhookProcessor.Settings
{
[Authorize]
[ApiController]
[Route("settings")]
[Route("/api/settings")]
public class SettingsController : ControllerBase
{
private readonly GetAgentRequestHandler _getAgentRequestHandler;
Expand Down
Loading

0 comments on commit 6de0272

Please sign in to comment.