-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
"Send test notification" button - Easier to understand test send resu…
…lts, Improved error handling, code refactor (#2888)
- Loading branch information
Showing
10 changed files
with
172 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,52 @@ | ||
$(document).ready(function() { | ||
$(document).ready(function () { | ||
|
||
$('#add-email-helper').click(function (e) { | ||
e.preventDefault(); | ||
email = prompt("Destination email"); | ||
if(email) { | ||
var n = $(".notification-urls"); | ||
var p=email_notification_prefix; | ||
$(n).val( $.trim( $(n).val() )+"\n"+email_notification_prefix+email ); | ||
} | ||
}); | ||
|
||
$('#send-test-notification').click(function (e) { | ||
e.preventDefault(); | ||
|
||
data = { | ||
notification_body: $('#notification_body').val(), | ||
notification_format: $('#notification_format').val(), | ||
notification_title: $('#notification_title').val(), | ||
notification_urls: $('.notification-urls').val(), | ||
tags: $('#tags').val(), | ||
window_url: window.location.href, | ||
} | ||
$('#add-email-helper').click(function (e) { | ||
e.preventDefault(); | ||
email = prompt("Destination email"); | ||
if (email) { | ||
var n = $(".notification-urls"); | ||
var p = email_notification_prefix; | ||
$(n).val($.trim($(n).val()) + "\n" + email_notification_prefix + email); | ||
} | ||
}); | ||
|
||
$('#send-test-notification').click(function (e) { | ||
e.preventDefault(); | ||
|
||
$.ajax({ | ||
type: "POST", | ||
url: notification_base_url, | ||
data : data, | ||
statusCode: { | ||
400: function(data) { | ||
// More than likely the CSRF token was lost when the server restarted | ||
alert(data.responseText); | ||
data = { | ||
notification_body: $('#notification_body').val(), | ||
notification_format: $('#notification_format').val(), | ||
notification_title: $('#notification_title').val(), | ||
notification_urls: $('.notification-urls').val(), | ||
tags: $('#tags').val(), | ||
window_url: window.location.href, | ||
} | ||
} | ||
}).done(function(data){ | ||
console.log(data); | ||
alert(data); | ||
}) | ||
}); | ||
|
||
$('.notifications-wrapper .spinner').fadeIn(); | ||
$('#notification-test-log').show(); | ||
$.ajax({ | ||
type: "POST", | ||
url: notification_base_url, | ||
data: data, | ||
statusCode: { | ||
400: function (data) { | ||
$("#notification-test-log>span").text(data.responseText); | ||
}, | ||
} | ||
}).done(function (data) { | ||
$("#notification-test-log>span").text(data); | ||
}).fail(function (jqXHR, textStatus, errorThrown) { | ||
// Handle connection refused or other errors | ||
if (textStatus === "error" && errorThrown === "") { | ||
console.error("Connection refused or server unreachable"); | ||
$("#notification-test-log>span").text("Error: Connection refused or server is unreachable."); | ||
} else { | ||
console.error("Error:", textStatus, errorThrown); | ||
$("#notification-test-log>span").text("An error occurred: " + textStatus); | ||
} | ||
}).always(function () { | ||
$('.notifications-wrapper .spinner').hide(); | ||
}) | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.