Initial commit
This commit is contained in:
35
view/adminhtml/templates/system/config/test_connection.phtml
Normal file
35
view/adminhtml/templates/system/config/test_connection.phtml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php $url = $block->getCustomUrl(); ?>
|
||||
|
||||
<script type="text/javascript">
|
||||
require(["jquery"],function($) {
|
||||
$('#whi_test_connection').click(function() {
|
||||
if (!confirm('Save the configuration before testing.')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: "<?php echo $url; ?>",
|
||||
type: 'GET',
|
||||
complete: function (response) {
|
||||
switch (response.status) {
|
||||
case 204:
|
||||
alert('Connection successful.');
|
||||
break;
|
||||
|
||||
case 401:
|
||||
case 403:
|
||||
alert('Invalid API key.');
|
||||
break;
|
||||
|
||||
default:
|
||||
alert('Failed to connect to the provided URL.');
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php echo $block->getButtonHtml(); ?>
|
||||
<p><sub><em>Note: Currently only works in Chromium-based browsers (Firefox blocks script execution).</em></sub></p>
|
||||
Reference in New Issue
Block a user