From 919645cbc25bbc2706b314511beaa8e251d7ddd2 Mon Sep 17 00:00:00 2001 From: psteiwer Date: Mon, 2 Mar 2020 10:15:44 -0500 Subject: [PATCH 01/28] Add MDX to tableError email Fixes #71 --- PivotSubscriptions/Task.cls | 4 ++-- PivotSubscriptions/Utils.cls | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/PivotSubscriptions/Task.cls b/PivotSubscriptions/Task.cls index 8d017d9..eefd717 100644 --- a/PivotSubscriptions/Task.cls +++ b/PivotSubscriptions/Task.cls @@ -111,7 +111,7 @@ ClassMethod SendEmail(pID, pPivot As %String, pEmails As %String, pFormat As %St } ElseIf 'tableStatus { // Check if both configuration settings for admin email is valid before sending error message If validAdminEmail { - Do ##class(PivotSubscriptions.Utils).TableErrorMessage(tSubscription,tEmail,pName,"TooLarge") + Do ##class(PivotSubscriptions.Utils).TableErrorMessage(tSubscription,tEmail,pName,"TooLarge",mdx) } } @@ -127,7 +127,7 @@ ClassMethod SendEmail(pID, pPivot As %String, pEmails As %String, pFormat As %St Do ##class(PivotSubscriptions.Utils).WriteUnsubscribe(msg) Do ##class(PivotSubscriptions.Utils).WriteEmailFooter(msg) - Do ##class(PivotSubscriptions.Utils).TableErrorMessage(tSubscription,tEmail,pName,"NoResults") + Do ##class(PivotSubscriptions.Utils).TableErrorMessage(tSubscription,tEmail,pName,"NoResults",mdx) } } diff --git a/PivotSubscriptions/Utils.cls b/PivotSubscriptions/Utils.cls index 67062ee..c345b02 100644 --- a/PivotSubscriptions/Utils.cls +++ b/PivotSubscriptions/Utils.cls @@ -184,7 +184,7 @@ ClassMethod WriteEmail(pSubscription As PivotSubscriptions.Subscription, pMsg As Do ##class(PivotSubscriptions.Utils).WriteEmailFooter(pMsg) } -ClassMethod TableErrorMessage(pSubscription As PivotSubscriptions.Subscription, pEmail As %String, pName As %String, pReason As %String) As %Status +ClassMethod TableErrorMessage(pSubscription As PivotSubscriptions.Subscription, pEmail As %String, pName As %String, pReason As %String, pMDX As %String) As %Status { Set tAdminEmail=##class(PivotSubscriptions.Utils).GetSettings("AdminEmail") Set tLog=##class(PivotSubscriptions.EventLog).CreateEvent("tableError",$username,pSubscription.Pivot,pSubscription.DayOfWeek,pSubscription.Hour,pSubscription.Minute,pSubscription.Format,tAdminEmail,pName,.pEvent) @@ -211,6 +211,8 @@ ClassMethod TableErrorMessage(pSubscription As PivotSubscriptions.Subscription, Do tMsg.TextData.WriteLine("The pivot table is too large to be embedded.
") } Do tMsg.TextData.WriteLine("
Please check the Subscription Manager.") + Do tMsg.TextData.WriteLine("

MDX Executed:") + Do tMsg.TextData.WriteLine(pMDX) Do ##class(PivotSubscriptions.Utils).WriteEmailFooter(tMsg) // Set recipient of email From 5ad3d1d3ce6ba00f22ce5d25d71b6f9b5f809ff3 Mon Sep 17 00:00:00 2001 From: psteiwer Date: Mon, 2 Mar 2020 13:24:28 -0500 Subject: [PATCH 02/28] Add details link to event log to see more info The page was getting kind of wide, so some columns are now hidden Clicking on the details link will show a popup with all details Fixes #63 --- PivotSubscriptions/EventLog.cls | 4 +- PivotSubscriptions/UI/Dialog/EventDetails.cls | 108 ++++++++++++++++++ PivotSubscriptions/UI/EventLogViewer.cls | 9 +- 3 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 PivotSubscriptions/UI/Dialog/EventDetails.cls diff --git a/PivotSubscriptions/EventLog.cls b/PivotSubscriptions/EventLog.cls index 185e028..68dea50 100644 --- a/PivotSubscriptions/EventLog.cls +++ b/PivotSubscriptions/EventLog.cls @@ -90,9 +90,9 @@ ClassMethod DayOfWeekDisplay(pDayOfWeek) As %String [ SqlProc ] Quit pDayOfWeek } -Query GetEvents() As %SQLQuery +Query GetEventsForUI() As %SQLQuery { - SELECT StartTime,EndTime,EventType,Name,Pivot,UserName,PivotSubscriptions.EventLog_DayOfWeekDisplay(DayOfWeek) As DayOfWeek,Format,"Hour","Minute",Emails,Status + SELECT ID As Details,StartTime,EndTime,EventType,Name,Emails,Status FROM PivotSubscriptions.EventLog ORDER BY ID DESC } diff --git a/PivotSubscriptions/UI/Dialog/EventDetails.cls b/PivotSubscriptions/UI/Dialog/EventDetails.cls new file mode 100644 index 0000000..bda61da --- /dev/null +++ b/PivotSubscriptions/UI/Dialog/EventDetails.cls @@ -0,0 +1,108 @@ +Class PivotSubscriptions.UI.Dialog.EventDetails Extends %DeepSee.UI.Dialog.standardDialog +{ + +/// Class name of application this page belongs to. +Parameter APPLICATION; + +/// Displayed name of this page. +Parameter PAGENAME; + +Parameter DOMAIN = "PivotSubscriptions"; + +Property EventId As %ZEN.Datatype.integer(ZENURL = "EVENTID"); + +Parameter APPLYBUTTON = 0; + +/// This Style block contains page-specific CSS style definitions. +XData Style +{ + +} + +/// This XML block defines the contents of this page. +XData dialogBody [ XMLNamespace = "http://www.intersystems.com/zen" ] +{ + + + +} + +/// Get the (localized) title string for the dialog. +Method %OnGetTitle() As %String +{ + Quit "Event Details" +} + +Method %OnGetSubtitle() As %String +{ + Quit "" +} + +ClassMethod DrawDetails(pEventId) As %Status +{ + Set tSC=$$$OK + + Set tEvent=##class(PivotSubscriptions.EventLog).%OpenId(pEventId) + &html< + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID#(pEventId)#
Type#(tEvent.EventType)#
Start Time#(tEvent.StartTime)#
End Time#(tEvent.EndTime)#
Name#(tEvent.Name)#
Pivot#(tEvent.Pivot)#
UserName#(tEvent.UserName)#
Format#(tEvent.Format)#
DayOfWeek#(##class(PivotSubscriptions.EventLog).DayOfWeekDisplay(tEvent.DayOfWeek))#
Time#(tEvent.Hour)#:#(tEvent.Minute)#
Email#(tEvent.Emails)#
Status#($system.Status.GetErrorText(tEvent.Status))#
+ > + + Quit tSC +} + +ClientMethod getDialogValue() [ Language = javascript ] +{ + return ''; +} + +} diff --git a/PivotSubscriptions/UI/EventLogViewer.cls b/PivotSubscriptions/UI/EventLogViewer.cls index 2ffb95c..322d5a3 100644 --- a/PivotSubscriptions/UI/EventLogViewer.cls +++ b/PivotSubscriptions/UI/EventLogViewer.cls @@ -17,7 +17,7 @@ XData contentPane [ XMLNamespace = "http://www.intersystems.com/zen" ] cellSpacing="2" fixedHeaders="false" queryClass="PivotSubscriptions.EventLog" - queryName="GetEvents" + queryName="GetEventsForUI" useSnapshot="true" showQuery="false" showZebra="true" @@ -25,12 +25,19 @@ XData contentPane [ XMLNamespace = "http://www.intersystems.com/zen" ] pageSize="100" maxRows="1000" > + } +/// Creates edit popup. +ClientMethod viewDetails(pId, pPivot) [ Internal, Language = javascript ] +{ + zenLaunchPopupWindow('PivotSubscriptions.UI.Dialog.EventDetails.cls?EVENTID='+pId,'EventDetails','status,resizable=yes,width=700,height=575'); +} + /// Get the (localized) title string for the page. Method %OnGetTitle() As %String [ Internal ] { From d1cc4765991f96131ec09cd813fe03e7b186aca8 Mon Sep 17 00:00:00 2001 From: psteiwer Date: Mon, 2 Mar 2020 18:11:59 -0500 Subject: [PATCH 03/28] Initial Unsubscribe commit --- PivotSubscriptions/EventLog.cls | 10 +++++++++ PivotSubscriptions/UI/Unsubscribe.cls | 30 +++++++++++++++++++++++++++ PivotSubscriptions/Utils.cls | 11 ++++++++++ 3 files changed, 51 insertions(+) create mode 100644 PivotSubscriptions/UI/Unsubscribe.cls diff --git a/PivotSubscriptions/EventLog.cls b/PivotSubscriptions/EventLog.cls index 68dea50..bce55bc 100644 --- a/PivotSubscriptions/EventLog.cls +++ b/PivotSubscriptions/EventLog.cls @@ -27,6 +27,10 @@ Property Name As %String(MAXLEN = 100); Property Status As %Status; +Property Subscription As PivotSubscriptions.Subscription; + +Property GUID As %String [ InitialExpression = {$System.Util.CreateGUID()} ]; + /// Takes in info about an Alert Task and logs the information to the TaskLog ClassMethod CreateEvent(pType, pUser, pPivot, pDayOfWeek, pHour, pMinute, pFormat, pEmails, pName, ByRef pEvent) As %Status { @@ -142,6 +146,12 @@ Storage Default Status + +Subscription + + +GUID + ^PivotSubscriptions.EventLogD EventLogDefaultData diff --git a/PivotSubscriptions/UI/Unsubscribe.cls b/PivotSubscriptions/UI/Unsubscribe.cls new file mode 100644 index 0000000..818b9eb --- /dev/null +++ b/PivotSubscriptions/UI/Unsubscribe.cls @@ -0,0 +1,30 @@ +Class PivotSubscriptions.UI.Unsubscribe Extends %CSP.REST +{ + +Parameter HandleCorsRequest = 1; + +XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ] +{ + + + +} + +ClassMethod Unsubscribe(pEmail, pGUID) As %Status +{ + Set tSC=$$$OK + Set tResult={} + + If ##class(PivotSubscriptions.Utils).CheckUnsubscribe(pSubscriptionId,pEmail,pGUID) { + Set tSubscription=##class(PivotSubscriptions.Subscription).%OpenId(pSubscriptionId) + // Remove email from subscription + // Delete subscription if it is the only email? + + Do tResult.%Set("Status",pEmail_" unsubscribed from "_tSubscription.Name) + } + + Write tResult.%ToJSON() + Quit tSC +} + +} diff --git a/PivotSubscriptions/Utils.cls b/PivotSubscriptions/Utils.cls index c345b02..da5d573 100644 --- a/PivotSubscriptions/Utils.cls +++ b/PivotSubscriptions/Utils.cls @@ -284,4 +284,15 @@ ClassMethod GenerateFileForSubscription(pType = "Excel", pMDX, pCustomFilter, pN Quit tSC } +ClassMethod CheckUnsubscribe(pSubscriptionId, pEmail, pGUID) As %Boolean +{ + Set tConfirmed=0 + + Set tSQL="SELECT ID FROM PivotSubscriptions.EventLog WHERE Subscription=? AND Emails=? AND GUID=?" + Set tSQLRS=##class(%SQL.Statement).%ExecDirect(,tSQL,pSubscriptionId,pEmail,pGUID) + Set tConfirmed=tSQLRS.%Next() + + Quit tConfirmed +} + } From a7015afa4ff7ce161ad737e7a2ec7cff464928d1 Mon Sep 17 00:00:00 2001 From: psteiwer Date: Tue, 3 Mar 2020 08:15:55 -0500 Subject: [PATCH 04/28] Add GUID to EventDetails --- PivotSubscriptions/UI/Dialog/EventDetails.cls | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/PivotSubscriptions/UI/Dialog/EventDetails.cls b/PivotSubscriptions/UI/Dialog/EventDetails.cls index bda61da..afc2383 100644 --- a/PivotSubscriptions/UI/Dialog/EventDetails.cls +++ b/PivotSubscriptions/UI/Dialog/EventDetails.cls @@ -50,6 +50,10 @@ ClassMethod DrawDetails(pEventId) As %Status ID #(pEventId)# + + GUID + #(tEvent.GUID)# + Type #(tEvent.EventType)# From 8645017a1dfbf1f123b52881a4e2154918cd9c2c Mon Sep 17 00:00:00 2001 From: psteiwer Date: Tue, 3 Mar 2020 08:40:01 -0500 Subject: [PATCH 05/28] Add new unsubscribe link to email --- PivotSubscriptions/Task.cls | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/PivotSubscriptions/Task.cls b/PivotSubscriptions/Task.cls index eefd717..7ba8779 100644 --- a/PivotSubscriptions/Task.cls +++ b/PivotSubscriptions/Task.cls @@ -89,6 +89,7 @@ ClassMethod SendEmail(pID, pPivot As %String, pEmails As %String, pFormat As %St Set server.smtpserver=##class(%SYS.Task.Config).GetData("MailServer") Set msg=##class(%Net.MailMessage).%New() Set msg.From="PivotSubscriptions" + Do msg.To.SetAt(tEmail,1) Set validAdminEmail=##class(PivotSubscriptions.Utils).CheckConfigurationGlobal("AdminEmail") @@ -100,10 +101,12 @@ ClassMethod SendEmail(pID, pPivot As %String, pEmails As %String, pFormat As %St Set msg.Subject=pName Set msg.IsBinary=0 Set msg.IsHTML=1 // Set IsHTML to 1 if email uses HTML + + Set tUnsubscribeList=$LB(tSubscription.%Id(),tEmail,pEvent.GUID) If tHasResults { // Add attachment - Do ##class(PivotSubscriptions.Utils).WriteEmail(tSubscription, msg, tableStatus) + Do ##class(PivotSubscriptions.Utils).WriteEmail(tSubscription,msg,tableStatus,tUnsubscribeList) // if table is too large, then just attach Excel instead If ((pFormat = "PDF") && (tableStatus)) { @@ -124,14 +127,12 @@ ClassMethod SendEmail(pID, pPivot As %String, pEmails As %String, pFormat As %St } Else { Do ##class(PivotSubscriptions.Utils).WriteEmailHeader(msg) Do msg.TextData.WriteLine(##class(PivotSubscriptions.Utils).GetSettings("NoDataMessage","No data for requested pivot.")) - Do ##class(PivotSubscriptions.Utils).WriteUnsubscribe(msg) + Do ##class(PivotSubscriptions.Utils).WriteUnsubscribe(msg,tUnsubscribeList) Do ##class(PivotSubscriptions.Utils).WriteEmailFooter(msg) Do ##class(PivotSubscriptions.Utils).TableErrorMessage(tSubscription,tEmail,pName,"NoResults",mdx) } } - - Do msg.To.SetAt(tEmail,1) // Send email If tHasResults||##class(PivotSubscriptions.Utils).GetSettings("SendNoData",1) { From c2de1788c17a49272867e2c6a4990d44a357d501 Mon Sep 17 00:00:00 2001 From: psteiwer Date: Tue, 3 Mar 2020 08:40:11 -0500 Subject: [PATCH 06/28] Add new unsubscribe link to email --- PivotSubscriptions/Utils.cls | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/PivotSubscriptions/Utils.cls b/PivotSubscriptions/Utils.cls index da5d573..1d5c7ce 100644 --- a/PivotSubscriptions/Utils.cls +++ b/PivotSubscriptions/Utils.cls @@ -37,7 +37,7 @@ ClassMethod GetSettings(pSetting As %String, pDefaultValue As %String = "") As % Quit $G(^PivotSubscriptions.Settings(pSetting),pDefaultValue) } -ClassMethod GenerateLink(ByRef pLink As %String) As %Status +ClassMethod GenerateLink(ByRef pLink As %String = "") As %Status { Set tSC=$$$OK @@ -45,29 +45,24 @@ ClassMethod GenerateLink(ByRef pLink As %String) As %Status If $$$ISERR(tSC) Quit tSC If ..CheckConfigurationGlobal("Http") { - Set tWebServerPortUrl=##class(PivotSubscriptions.Utils).GetSettings("Http") + Set pLink=##class(PivotSubscriptions.Utils).GetSettings("Http") } Else { - Set tWebServerPortUrl="http://" + Set pLink="http://" } If ..CheckConfigurationGlobal("Server") { - Set tWebServerPortUrl=tWebServerPortUrl_##class(PivotSubscriptions.Utils).GetSettings("Server") + Set pLink=pLink_##class(PivotSubscriptions.Utils).GetSettings("Server") } Else { - Set tWebServerPortUrl=tWebServerPortUrl_h + Set pLink=pLink_h } If ..CheckConfigurationGlobal("Port") { - Set tWebServerPortUrl=tWebServerPortUrl_":"_##class(PivotSubscriptions.Utils).GetSettings("Port") + Set pLink=pLink_":"_##class(PivotSubscriptions.Utils).GetSettings("Port") } Else { If '..CheckConfigurationGlobal("Server") { - Set tWebServerPortUrl=tWebServerPortUrl_":"_p + Set pLink=pLink_":"_p } } - - Set tNamespace=$System.CSP.GetDefaultApp($Namespace) - Set tApplicationName="/PivotSubscriptions.UI.SubscriptionManager.zen" - - Set pLink=tWebServerPortUrl_tNamespace_tApplicationName Quit tSC } @@ -116,13 +111,15 @@ ClassMethod WriteEmailHeader(pMsg As %Net.MailMessage) Do pMsg.TextData.WriteLine("

") } -ClassMethod WriteUnsubscribe(pMsg As %Net.MailMessage) +ClassMethod WriteUnsubscribe(pMsg As %Net.MailMessage, pUnsubscribeList) { Do ##class(PivotSubscriptions.Utils).GenerateLink(.tLink) + Set tLink=tLink_"/csp/pivotsubscriptionsunsubscribe/" + Set tLink=tLink_$LTS(pUnsubscribeList,"/") Do pMsg.TextData.WriteLine("

") Do pMsg.TextData.WriteLine("") - Do pMsg.TextData.WriteLine("
 
 
You can manage your subscriptions here.
You can edit days of the week/time/format/recipients and delete in the Subscriptions Manager portal.
 
") + Do pMsg.TextData.WriteLine(" To Unsubscribe, click here.You can edit days of the week/time/format/recipients and delete in the Subscriptions Manager portal. ") } /// Write footer for any email, including link generation @@ -138,7 +135,7 @@ ClassMethod WriteEmailFooter(pMsg As %Net.MailMessage) } /// Write improved email format for subscription, including embeded pivot table -ClassMethod WriteEmail(pSubscription As PivotSubscriptions.Subscription, pMsg As %Net.MailMessage, pTableStatus) +ClassMethod WriteEmail(pSubscription As PivotSubscriptions.Subscription, pMsg As %Net.MailMessage, pTableStatus, pUnsubscribeList) { Do ##class(PivotSubscriptions.Utils).WriteEmailHeader(pMsg) @@ -180,7 +177,7 @@ ClassMethod WriteEmail(pSubscription As PivotSubscriptions.Subscription, pMsg As Do pMsg.TextData.WriteLine("Pivot table is too big to be embedded. Please see attachment.") } - Do ##class(PivotSubscriptions.Utils).WriteUnsubscribe(pMsg) + Do ##class(PivotSubscriptions.Utils).WriteUnsubscribe(pMsg,pUnsubscribeList) Do ##class(PivotSubscriptions.Utils).WriteEmailFooter(pMsg) } From 717a449f9ff49efeaa875425fb54ef79f8dfe3ea Mon Sep 17 00:00:00 2001 From: psteiwer Date: Tue, 3 Mar 2020 09:01:23 -0500 Subject: [PATCH 07/28] Log subscription id in event log --- PivotSubscriptions/EventLog.cls | 3 ++- PivotSubscriptions/Task.cls | 2 +- PivotSubscriptions/UI/Dialog/EditSubscription.cls | 2 +- PivotSubscriptions/UI/SubscriptionManager.cls | 2 +- PivotSubscriptions/Utils.cls | 2 +- 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/PivotSubscriptions/EventLog.cls b/PivotSubscriptions/EventLog.cls index bce55bc..b649ebe 100644 --- a/PivotSubscriptions/EventLog.cls +++ b/PivotSubscriptions/EventLog.cls @@ -32,12 +32,13 @@ Property Subscription As PivotSubscriptions.Subscription; Property GUID As %String [ InitialExpression = {$System.Util.CreateGUID()} ]; /// Takes in info about an Alert Task and logs the information to the TaskLog -ClassMethod CreateEvent(pType, pUser, pPivot, pDayOfWeek, pHour, pMinute, pFormat, pEmails, pName, ByRef pEvent) As %Status +ClassMethod CreateEvent(pType, pSubscriptionId, pUser, pPivot, pDayOfWeek, pHour, pMinute, pFormat, pEmails, pName, ByRef pEvent) As %Status { Set tSC=$$$OK Set tEventLog=##class(PivotSubscriptions.EventLog).%New() Set tEventLog.EventType=pType + Set tEventLog.Subscription=pSubscriptionId Set tEventLog.UserName=pUser Set tEventLog.Pivot=pPivot Set tEventLog.Name=pName diff --git a/PivotSubscriptions/Task.cls b/PivotSubscriptions/Task.cls index 7ba8779..3e19c94 100644 --- a/PivotSubscriptions/Task.cls +++ b/PivotSubscriptions/Task.cls @@ -67,7 +67,7 @@ ClassMethod SendEmail(pID, pPivot As %String, pEmails As %String, pFormat As %St For tCount=1:1:$l(pEmails,",") { Set tEmail=$p(pEmails,",",tCount) - Set tSC=##class(PivotSubscriptions.EventLog).CreateEvent("sendSubscription",$username,pPivot,tSubscription.DayOfWeek,tSubscription.Hour,tSubscription.Minute,tSubscription.Format,tEmail,pName,.pEvent) + Set tSC=##class(PivotSubscriptions.EventLog).CreateEvent("sendSubscription",pID,$username,pPivot,tSubscription.DayOfWeek,tSubscription.Hour,tSubscription.Minute,tSubscription.Format,tEmail,pName,.pEvent) If $$$ISERR(tSC) Quit tSC Set tHasResults=0 diff --git a/PivotSubscriptions/UI/Dialog/EditSubscription.cls b/PivotSubscriptions/UI/Dialog/EditSubscription.cls index 7caf634..e2b024d 100644 --- a/PivotSubscriptions/UI/Dialog/EditSubscription.cls +++ b/PivotSubscriptions/UI/Dialog/EditSubscription.cls @@ -160,7 +160,7 @@ Method EditSubscription(pSubscriptionId, pPivot, pDayOfWeek, pHour, pMinute, pEm Set tEventType="create" } - Set tSC=##class(PivotSubscriptions.EventLog).CreateEvent(tEventType,$username,tSubscription.Pivot,tSubscription.DayOfWeek,tSubscription.Hour,tSubscription.Minute,tSubscription.Format,tSubscription.Emails,tSubscription.Name,.tEvent) + Set tSC=##class(PivotSubscriptions.EventLog).CreateEvent(tEventType,pSubscriptionId,$username,tSubscription.Pivot,tSubscription.DayOfWeek,tSubscription.Hour,tSubscription.Minute,tSubscription.Format,tSubscription.Emails,tSubscription.Name,.tEvent) Set tSubscription.DayOfWeek=pDayOfWeek Set tSubscription.Hour=pHour diff --git a/PivotSubscriptions/UI/SubscriptionManager.cls b/PivotSubscriptions/UI/SubscriptionManager.cls index 84a1ebb..a365e5d 100644 --- a/PivotSubscriptions/UI/SubscriptionManager.cls +++ b/PivotSubscriptions/UI/SubscriptionManager.cls @@ -133,7 +133,7 @@ Method Delete(pId As %Integer) As %String [ ZenMethod ] Set tMsg="Subscription Deleted." Set tSubscription=##class(PivotSubscriptions.Subscription).%OpenId(pId) - Set tSC=##class(PivotSubscriptions.EventLog).CreateEvent("delete",$username,tSubscription.Pivot,tSubscription.DayOfWeek,tSubscription.Hour,tSubscription.Minute,tSubscription.Format,tSubscription.Emails,tSubscription.Name,.tEvent) + Set tSC=##class(PivotSubscriptions.EventLog).CreateEvent("delete",pId,$username,tSubscription.Pivot,tSubscription.DayOfWeek,tSubscription.Hour,tSubscription.Minute,tSubscription.Format,tSubscription.Emails,tSubscription.Name,.tEvent) If $$$ISERR(tSC) Quit tSC diff --git a/PivotSubscriptions/Utils.cls b/PivotSubscriptions/Utils.cls index 1d5c7ce..af9b5b4 100644 --- a/PivotSubscriptions/Utils.cls +++ b/PivotSubscriptions/Utils.cls @@ -184,7 +184,7 @@ ClassMethod WriteEmail(pSubscription As PivotSubscriptions.Subscription, pMsg As ClassMethod TableErrorMessage(pSubscription As PivotSubscriptions.Subscription, pEmail As %String, pName As %String, pReason As %String, pMDX As %String) As %Status { Set tAdminEmail=##class(PivotSubscriptions.Utils).GetSettings("AdminEmail") - Set tLog=##class(PivotSubscriptions.EventLog).CreateEvent("tableError",$username,pSubscription.Pivot,pSubscription.DayOfWeek,pSubscription.Hour,pSubscription.Minute,pSubscription.Format,tAdminEmail,pName,.pEvent) + Set tLog=##class(PivotSubscriptions.EventLog).CreateEvent("tableError",pSubscription.%Id(),$username,pSubscription.Pivot,pSubscription.DayOfWeek,pSubscription.Hour,pSubscription.Minute,pSubscription.Format,tAdminEmail,pName,.pEvent) If $$$ISERR(tLog) Quit tLog From ec111bf45c747a0731c747b80110b1c66a6eb86c Mon Sep 17 00:00:00 2001 From: psteiwer Date: Tue, 3 Mar 2020 09:01:57 -0500 Subject: [PATCH 08/28] Fix generated unsubscribe link --- PivotSubscriptions/Utils.cls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PivotSubscriptions/Utils.cls b/PivotSubscriptions/Utils.cls index af9b5b4..a37c0b2 100644 --- a/PivotSubscriptions/Utils.cls +++ b/PivotSubscriptions/Utils.cls @@ -114,7 +114,7 @@ ClassMethod WriteEmailHeader(pMsg As %Net.MailMessage) ClassMethod WriteUnsubscribe(pMsg As %Net.MailMessage, pUnsubscribeList) { Do ##class(PivotSubscriptions.Utils).GenerateLink(.tLink) - Set tLink=tLink_"/csp/pivotsubscriptionsunsubscribe/" + Set tLink=tLink_"/csp/pivotsubscriptionsunsubscribe/unsubscribe/" Set tLink=tLink_$LTS(pUnsubscribeList,"/") Do pMsg.TextData.WriteLine("

") From 112a7d2e0039cf3916c373ca4eea8b4e65f2db7c Mon Sep 17 00:00:00 2001 From: psteiwer Date: Tue, 3 Mar 2020 09:04:13 -0500 Subject: [PATCH 09/28] Fix Subscription reference in CreateEvent --- PivotSubscriptions/EventLog.cls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PivotSubscriptions/EventLog.cls b/PivotSubscriptions/EventLog.cls index b649ebe..0423061 100644 --- a/PivotSubscriptions/EventLog.cls +++ b/PivotSubscriptions/EventLog.cls @@ -38,7 +38,7 @@ ClassMethod CreateEvent(pType, pSubscriptionId, pUser, pPivot, pDayOfWeek, pHour Set tEventLog=##class(PivotSubscriptions.EventLog).%New() Set tEventLog.EventType=pType - Set tEventLog.Subscription=pSubscriptionId + Set tEventLog.Subscription=##class(PivotSubscriptions.Subscription).%OpenId(pSubscriptionId) Set tEventLog.UserName=pUser Set tEventLog.Pivot=pPivot Set tEventLog.Name=pName From 26f281bb6e531f48c8308d31515dbdc086c6737b Mon Sep 17 00:00:00 2001 From: psteiwer Date: Tue, 3 Mar 2020 09:13:21 -0500 Subject: [PATCH 10/28] Add Unsubscribe method --- PivotSubscriptions/Subscription.cls | 27 +++++++++++++++++++++++++++ PivotSubscriptions/UI/Unsubscribe.cls | 13 ++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/PivotSubscriptions/Subscription.cls b/PivotSubscriptions/Subscription.cls index e15cfb4..b548f4c 100644 --- a/PivotSubscriptions/Subscription.cls +++ b/PivotSubscriptions/Subscription.cls @@ -25,6 +25,33 @@ Property CustomFilters As array Of %String(MAXLEN = ""); Property CustomEmailText As %String(MAXLEN = ""); +Method Unsubscribe(pEmail) As %Status +{ + Set tSC=$$$OK + + Set tEmailList=$LFS(..Emails,",") + + If $LL(tEmailList)=1 { + If ..Emails=pEmail { + // This is the only Email for the subscription, delete subscription + Set tSC=##class(PivotSubscriptions.Subscription).%DeleteId(..%Id()) + Return tSC + } + } + + Set tPosition=$Listfind(tEmailList,pEmail) + If tPosition=1 { + Set tEmailList=$List(tEmailList,2,*) + } Else { + Set tEmailList=$List(tEmailList,1,tPosition-1)_$List(tEmailList,tPosition+1,*) + } + + Set ..Emails=$LTS(tEmailList,",") + Set tSC=..%Save() + + Quit tSC +} + Storage Default { diff --git a/PivotSubscriptions/UI/Unsubscribe.cls b/PivotSubscriptions/UI/Unsubscribe.cls index 818b9eb..dffa5ca 100644 --- a/PivotSubscriptions/UI/Unsubscribe.cls +++ b/PivotSubscriptions/UI/Unsubscribe.cls @@ -10,17 +10,20 @@ XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ] } -ClassMethod Unsubscribe(pEmail, pGUID) As %Status +ClassMethod Unsubscribe(pSubscriptionId, pEmail, pGUID) As %Status { Set tSC=$$$OK Set tResult={} + Do tResult.%Set("Status",$$$ERROR($$$GeneralError,"Invalid Request")) If ##class(PivotSubscriptions.Utils).CheckUnsubscribe(pSubscriptionId,pEmail,pGUID) { Set tSubscription=##class(PivotSubscriptions.Subscription).%OpenId(pSubscriptionId) - // Remove email from subscription - // Delete subscription if it is the only email? - - Do tResult.%Set("Status",pEmail_" unsubscribed from "_tSubscription.Name) + Set tSC=tSubscription.Unsubscribe(pEmail) + If $$$ISERR(tSC) { + Do tResult.%Set("Status",$SYSTEM.Status.GetErrorText(tSC)) + } Else { + Do tResult.%Set("Status",pEmail_" unsubscribed from "_tSubscription.Name) + } } Write tResult.%ToJSON() From 8703df30830dc12c18b9647cff3375e2bd1d0e65 Mon Sep 17 00:00:00 2001 From: psteiwer Date: Tue, 3 Mar 2020 09:26:18 -0500 Subject: [PATCH 11/28] Add unsubscribe event --- PivotSubscriptions/EventLog.cls | 2 +- PivotSubscriptions/Subscription.cls | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/PivotSubscriptions/EventLog.cls b/PivotSubscriptions/EventLog.cls index 0423061..72a37b5 100644 --- a/PivotSubscriptions/EventLog.cls +++ b/PivotSubscriptions/EventLog.cls @@ -3,7 +3,7 @@ Class PivotSubscriptions.EventLog Extends %Persistent { /// Event Type covers: create, update, delete, sendSubscription, and tableError -Property EventType As %String(VALUELIST = ",create,update,delete,sendSubscription,tableError"); +Property EventType As %String(VALUELIST = ",create,update,delete,sendSubscription,tableError,unsubscribe"); Property StartTime As %TimeStamp [ InitialExpression = {$zdt($h, 3, 1)} ]; diff --git a/PivotSubscriptions/Subscription.cls b/PivotSubscriptions/Subscription.cls index b548f4c..7800f80 100644 --- a/PivotSubscriptions/Subscription.cls +++ b/PivotSubscriptions/Subscription.cls @@ -29,6 +29,8 @@ Method Unsubscribe(pEmail) As %Status { Set tSC=$$$OK + Set tSC=##class(PivotSubscriptions.EventLog).CreateEvent("unsubscribe",..%Id(),$username,..Pivot,..DayOfWeek,..Hour,..Minute,..Format,pEmail,..Name,.tEvent) + Set tEmailList=$LFS(..Emails,",") If $LL(tEmailList)=1 { @@ -49,6 +51,8 @@ Method Unsubscribe(pEmail) As %Status Set ..Emails=$LTS(tEmailList,",") Set tSC=..%Save() + Do tEvent.UpdateStatus(tSC) + Quit tSC } From 7211498138c55e708de9ce66c86e088f22ace5fd Mon Sep 17 00:00:00 2001 From: psteiwer Date: Tue, 3 Mar 2020 09:26:41 -0500 Subject: [PATCH 12/28] Fix unsubscribe of last email in list --- PivotSubscriptions/Subscription.cls | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PivotSubscriptions/Subscription.cls b/PivotSubscriptions/Subscription.cls index 7800f80..87241ae 100644 --- a/PivotSubscriptions/Subscription.cls +++ b/PivotSubscriptions/Subscription.cls @@ -44,6 +44,8 @@ Method Unsubscribe(pEmail) As %Status Set tPosition=$Listfind(tEmailList,pEmail) If tPosition=1 { Set tEmailList=$List(tEmailList,2,*) + } ElseIf tPosition=$LL(tEmailList) { + Set tEmailList=$List(tEmailList,1,*-1) } Else { Set tEmailList=$List(tEmailList,1,tPosition-1)_$List(tEmailList,tPosition+1,*) } From 624cc87d067bb7bdae9bea189e6b8a4e89d0afd2 Mon Sep 17 00:00:00 2001 From: psteiwer Date: Tue, 3 Mar 2020 09:28:27 -0500 Subject: [PATCH 13/28] Log unsubscribe status when delete happens --- PivotSubscriptions/Subscription.cls | 1 + 1 file changed, 1 insertion(+) diff --git a/PivotSubscriptions/Subscription.cls b/PivotSubscriptions/Subscription.cls index 87241ae..a28d03b 100644 --- a/PivotSubscriptions/Subscription.cls +++ b/PivotSubscriptions/Subscription.cls @@ -37,6 +37,7 @@ Method Unsubscribe(pEmail) As %Status If ..Emails=pEmail { // This is the only Email for the subscription, delete subscription Set tSC=##class(PivotSubscriptions.Subscription).%DeleteId(..%Id()) + Do tEvent.UpdateStatus(tSC) Return tSC } } From 8f1a2bfa6449f1dc0a1058a4975293dd1658aca3 Mon Sep 17 00:00:00 2001 From: psteiwer Date: Tue, 3 Mar 2020 09:30:53 -0500 Subject: [PATCH 14/28] Add Delete event to unsubscribe with 1 email --- PivotSubscriptions/Subscription.cls | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PivotSubscriptions/Subscription.cls b/PivotSubscriptions/Subscription.cls index a28d03b..cf8ec2f 100644 --- a/PivotSubscriptions/Subscription.cls +++ b/PivotSubscriptions/Subscription.cls @@ -36,7 +36,9 @@ Method Unsubscribe(pEmail) As %Status If $LL(tEmailList)=1 { If ..Emails=pEmail { // This is the only Email for the subscription, delete subscription + Set tSC=##class(PivotSubscriptions.EventLog).CreateEvent("delete",,..%Id(),$username,..Pivot,..DayOfWeek,..Hour,..Minute,..Format,..Emails,..Name,.tDeleteEvent) Set tSC=##class(PivotSubscriptions.Subscription).%DeleteId(..%Id()) + Do tDeleteEvent.UpdateStatus(tSC) Do tEvent.UpdateStatus(tSC) Return tSC } From 7dfa710238ae75edaaad4b80ce1ac0cc04c890e5 Mon Sep 17 00:00:00 2001 From: psteiwer Date: Tue, 3 Mar 2020 09:43:56 -0500 Subject: [PATCH 15/28] Create WebApp in installer --- PivotSubscriptions/Installer.cls | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/PivotSubscriptions/Installer.cls b/PivotSubscriptions/Installer.cls index 65ae448..6a5f55e 100644 --- a/PivotSubscriptions/Installer.cls +++ b/PivotSubscriptions/Installer.cls @@ -18,10 +18,13 @@ ClassMethod RunInstaller(pRootDir) Set tItem.title="Pivot Subscriptions" Set tItem.bookCover="{background: {style:'background:white;',src:'covers/PivotSubscriptions_Cover.png'},header: {text:'$type',style:'display: none;'},title: {text:'$title',style:'display: none;'},image: {style:'display: none;',src:'deepsee/ds2_globe_44.png',imageStyle:'width:64px;height:64px;'},subtitle: {style:'display: none;'},footer: {text:'$owner',style:'display: none;'}}" Set tSC=tItem.%Save() - - If $$$ISERR(tSC) Quit + If $$$ISERR(tSC) Quit tSC Set tSC=##class(PivotSubscriptions.Task).ConfigureTask() + If $$$ISERR(tSC) Quit tSC + + Set tSC=##class(PivotSubscriptions.Installer).ConfigureUnsubscribeWebApp() + If $$$ISERR(tSC) Quit tSC Quit tSC } @@ -50,4 +53,29 @@ ClassMethod ImportImage(pDir) As %Status Quit tSC } +ClassMethod ConfigureUnsubscribeWebApp() As %Status +{ + Set tSC=$$$OK + + Set tNamespace=$Namespace + ZN "%SYS" + + Try { + If '##class(Security.Applications).Exists("/api/pivotsubscriptionsunsubscribe") { + Set tWebApp=##class(Security.Applications).%New() + Set tWebApp.Name="/api/pivotsubscriptionsunsubscribe" + Set tWebApp.NameSpace=tNamespace + Set tWebApp.DispatchClass="PivotSubscriptions.UI.Unsubscribe" + Set tWebApp.AutheEnabled=64 + Set tSC=tWebApp.%Save() + } + } Catch ex { + Set tSC=ex.AsStatus() + } + + ZN tNamespace + + Quit tSC +} + } From d3403c8a2973d2bf9a4303a24cff3f87b3e6106a Mon Sep 17 00:00:00 2001 From: psteiwer Date: Tue, 3 Mar 2020 09:44:54 -0500 Subject: [PATCH 16/28] Fix web app name in Unsubscribe link --- PivotSubscriptions/Utils.cls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PivotSubscriptions/Utils.cls b/PivotSubscriptions/Utils.cls index a37c0b2..e628675 100644 --- a/PivotSubscriptions/Utils.cls +++ b/PivotSubscriptions/Utils.cls @@ -114,7 +114,7 @@ ClassMethod WriteEmailHeader(pMsg As %Net.MailMessage) ClassMethod WriteUnsubscribe(pMsg As %Net.MailMessage, pUnsubscribeList) { Do ##class(PivotSubscriptions.Utils).GenerateLink(.tLink) - Set tLink=tLink_"/csp/pivotsubscriptionsunsubscribe/unsubscribe/" + Set tLink=tLink_"/api/pivotsubscriptionsunsubscribe/unsubscribe/" Set tLink=tLink_$LTS(pUnsubscribeList,"/") Do pMsg.TextData.WriteLine("

") From 690e362e1ebc0b2f5c3a26f5cd8c1e860229491d Mon Sep 17 00:00:00 2001 From: psteiwer Date: Tue, 3 Mar 2020 11:47:09 -0500 Subject: [PATCH 17/28] Assign Subscription ObjectId to Event --- PivotSubscriptions/EventLog.cls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PivotSubscriptions/EventLog.cls b/PivotSubscriptions/EventLog.cls index 72a37b5..82f0b1a 100644 --- a/PivotSubscriptions/EventLog.cls +++ b/PivotSubscriptions/EventLog.cls @@ -38,7 +38,7 @@ ClassMethod CreateEvent(pType, pSubscriptionId, pUser, pPivot, pDayOfWeek, pHour Set tEventLog=##class(PivotSubscriptions.EventLog).%New() Set tEventLog.EventType=pType - Set tEventLog.Subscription=##class(PivotSubscriptions.Subscription).%OpenId(pSubscriptionId) + Do tEventLog.SubscriptionSetObjectId(pSubscriptionId) Set tEventLog.UserName=pUser Set tEventLog.Pivot=pPivot Set tEventLog.Name=pName From db9357d6921e1af12b1560a4e048a93a32488e8b Mon Sep 17 00:00:00 2001 From: psteiwer Date: Tue, 3 Mar 2020 11:58:10 -0500 Subject: [PATCH 18/28] Update SendEmail error logging Fixes #68 --- PivotSubscriptions/Task.cls | 46 +++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/PivotSubscriptions/Task.cls b/PivotSubscriptions/Task.cls index 3e19c94..e3e149a 100644 --- a/PivotSubscriptions/Task.cls +++ b/PivotSubscriptions/Task.cls @@ -70,18 +70,20 @@ ClassMethod SendEmail(pID, pPivot As %String, pEmails As %String, pFormat As %St Set tSC=##class(PivotSubscriptions.EventLog).CreateEvent("sendSubscription",pID,$username,pPivot,tSubscription.DayOfWeek,tSubscription.Hour,tSubscription.Minute,tSubscription.Format,tEmail,pName,.pEvent) If $$$ISERR(tSC) Quit tSC - Set tHasResults=0 + Try { + Set tHasResults=0 - Set tCustomFilter=tSubscription.CustomFilters.GetAt(tEmail) - Set tSC=##class(PivotSubscriptions.Utils).ExecuteForSubscription(mdx,tCustomFilter,.tHasResults) - - If tHasResults { - // Only generate file if requested pivot has results - Set tSC=##class(PivotSubscriptions.Utils).GenerateFileForSubscription("Excel",mdx,tCustomFilter,pName,pPivot,.tFilename) - } + Set tCustomFilter=tSubscription.CustomFilters.GetAt(tEmail) + Set tSC=##class(PivotSubscriptions.Utils).ExecuteForSubscription(mdx,tCustomFilter,.tHasResults) + If $$$ISERR(tSC) Quit + + If tHasResults { + // Only generate file if requested pivot has results + Set tSC=##class(PivotSubscriptions.Utils).GenerateFileForSubscription("Excel",mdx,tCustomFilter,pName,pPivot,.tFilename) + If $$$ISERR(tSC) Quit + } - // Generate email - If tSC { + // Generate email // check whether the table generated is too wide/truncated AND whether the table has data Set tableStatus=##class(PivotSubscriptions.Utils).CheckTable(pName) @@ -111,6 +113,7 @@ ClassMethod SendEmail(pID, pPivot As %String, pEmails As %String, pFormat As %St // if table is too large, then just attach Excel instead If ((pFormat = "PDF") && (tableStatus)) { Set tSC=##class(PivotSubscriptions.Utils).GenerateFileForSubscription("PDF",mdx,tCustomFilter,pName,pPivot,.tFilename) + If $$$ISERR(tSC) Quit } ElseIf 'tableStatus { // Check if both configuration settings for admin email is valid before sending error message If validAdminEmail { @@ -118,12 +121,8 @@ ClassMethod SendEmail(pID, pPivot As %String, pEmails As %String, pFormat As %St } } - Set status=msg.AttachFile("",tFilename) - - If $$$ISERR(status) { - Do $System.Status.DisplayError(status) - Quit $$$ERROR() - } + Set tSC=msg.AttachFile("",tFilename) + If $$$ISERR(tSC) Quit } Else { Do ##class(PivotSubscriptions.Utils).WriteEmailHeader(msg) Do msg.TextData.WriteLine(##class(PivotSubscriptions.Utils).GetSettings("NoDataMessage","No data for requested pivot.")) @@ -132,14 +131,17 @@ ClassMethod SendEmail(pID, pPivot As %String, pEmails As %String, pFormat As %St Do ##class(PivotSubscriptions.Utils).TableErrorMessage(tSubscription,tEmail,pName,"NoResults",mdx) } + + // Send email + If tHasResults||##class(PivotSubscriptions.Utils).GetSettings("SendNoData",1) { + Set tSC=server.Send(msg) + If $$$ISERR(tSC) Quit + } + } Catch ex { + Set tSC=ex.AsStatus() } - // Send email - If tHasResults||##class(PivotSubscriptions.Utils).GetSettings("SendNoData",1) { - Set tSC=server.Send(msg) - Set tSC=pEvent.UpdateStatus(tSC) - If $$$ISERR(tSC) Quit tSC - } + Set tSC=pEvent.UpdateStatus(tSC) If tHasResults { // Delete file From 3dda057eff0f79d89ed914fa0c86963372fdbb3f Mon Sep 17 00:00:00 2001 From: psteiwer Date: Tue, 3 Mar 2020 12:07:10 -0500 Subject: [PATCH 19/28] Fix Minute display in EventDetails --- PivotSubscriptions/UI/Dialog/EventDetails.cls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PivotSubscriptions/UI/Dialog/EventDetails.cls b/PivotSubscriptions/UI/Dialog/EventDetails.cls index afc2383..a4f7cb6 100644 --- a/PivotSubscriptions/UI/Dialog/EventDetails.cls +++ b/PivotSubscriptions/UI/Dialog/EventDetails.cls @@ -88,7 +88,7 @@ ClassMethod DrawDetails(pEventId) As %Status Time - #(tEvent.Hour)#:#(tEvent.Minute)# + #(tEvent.Hour)#:#($replace($j(tEvent.Minute,2)," ",0))# Email From 88c59b65ea8587b54a93bba37fc5801aa1cd9574 Mon Sep 17 00:00:00 2001 From: psteiwer Date: Tue, 3 Mar 2020 12:09:50 -0500 Subject: [PATCH 20/28] Display OK if there is no error in Event Details --- PivotSubscriptions/UI/Dialog/EventDetails.cls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PivotSubscriptions/UI/Dialog/EventDetails.cls b/PivotSubscriptions/UI/Dialog/EventDetails.cls index a4f7cb6..3cf4fbb 100644 --- a/PivotSubscriptions/UI/Dialog/EventDetails.cls +++ b/PivotSubscriptions/UI/Dialog/EventDetails.cls @@ -96,7 +96,7 @@ ClassMethod DrawDetails(pEventId) As %Status Status - #($system.Status.GetErrorText(tEvent.Status))# + #($Select(tEvent.Status:"OK",1:$system.Status.GetErrorText(tEvent.Status)))# > From b1aa534ac859273111242ab955b0d528906a6cbb Mon Sep 17 00:00:00 2001 From: psteiwer Date: Tue, 3 Mar 2020 12:11:37 -0500 Subject: [PATCH 21/28] Event Log Viewer now has a page size of 50 Fixes #79 --- PivotSubscriptions/UI/EventLogViewer.cls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PivotSubscriptions/UI/EventLogViewer.cls b/PivotSubscriptions/UI/EventLogViewer.cls index 322d5a3..5c4d0c9 100644 --- a/PivotSubscriptions/UI/EventLogViewer.cls +++ b/PivotSubscriptions/UI/EventLogViewer.cls @@ -22,7 +22,7 @@ XData contentPane [ XMLNamespace = "http://www.intersystems.com/zen" ] showQuery="false" showZebra="true" showRowNumbers="false" - pageSize="100" + pageSize="50" maxRows="1000" > From 14481de2ae534df32076b8ab294827a5dfaffde9 Mon Sep 17 00:00:00 2001 From: psteiwer Date: Tue, 3 Mar 2020 12:38:54 -0500 Subject: [PATCH 22/28] Update Version String --- PivotSubscriptions/Utils.cls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PivotSubscriptions/Utils.cls b/PivotSubscriptions/Utils.cls index 64f478e..bed25b3 100644 --- a/PivotSubscriptions/Utils.cls +++ b/PivotSubscriptions/Utils.cls @@ -3,7 +3,7 @@ Class PivotSubscriptions.Utils ClassMethod GetVersion() As %String { - Quit "v1.3.0" + Quit "v1.4.0" } /// Utility method for saving and updating global variables From 1c73656220e78950bc37694f558aa44d1cd23f32 Mon Sep 17 00:00:00 2001 From: psteiwer Date: Tue, 3 Mar 2020 17:52:36 -0500 Subject: [PATCH 23/28] Unsubscribing multiple times causes duplicate emails --- PivotSubscriptions/Subscription.cls | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/PivotSubscriptions/Subscription.cls b/PivotSubscriptions/Subscription.cls index cf8ec2f..5aa67ca 100644 --- a/PivotSubscriptions/Subscription.cls +++ b/PivotSubscriptions/Subscription.cls @@ -45,7 +45,9 @@ Method Unsubscribe(pEmail) As %Status } Set tPosition=$Listfind(tEmailList,pEmail) - If tPosition=1 { + If tPosition=0 { + Set tSC=$$$ERROR($$$GeneralError,"Not subscribed") + } ElseIf tPosition=1 { Set tEmailList=$List(tEmailList,2,*) } ElseIf tPosition=$LL(tEmailList) { Set tEmailList=$List(tEmailList,1,*-1) @@ -53,9 +55,11 @@ Method Unsubscribe(pEmail) As %Status Set tEmailList=$List(tEmailList,1,tPosition-1)_$List(tEmailList,tPosition+1,*) } - Set ..Emails=$LTS(tEmailList,",") - Set tSC=..%Save() - + If tPosition'=0 { + Set ..Emails=$LTS(tEmailList,",") + Set tSC=..%Save() + } + Do tEvent.UpdateStatus(tSC) Quit tSC From ff90a906bba37ec42a95702591ec262303725cc6 Mon Sep 17 00:00:00 2001 From: psteiwer Date: Tue, 3 Mar 2020 18:08:19 -0500 Subject: [PATCH 24/28] Add username back to Event Log Viewer --- PivotSubscriptions/EventLog.cls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PivotSubscriptions/EventLog.cls b/PivotSubscriptions/EventLog.cls index 82f0b1a..1135c45 100644 --- a/PivotSubscriptions/EventLog.cls +++ b/PivotSubscriptions/EventLog.cls @@ -97,7 +97,7 @@ ClassMethod DayOfWeekDisplay(pDayOfWeek) As %String [ SqlProc ] Query GetEventsForUI() As %SQLQuery { - SELECT ID As Details,StartTime,EndTime,EventType,Name,Emails,Status + SELECT ID As Details,StartTime,EndTime,EventType,Username,Name,Emails,Status FROM PivotSubscriptions.EventLog ORDER BY ID DESC } From fd85be78337b88775d071ee28854064337cff43b Mon Sep 17 00:00:00 2001 From: psteiwer Date: Tue, 3 Mar 2020 18:08:31 -0500 Subject: [PATCH 25/28] Fix tab --- PivotSubscriptions/Subscription.cls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PivotSubscriptions/Subscription.cls b/PivotSubscriptions/Subscription.cls index 5aa67ca..571970c 100644 --- a/PivotSubscriptions/Subscription.cls +++ b/PivotSubscriptions/Subscription.cls @@ -59,7 +59,7 @@ Method Unsubscribe(pEmail) As %Status Set ..Emails=$LTS(tEmailList,",") Set tSC=..%Save() } - + Do tEvent.UpdateStatus(tSC) Quit tSC From e9b0d1b8d4872b623020275865e5093338557af8 Mon Sep 17 00:00:00 2001 From: psteiwer Date: Wed, 4 Mar 2020 10:01:15 -0500 Subject: [PATCH 26/28] Update README for Unsubscribe --- README.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index cb22439..41cf115 100644 --- a/README.md +++ b/README.md @@ -19,16 +19,17 @@ Once installation is complete, a new "Pivot Subscriptions" Link will be added to 5. Follow the Configuration steps ## Configuration steps -### Configure Default Namespace -To ensure that links to the SubscriptionManager page are correctly generated, the Default Application of the namespace you are working in is correctly configured. -1. Go to Management Portal -2. Go to System Administration > Security > Applications > Web Applications -3. Click on /csp/??? where ??? is the namespace you are working in -4. Check the checkbox next to Namespace Default Application and Save - ### Configure Task Manager Email Settings Subscriptions are delivered by Email. The Task Manager Email must be configured to allow alerts to be delivered by Email. At a minimum, the SMTP Server must be assigned in the Task Manager Email Settings (Management Portal -> System Administration -> Configuration -> Additional Settings -> Task Manager Email). For more information, please see the documentation. +### Unsubscribe Web Application +A new Web Application is created to allow users to manually unsubscribe to subscriptions by clicking on the unsubscribe link include in the subscription email. This new Web Application is "/api/pivotsubscriptionsunsubscribe". It allows unauthenticated access to a REST API that only allows users to unsubscribe if they have the specific URL. Depending on security settings, it may be necessary to give the application additional permissions. This can be accomplished in The Management Portal -> System Administration -> Security -> Applications -> Web Applications -> /api/pivotsubscriptionsunsubscribe -> Application Roles Tab. +These additional permissions include: +1) The Database Resource for the Database that contains the PivotSubscriptions Code +2) The Database Resource for the Database that contains the PivotSubscriptions Data +3) The Database Resource for the NameSpace's Default Globals Database where PivotSubscriptions is installed +Depending on your security settings and mapping configuration, this may be between 0 and 3 resources that are needed. + ### Optional: Custom Action The Piovt List page gives access to a list of Pivot Tables available to the user. From there, a Pivot Subscription can be added. However, if you would like to add a Pivot Subscription directly from Analyzer or from a Dashboard, you will need to configure a new Custom Action. In order to add the Custom Action, an Action Class is first needed. For more information, please see the documentation for defining custom actions. In your Action KPI, define the new action as: ``` From bcbc562b41b2705d33017ce557b3a9db144e2af3 Mon Sep 17 00:00:00 2001 From: psteiwer Date: Wed, 4 Mar 2020 14:30:05 -0500 Subject: [PATCH 27/28] Check if Subscription exists --- PivotSubscriptions/UI/Unsubscribe.cls | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PivotSubscriptions/UI/Unsubscribe.cls b/PivotSubscriptions/UI/Unsubscribe.cls index dffa5ca..8c9a433 100644 --- a/PivotSubscriptions/UI/Unsubscribe.cls +++ b/PivotSubscriptions/UI/Unsubscribe.cls @@ -16,7 +16,7 @@ ClassMethod Unsubscribe(pSubscriptionId, pEmail, pGUID) As %Status Set tResult={} Do tResult.%Set("Status",$$$ERROR($$$GeneralError,"Invalid Request")) - If ##class(PivotSubscriptions.Utils).CheckUnsubscribe(pSubscriptionId,pEmail,pGUID) { + If ##class(PivotSubscriptions.Subscription).%ExistsId(pSubscriptionId)&&##class(PivotSubscriptions.Utils).CheckUnsubscribe(pSubscriptionId,pEmail,pGUID) { Set tSubscription=##class(PivotSubscriptions.Subscription).%OpenId(pSubscriptionId) Set tSC=tSubscription.Unsubscribe(pEmail) If $$$ISERR(tSC) { From 875462a85cb6501a386254b7e89bc7213b3b4196 Mon Sep 17 00:00:00 2001 From: Peter Steiwer Date: Wed, 4 Mar 2020 14:31:22 -0500 Subject: [PATCH 28/28] Fix line break --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 41cf115..e65c082 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ These additional permissions include: 1) The Database Resource for the Database that contains the PivotSubscriptions Code 2) The Database Resource for the Database that contains the PivotSubscriptions Data 3) The Database Resource for the NameSpace's Default Globals Database where PivotSubscriptions is installed + Depending on your security settings and mapping configuration, this may be between 0 and 3 resources that are needed. ### Optional: Custom Action @@ -42,4 +43,4 @@ If (pAction="AddPivotSubscription") { } ``` -The ActionCommand Method will generate a command that will allow for the creation of the Pivot Subscription \ No newline at end of file +The ActionCommand Method will generate a command that will allow for the creation of the Pivot Subscription