diff --git a/.vscode/launch.json b/.vscode/launch.json index 4044e905..ac7626ce 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -52,7 +52,7 @@ "AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles", "AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles", "AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles", - "AYANOVA_SERVER_TEST_MODE": "false", + "AYANOVA_SERVER_TEST_MODE": "true", "AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small", "AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7", "AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\PostgreSQLPortable_12.0\\App\\PgSQL\\bin\\" diff --git a/devdocs/specs/core-notification.txt b/devdocs/specs/core-notification.txt index 736f168c..2d81efc0 100644 --- a/devdocs/specs/core-notification.txt +++ b/devdocs/specs/core-notification.txt @@ -12,9 +12,11 @@ client end is a list type form also each object can notify directly on demand and all users have default notification subscription - No longer templating but rather using short single text string with link back to open instead and optionally send report / attachment or whatever + No longer templating but rather using short single text string with link back to open instead and optionally links to open report / attachment or whatever also no delivery days or hours fuckery anymore, all deliveries happen all the time as appropriate to the event deliver date. If user wants that they can configure their device email notification settings, not our concern anymore. + + No reports are attached anymore, no need to generate a report outside of a User login session via the client!!! ########################################################### @@ -190,7 +192,7 @@ methods they have two entries here, no other table indicates events to be tracke so for example a CreatedWithTag notification or UpdatedWithTag notification will work on any object with that tag if a specific type i.e. customer with that tag Then they can control by tag as well, tags are used to filter and include (or any if no tags), s filter out and trump tags These are also used for tag type conditions - (aID, userId, ayatype, aEventType, advancenoticetimespan, agevalue, idvalue, decvalue, aDeliveryMethod, deliveryaddress, attachreportid, tags, s, HASH) + (aID, userId, ayatype, aEventType, advancenoticetimespan, agevalue, idvalue, decvalue, aDeliveryMethod, deliveryaddress, linkreportid, tags, s, HASH) /Notifyevent table - contains all events, created by updating objects or directly in some cases and used by generator for processing as deliveries created (timestamp used to clean out old stuck events), ayatype, objectid, eventtype, appliestouserid (single subscriber event), aEventDate, ASAVEDMESSAGE, HASH? @@ -302,7 +304,7 @@ General thinking of reforming it, making all notifications very short since user can go to directly view data online anyway now, why have an overly time consuming system to format and shit i.e. no notification more than an SMS (160 characters but will accept more and split them up to 1600) tweet in length (280 characters) - In cases where user wants to send an attachment / report / wiki that's another thing entirely but the message is still super short + In cases where user wants to send a link to an attachment / report / wiki that's another thing entirely but the message is still super short All notifications can be optionally filtered IN or OUT via tags on notification related object. I.E. a workorder status change can be ignored or only see if it's tagged "region-new-york" etc diff --git a/docs/8.0/ayanova/docs/form-ay-report-edit.md b/docs/8.0/ayanova/docs/form-ay-report-edit.md index 7af5fe91..dde58d63 100644 --- a/docs/8.0/ayanova/docs/form-ay-report-edit.md +++ b/docs/8.0/ayanova/docs/form-ay-report-edit.md @@ -264,13 +264,16 @@ The ayGetFromAPI function works with GET routes in the API: ```async function ayGetFromAPI(route, token) {...``` +The `token` parameter is optional and if not provided will be set by default to the current User's access token. + *POST* The ayPostToAPI function works with POST routes in the API: -```async function ayPostToAPI(route, token, data) {...``` +```async function ayPostToAPI(route, data, token) {...``` +The `token` parameter is optional and if not provided will be set by default to the current User's access token. *Parameters* @@ -298,8 +301,7 @@ async function ayPrepareData(reportData) { reportData.myData= { ServerInfo:await ayGetFromAPI( - route, - reportData.ayClientMetaData.Authorization + route ) }; @@ -311,8 +313,7 @@ async function ayPrepareData(reportData) { let searchPostData={phrase: "Fish"}; reportData.myData.SearchResults = await ayPostToAPI( - route, - reportData.ayClientMetaData.Authorization, + route, searchPostData ); return reportData; diff --git a/server/AyaNova/biz/ReportBiz.cs b/server/AyaNova/biz/ReportBiz.cs index c62ff8d2..7c96213e 100644 --- a/server/AyaNova/biz/ReportBiz.cs +++ b/server/AyaNova/biz/ReportBiz.cs @@ -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(); diff --git a/server/AyaNova/generator/CoreJobNotify.cs b/server/AyaNova/generator/CoreJobNotify.cs index 97783226..b0149d95 100644 --- a/server/AyaNova/generator/CoreJobNotify.cs +++ b/server/AyaNova/generator/CoreJobNotify.cs @@ -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 diff --git a/server/AyaNova/models/NotifySubscription.cs b/server/AyaNova/models/NotifySubscription.cs index e55ed60d..83a12c49 100644 --- a/server/AyaNova/models/NotifySubscription.cs +++ b/server/AyaNova/models/NotifySubscription.cs @@ -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 diff --git a/server/AyaNova/resource/rpt/ay-report.js b/server/AyaNova/resource/rpt/ay-report.js index cded7f84..4942929f 100644 --- a/server/AyaNova/resource/rpt/ay-report.js +++ b/server/AyaNova/resource/rpt/ay-report.js @@ -24,6 +24,13 @@ function ayRegisterHelpers() { )}logo/${size}`; return new Handlebars.SafeString(""); }); + + 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", diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index d30b0ca6..358ad469 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -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, " +