This commit is contained in:
@@ -243,7 +243,3 @@ DOCKER / LINUX CHEAT SHEET
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- <Target Name="CopyCustomContent" AfterTargets="AfterBuild">
|
|
||||||
<Copy SourceFiles=".\resource\ay-report.js;" DestinationFolder="$(OutDir)\resource\rpt" />
|
|
||||||
<!-- <Copy SourceFiles=".\resource\rpt\ay-report.js;.\resource\rpt\ay-hb.js;.\resource\rpt\ay-md.js" DestinationFolder="$(OutDir)\resource\rpt" /> -->
|
|
||||||
</Target> -->
|
|
||||||
@@ -2,4 +2,13 @@ FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY ./files .
|
COPY ./files .
|
||||||
RUN apk add postgresql-client
|
RUN apk add postgresql-client
|
||||||
|
RUN apk add --no-cache \
|
||||||
|
chromium \
|
||||||
|
nss \
|
||||||
|
freetype \
|
||||||
|
freetype-dev \
|
||||||
|
harfbuzz \
|
||||||
|
ca-certificates \
|
||||||
|
ttf-freefont
|
||||||
|
|
||||||
ENTRYPOINT ["dotnet", "AyaNova.dll"]
|
ENTRYPOINT ["dotnet", "AyaNova.dll"]
|
||||||
|
|||||||
@@ -44,15 +44,21 @@
|
|||||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUi" Version="5.4.1" />
|
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUi" Version="5.4.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="CopyCustomContent" AfterTargets="AfterBuild">
|
<!-- <Target Name="CopyCustomContent" AfterTargets="AfterBuild">
|
||||||
<Copy SourceFiles=".\resource\de.json;.\resource\en.json;.\resource\es.json;.\resource\fr.json" DestinationFolder="$(OutDir)\resource" />
|
<Copy SourceFiles=".\resource\de.json;.\resource\en.json;.\resource\es.json;.\resource\fr.json" DestinationFolder="$(OutDir)\resource" />
|
||||||
<!-- <Copy SourceFiles=".\resource\rpt\ay-report.js;.\resource\rpt\ay-hb.js;.\resource\rpt\ay-md.js" DestinationFolder="$(OutDir)\resource\rpt" /> -->
|
</Target> -->
|
||||||
</Target>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include=".\resource\rpt\*.*">
|
<Content Include=".\resource\*.*">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include=".\resource\rpt\*.*">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -91,7 +91,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
if (!Directory.Exists(ReportJSFolderPath))
|
if (!Directory.Exists(ReportJSFolderPath))
|
||||||
throw new System.Exception($"E1012: \"reportjs\" folder not found where expected: \"{ReportJSFolderPath}\", installation damaged?");
|
throw new System.Exception($"E1012: \"reportjs\" folder not found where expected: \"{ReportJSFolderPath}\", installation damaged?");
|
||||||
|
|
||||||
await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision);
|
|
||||||
|
|
||||||
//sample CSS
|
//sample CSS
|
||||||
var reportCSS = @"
|
var reportCSS = @"
|
||||||
@@ -123,9 +123,26 @@ namespace AyaNova.Api.Controllers
|
|||||||
var aylogo = $"{{small:'{API_URL}logo/small',medium:'{API_URL}logo/medium',large:'{API_URL}logo/large'}}";
|
var aylogo = $"{{small:'{API_URL}logo/small',medium:'{API_URL}logo/medium',large:'{API_URL}logo/large'}}";
|
||||||
var reportData = "{ person: { firstname: 'Tyler', lastname: 'Mott' },aylogo:[AYLOGO], mdtest:'| CODE | MEANING |\\n| ----- | ------------------------------ |\\n| E1000 | Could not connect to the database specified in the [connection string](ops-config-db.md). |\\n| E1050 | XXXXXXXX |\\n| E1012 | Missing resource folder. AyaNova was started from the wrong location or was not installed properly. |\\n' }";
|
var reportData = "{ person: { firstname: 'Tyler', lastname: 'Mott' },aylogo:[AYLOGO], mdtest:'| CODE | MEANING |\\n| ----- | ------------------------------ |\\n| E1000 | Could not connect to the database specified in the [connection string](ops-config-db.md). |\\n| E1050 | XXXXXXXX |\\n| E1012 | Missing resource folder. AyaNova was started from the wrong location or was not installed properly. |\\n' }";
|
||||||
reportData = reportData.Replace("[AYLOGO]", aylogo);
|
reportData = reportData.Replace("[AYLOGO]", aylogo);
|
||||||
using (var browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true }))
|
|
||||||
|
log.LogInformation($"setting Chrome launchoptions for os:");
|
||||||
|
var lo = new LaunchOptions { Headless = true };
|
||||||
|
bool isWindows = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows);
|
||||||
|
if (!isWindows)
|
||||||
|
{
|
||||||
|
log.LogInformation($"IS NOT WINDOWS: setting executable path for chrome");
|
||||||
|
lo.ExecutablePath = "/usr/bin/chromium-browser";
|
||||||
|
lo.Args = new string[] { "--no-sandbox" };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
log.LogInformation($"IS WINDOWS: Calling browserFetcher download async now:");
|
||||||
|
await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision);
|
||||||
|
}
|
||||||
|
log.LogInformation($"Calling browser.launchAsync now:");
|
||||||
|
using (var browser = await Puppeteer.LaunchAsync(lo))
|
||||||
using (var page = await browser.NewPageAsync())
|
using (var page = await browser.NewPageAsync())
|
||||||
{
|
{
|
||||||
|
log.LogInformation($"In using for page ops adding scripts and report now:");
|
||||||
|
|
||||||
//Add handlebars JS for compiling and presenting
|
//Add handlebars JS for compiling and presenting
|
||||||
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-hb.js") });
|
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-hb.js") });
|
||||||
@@ -156,6 +173,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
|
|
||||||
//render to pdf and return
|
//render to pdf and return
|
||||||
var pdfBuffer = await page.PdfDataAsync();
|
var pdfBuffer = await page.PdfDataAsync();
|
||||||
|
log.LogInformation($"returning results now:");
|
||||||
return new FileContentResult(pdfBuffer, "application/pdf");
|
return new FileContentResult(pdfBuffer, "application/pdf");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user