This commit is contained in:
@@ -404,6 +404,8 @@ namespace AyaNova.Biz
|
||||
//add Server meta data
|
||||
var serverMeta = $"{{ayApiUrl:`{apiUrl}`}}";
|
||||
|
||||
//add Report meta data
|
||||
var reportMeta = $"{{Id:{report.Id},Name:`{report.Name}`,Notes:`{report.Notes}`,ObjectType:`{report.ObjectType}`,DataListKey:`{reportParam.DataListKey}`,ListView:`{reportParam.ListView}`,SelectedRowIds: `{string.Join(",", reportParam.SelectedRowIds)}`}}";
|
||||
|
||||
|
||||
#if (DEBUG)
|
||||
@@ -412,7 +414,7 @@ namespace AyaNova.Biz
|
||||
|
||||
#endif
|
||||
//prePareData / preRender
|
||||
var ReportDataObject = $"{{ ayReportData:{ReportData}, ayClientMetaData:{clientMeta}, ayServerMetaData:{serverMeta} }}";
|
||||
var ReportDataObject = $"{{ ayReportData:{ReportData}, ayReportMetaData:{reportMeta}, ayClientMetaData:{clientMeta}, ayServerMetaData:{serverMeta} }}";
|
||||
var PreParedReportDataObject = await page.EvaluateExpressionAsync<dynamic>($"ayPreRender({ReportDataObject});");//note ayPreRender is async but dont' use await to call it as the EvaluateExpressionAsync function knows how to handle that already
|
||||
|
||||
//compile the template
|
||||
|
||||
@@ -86,13 +86,55 @@ async function ayPrepareData(reportData) {
|
||||
//before the report is rendered
|
||||
//modify data as required here and return it to change the data before the report renders
|
||||
|
||||
//Example of using API method to fetch data from API server and make it available to the report template
|
||||
let route=`${reportData.ayServerMetaData.ayApiUrl}enum-list/list/AyaType`;
|
||||
//Example of using API GET method to fetch data from API server and make it available to the report template
|
||||
let route=`${reportData.ayServerMetaData.ayApiUrl}server-info`;
|
||||
|
||||
//Put the data into the main report data object so it's available to the template
|
||||
reportData.myData={AyaTypeList:await ayGetFromAPI(route, reportData.ayClientMetaData.Authorization)};
|
||||
reportData.myData={ServerInfo:await ayGetFromAPI(route, reportData.ayClientMetaData.Authorization)};
|
||||
|
||||
//Example API POST method to fetch data from api server
|
||||
route=`${reportData.ayServerMetaData.ayApiUrl}search`;
|
||||
let searchPostData={phrase: "Fish"};
|
||||
reportData.myData.SearchResults=await ayPostToAPI(route, reportData.ayClientMetaData.Authorization,searchPostData);
|
||||
|
||||
return reportData;
|
||||
}
|
||||
|
||||
<html>
|
||||
|
||||
<body>
|
||||
|
||||
<div>
|
||||
<h4>ayServerMetaData</h4>
|
||||
{{ ayJSON ayServerMetaData }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h4>ayClientMetaData</h4>
|
||||
{{ ayJSON ayClientMetaData }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h4>ayReportMetaData</h4>
|
||||
{{ ayJSON ayReportMetaData }}
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<h4>myData</h4>
|
||||
<h5>(Fetched dynamically from API route <strong>enum-list/list/AyaType</strong>)</h5>
|
||||
{{ ayJSON myData }}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h4>ayReportData</h4>
|
||||
{{#each ayReportData}}
|
||||
<h2>{{ Name }}</h2>
|
||||
<div>Notes: <span class="example">{{ Notes }}</span></div>
|
||||
{{/each}}
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user