Initial email settings UI commit

Added email settings page, settings now save in database, ability to send an email to client when it's created
This commit is contained in:
Arminas 2022-12-30 19:10:27 +02:00 committed by GitHub
parent f8a10417ea
commit c31636b66e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 568 additions and 25 deletions

View file

@ -134,6 +134,14 @@
</p>
</a>
</li>
<li class="nav-item">
<a href="{{.basePath}}/email-settings" class="nav-link {{if eq .baseData.Active "email-settings" }}active{{end}}">
<i class="nav-icon fas fa-cog"></i>
<p>
Email Settings
</p>
</a>
</li>
<li class="nav-item">
<a href="{{.basePath}}/users-settings" class="nav-link {{if eq .baseData.Active "users-settings" }}active{{end}}">
<i class="nav-icon fas fa-cog"></i>
@ -226,6 +234,14 @@
</label>
</div>
</div>
<div class="form-group">
<div class="icheck-primary d-inline">
<input type="checkbox" id="send_email_after_creation" {{ if .client_defaults.EnableAfterCreation }}checked{{ end }}>
<label for="send_email_after_creation">
Send email after creation
</label>
</div>
</div>
<details>
<summary><strong>Public and Preshared Keys</strong>
<i class="fas fa-info-circle" data-toggle="tooltip"
@ -399,6 +415,7 @@
success: function(resp) {
$("#modal_new_client").modal('hide');
toastr.success('Created new client successfully');
sendEmailAfterCreation(resp.id, resp.email);
// Update the home page (clients page) after adding successfully
if (window.location.pathname === "{{.basePath}}/") {
populateClient(resp.id);
@ -431,6 +448,31 @@
}
});
}
function sendEmailAfterCreation(client_id, client_email) {
console.log("Do you even try?");
if ($("#send_email_after_creation").is(':checked')) {
if (client_email !== "" && client_id) {
const data = {"id": client_id, "email": client_email};
$.ajax({
cache: false,
method: 'POST',
url: '{{.basePath}}/email-client',
dataType: 'json',
contentType: "application/json",
data: JSON.stringify(data),
success: function (resp) {
toastr.success('Sent email to client successfully');
},
error: function (jqXHR, exception) {
const responseJson = jQuery.parseJSON(jqXHR.responseText);
toastr.error(responseJson['message']);
}
});
}
}
}
</script>
<script>
//Initialize Select2 Elements