Skip to content

Commit

Permalink
Merge pull request #95 from psteiwer/dev-v1.6
Browse files Browse the repository at this point in the history
Dev v1.6
  • Loading branch information
psteiwer authored Jan 29, 2021
2 parents c2103e2 + fbb1e2e commit 9691c41
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 16 deletions.
70 changes: 63 additions & 7 deletions PivotSubscriptions/Installer.cls
Original file line number Diff line number Diff line change
@@ -1,6 +1,55 @@
Class PivotSubscriptions.Installer
{

XData LocalInstall [ XMLNamespace = INSTALLER ]
{
<Manifest>
<Namespace Name="${NAMESPACE}" Create="no" Ensemble="0">
<Role
Name="PivotSubscriptionsUnsubscribe"
/>
<!--CSPApplication
Url="/api/pivotsubscriptionsunsubscribe"
Directory="${CSPDIR}"
DispatchClass="PivotSubscriptions.UI.Unsubscribe"
Grant="PivotSubscriptionsUnsubscribe"
AuthenticationMethods="64"
/-->
<Invoke Class="PivotSubscriptions.Installer" Method="ConfigureUnsubscribeWebApp" CheckStatus="1">
</Invoke>
<Import File="${APPPATH}/PivotSubscriptions/" Flags="ck" Recurse="1"/>
<Invoke Class="PivotSubscriptions.Installer" Method="ImportImage" CheckStatus="1">
<Arg Value="${APPPATH}/Assets/PivotSubscriptions_BookCover.png"/>
</Invoke>
<Invoke Class="PivotSubscriptions.Installer" Method="CreateBookCover" CheckStatus="1">
</Invoke>
<Invoke Class="PivotSubscriptions.Task" Method="ConfigureTask" CheckStatus="1">
</Invoke>
<Invoke Class="%SQL.Manager.API" Method="SaveObjPriv">
<Arg Value="s"/>
<Arg Value="1"/>
<Arg Value="PivotSubscriptions.EventLog"/>
<Arg Value="PivotSubscriptionsUnsubscribe"/>
<Arg Value="0"/>
<Arg Value="-1"/>
</Invoke>
</Namespace>
</Manifest>
}

ClassMethod setup(ByRef pVars, pLogLevel As %Integer = 3, pInstaller As %Installer.Installer, pLogger As %Installer.AbstractLogger) As %Status [ CodeMode = objectgenerator, Internal ]
{
#; Let XGL document generate code for this method.
Quit ##class(%Installer.Manifest).%Generate(%compiledclass,%code,"LocalInstall")
}

ClassMethod RunLocalInstall(pRootDir, pNamespace = {$Namespace}) As %Status
{
Set tVars("APPPATH")=pRootDir
Set tVars("NAMESPACE")=pNamespace
Quit ..setup(.tVars,3)
}

ClassMethod RunInstaller(pRootDir = "")
{
Set tSC=$$$OK
Expand All @@ -11,13 +60,7 @@ ClassMethod RunInstaller(pRootDir = "")
If $$$ISERR(tSC) Quit
}

Set tItem=##class(%DeepSee.UserLibrary.Link).%New()
Set tItem.fullName="Pivot Subscriptions"
Set tPage="PivotSubscriptions.UI.SubscriptionManager.zen"
Set tItem.href=$system.CSP.GetPortalApp($namespace,tPage)_tPage
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: {text:'"_##class(PivotSubscriptions.Utils).GetVersion()_"',style:'font-size:9px;top:179px;'},footer: {text:'$owner',style:'display: none;'}}"
Set tSC=tItem.%Save()
Set tSC=##class(PivotSubscriptions.Installer).CreateBookCover()
If $$$ISERR(tSC) Quit tSC

Set tSC=##class(PivotSubscriptions.Task).ConfigureTask()
Expand All @@ -29,6 +72,19 @@ ClassMethod RunInstaller(pRootDir = "")
Quit tSC
}

ClassMethod CreateBookCover() As %Status
{
Set tItem=##class(%DeepSee.UserLibrary.Link).%New()
Set tItem.fullName="Pivot Subscriptions"
Set tPage="PivotSubscriptions.UI.SubscriptionManager.zen"
Set tItem.href=$system.CSP.GetPortalApp($namespace,tPage)_tPage
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: {text:'"_##class(PivotSubscriptions.Utils).GetVersion()_"',style:'font-size:9px;top:179px;'},footer: {text:'$owner',style:'display: none;'}}"
Set tSC=tItem.%Save()

Quit tSC
}

/// Import Cover, code taken from %DeepSee.UI.Dialog.ImageUpload:%OnSubmit
ClassMethod ImportImage(pDir) As %Status
{
Expand Down
4 changes: 2 additions & 2 deletions PivotSubscriptions/Task.cls
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ ClassMethod SendEmail(pID, pSendNow As %Boolean = 0, pPivot As %String, pEmails
} 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",mdx)
Do ##class(PivotSubscriptions.Utils).TableErrorMessage(tSubscription,tEmail,pName,"TooLarge",mdx,tCustomFilter)
}
}

Expand All @@ -138,7 +138,7 @@ ClassMethod SendEmail(pID, pSendNow As %Boolean = 0, pPivot As %String, pEmails
Do ##class(PivotSubscriptions.Utils).WriteUnsubscribe(msg,tUnsubscribeList)
Do ##class(PivotSubscriptions.Utils).WriteEmailFooter(msg)

Do ##class(PivotSubscriptions.Utils).TableErrorMessage(tSubscription,tEmail,pName,"NoResults",mdx)
Do ##class(PivotSubscriptions.Utils).TableErrorMessage(tSubscription,tEmail,pName,"NoResults",mdx,tCustomFilter)
}

// Send email
Expand Down
8 changes: 7 additions & 1 deletion PivotSubscriptions/UI/Dialog/EditSubscription.cls
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ XData dialogBody [ XMLNamespace = "http://www.intersystems.com/zen" ]
<image src="deepsee/ds2_magnify_18.png" width="16" height="16" title="Add custom filter" onclick="zenPage.customFilter();"/>
</vgroup>
</hgroup>
<expando caption="Custom Email" expanded="false">
<expando id="CustomEmailExpando" caption="Custom Email" expanded="false">
<textarea id="CustomEmailText" label="Custom Email Text. Included before Pivot Table in Email." cols="50" rows="5"/>
</expando>
</pane>
Expand Down Expand Up @@ -90,6 +90,12 @@ Method %OnAfterCreatePage() As %Status
Do ..CustomFilters.SetAt(tVal,tKey)
Set tVal=tSubscription.CustomFilters.GetNext(.tKey)
}

// Expand Custom Email Expando if CustomEmailText is populated
If tSubscription.CustomEmailText'="" {
Set tCustomEmailExpando=..%GetComponentById("CustomEmailExpando")
Set tCustomEmailExpando.expanded=1
}
}

Set tTable=..%GetComponentById("PivotTable")
Expand Down
13 changes: 10 additions & 3 deletions PivotSubscriptions/UI/EventLogViewer.cls
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@ XData contentPane [ XMLNamespace = "http://www.intersystems.com/zen" ]
<tablePane id="tablePane"
cellSpacing="2"
fixedHeaders="false"
queryClass="PivotSubscriptions.EventLog"
queryName="GetEventsForUI"
tableName="PivotSubscriptions.EventLog"
orderByClause="ID DESC"
useSnapshot="true"
showQuery="false"
showZebra="true"
showRowNumbers="false"
pageSize="50"
maxRows="1000"
>
<column colName="Details" onclick="zenPage.viewDetails(#(%query.Details)#)" linkCaption="Details" link="#"/>
<column colName="ID" header="Details" onclick="zenPage.viewDetails(#(%query.ID)#)" linkCaption="Details" link="#"/>
<column colName="StartTime" filterType="text" filterOp="UP["/>
<column colName="EndTime" filterType="text" filterOp="UP["/>
<column colName="EventType" filterType="text" filterOp="UP["/>
<column colName="UserName" filterType="text" filterOp="UP["/>
<column colName="Name" filterType="text" filterOp="UP["/>
<column colName="Emails" filterType="text" filterOp="UP["/>
<column colName="Status" filterType="text" filterOp="UP["/>
</tablePane>
</vgroup>
</hgroup>
Expand Down
7 changes: 6 additions & 1 deletion PivotSubscriptions/UI/PivotList.cls
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ Method ExecuteRS(pRS As %ResultSet, Output pSC As %Status, pInfo As %ZEN.Auxilia

ClientMethod launchAddSubscription(pivotName) [ Language = javascript ]
{
var url=zenLink('PivotSubscriptions.UI.Dialog.EditSubscription.zen')+'?SUBSCRIPTIONID=0&PIVOTNAME='+encodeURIComponent(pivotName);
var url=zenLink('PivotSubscriptions.UI.Dialog.EditSubscription.zen')
var paramChar="?"
if (url.indexOf("?")>-1) {
paramChar="&"
}
url=url+paramChar+'SUBSCRIPTIONID=0&PIVOTNAME='+encodeURIComponent(pivotName);
zenPage.launchPopupWindow(url,'Add Subscription','status,scrollbars,resizable,width=700,height=575');
}

Expand Down
17 changes: 15 additions & 2 deletions PivotSubscriptions/Utils.cls
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Class PivotSubscriptions.Utils

ClassMethod GetVersion() As %String
{
Quit "v1.5.0"
Quit "v1.6.0"
}

/// Utility method for saving and updating global variables
Expand Down Expand Up @@ -169,6 +169,15 @@ ClassMethod WriteEmail(pSubscription As PivotSubscriptions.Subscription, pMsg As
} ElseIf (($Find(tLine,"<x"))||($Find(tLine,"</x"))||($Find(tLine,"<body>"))||($Find(tLine,"<html>"))||(tLine="</html>")) {
Continue
} Else {
// If 'Short Date' exists, the time value has been changed to excel format
If ($Find(tLine,"'Short Date'")) {
Set tTimeStartPos=$Find(tLine,"'Short Date'")+2
Set tTimeEndPos=$Find(tLine,"<",tTimeStartPos)-2
Set tTime=$E(tLine,tTimeStartPos,tTimeEndPos)
Set tTime=tTime+$ZDateH("12/30/1899")
// Insert the new date display, using the default DeepSee date display option
Set tLine=$E(tLine,1,tTimeStartPos-1)_$ZDate(tTime,6)_$E(tLine,tTimeEndPos+1,*)
}
Do pMsg.TextData.WriteLine(tLine)
}
}
Expand All @@ -181,7 +190,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, pMDX As %String) As %Status
ClassMethod TableErrorMessage(pSubscription As PivotSubscriptions.Subscription, pEmail As %String, pName As %String, pReason As %String, pMDX As %String, pCustomFilter As %String = "") As %Status
{
Set tAdminEmail=##class(PivotSubscriptions.Utils).GetSettings("AdminEmail")
Set tLog=##class(PivotSubscriptions.EventLog).CreateEvent("tableError",pSubscription.%Id(),$username,pSubscription.Pivot,pSubscription.DayOfWeek,pSubscription.Hour,pSubscription.Minute,pSubscription.Format,tAdminEmail,pName,pSubscription.RunOnce,.pEvent)
Expand Down Expand Up @@ -210,6 +219,10 @@ ClassMethod TableErrorMessage(pSubscription As PivotSubscriptions.Subscription,
Do tMsg.TextData.WriteLine("<br>Please check the <i>Subscription Manager</i>.")
Do tMsg.TextData.WriteLine("<br/><br/>MDX Executed:")
Do tMsg.TextData.WriteLine(pMDX)
If pCustomFilter'="" {
Do tMsg.TextData.WriteLine("<br/><br/>Custom Filter:")
Do tMsg.TextData.WriteLine(pCustomFilter)
}
Do ##class(PivotSubscriptions.Utils).WriteEmailFooter(tMsg)

// Set recipient of email
Expand Down

0 comments on commit 9691c41

Please sign in to comment.