mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Small mods to slack jquery
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
80d36cd72b
commit
cde2bad297
|
@ -158,7 +158,6 @@
|
||||||
|
|
||||||
$('input:text').keyup(fieldcheck); // if *any* text field changes, we recalculate button states
|
$('input:text').keyup(fieldcheck); // if *any* text field changes, we recalculate button states
|
||||||
|
|
||||||
|
|
||||||
$("#slacktest").click(function() {
|
$("#slacktest").click(function() {
|
||||||
|
|
||||||
$("#slacktestrow").removeClass('text-success');
|
$("#slacktestrow").removeClass('text-success');
|
||||||
|
@ -167,10 +166,12 @@
|
||||||
$("#slackteststatus").html('');
|
$("#slackteststatus").html('');
|
||||||
$("#slacktesticon").html('<i class="fa fa-spinner spin"></i> Sending Slack test message...');
|
$("#slacktesticon").html('<i class="fa fa-spinner spin"></i> Sending Slack test message...');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|
||||||
url: '{{ route('api.settings.slacktest') }}',
|
url: '{{ route('api.settings.slacktest') }}',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
"X-Requested-With": 'XMLHttpRequest',
|
"X-Requested-With": 'XMLHttpRequest',
|
||||||
|
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content'),
|
||||||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content')
|
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content')
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
|
@ -182,19 +183,24 @@
|
||||||
|
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
|
|
||||||
|
accepts: {
|
||||||
|
text: "application/json"
|
||||||
|
},
|
||||||
|
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
$('#save_slack').removeAttr('disabled');
|
$('#save_slack').removeAttr('disabled');
|
||||||
$("#slacktesticon").html('');
|
$("#slacktesticon").html('');
|
||||||
$("#slacktestrow").addClass('text-success');
|
$("#slacktestrow").addClass('text-success');
|
||||||
$("#slackteststatus").addClass('text-success');
|
$("#slackteststatus").addClass('text-success');
|
||||||
$("#slackteststatus").html('<i class="fa fa-check text-success"></i> Success! Check the ' + $('#slack_channel').val() + ' channel for your test message, and be sure to click SAVE below to store your settings.');
|
$("#slackteststatus").html('<i class="fa fa-check text-success"></i> Success! Check the ' + $('#slack_channel').val() + ' channel for your test message, and be sure to click SAVE below to store your settings.');
|
||||||
},
|
},
|
||||||
|
|
||||||
error: function (data) {
|
error: function (data) {
|
||||||
|
|
||||||
|
|
||||||
if (data.responseJSON) {
|
if (data.responseJSON) {
|
||||||
var errors = data.responseJSON.message;
|
var errors = data.responseJSON.errors;
|
||||||
|
var error_msg = data.responseJSON.message;
|
||||||
} else {
|
} else {
|
||||||
var errors;
|
var errors;
|
||||||
}
|
}
|
||||||
|
@ -204,15 +210,15 @@
|
||||||
$('#save_slack').attr("disabled", true);
|
$('#save_slack').attr("disabled", true);
|
||||||
$("#slacktesticon").html('');
|
$("#slacktesticon").html('');
|
||||||
$("#slackteststatus").addClass('text-danger');
|
$("#slackteststatus").addClass('text-danger');
|
||||||
$("#slacktesticon").html('<i class="fa fa-exclamation-triangle text-danger"></i>');
|
$("#slacktesticon").html('<i class="fa fa-exclamation-triangle text-danger"></i><span class="text-danger">' + error_msg+ '</span>');
|
||||||
|
|
||||||
if (data.status == 500) {
|
if (data.status == 500) {
|
||||||
$('#slackteststatus').html('500 Server Error');
|
$('#slackteststatus').html('500 Server Error');
|
||||||
} else if (data.status == 400) {
|
} else if ((data.status == 400) || (data.status == 422)) {
|
||||||
|
|
||||||
if (typeof errors != 'string') {
|
if (typeof errors != 'string') {
|
||||||
|
|
||||||
for (i = 0; i < errors.length; i++) {
|
for (i in errors) {
|
||||||
if (errors[i]) {
|
if (errors[i]) {
|
||||||
error_text += '<li>Error: ' + errors[i];
|
error_text += '<li>Error: ' + errors[i];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue