From 0d6425cf8bd39a21b25253a70a9b272f0d52d4a7 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 29 Aug 2022 20:57:24 +0000 Subject: [PATCH] support for vendor notifications webhook --- Controllers/VendorNotificationController.cs | 59 +++++++ notes/deploy.txt | 2 +- util/RfVersion.cs | 2 +- wwwroot/default.htm | 115 +++++++------- wwwroot/js/app.api.js | 2 +- wwwroot/js/app.shell.js | 22 +++ wwwroot/js/app.vendorNotification.js | 148 ++++++++++++++++++ wwwroot/js/app.vendorNotifications.js | 92 +++++++++++ wwwroot/js/templates/app.shell.handlebars | 67 ++++++-- .../app.vendorNotification.handlebars | 49 ++++++ .../app.vendorNotifications.handlebars | 3 + 11 files changed, 485 insertions(+), 76 deletions(-) create mode 100644 Controllers/VendorNotificationController.cs create mode 100644 wwwroot/js/app.vendorNotification.js create mode 100644 wwwroot/js/app.vendorNotifications.js create mode 100644 wwwroot/js/templates/app.vendorNotification.handlebars create mode 100644 wwwroot/js/templates/app.vendorNotifications.handlebars diff --git a/Controllers/VendorNotificationController.cs b/Controllers/VendorNotificationController.cs new file mode 100644 index 0000000..4b215e0 --- /dev/null +++ b/Controllers/VendorNotificationController.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Authorization; +using Microsoft.EntityFrameworkCore; +using rockfishCore.Models; +using rockfishCore.Util; +using System.ComponentModel.DataAnnotations; + +namespace rockfishCore.Controllers +{ + //### OUR ROUTE CALLED FROM ROCKFISH CLIENT #### + [Produces("application/json")] + [Route("api/vendor-notifications")] + [Authorize] + public class VendorNotificationController : Controller + { + private readonly rockfishContext ct; + + + public VendorNotificationController(rockfishContext context) + { + ct = context; + } + + // GET: api/vendor-notifications/5 + [HttpGet("{id}")] + public async Task GetRfCase([FromRoute] long id) + { + if (!ModelState.IsValid) + { + return BadRequest(ModelState); + } + + var RfCase = await ct.VendorNotification.SingleOrDefaultAsync(m => m.Id == id); + + if (RfCase == null) + { + return NotFound(); + } + + return Ok(RfCase); + } + + + [HttpGet("list")] + public async Task GetList([FromRoute] long siteId) + { + return Ok(await ct.VendorNotification.AsNoTracking().OrderByDescending(z => z.Id).ToListAsync()); + } + + + + + }//eoc +}//eons \ No newline at end of file diff --git a/notes/deploy.txt b/notes/deploy.txt index 2a049a9..871ab26 100644 --- a/notes/deploy.txt +++ b/notes/deploy.txt @@ -5,7 +5,7 @@ 1) SET VERSION SET app.api RFVERSION property -RENAME ?rfv=6.20 parameter in default.htm to the new version so all files update on mobile +RENAME ?rfv=6.21 parameter in default.htm to the new version so all files update on mobile 1.5) Run buildtemplates.bat if handlebars templates have changed at all diff --git a/util/RfVersion.cs b/util/RfVersion.cs index 555b546..acf699a 100644 --- a/util/RfVersion.cs +++ b/util/RfVersion.cs @@ -2,7 +2,7 @@ namespace rockfishCore.Util { public static class RfVersion { - public const string NumberOnly="6.20"; + public const string NumberOnly="6.21"; public const string Full = "Rockfish server " + NumberOnly; } } \ No newline at end of file diff --git a/wwwroot/default.htm b/wwwroot/default.htm index 3807192..d9f6c8e 100644 --- a/wwwroot/default.htm +++ b/wwwroot/default.htm @@ -11,73 +11,76 @@ Rockfish loading.... - - - - - + + + + + - - - - + + + + - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + \ No newline at end of file diff --git a/wwwroot/js/app.api.js b/wwwroot/js/app.api.js index 209be2d..fa3f7bd 100644 --- a/wwwroot/js/app.api.js +++ b/wwwroot/js/app.api.js @@ -30,7 +30,7 @@ app.api = (function () { licenseEmailResponse, test; - RockFishVersion = "6.20"; + RockFishVersion = "6.21"; ////////////////////////////////////////////////////////////////////////////////////// // NOT AUTHORIZED ERROR HANDLER diff --git a/wwwroot/js/app.shell.js b/wwwroot/js/app.shell.js index 10d3126..e3de2a2 100644 --- a/wwwroot/js/app.shell.js +++ b/wwwroot/js/app.shell.js @@ -230,6 +230,11 @@ app.shell = (function () { page("/trialEdit/:id", trialEdit); page("/ravLicenses/:id/:cust_id", ravLicenses); page("/ravLicense/:id/:cust_id", ravLicense); + + page("/vendorNotifications", vendorNotifications); + page("/vendorNotifications/:id", vendorNotification); + + page("*", notFound); page({ hashbang: true @@ -556,6 +561,23 @@ app.shell = (function () { app.ravLicenses.initModule(); }; + var vendorNotification = function (ctx) { + app.nav.setSelectedMenuItem("vendornotifications"); + app.vendorNotification.configModule({ + context: ctx + }); + app.vendorNotification.initModule(); + }; + + var vendorNotifications = function (ctx) { + app.nav.setSelectedMenuItem("vendornotifications"); + app.vendorNotifications.configModule({ + context: ctx + }); + app.vendorNotifications.initModule(); + }; + + var notFound = function (ctx) { app.fourohfour.configModule({ context: ctx diff --git a/wwwroot/js/app.vendorNotification.js b/wwwroot/js/app.vendorNotification.js new file mode 100644 index 0000000..a0d2006 --- /dev/null +++ b/wwwroot/js/app.vendorNotification.js @@ -0,0 +1,148 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.vendorNotification = (function () { + "use strict"; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var stateMap = {}, + onSave, + onDelete, + configModule, + initModule; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN EVENT HANDLERS ------------------- + + //ONSAVE + // + onSave = function (event) { + event.preventDefault(); + $.gevent.publish("app-clear-error"); + + alert("STUB: ONSAVE"); + // //get form data + // var formData = $("form").serializeArray({ + // checkboxesAsBools: true + // }); + + // var submitData = app.utilB.objectifyFormDataArray(formData); + + // //is this a new record? + // if (stateMap.id != "new") { + // //put id into the form data + // submitData.id = stateMap.id; + + // app.api.update("vendor-notifications", submitData, function (res) { + // if (res.error) { + // $.gevent.publish("app-show-error", res.msg); + // } + // }); + // } + return false; //prevent default? + }; + + //ONDELETE + // + onDelete = function (event) { + event.preventDefault(); + $.gevent.publish("app-clear-error"); + alert("STUB: onDelete"); + // var r = confirm("Are you sure you want to delete this record?"); + // if (r == true) { + // //Delete + // app.api.remove("vendor-notifications/" + stateMap.id, function (res) { + // if (res.error) { + // $.gevent.publish("app-show-error", res.msg); + // } else { + // //deleted, return to list + // page("#!/vendorNotifications"); + // return false; + // } + // }); + // } else { + // return false; + // } + return false; //prevent default? + }; + + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + + //CONFIGMODULE + // + configModule = function (context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; + } + }; + + //INITMODULE + // + initModule = function ($container) { + if (typeof $container === "undefined") { + $container = $("#app-shell-main-content"); + } + + $container.html(Handlebars.templates["app.vendorNotification"]({})); + + ////app.nav.setContextTitle("Case"); + + //Context menu + app.nav.contextClear(); + app.nav.contextAddLink( + "vendor-notifications/", + "Notifications", + "bell" + ); + + //case 3513 (ironically I can't see it yet) + document.title = "Vendor notification " + stateMap.id; + //fetch existing record + app.api.get("vendor-notifications/" + stateMap.id, function (res) { + if (res.error) { + $.gevent.publish("app-show-error", res.msg); + } else { + //set the caseid header //New + $("#notificationid").html(stateMap.id); + $("#dtcreated").html( + "created " + + app.utilB.epochToLocalShortDateTime(res.dtCreated) + ); + + if (res.processed) { + $("#processed").html("Processed"); + $("#dtprocessed").html( + "processed " + + app.utilB.epochToLocalShortDateTime(res.dtProcessed) + ); + } else { + $("#processed").html("NOT PROCESSED"); + } + + $("#vendor").html(res.vendor); + $("#data").html(res.data); + + //fill out form + app.utilB.formData(res); + + //================ + } + }); + }; + + // RETURN PUBLIC METHODS + // + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +})(); diff --git a/wwwroot/js/app.vendorNotifications.js b/wwwroot/js/app.vendorNotifications.js new file mode 100644 index 0000000..3c52e48 --- /dev/null +++ b/wwwroot/js/app.vendorNotifications.js @@ -0,0 +1,92 @@ +/*jslint browser : true, continue : true, + devel : true, indent : 2, maxerr : 50, + newcap : true, nomen : true, plusplus : true, + regexp : true, sloppy : true, vars : false, + white : true +*/ + +/*global $, app */ + +app.vendorNotifications = (function () { + "use strict"; + //---------------- BEGIN MODULE SCOPE VARIABLES -------------- + var stateMap = {}, + configModule, + initModule; + //----------------- END MODULE SCOPE VARIABLES --------------- + + //------------------- BEGIN UTILITY METHODS ------------------ + + //-------------------- END UTILITY METHODS ------------------- + + //------------------- BEGIN EVENT HANDLERS ------------------- + + //-------------------- END EVENT HANDLERS -------------------- + + //------------------- BEGIN PUBLIC METHODS ------------------- + //CONFIGMODULE + // + configModule = function (context) { + stateMap.context = context.context; + if (stateMap.context.params.id) { + stateMap.id = stateMap.context.params.id; //siteid + } + }; + + //INITMODULE + // + initModule = function ($container) { + if (typeof $container === "undefined") { + $container = $("#app-shell-main-content"); + } + $container.html(Handlebars.templates["app.vendorNotifications"]({})); + + //case 3513 + document.title = "Vendor notifications"; + + //=================== + //Get notifications + app.api.get("vendor-notifications/list/", function (res) { + if (res.error) { + $.gevent.publish("app-show-error", res.msg); + } else { + var $appList = $("#rf-list"); + + $appList.append(""); + } + }); + //=========/licenses============== + + app.nav.contextClear(); ///ravLicense/122 + }; + + //PUBLIC METHODS + // + return { + configModule: configModule, + initModule: initModule + }; + //------------------- END PUBLIC METHODS --------------------- +})(); diff --git a/wwwroot/js/templates/app.shell.handlebars b/wwwroot/js/templates/app.shell.handlebars index f427c37..0b598ec 100644 --- a/wwwroot/js/templates/app.shell.handlebars +++ b/wwwroot/js/templates/app.shell.handlebars @@ -1,7 +1,18 @@ - - - -
+
diff --git a/wwwroot/js/templates/app.vendorNotification.handlebars b/wwwroot/js/templates/app.vendorNotification.handlebars new file mode 100644 index 0000000..c1499b7 --- /dev/null +++ b/wwwroot/js/templates/app.vendorNotification.handlebars @@ -0,0 +1,49 @@ +
+
+
+ + +
+ +
+ + +
+ +
+ +
+
+ + +
+
+ +
+
+ + +
+
+ +
+ + {{!
+ + +
}} + +
+ +
\ No newline at end of file diff --git a/wwwroot/js/templates/app.vendorNotifications.handlebars b/wwwroot/js/templates/app.vendorNotifications.handlebars new file mode 100644 index 0000000..28be4e5 --- /dev/null +++ b/wwwroot/js/templates/app.vendorNotifications.handlebars @@ -0,0 +1,3 @@ +
+
+
\ No newline at end of file