Browse Source

Started frontend work for sending test email from sending_profiles page. This will need to wait for rewrite of /util/send_test_email to send with default template, etc.

pull/169/head
William Woodson 5 years ago
parent
commit
3d8126e981
2 changed files with 76 additions and 2 deletions
  1. +34
    -0
      static/js/app/sending_profiles.js
  2. +42
    -2
      templates/sending_profiles.html

+ 34
- 0
static/js/app/sending_profiles.js View File

@ -1,5 +1,39 @@
var profiles = []
// Attempts to send a test email by POSTing to /campaigns/
/*function sendTestEmail() {
var test_email_request = {
template: { name: '' },
first_name: $("input[name=to_first_name]").val(),
last_name: $("input[name=to_last_name]").val(),
email: $("input[name=to_email]").val(),
position: $("input[name=to_position]").val(),
url: '',
page: { name: '' },
smtp: {
from_address: $("#from").val(),
host: $("#host").val(),
username: $("#username").val(),
password: $("#password").val(),
ignore_cert_errors: $("#ignore_cert_errors").prop("checked")
}
}
btnHtml = $("#sendTestModalSubmit").html()
$("#sendTestModalSubmit").html('<i class="fa fa-spinner fa-spin"></i> Sending')
// Send the test email
api.send_test_email(test_email_request)
.success(function(data) {
$("#sendTestEmailModal\\.flashes").empty().append("<div style=\"text-align:center\" class=\"alert alert-success\">\
<i class=\"fa fa-check-circle\"></i> Email Sent!</div>")
$("#sendTestModalSubmit").html(btnHtml)
})
.error(function(data) {
$("#sendTestEmailModal\\.flashes").empty().append("<div style=\"text-align:center\" class=\"alert alert-danger\">\
<i class=\"fa fa-exclamation-circle\"></i> " + data.responseJSON.message + "</div>")
$("#sendTestModalSubmit").html(btnHtml)
})
}*/ //disable sendTestEmail functionality on sending profile page until update handling of /util/send_test_email
// Save attempts to POST to /smtp/
function save(idx) {
var profile = {}

+ 42
- 2
templates/sending_profiles.html View File

@ -79,11 +79,11 @@
</div>
<label class="control-label" for="name">From:</label>
<div class="form-group">
<input type="text" class="form-control" placeholder="First Last <test@example.com>" id="from" autofocus/>
<input type="text" class="form-control" placeholder="First Last <test@example.com>" id="from" autofocus required/>
</div>
<label class="control-label" for="name">Host:</label>
<div class="form-group">
<input type="text" class="form-control" placeholder="smtp.example.com:25" id="host" autofocus/>
<input type="text" class="form-control" placeholder="smtp.example.com:25" id="host" autofocus required/>
</div>
<label class="control-label" for="name">Username:</label>
<div class="form-group">
@ -97,6 +97,8 @@
<input id="ignore_cert_errors" type="checkbox" checked>
<label for="ignore_cert_errors">Ignore Certificate Errors <i class="fa fa-question-circle" data-toggle="tooltip" data-placement="right" title="Ignore common certificate errors such as self-signed certs (exposes you to MiTM attacks - use carefully!)"></i></label>
</div>
<!-- <button type="button" data-toggle="modal" data-target="#sendTestEmailModal" class="btn btn-primary"><i class="fa fa-envelope"></i> Send Test Email</button> -->
<!-- disable sendTestEmail functionality on sending profile page until update handling of /util/send_test_email -->
</div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn btn-default" onclick="dismiss()">Cancel</button>
@ -105,6 +107,44 @@
</div>
</div>
</div>
<!-- Send Test Email Modal -->
<!-- <div class="modal" id="sendTestEmailModal" tabindex="-1" role="dialog" aria-labelledby="modalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content"> -->
<!-- New Email Modal -->
<!-- <div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="sendTestEmailModalTitle">Send Test Email</h4>
</div>
<div class="modal-body">
<div class="row" id="sendTestEmailModal.flashes"></div>
<div class="row">
<div class="col-sm-12">
<label class="control-label" for="to">Send Test Email to:</label>
</div>
<br>
<div class="col-sm-2">
<input type="text" class="form-control" placeholder="First Name" name="to_first_name">
</div>
<div class="col-sm-2">
<input type="text" class="form-control" placeholder="Last Name" name="to_last_name">
</div>
<div class="col-sm-4">
<input type="email" class="form-control" placeholder="Email" name="to_email" required>
</div>
<div class="col-sm-4">
<input type="text" class="form-control" placeholder="Position" name="to_position">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn btn-default">Cancel</button>
<button type="button" class="btn btn-primary" id="sendTestModalSubmit" onclick="sendTestEmail()"><i class="fa fa-envelope"></i> Send</button>
</div>
</div>
</div>
</div> -->
<!-- disable sendTestEmail functionality on sending profile page until update handling of /util/send_test_email -->
{{end}}
{{define "scripts"}}
<script src="/js/ckeditor/ckeditor.js"></script>

Loading…
Cancel
Save