diff --git a/src/dashboard.py b/src/dashboard.py index 14dc917..882282d 100644 --- a/src/dashboard.py +++ b/src/dashboard.py @@ -1883,7 +1883,8 @@ class DashboardConfig: "encryption": "", "username": "", "email_password": "", - "send_from": "" + "send_from": "", + "email_template": "" }, "WireGuardConfiguration": { "autostart": "" @@ -3053,15 +3054,14 @@ def API_Email_Send(): data = request.get_json() if "Receiver" not in data.keys(): return ResponseObject(False, "Please at least specify receiver") - body = data.get('Body', '') + download = None if "ConfigurationName" in data.keys() and "Peer" in data.keys(): if data.get('ConfigurationName') in WireguardConfigurations.keys(): configuration = WireguardConfigurations.get(data.get('ConfigurationName')) attachmentName = "" if configuration is not None: fp, p = configuration.searchPeer(data.get('Peer')) - print(fp) if fp: template = Template(body) download = p.downloadPeer() @@ -3073,9 +3073,34 @@ def API_Email_Send(): attachmentName = f'{u}.conf' s, m = EmailSender.send(data.get('Receiver'), data.get('Subject', ''), body, - data.get('IncludeAttachment', False), download['fileName']) + data.get('IncludeAttachment', False), (download.get('fileName', '') if download else '')) return ResponseObject(s, m) +@app.post(f'{APP_PREFIX}/api/email/previewBody') +def API_Email_PreviewBody(): + data = request.get_json() + body = data.get('Body', '') + if len(body) == 0: + return ResponseObject(False, "Nothing to preview") + if ("ConfigurationName" not in data.keys() + or "Peer" not in data.keys() or data.get('ConfigurationName') not in WireguardConfigurations.keys()): + return ResponseObject(False, "Please specify configuration and peer") + + configuration = WireguardConfigurations.get(data.get('ConfigurationName')) + fp, p = configuration.searchPeer(data.get('Peer')) + if not fp: + return ResponseObject(False, "Peer does not exist") + + try: + template = Template(body) + download = p.downloadPeer() + body = template.render(peer=p.toJson(), configurationFile=download) + return ResponseObject(data=body) + except Exception as e: + return ResponseObject(False, message=str(e)) + + + @app.get(f'{APP_PREFIX}/api/systemStatus') def API_SystemStatus(): cpu_percpu = psutil.cpu_percent(interval=0.5, percpu=True) diff --git a/src/static/app/src/components/configurationComponents/peerShareLinkComponents/peerShareWithEmail.vue b/src/static/app/src/components/configurationComponents/peerShareLinkComponents/peerShareWithEmail.vue index cd89fbb..a223f62 100644 --- a/src/static/app/src/components/configurationComponents/peerShareLinkComponents/peerShareWithEmail.vue +++ b/src/static/app/src/components/configurationComponents/peerShareLinkComponents/peerShareWithEmail.vue @@ -1,23 +1,28 @@ \ No newline at end of file diff --git a/src/static/app/src/components/configurationComponents/peerShareLinkComponents/peerShareWithEmailBodyPreview.vue b/src/static/app/src/components/configurationComponents/peerShareLinkComponents/peerShareWithEmailBodyPreview.vue new file mode 100644 index 0000000..e2d1823 --- /dev/null +++ b/src/static/app/src/components/configurationComponents/peerShareLinkComponents/peerShareWithEmailBodyPreview.vue @@ -0,0 +1,70 @@ + + + + + \ No newline at end of file diff --git a/src/static/app/src/components/configurationComponents/peerShareLinkModal.vue b/src/static/app/src/components/configurationComponents/peerShareLinkModal.vue index 55ede29..98d4d07 100644 --- a/src/static/app/src/components/configurationComponents/peerShareLinkModal.vue +++ b/src/static/app/src/components/configurationComponents/peerShareLinkModal.vue @@ -21,7 +21,8 @@ export default { data(){ return { dataCopy: undefined, - loading: false + loading: false, + fullscreen: false } }, setup(){ @@ -107,7 +108,7 @@ export default {