@plutonhq/core-backend 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/createApp.js +1 -1
- package/dist/createApp.js.map +1 -1
- package/dist/notifications/BackupNotification.d.ts +2 -0
- package/dist/notifications/BackupNotification.d.ts.map +1 -1
- package/dist/notifications/BackupNotification.js +1 -1
- package/dist/notifications/BackupNotification.js.map +1 -1
- package/dist/notifications/BaseNotification.d.ts.map +1 -1
- package/dist/notifications/BaseNotification.js +1 -1
- package/dist/notifications/BaseNotification.js.map +1 -1
- package/dist/notifications/channels/NotificationChannelResolver.d.ts +2 -2
- package/dist/notifications/channels/NotificationChannelResolver.d.ts.map +1 -1
- package/dist/notifications/channels/NotificationChannelResolver.js +1 -1
- package/dist/notifications/channels/NotificationChannelResolver.js.map +1 -1
- package/dist/notifications/channels/SMTPChannel.js.map +1 -1
- package/dist/notifications/templateLoader.d.ts +15 -0
- package/dist/notifications/templateLoader.d.ts.map +1 -0
- package/dist/notifications/templateLoader.js +1 -0
- package/dist/notifications/templateLoader.js.map +1 -0
- package/dist/notifications/templates/email/backup/BackupFailedNotification.d.ts.map +1 -1
- package/dist/notifications/templates/email/backup/BackupFailedNotification.ejs +109 -0
- package/dist/notifications/templates/email/backup/BackupFailedNotification.js +1 -1
- package/dist/notifications/templates/email/backup/BackupFailedNotification.js.map +1 -1
- package/dist/notifications/templates/email/backup/BackupFailedNotification.ts +110 -0
- package/dist/notifications/templates/email/backup/BackupStartedNotification.d.ts.map +1 -1
- package/dist/notifications/templates/email/backup/BackupStartedNotification.ejs +159 -0
- package/dist/notifications/templates/email/backup/BackupStartedNotification.js +1 -1
- package/dist/notifications/templates/email/backup/BackupStartedNotification.js.map +1 -1
- package/dist/notifications/templates/email/backup/BackupStartedNotification.ts +87 -0
- package/dist/notifications/templates/email/backup/BackupSuccessNotification.d.ts.map +1 -1
- package/dist/notifications/templates/email/backup/BackupSuccessNotification.ejs +163 -0
- package/dist/notifications/templates/email/backup/BackupSuccessNotification.js +1 -1
- package/dist/notifications/templates/email/backup/BackupSuccessNotification.js.map +1 -1
- package/dist/notifications/templates/email/backup/BackupSuccessNotification.ts +97 -0
- package/dist/notifications/templates/email/email.html +801 -0
- package/dist/notifications/templates/email/test-email/TestEmailNotification.ts +27 -0
- package/dist/services/SettingsService.d.ts +2 -0
- package/dist/services/SettingsService.d.ts.map +1 -1
- package/dist/services/SettingsService.js +1 -1
- package/dist/services/SettingsService.js.map +1 -1
- package/dist/stores/PlanStore.d.ts.map +1 -1
- package/dist/stores/PlanStore.js +1 -1
- package/dist/stores/PlanStore.js.map +1 -1
- package/dist/stores/SettingsStore.d.ts +3 -1
- package/dist/stores/SettingsStore.d.ts.map +1 -1
- package/dist/stores/SettingsStore.js +1 -1
- package/dist/stores/SettingsStore.js.map +1 -1
- package/dist/types/notifications.d.ts +11 -0
- package/dist/types/notifications.d.ts.map +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
<div>
|
|
2
|
+
<div class="center">
|
|
3
|
+
<h2 class="title title-success">
|
|
4
|
+
🚀 <a href="<%= appUrl %>/plan/<%= plan.id %>"><%= plan.title %></a> Successfully Started!
|
|
5
|
+
</h2>
|
|
6
|
+
</div>
|
|
7
|
+
<!-- Basic Summary Info -->
|
|
8
|
+
<div class="backupSummary">
|
|
9
|
+
<div class="backupSummary_basic">
|
|
10
|
+
<table role="presentation" cellpadding="0" cellspacing="0">
|
|
11
|
+
<tr class="backupSummary_title">
|
|
12
|
+
<td style="text-align: left">
|
|
13
|
+
<i class="img-icon">
|
|
14
|
+
<img
|
|
15
|
+
width="14"
|
|
16
|
+
height="14"
|
|
17
|
+
src="https://pluton.b-cdn.net/email/uploading.png"
|
|
18
|
+
style="vertical-align: middle"
|
|
19
|
+
/>
|
|
20
|
+
</i>
|
|
21
|
+
<strong>Backing Up <%= plan.sourceConfig.includes.length || 0 %> sources</strong>
|
|
22
|
+
</td>
|
|
23
|
+
<td style="text-align: left"></td>
|
|
24
|
+
<td style="text-align: right">
|
|
25
|
+
<i class="img-icon"
|
|
26
|
+
><img
|
|
27
|
+
width="12"
|
|
28
|
+
height="12"
|
|
29
|
+
src="https://pluton.b-cdn.net/email/hourglass.png"
|
|
30
|
+
style="vertical-align: middle"
|
|
31
|
+
/></i>
|
|
32
|
+
<strong>In Progress</strong>
|
|
33
|
+
</td>
|
|
34
|
+
</tr>
|
|
35
|
+
<tr class="backupSummary_details">
|
|
36
|
+
<td style="text-align: left">
|
|
37
|
+
<span><strong><%= deviceName %></strong></span>
|
|
38
|
+
<span>Device</span>
|
|
39
|
+
</td>
|
|
40
|
+
<td style="text-align: center; width: 4%">
|
|
41
|
+
<span class="backupSummary_arrow">➝</span>
|
|
42
|
+
</td>
|
|
43
|
+
<td style="text-align: right">
|
|
44
|
+
<span><strong><%= storageName %></strong></span>
|
|
45
|
+
<span><%= storageTypeName %></span>
|
|
46
|
+
</td>
|
|
47
|
+
</tr>
|
|
48
|
+
</table>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
51
|
+
<!-- Basic Date and Time -->
|
|
52
|
+
<div class="backupDateTime">
|
|
53
|
+
<table role="presentation" cellpadding="0" cellspacing="0">
|
|
54
|
+
<tr class="backupSummary_date">
|
|
55
|
+
<td style="text-align: left">
|
|
56
|
+
<i class="img-icon"
|
|
57
|
+
><img width="14" height="14" src="https://pluton.b-cdn.net/email/clock.png"
|
|
58
|
+
/></i>
|
|
59
|
+
Started At:
|
|
60
|
+
</td>
|
|
61
|
+
<td style="text-align: right"><%= startDate %></td>
|
|
62
|
+
</tr>
|
|
63
|
+
<tr class="backupSummary_date">
|
|
64
|
+
<td style="text-align: left">
|
|
65
|
+
<i class="img-icon"
|
|
66
|
+
><img width="14" height="14" src="https://pluton.b-cdn.net/email/check.png"
|
|
67
|
+
/></i>
|
|
68
|
+
Completed At:
|
|
69
|
+
</td>
|
|
70
|
+
<td style="text-align: right">In Progress</td>
|
|
71
|
+
</tr>
|
|
72
|
+
</table>
|
|
73
|
+
</div>
|
|
74
|
+
<div class="backupDetails">
|
|
75
|
+
<table cellpadding="0" cellspacing="0" width="100%">
|
|
76
|
+
<tr>
|
|
77
|
+
<td align="center">
|
|
78
|
+
<table
|
|
79
|
+
cellpadding="0"
|
|
80
|
+
cellspacing="0"
|
|
81
|
+
width="600"
|
|
82
|
+
style="max-width: 600px"
|
|
83
|
+
class="backupDetailsColumnsWrapper"
|
|
84
|
+
>
|
|
85
|
+
<tr>
|
|
86
|
+
<td valign="top" width="50%" class="backupDetailsColumn" style="padding-right: 10px">
|
|
87
|
+
<table cellpadding="20" cellspacing="0" width="100%" class="backupDetailsCard">
|
|
88
|
+
<tr>
|
|
89
|
+
<td class="backupDetailsCardContent">
|
|
90
|
+
<h4 class="backupDetailsTitle"><i class="icon">ılı</i> BACKUP STATS</h4>
|
|
91
|
+
|
|
92
|
+
<table cellpadding="0" cellspacing="0" width="100%">
|
|
93
|
+
<tr>
|
|
94
|
+
<td width="50%" class="backupDetailsStat">
|
|
95
|
+
<p class="backupDetailsValue">
|
|
96
|
+
<%= formatBytes(stats.total_bytes_processed || 0) %>
|
|
97
|
+
</p>
|
|
98
|
+
<p class="backupDetailsLabel">Backup Size</p>
|
|
99
|
+
</td>
|
|
100
|
+
<td width="50%" class="backupDetailsStat">
|
|
101
|
+
<p class="backupDetailsValue">
|
|
102
|
+
<%= formatNumberToK(stats.total_files_processed || 0) %>
|
|
103
|
+
</p>
|
|
104
|
+
<p class="backupDetailsLabel">Total Files</p>
|
|
105
|
+
</td>
|
|
106
|
+
</tr>
|
|
107
|
+
</table>
|
|
108
|
+
</td>
|
|
109
|
+
</tr>
|
|
110
|
+
</table>
|
|
111
|
+
</td>
|
|
112
|
+
|
|
113
|
+
<td valign="top" width="50%" class="backupDetailsColumn" style="padding-left: 10px">
|
|
114
|
+
<table cellpadding="20" cellspacing="0" width="100%" class="backupDetailsCard">
|
|
115
|
+
<tr>
|
|
116
|
+
<td class="backupDetailsCardContent">
|
|
117
|
+
<h4 class="backupDetailsTitle"><i class="icon">⇄</i> FILES CHANGED (EST.)</h4>
|
|
118
|
+
|
|
119
|
+
<table cellpadding="0" cellspacing="0" width="100%">
|
|
120
|
+
<tr>
|
|
121
|
+
<td width="33.33%" class="backupDetailsChange">
|
|
122
|
+
<p class="backupDetailsValue">
|
|
123
|
+
<%= formatNumberToK((stats?.files_new || 0) + (stats?.dirs_new || 0))
|
|
124
|
+
%>
|
|
125
|
+
</p>
|
|
126
|
+
<p class="backupDetailsLabel">New</p>
|
|
127
|
+
</td>
|
|
128
|
+
<td width="33.33%" class="backupDetailsChange">
|
|
129
|
+
<p class="backupDetailsValue">
|
|
130
|
+
<%= formatNumberToK((stats?.files_changed || 0) + (stats?.dirs_changed
|
|
131
|
+
|| 0)) %>
|
|
132
|
+
</p>
|
|
133
|
+
<p class="backupDetailsLabel">Modified</p>
|
|
134
|
+
</td>
|
|
135
|
+
<td width="33.33%" class="backupDetailsChange">
|
|
136
|
+
<p class="backupDetailsValue">0</p>
|
|
137
|
+
<p class="backupDetailsLabel">Removed</p>
|
|
138
|
+
</td>
|
|
139
|
+
</tr>
|
|
140
|
+
</table>
|
|
141
|
+
</td>
|
|
142
|
+
</tr>
|
|
143
|
+
</table>
|
|
144
|
+
</td>
|
|
145
|
+
</tr>
|
|
146
|
+
</table>
|
|
147
|
+
</td>
|
|
148
|
+
</tr>
|
|
149
|
+
</table>
|
|
150
|
+
</div>
|
|
151
|
+
<!-- Notification Settings Info -->
|
|
152
|
+
<div class="center notificationMsg">
|
|
153
|
+
<p>
|
|
154
|
+
You are receiving this email because you've enabled Email Notification for this backup Plan.
|
|
155
|
+
You can customize the Notification Settings
|
|
156
|
+
<a href="<%= appUrl %>/plan/<%= plan.id %>/?settings">here</a>.
|
|
157
|
+
</p>
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import ejs from"ejs";import
|
|
1
|
+
import ejs from"ejs";import{configService}from"../../../../services/ConfigService";import{providers}from"../../../../utils/providers";import{formatBytes,formatNumberToK}from"../../../../utils/formatter";import{BaseNotification}from"../../../BaseNotification";import{loadBackupTemplate}from"../../../templateLoader";export class BackupStartedNotification extends BaseNotification{constructor(data){super(),this.subject=`Backup Started: ${data.plan.title}`,this.contentType=data.output||"html",this.content=this.buildContent(data)}buildContent(data){return"json"===this.contentType?this.buildJSONContent(data):this.buildHTMLContent(data)}buildJSONContent(data){const{appTitle:appTitle,deviceName:deviceName,storageName:storageName,storageType:storageType,plan:plan,stats:stats,startTime:startTime}=data,payload={appTitle:appTitle,deviceName:deviceName,storageName:storageName,storageType:storageType,storagePath:plan.storagePath||"",stats:stats,startTime:startTime,planID:plan.id,planTitle:plan.title,planType:plan.method,planSource:{included:plan.sourceConfig?.includes.join(", ")||"",excluded:plan.sourceConfig?.excludes.join(", ")||""},eventName:"backup_started"};return JSON.stringify(payload)}buildHTMLContent(data){const startDate=new Date(data.startTime?data.startTime:0).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric"}),storageTypeName=data.storageType?providers[data.storageType]?.name||data.storageType:"",templateString=loadBackupTemplate("BackupStartedNotification.ejs"),renderedBody=ejs.render(templateString,{...data,appUrl:configService.config.APP_URL,storageTypeName:storageTypeName,startDate:startDate,formatBytes:formatBytes,formatNumberToK:formatNumberToK});return this.applyEmailTemplate(renderedBody,{appTitle:configService.config.APP_TITLE||"Pluton",preHeader:`Backup Started: ${data.plan.title}`})}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackupStartedNotification.js","sourceRoot":"","sources":["../../../../../src/notifications/templates/email/backup/BackupStartedNotification.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"BackupStartedNotification.js","sourceRoot":"","sources":["../../../../../src/notifications/templates/email/backup/BackupStartedNotification.ts"],"names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AI,CAAC,KAAK,EAAE;SAC/C,CAAC,CAAC;IACJ,CAAC;CACD"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import ejs from 'ejs';
|
|
2
|
+
import { configService } from '../../../../services/ConfigService';
|
|
3
|
+
import { Plan } from '../../../../db/schema/plans';
|
|
4
|
+
import { providers } from '../../../../utils/providers';
|
|
5
|
+
import { BackupNotificationJSONPayload, BackupTaskStats } from '../../../../types/backups';
|
|
6
|
+
import { formatBytes, formatNumberToK } from '../../../../utils/formatter';
|
|
7
|
+
import { BaseNotification } from '../../../BaseNotification';
|
|
8
|
+
import { loadBackupTemplate } from '../../../templateLoader';
|
|
9
|
+
|
|
10
|
+
export interface BackupStartedPayload {
|
|
11
|
+
appTitle: string;
|
|
12
|
+
deviceName: string;
|
|
13
|
+
storageName: string;
|
|
14
|
+
storageType: string;
|
|
15
|
+
plan: Plan;
|
|
16
|
+
startTime: Date;
|
|
17
|
+
stats?: BackupTaskStats;
|
|
18
|
+
output?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class BackupStartedNotification extends BaseNotification {
|
|
22
|
+
constructor(data: BackupStartedPayload) {
|
|
23
|
+
super();
|
|
24
|
+
this.subject = `Backup Started: ${data.plan.title}`;
|
|
25
|
+
this.contentType = data.output || 'html';
|
|
26
|
+
this.content = this.buildContent(data);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
buildContent(data: BackupStartedPayload): string {
|
|
30
|
+
if (this.contentType === 'json') {
|
|
31
|
+
return this.buildJSONContent(data);
|
|
32
|
+
}
|
|
33
|
+
return this.buildHTMLContent(data);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
protected buildJSONContent(data: BackupStartedPayload): string {
|
|
37
|
+
const { appTitle, deviceName, storageName, storageType, plan, stats, startTime } = data;
|
|
38
|
+
const payload: BackupNotificationJSONPayload = {
|
|
39
|
+
appTitle,
|
|
40
|
+
deviceName,
|
|
41
|
+
storageName,
|
|
42
|
+
storageType,
|
|
43
|
+
storagePath: plan.storagePath || '',
|
|
44
|
+
stats,
|
|
45
|
+
startTime,
|
|
46
|
+
planID: plan.id,
|
|
47
|
+
planTitle: plan.title,
|
|
48
|
+
planType: plan.method,
|
|
49
|
+
planSource: {
|
|
50
|
+
included: plan.sourceConfig?.includes.join(', ') || '',
|
|
51
|
+
excluded: plan.sourceConfig?.excludes.join(', ') || '',
|
|
52
|
+
},
|
|
53
|
+
eventName: 'backup_started',
|
|
54
|
+
};
|
|
55
|
+
return JSON.stringify(payload);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
protected buildHTMLContent(data: BackupStartedPayload): string {
|
|
59
|
+
// Generate the Email Body
|
|
60
|
+
const startDate = new Date(data.startTime ? data.startTime : 0).toLocaleDateString('en-US', {
|
|
61
|
+
year: 'numeric',
|
|
62
|
+
month: 'long',
|
|
63
|
+
day: 'numeric',
|
|
64
|
+
hour: 'numeric',
|
|
65
|
+
minute: 'numeric',
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const storageTypeName = data.storageType
|
|
69
|
+
? providers[data.storageType]?.name || data.storageType
|
|
70
|
+
: '';
|
|
71
|
+
|
|
72
|
+
const templateString = loadBackupTemplate('BackupStartedNotification.ejs');
|
|
73
|
+
const renderedBody = ejs.render(templateString, {
|
|
74
|
+
...data,
|
|
75
|
+
appUrl: configService.config.APP_URL,
|
|
76
|
+
storageTypeName,
|
|
77
|
+
startDate,
|
|
78
|
+
formatBytes,
|
|
79
|
+
formatNumberToK,
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return this.applyEmailTemplate(renderedBody, {
|
|
83
|
+
appTitle: configService.config.APP_TITLE || 'Pluton',
|
|
84
|
+
preHeader: `Backup Started: ${data.plan.title}`,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackupSuccessNotification.d.ts","sourceRoot":"","sources":["../../../../../src/notifications/templates/email/backup/BackupSuccessNotification.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BackupSuccessNotification.d.ts","sourceRoot":"","sources":["../../../../../src/notifications/templates/email/backup/BackupSuccessNotification.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAEnD,OAAO,EAAE,qBAAqB,EAAiC,MAAM,2BAA2B,CAAC;AAEjG,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAG7D,MAAM,WAAW,gCAAgC;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,IAAI,CAAC;IAChB,OAAO,EAAE,IAAI,CAAC;IACd,KAAK,CAAC,EAAE,qBAAqB,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CAClC;AAED,qBAAa,yBAA0B,SAAQ,gBAAgB;gBAClD,IAAI,EAAE,gCAAgC;IAOlD,SAAS,CAAC,YAAY,CAAC,IAAI,EAAE,gCAAgC,GAAG,MAAM;IAOtE,SAAS,CAAC,gBAAgB,CAAC,IAAI,EAAE,gCAAgC,GAAG,MAAM;IAwB1E,SAAS,CAAC,gBAAgB,CAAC,IAAI,EAAE,gCAAgC,GAAG,MAAM;CAoC1E"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
<div>
|
|
2
|
+
<div class="center">
|
|
3
|
+
<h2 class="title title-success">
|
|
4
|
+
<i class="img-icon icon--check"
|
|
5
|
+
><img width="14" height="14" src="https://pluton.b-cdn.net/email/check-white.png"
|
|
6
|
+
/></i>
|
|
7
|
+
<a href="<%= appUrl %>/plan/<%= plan.id %>"><%= plan.title %></a> Successfully Completed!
|
|
8
|
+
</h2>
|
|
9
|
+
</div>
|
|
10
|
+
<!-- Basic Summary Info -->
|
|
11
|
+
<div class="backupSummary">
|
|
12
|
+
<div class="backupSummary_basic">
|
|
13
|
+
<table role="presentation" cellpadding="0" cellspacing="0">
|
|
14
|
+
<tr class="backupSummary_title">
|
|
15
|
+
<td style="text-align: left">
|
|
16
|
+
<i class="img-icon">
|
|
17
|
+
<img
|
|
18
|
+
width="14"
|
|
19
|
+
height="14"
|
|
20
|
+
src="https://pluton.b-cdn.net/email/uploading.png"
|
|
21
|
+
style="vertical-align: middle"
|
|
22
|
+
/>
|
|
23
|
+
</i>
|
|
24
|
+
<strong>Backed Up <%= plan.sourceConfig.includes.length || 0 %> sources</strong>
|
|
25
|
+
</td>
|
|
26
|
+
<td style="text-align: left"></td>
|
|
27
|
+
<td style="text-align: right">
|
|
28
|
+
<i class="img-icon"
|
|
29
|
+
><img
|
|
30
|
+
width="12"
|
|
31
|
+
height="12"
|
|
32
|
+
src="https://pluton.b-cdn.net/email/hourglass.png"
|
|
33
|
+
style="vertical-align: middle"
|
|
34
|
+
/></i>
|
|
35
|
+
Duration:
|
|
36
|
+
<strong><%= formatDuration(stats?.total_duration || 0) %></strong>
|
|
37
|
+
</td>
|
|
38
|
+
</tr>
|
|
39
|
+
<tr class="backupSummary_details">
|
|
40
|
+
<td style="text-align: left">
|
|
41
|
+
<span><strong><%= deviceName %></strong></span>
|
|
42
|
+
<span>Device</span>
|
|
43
|
+
</td>
|
|
44
|
+
<td style="text-align: center; width: 4%">
|
|
45
|
+
<span class="backupSummary_arrow">➝</span>
|
|
46
|
+
</td>
|
|
47
|
+
<td style="text-align: right">
|
|
48
|
+
<span><strong><%= storageName %></strong></span>
|
|
49
|
+
<span><%= storageTypeName %></span>
|
|
50
|
+
</td>
|
|
51
|
+
</tr>
|
|
52
|
+
</table>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
<!-- Basic Date and Time -->
|
|
56
|
+
<div class="backupDateTime">
|
|
57
|
+
<table role="presentation" cellpadding="0" cellspacing="0">
|
|
58
|
+
<tr class="backupSummary_date">
|
|
59
|
+
<td style="text-align: left">
|
|
60
|
+
<i class="img-icon"
|
|
61
|
+
><img width="14" height="14" src="https://pluton.b-cdn.net/email/clock.png"
|
|
62
|
+
/></i>
|
|
63
|
+
Started At:
|
|
64
|
+
</td>
|
|
65
|
+
<td style="text-align: right"><%= startDate %></td>
|
|
66
|
+
</tr>
|
|
67
|
+
<tr class="backupSummary_date">
|
|
68
|
+
<td style="text-align: left">
|
|
69
|
+
<i class="img-icon"
|
|
70
|
+
><img width="14" height="14" src="https://pluton.b-cdn.net/email/check.png"
|
|
71
|
+
/></i>
|
|
72
|
+
Completed At:
|
|
73
|
+
</td>
|
|
74
|
+
<td style="text-align: right"><%= endDate %></td>
|
|
75
|
+
</tr>
|
|
76
|
+
</table>
|
|
77
|
+
</div>
|
|
78
|
+
<div class="backupDetails">
|
|
79
|
+
<table cellpadding="0" cellspacing="0" width="100%">
|
|
80
|
+
<tr>
|
|
81
|
+
<td align="center">
|
|
82
|
+
<table
|
|
83
|
+
cellpadding="0"
|
|
84
|
+
cellspacing="0"
|
|
85
|
+
width="600"
|
|
86
|
+
style="max-width: 600px"
|
|
87
|
+
class="backupDetailsColumnsWrapper"
|
|
88
|
+
>
|
|
89
|
+
<tr>
|
|
90
|
+
<td valign="top" width="50%" class="backupDetailsColumn" style="padding-right: 10px">
|
|
91
|
+
<table cellpadding="20" cellspacing="0" width="100%" class="backupDetailsCard">
|
|
92
|
+
<tr>
|
|
93
|
+
<td class="backupDetailsCardContent">
|
|
94
|
+
<h4 class="backupDetailsTitle"><i class="icon">ılı</i> BACKUP STATS</h4>
|
|
95
|
+
|
|
96
|
+
<table cellpadding="0" cellspacing="0" width="100%">
|
|
97
|
+
<tr>
|
|
98
|
+
<td width="50%" class="backupDetailsStat">
|
|
99
|
+
<p class="backupDetailsValue">
|
|
100
|
+
<%= formatBytes(stats.total_bytes_processed || 0) %>
|
|
101
|
+
</p>
|
|
102
|
+
<p class="backupDetailsLabel">Backup Size</p>
|
|
103
|
+
</td>
|
|
104
|
+
<td width="50%" class="backupDetailsStat">
|
|
105
|
+
<p class="backupDetailsValue">
|
|
106
|
+
<%= formatNumberToK(stats.total_files_processed || 0) %>
|
|
107
|
+
</p>
|
|
108
|
+
<p class="backupDetailsLabel">Total Files</p>
|
|
109
|
+
</td>
|
|
110
|
+
</tr>
|
|
111
|
+
</table>
|
|
112
|
+
</td>
|
|
113
|
+
</tr>
|
|
114
|
+
</table>
|
|
115
|
+
</td>
|
|
116
|
+
|
|
117
|
+
<td valign="top" width="50%" class="backupDetailsColumn" style="padding-left: 10px">
|
|
118
|
+
<table cellpadding="20" cellspacing="0" width="100%" class="backupDetailsCard">
|
|
119
|
+
<tr>
|
|
120
|
+
<td class="backupDetailsCardContent">
|
|
121
|
+
<h4 class="backupDetailsTitle"><i class="icon">⇄</i> FILES CHANGED</h4>
|
|
122
|
+
|
|
123
|
+
<table cellpadding="0" cellspacing="0" width="100%">
|
|
124
|
+
<tr>
|
|
125
|
+
<td width="33.33%" class="backupDetailsChange">
|
|
126
|
+
<p class="backupDetailsValue">
|
|
127
|
+
<%= formatNumberToK((stats?.files_new || 0) + (stats?.dirs_new || 0))
|
|
128
|
+
%>
|
|
129
|
+
</p>
|
|
130
|
+
<p class="backupDetailsLabel">New</p>
|
|
131
|
+
</td>
|
|
132
|
+
<td width="33.33%" class="backupDetailsChange">
|
|
133
|
+
<p class="backupDetailsValue">
|
|
134
|
+
<%= formatNumberToK((stats?.files_changed || 0) + (stats?.dirs_changed
|
|
135
|
+
|| 0)) %>
|
|
136
|
+
</p>
|
|
137
|
+
<p class="backupDetailsLabel">Modified</p>
|
|
138
|
+
</td>
|
|
139
|
+
<td width="33.33%" class="backupDetailsChange">
|
|
140
|
+
<p class="backupDetailsValue">0</p>
|
|
141
|
+
<p class="backupDetailsLabel">Removed</p>
|
|
142
|
+
</td>
|
|
143
|
+
</tr>
|
|
144
|
+
</table>
|
|
145
|
+
</td>
|
|
146
|
+
</tr>
|
|
147
|
+
</table>
|
|
148
|
+
</td>
|
|
149
|
+
</tr>
|
|
150
|
+
</table>
|
|
151
|
+
</td>
|
|
152
|
+
</tr>
|
|
153
|
+
</table>
|
|
154
|
+
</div>
|
|
155
|
+
<!-- Notification Settings Info -->
|
|
156
|
+
<div class="center notificationMsg">
|
|
157
|
+
<p>
|
|
158
|
+
You are receiving this email because you've enabled Email Notification for this backup Plan.
|
|
159
|
+
You can customize the Notification Settings
|
|
160
|
+
<a href="<%= appUrl %>/plan/<%= plan.id %>/?settings">here</a>.
|
|
161
|
+
</p>
|
|
162
|
+
</div>
|
|
163
|
+
</div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import ejs from"ejs";import
|
|
1
|
+
import ejs from"ejs";import{configService}from"../../../../services/ConfigService";import{providers}from"../../../../utils/providers";import{formatBytes,formatDuration,formatNumberToK}from"../../../../utils/formatter";import{BaseNotification}from"../../../BaseNotification";import{loadBackupTemplate}from"../../../templateLoader";export class BackupSuccessNotification extends BaseNotification{constructor(data){super(),this.subject=`Backup Complete: ${data.plan.title}`,this.contentType=data.output||"html",this.content=this.buildContent(data)}buildContent(data){return"json"===this.contentType?this.buildJSONContent(data):this.buildHTMLContent(data)}buildJSONContent(data){const{appTitle:appTitle,deviceName:deviceName,storageName:storageName,storageType:storageType,plan:plan,stats:stats,startTime:startTime,endTime:endTime}=data,payload={appTitle:appTitle,deviceName:deviceName,storageName:storageName,storageType:storageType,storagePath:plan.storagePath||"",stats:stats,startTime:startTime,endTime:endTime,planID:plan.id,planTitle:plan.title,planType:plan.method,planSource:{included:plan.sourceConfig?.includes.join(", ")||"",excluded:plan.sourceConfig?.excludes.join(", ")||""},eventName:"backup_success"};return JSON.stringify(payload)}buildHTMLContent(data){const startDate=new Date(data.startTime?data.startTime:0).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric"}),endDate=new Date(data.endTime?data.endTime:0).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric"}),storageTypeName=data.storageType?providers[data.storageType]?.name||data.storageType:"",templateString=loadBackupTemplate("BackupSuccessNotification.ejs"),renderedBody=ejs.render(templateString,{...data,appUrl:configService.config.APP_URL,storageTypeName:storageTypeName,startDate:startDate,endDate:endDate,formatBytes:formatBytes,formatDuration:formatDuration,formatNumberToK:formatNumberToK});return this.applyEmailTemplate(renderedBody,{appTitle:configService.config.APP_TITLE||"Pluton",preHeader:`Backup Success: ${data.plan.title}`})}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BackupSuccessNotification.js","sourceRoot":"","sources":["../../../../../src/notifications/templates/email/backup/BackupSuccessNotification.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"BackupSuccessNotification.js","sourceRoot":"","sources":["../../../../../src/notifications/templates/email/backup/BackupSuccessNotification.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAEnE,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC3F,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAc7D,MAAM,OAAO,yBAA0B,SAAQ,gBAAgB;IAC9D,YAAY,IAAsC;QACjD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,oBAAoB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QACrD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC;QACzC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IACxC,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AAI,EAAE,SAAS;YACf,MAAM,EAAE,SAAS;SACjB,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,kBAAkB,CAAC,OAAO,EAAE;YACrF,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,MAAM;YACb,GAAG,EAAE,SAAS;YACd,IAAI,EAAE,SAAS;YACf,MAAM,EAAE,SAAS;SACjB,CAAC,CAAC;QACH,MAAM,eAAe,GAAG,IAAI,CAAC,WAAW;YACvC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,IAAI,IAAI,IAAI,CAAC,WAAW;YACvD,CAAC,CAAC,EAAE,CAAC;QACN,MAAM,cAAc,GAAG,kBAAkB,CAAC,+BAA+B,CAAC,CAAC;QAC3E,MAAM,YAAY,GAAG,GAAG,CAAC,MAAM,CAAC,cAAc,EAAE;YAC/C,GAAG,IAAI;YACP,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,OAAO;YACpC,eAAe;YACf,SAAS;YACT,OAAO;YACP,WAAW;YACX,cAAc;YACd,eAAe;SACf,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,kBAAkB,CAAC,YAAY,EAAE;YAC5C,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,SAAS,IAAI,QAAQ;YACpD,SAAS,EAAE,mBAAmB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;SAC/C,CAAC,CAAC;IACJ,CAAC;CACD"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import ejs from 'ejs';
|
|
2
|
+
import { configService } from '../../../../services/ConfigService';
|
|
3
|
+
import { Plan } from '../../../../db/schema/plans';
|
|
4
|
+
import { providers } from '../../../../utils/providers';
|
|
5
|
+
import { BackupCompletionStats, BackupNotificationJSONPayload } from '../../../../types/backups';
|
|
6
|
+
import { formatBytes, formatDuration, formatNumberToK } from '../../../../utils/formatter';
|
|
7
|
+
import { BaseNotification } from '../../../BaseNotification';
|
|
8
|
+
import { loadBackupTemplate } from '../../../templateLoader';
|
|
9
|
+
|
|
10
|
+
export interface BackupSuccessNotificationPayload {
|
|
11
|
+
appTitle: string;
|
|
12
|
+
deviceName: string;
|
|
13
|
+
storageName: string;
|
|
14
|
+
storageType: string;
|
|
15
|
+
plan: Plan;
|
|
16
|
+
startTime: Date;
|
|
17
|
+
endTime: Date;
|
|
18
|
+
stats?: BackupCompletionStats;
|
|
19
|
+
output?: 'html' | 'json' | 'push';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class BackupSuccessNotification extends BaseNotification {
|
|
23
|
+
constructor(data: BackupSuccessNotificationPayload) {
|
|
24
|
+
super();
|
|
25
|
+
this.subject = `Backup Complete: ${data.plan.title}`;
|
|
26
|
+
this.contentType = data.output || 'html';
|
|
27
|
+
this.content = this.buildContent(data);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
protected buildContent(data: BackupSuccessNotificationPayload): string {
|
|
31
|
+
if (this.contentType === 'json') {
|
|
32
|
+
return this.buildJSONContent(data);
|
|
33
|
+
}
|
|
34
|
+
return this.buildHTMLContent(data);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
protected buildJSONContent(data: BackupSuccessNotificationPayload): string {
|
|
38
|
+
const { appTitle, deviceName, storageName, storageType, plan, stats, startTime, endTime } =
|
|
39
|
+
data;
|
|
40
|
+
const payload: BackupNotificationJSONPayload = {
|
|
41
|
+
appTitle,
|
|
42
|
+
deviceName,
|
|
43
|
+
storageName,
|
|
44
|
+
storageType,
|
|
45
|
+
storagePath: plan.storagePath || '',
|
|
46
|
+
stats,
|
|
47
|
+
startTime,
|
|
48
|
+
endTime,
|
|
49
|
+
planID: plan.id,
|
|
50
|
+
planTitle: plan.title,
|
|
51
|
+
planType: plan.method,
|
|
52
|
+
planSource: {
|
|
53
|
+
included: plan.sourceConfig?.includes.join(', ') || '',
|
|
54
|
+
excluded: plan.sourceConfig?.excludes.join(', ') || '',
|
|
55
|
+
},
|
|
56
|
+
eventName: 'backup_success',
|
|
57
|
+
};
|
|
58
|
+
return JSON.stringify(payload);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
protected buildHTMLContent(data: BackupSuccessNotificationPayload): string {
|
|
62
|
+
// Generate the Email Body
|
|
63
|
+
const startDate = new Date(data.startTime ? data.startTime : 0).toLocaleDateString('en-US', {
|
|
64
|
+
year: 'numeric',
|
|
65
|
+
month: 'long',
|
|
66
|
+
day: 'numeric',
|
|
67
|
+
hour: 'numeric',
|
|
68
|
+
minute: 'numeric',
|
|
69
|
+
});
|
|
70
|
+
const endDate = new Date(data.endTime ? data.endTime : 0).toLocaleDateString('en-US', {
|
|
71
|
+
year: 'numeric',
|
|
72
|
+
month: 'long',
|
|
73
|
+
day: 'numeric',
|
|
74
|
+
hour: 'numeric',
|
|
75
|
+
minute: 'numeric',
|
|
76
|
+
});
|
|
77
|
+
const storageTypeName = data.storageType
|
|
78
|
+
? providers[data.storageType]?.name || data.storageType
|
|
79
|
+
: '';
|
|
80
|
+
const templateString = loadBackupTemplate('BackupSuccessNotification.ejs');
|
|
81
|
+
const renderedBody = ejs.render(templateString, {
|
|
82
|
+
...data,
|
|
83
|
+
appUrl: configService.config.APP_URL,
|
|
84
|
+
storageTypeName,
|
|
85
|
+
startDate,
|
|
86
|
+
endDate,
|
|
87
|
+
formatBytes,
|
|
88
|
+
formatDuration,
|
|
89
|
+
formatNumberToK,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
return this.applyEmailTemplate(renderedBody, {
|
|
93
|
+
appTitle: configService.config.APP_TITLE || 'Pluton',
|
|
94
|
+
preHeader: `Backup Success: ${data.plan.title}`,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|