This commit is contained in:
@@ -4,6 +4,7 @@ using System.IO;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using AyaNova.Models;
|
||||
using AyaNova.Api.ControllerHelpers;
|
||||
@@ -81,6 +82,10 @@ namespace AyaNova.Api.Controllers
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
|
||||
var httpConnectionFeature = HttpContext.Features.Get<IHttpConnectionFeature>();
|
||||
var API_URL=$"http://127.0.0.1:{httpConnectionFeature.LocalPort}/api/v8/";
|
||||
//var localIpAddress = httpConnectionFeature?.LocalIpAddress;
|
||||
|
||||
var ReportJSFolderPath = Path.Combine(ServerBootConfig.AYANOVA_CONTENT_ROOT_PATH, "resource", "reportjs");
|
||||
if (!Directory.Exists(ReportJSFolderPath))
|
||||
throw new System.Exception($"E1012: \"reportjs\" folder not found where expected: \"{ReportJSFolderPath}\", installation damaged?");
|
||||
@@ -113,13 +118,16 @@ namespace AyaNova.Api.Controllers
|
||||
|
||||
//sample template
|
||||
//var reportTemplate = "'<div>{{#with person}}<span class=\"ay-red\">{{firstname}}</span> {{aycaps lastname}}{{/with}}</div>'";
|
||||
var reportTemplate = "'<!DOCTYPE html><html><head><title>test title</title></head><body> <img src=\"http://localhost:7575/api/v8/logo/medium\" />"+
|
||||
"<h1>Test page top</h1><p class=\"ay-blue\">A blue paragraph</p><div>{{#with person}}<span class=\"ay-red\">{{firstname}}</span> {{aycaps lastname}}{{/with}}</div>"+
|
||||
var reportTemplate = "'<!DOCTYPE html><html><head><title>test title</title></head><body> <img src=\"{{aylogo.large}}\" />" +
|
||||
"<h1>Test page top</h1><p class=\"ay-blue\">A blue paragraph</p><div>{{#with person}}<span class=\"ay-red\">{{firstname}}</span> {{aycaps lastname}}{{/with}}</div>" +
|
||||
"<br/><br/><h4>Some markdown</h4><div>{{{aymarkdown mdtest}}}</div></body></html>'";
|
||||
|
||||
//data object
|
||||
var reportData = "{ person: { firstname: 'Tyler', lastname: 'Mott' }, 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' }";
|
||||
//data object
|
||||
|
||||
|
||||
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' }";
|
||||
reportData = reportData.Replace("[AYLOGO]", aylogo);
|
||||
using (var browser = await Puppeteer.LaunchAsync(new LaunchOptions { Headless = true }))
|
||||
using (var page = await browser.NewPageAsync())
|
||||
{
|
||||
@@ -128,10 +136,10 @@ namespace AyaNova.Api.Controllers
|
||||
await page.AddScriptTagAsync(new AddTagOptions() { Path = hbspath });
|
||||
|
||||
//add marked for markdown processing
|
||||
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "marked.js") });
|
||||
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "marked.js") });
|
||||
|
||||
//test add helpers
|
||||
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-hb-helpers.js") });
|
||||
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ay-report.js") });
|
||||
|
||||
|
||||
|
||||
|
||||
2624
server/AyaNova/resource/reportjs/marked.js
Normal file
2624
server/AyaNova/resource/reportjs/marked.js
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user