diff --git a/server/AyaNova/biz/PrimeData.cs b/server/AyaNova/biz/PrimeData.cs
index f9321973..e425dcc2 100644
--- a/server/AyaNova/biz/PrimeData.cs
+++ b/server/AyaNova/biz/PrimeData.cs
@@ -118,11 +118,30 @@ namespace AyaNova.Biz
+ ///
+ /// Prime the Report Templates
+ ///
+ public static async Task PrimeReportTemplates()
+ {
+ //Read in each stock translation from a text file and then create them in the DB
+ var ReportFilesPath = Path.Combine(ServerBootConfig.AYANOVA_CONTENT_ROOT_PATH, "resource\\rpt\\stock-report-templates");
+ if (!Directory.Exists(ReportFilesPath))
+ {
+ throw new System.Exception($"E1012: \"resource\\rpt\\stock-report-templates\" folder not found where expected: \"{ReportFilesPath}\", installation damaged?");
+ }
+ //iterate all ayrt files and import each one
+ using (AyContext ct = ServiceProviderProvider.DBContext)
+ {
+ ReportBiz r = ReportBiz.GetBiz(ct);
-
-
-
+ System.IO.DirectoryInfo di = new DirectoryInfo(ReportFilesPath);
+ foreach (FileInfo file in di.EnumerateFiles())
+ {
+ await r.ImportAsync(JObject.Parse(await File.ReadAllTextAsync(file.FullName)));
+ }
+ }
+ }
}//eoc
diff --git a/server/AyaNova/resource/rpt/stock-report-templates/EXAMPLE API use and meta data.ayrt b/server/AyaNova/resource/rpt/stock-report-templates/EXAMPLE API use and meta data.ayrt
new file mode 100644
index 00000000..212e6263
--- /dev/null
+++ b/server/AyaNova/resource/rpt/stock-report-templates/EXAMPLE API use and meta data.ayrt
@@ -0,0 +1 @@
+{"Name":"EXAMPLE API use and meta data","Active":true,"Notes":"","Roles":124927,"ObjectType":2,"Template":"\n\n
\n\tExample: Meta data and API usage
\n\tSee help documentation for details
\n\t\n\t\n\t\t
ayServerMetaData
\n\t\t{{ ayJSON ayServerMetaData }}\n\t\n\n\t\n\t\t
ayClientMetaData
\n\t\t{{ ayJSON ayClientMetaData }}\n\t\n\n\t\n\t\t
ayReportMetaData
\n\t\t{{ ayJSON ayReportMetaData }}\n\t\n\n\n\t\n\t\t
myData
\n\t\t(Fetched dynamically from API route enum-list/list/AyaType)
\n\t\t{{ ayJSON myData }}\n\t\n\n\t\n\t\t
ayReportData
\n\t\t{{#each ayReportData}}\n\t\t
{{ Name }}
\n\t\t
Notes: {{ Notes }}
\n\t\t{{/each}}\n\t
\n\n\n","Style":".example {\n color: blue;\n}","JsPrerender":"async function ayPrepareData(reportData) {\n //this function (if present) is called with the report data \n //before the report is rendered\n //modify data as required here and return it to change the data before the report renders \n\n //Example of using API GET method to fetch data from API server and make it available to the report template\n let route=`${reportData.ayServerMetaData.ayApiUrl}server-info`;\n\n //Put the data into the main report data object so it's available to the template\n reportData.myData={ServerInfo:await ayGetFromAPI(route, reportData.ayClientMetaData.Authorization)};\n\n //Example API POST method to fetch data from api server\n route=`${reportData.ayServerMetaData.ayApiUrl}search`;\n let searchPostData={phrase: \"Fish\"};\n reportData.myData.SearchResults=await ayPostToAPI(route, reportData.ayClientMetaData.Authorization,searchPostData);\n\n return reportData;\n}","JsHelpers":"//Register custom Handlebars helpers here to use in your report script\n//https://handlebarsjs.com/guide/#custom-helpers\nHandlebars.registerHelper('loud', function (aString) {\n return aString.toUpperCase()\n})","RenderType":0}
\ No newline at end of file
diff --git a/server/AyaNova/resource/rpt/stock-report-templates/EXAMPLE Translation helper.ayrt b/server/AyaNova/resource/rpt/stock-report-templates/EXAMPLE Translation helper.ayrt
new file mode 100644
index 00000000..6477acae
--- /dev/null
+++ b/server/AyaNova/resource/rpt/stock-report-templates/EXAMPLE Translation helper.ayrt
@@ -0,0 +1 @@
+{"Name":"EXAMPLE Translation helper","Active":true,"Notes":"","Roles":124927,"ObjectType":2,"Template":"\n\n\n\n\tExample: Translation helper
\n\tSee help documentation for details
\n\t\n\t\n\t\t
ayReportData
\n\t\t{{#each ayReportData}}\n\t\t
{{ayT 'WidgetName' }}: {{ Name }}
\n\t\t
{{ayT 'WidgetNotes' }}: {{ Notes }}
\n\t\t{{/each}}\n\t
\n\n\n","Style":".example {\n color: blue;\n}","JsPrerender":"async function ayPrepareData(reportData){ \n //Fetch translation keys required for report\n //Server will get the translations that match the current logged in user's language \n //Only translation keys pre-fetched here will be available for use with the ayT translation helper\n ayGetTranslations([\n \"Widget\",\n \"WidgetName\",\n \"WidgetSerial\",\n \"WidgetDollarAmount\",\n \"WidgetCount\",\n \"WidgetStartDate\",\n \"WidgetEndDate\",\n \"WidgetNotes\",\n \"WidgetCustom1\",\n \"WidgetCustom2\",\n \"WidgetCustom3\",\n \"WidgetCustom4\",\n \"WidgetCustom5\",\n \"WidgetCustom6\",\n \"WidgetCustom7\",\n \"WidgetCustom8\",\n \"WidgetCustom9\",\n \"WidgetCustom10\",\n \"WidgetCustom11\",\n \"WidgetCustom12\",\n \"WidgetCustom13\",\n \"WidgetCustom14\",\n \"WidgetCustom15\",\n \"WidgetCustom16\",\n ]);\n \n return reportData;\n}","JsHelpers":"//Register custom Handlebars helpers here to use in your report script\n//https://handlebarsjs.com/guide/#custom-helpers\nHandlebars.registerHelper('loud', function (aString) {\n return aString.toUpperCase()\n})","RenderType":0}
\ No newline at end of file
diff --git a/server/AyaNova/resource/rpt/stock-report-templates/EXAMPLE localization helpers.ayrt b/server/AyaNova/resource/rpt/stock-report-templates/EXAMPLE localization helpers.ayrt
new file mode 100644
index 00000000..02712ae2
--- /dev/null
+++ b/server/AyaNova/resource/rpt/stock-report-templates/EXAMPLE localization helpers.ayrt
@@ -0,0 +1 @@
+{"Name":"EXAMPLE localization helpers","Active":true,"Notes":"","Roles":124927,"ObjectType":2,"Template":"\n\n\n\tExample: Localization helpers
\n\tSee help documentation for details
\n\n\t\n\t\t
Client locale settings used
\n\t\tBrowser TimeZone: {{ ayClientMetaData.TimeZoneName }}
\n\t\tBrowser LanguageName: {{ ayClientMetaData.LanguageName }}
\n\t\tHour12: {{ ayClientMetaData.Hour12 }}
\n\t\tCurrencyName: {{ ayClientMetaData.CurrencyName }}
\n\t\n\t\n\t\t{{#each ayReportData}}\n\t\t
{{ayT 'WidgetName' }}: {{ Name }}
\n\t\tStartDate as DateTime: {{ ayDateTime StartDate}}
\n\t\tStartDate as Date : {{ ayDate StartDate}}
\n\t\tStartDate as Time: {{ ayTime StartDate}}
\n\t\tDollarAmount as Currency: {{ ayCurrency DollarAmount}}
\n\t\tDollarAmount as Number: {{ ayDecimal DollarAmount}}
\n\t\t
\n\t\t{{/each}}\n\t\n\n\n","Style":".example {\n color: blue;\n}","JsPrerender":"async function ayPrepareData(reportData){ \n return reportData;\n}","JsHelpers":"//Register custom Handlebars helpers here to use in your report script\n//https://handlebarsjs.com/guide/#custom-helpers\nHandlebars.registerHelper('loud', function (aString) {\n return aString.toUpperCase()\n})","RenderType":0}
\ No newline at end of file
diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs
index 358ad469..27fa375c 100644
--- a/server/AyaNova/util/AySchema.cs
+++ b/server/AyaNova/util/AySchema.cs
@@ -725,6 +725,9 @@ $BODY$;
await ExecQueryAsync("CREATE TABLE areport (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(255) not null unique, active bool, " +
"notes text, roles integer not null, objecttype integer not null, template text, style text, jsprerender text, jshelpers text, rendertype integer not null )");
await SetSchemaLevelAsync(++currentSchema);
+
+ //Load the stock REPORT TEMPLATES
+ await AyaNova.Biz.PrimeData.PrimeReportTemplates();
}