This commit is contained in:
2020-09-08 22:53:19 +00:00
parent d41046eba6
commit af9263649a
8 changed files with 63 additions and 18 deletions

View File

@@ -280,7 +280,7 @@ namespace AyaNova.Biz
{
//TODO: this is shitty, needs to mention notifications to be maximally useful
if (await ct.NotifySubscription.AnyAsync(z => z.AttachReportId == inObj.Id) == true)
if (await ct.NotifySubscription.AnyAsync(z => z.LinkToReportId == inObj.Id) == true)
{
AddError(ApiErrorCode.INVALID_OPERATION, null, "LT:ErrorDBForeignKeyViolation");
return;
@@ -396,18 +396,23 @@ namespace AyaNova.Biz
await page.AddScriptTagAsync(new AddTagOptions() { Content = report.JsHelpers });
await page.AddStyleTagAsync(new AddTagOptions() { Content = report.Style });
//add Client meta data
//Client meta data
var clientMeta = "{}";
if (reportParam.ClientMeta != null)
clientMeta = reportParam.ClientMeta.ToString();
//add Server meta data
//Server meta data
var serverMeta = $"{{ayApiUrl:`{apiUrl}`}}";
//add Report meta data
//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)}`}}";
//duplicate meta data in report page wide variable for use by our internal functions
await page.AddScriptTagAsync(new AddTagOptions() { Content = $"var AYMETA={{ ayReportMetaData:{reportMeta}, ayClientMetaData:{clientMeta}, ayServerMetaData:{serverMeta} }}" });
#if (DEBUG)
//view page contents
var pagecontent = await page.GetContentAsync();

View File

@@ -102,7 +102,7 @@ namespace AyaNova.Biz
//OPERATIONS_PROBLEMS - backup, notifications, out of memory, what have you, anyone can subscribe to it regardless of rights
//this is just to let people know there is a problem
//todo: create message here if not already set?
//todo: generate and attach report here?
//todo: Link to open report in here
//All items have an event date, for non time delayed events it's just the moment it was created

View File

@@ -21,7 +21,7 @@ namespace AyaNova.Models
[Required]
public NotifyDeliveryMethod DeliveryMethod { get; set; }
public string DeliveryAddress { get; set; }
public long AttachReportId { get; set; }
public long LinkToReportId { get; set; }
//CREATE NOTIFY EVENT CONDITIONS - Following fields are all conditions set on whether to create a notify event or not
@@ -44,7 +44,7 @@ namespace AyaNova.Models
DecValue = 0;
AgeValue = TimeSpan.Zero;
AdvanceNotice = TimeSpan.Zero;
AttachReportId = 0;
LinkToReportId = 0;
}
}//eoc

View File

@@ -24,6 +24,13 @@ function ayRegisterHelpers() {
)}logo/${size}`;
return new Handlebars.SafeString("<img src='" + url + "'/>");
});
Handlebars.registerHelper("ayT", function (translationKey) {
if (ayTranslationKeyCache[translationKey] == undefined) {
return translationKey;
}
return ayTranslationKeyCache[translationKey];
});
} //eof
async function ayPreRender(ayAllData) {
@@ -34,10 +41,39 @@ async function ayPreRender(ayAllData) {
}
}
//////////////////////////////////
// cache to hold translations keys
//
var ayTranslationKeyCache = {};
///////////////////////////////////
// GET TRANSLATIONS FROM API SERVER
//
async function ayGetTranslations(keys) {
try {
let r = await fetch(route, {
method: "get",
mode: "cors",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
Authorization: token
}
});
return await r.json();
} catch (error) {
//fundamental error, can't proceed with this call
// handleError("GET", error, route);
//todo: deal with this properly
throw error;
}
}
///////////////////////////////////
// GET DATA FROM API SERVER
//
async function ayGetFromAPI(route, token) {
token = token || AYMETA.ayClientMetaData.Authorization;
try {
let r = await fetch(route, {
method: "get",
@@ -60,7 +96,8 @@ async function ayGetFromAPI(route, token) {
///////////////////////////////////
// POST DATA TO API SERVER
//
async function ayPostToAPI(route, token, data) {
async function ayPostToAPI(route, data, token) {
token = token || AYMETA.ayClientMetaData.Authorization;
try {
fetchOptions = {
method: "post",

View File

@@ -687,7 +687,7 @@ $BODY$;
await ExecQueryAsync("CREATE TABLE anotifysubscription (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, " +
"userid bigint not null, ayatype integer not null, eventtype integer not null, advancenotice interval not null, " +
"idvalue bigint not null, decvalue decimal(19,4) not null, agevalue interval not null, deliverymethod integer not null, " +
"deliveryaddress text, attachreportid bigint not null, tags varchar(255) ARRAY)");
"deliveryaddress text, linkreportid bigint not null, tags varchar(255) ARRAY)");
await ExecQueryAsync("CREATE TABLE anotifyevent (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, created timestamp not null, " +
"ayatype integer not null, objectid bigint not null, name varchar(255) not null, eventtype integer not null, notifysubscriptionid bigint not null references anotifysubscription(id) on delete cascade, " +