This commit is contained in:
2020-08-25 15:53:17 +00:00
parent ee57a3752c
commit 43b3048ef0

View File

@@ -83,19 +83,14 @@ namespace AyaNova.Api.Controllers
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason)); return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
var httpConnectionFeature = HttpContext.Features.Get<IHttpConnectionFeature>(); 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; //var localIpAddress = httpConnectionFeature?.LocalIpAddress;
//todo: validate files are present somehow?
var ReportJSFolderPath = Path.Combine(ServerBootConfig.AYANOVA_CONTENT_ROOT_PATH, "resource", "reportjs"); var ReportJSFolderPath = Path.Combine(ServerBootConfig.AYANOVA_CONTENT_ROOT_PATH, "resource", "reportjs");
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?");
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); await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision);
//sample CSS //sample CSS
@@ -118,7 +113,7 @@ namespace AyaNova.Api.Controllers
//sample template //sample template
//var reportTemplate = "'<div>{{#with person}}<span class=\"ay-red\">{{firstname}}</span> {{aycaps lastname}}{{/with}}</div>'"; //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>" + "<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>'"; "<br/><br/><h4>Some markdown</h4><div>{{{aymarkdown mdtest}}}</div></body></html>'";
@@ -133,7 +128,7 @@ namespace AyaNova.Api.Controllers
{ {
//Add handlebars JS for compiling and presenting //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 //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") });