This commit is contained in:
@@ -83,19 +83,14 @@ namespace AyaNova.Api.Controllers
|
||||
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 API_URL = $"http://127.0.0.1:{httpConnectionFeature.LocalPort}/api/v8/";
|
||||
//var localIpAddress = httpConnectionFeature?.LocalIpAddress;
|
||||
|
||||
//todo: validate files are present somehow?
|
||||
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?");
|
||||
|
||||
|
||||
var hbspath = Path.Combine(ReportJSFolderPath, "ayhandlebars.js");
|
||||
if (!System.IO.File.Exists(hbspath))
|
||||
throw new System.Exception($"E1012: \"ayhandlebars.js\" file not found where expected: \"{hbspath}\", installation damaged?");
|
||||
|
||||
|
||||
await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision);
|
||||
|
||||
//sample CSS
|
||||
@@ -118,13 +113,13 @@ 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=\"{{aylogo.large}}\" />" +
|
||||
var reportTemplate = "'<!DOCTYPE html><html><head><title>test title</title></head><body> <img src=\"{{aylogo.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>" +
|
||||
"<br/><br/><h4>Some markdown</h4><div>{{{aymarkdown mdtest}}}</div></body></html>'";
|
||||
|
||||
//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);
|
||||
@@ -133,7 +128,7 @@ namespace AyaNova.Api.Controllers
|
||||
{
|
||||
|
||||
//Add handlebars JS for compiling and presenting
|
||||
await page.AddScriptTagAsync(new AddTagOptions() { Path = hbspath });
|
||||
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "ayhandlebars.js") });
|
||||
|
||||
//add marked for markdown processing
|
||||
await page.AddScriptTagAsync(new AddTagOptions() { Path = Path.Combine(ReportJSFolderPath, "marked.js") });
|
||||
|
||||
Reference in New Issue
Block a user