default_logs.php
| 1 | <?php |
| 2 | /** |
| 3 | * @package VikAppointments |
| 4 | * @subpackage core |
| 5 | * @author E4J s.r.l. |
| 6 | * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved. |
| 7 | * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 | * @link https://vikwp.com |
| 9 | */ |
| 10 | |
| 11 | // No direct access |
| 12 | defined('ABSPATH') or die('No script kiddies please!'); |
| 13 | |
| 14 | $vik = VAPApplication::getInstance(); |
| 15 | |
| 16 | $options = array(); |
| 17 | $options[] = JHtml::fetch('select.option', '', ''); |
| 18 | |
| 19 | foreach (array_reverse($this->logs) as $file => $name) |
| 20 | { |
| 21 | $options[] = JHtml::fetch('select.option', basename($file), $name); |
| 22 | } |
| 23 | |
| 24 | ?> |
| 25 | |
| 26 | <div style="display: flex;"> |
| 27 | |
| 28 | <select id="vap-log-sel"> |
| 29 | <?php echo JHtml::fetch('select.options', $options); ?> |
| 30 | </select> |
| 31 | |
| 32 | <button type="button" class="btn" id="load-log-btn" disabled style="margin-left: 10px;"> |
| 33 | <?php echo JText::translate('VAPLOAD'); ?> |
| 34 | </button> |
| 35 | |
| 36 | </div> |
| 37 | |
| 38 | <pre id="vap-log-content" style="margin-top: 15px; max-height: 500px; overflow-y: scroll; display: none;"></pre> |
| 39 | |
| 40 | <?php |
| 41 | JText::script('VAPFILTERSELECTFILE'); |
| 42 | JText::script('VAPCONNECTIONLOSTERROR'); |
| 43 | ?> |
| 44 | |
| 45 | <script> |
| 46 | |
| 47 | jQuery(function($) { |
| 48 | $('#vap-log-sel').select2({ |
| 49 | placeholder: Joomla.JText._('VAPFILTERSELECTFILE'), |
| 50 | allowClear: false, |
| 51 | width: '100%', |
| 52 | }); |
| 53 | |
| 54 | $('#vap-log-sel').on('change', function() { |
| 55 | if ($(this).val()) { |
| 56 | $('#load-log-btn').prop('disabled', false); |
| 57 | } else { |
| 58 | $('#load-log-btn').prop('disabled', true); |
| 59 | } |
| 60 | }); |
| 61 | |
| 62 | $('#load-log-btn').on('click', function() { |
| 63 | const file = $('#vap-log-sel').val(); |
| 64 | |
| 65 | if (!file || $(this).prop('disabled')) { |
| 66 | return false; |
| 67 | } |
| 68 | |
| 69 | $('#vap-log-content').hide(); |
| 70 | $(this).prop('disabled', true); |
| 71 | |
| 72 | UIAjax.do( |
| 73 | '<?php echo $vik->ajaxUrl('index.php?option=com_vikappointments&task=webhook.loadlogajax'); ?>', |
| 74 | { |
| 75 | file: file, |
| 76 | }, |
| 77 | (resp) => { |
| 78 | $('#vap-log-content').html(resp).show(); |
| 79 | $(this).prop('disabled', false); |
| 80 | }, |
| 81 | (err) => { |
| 82 | alert(err.responseText || Joomla.JText._('VAPCONNECTIONLOSTERROR')) |
| 83 | $(this).prop('disabled', false); |
| 84 | } |
| 85 | ); |
| 86 | }); |
| 87 | }); |
| 88 | |
| 89 | </script> |
| 90 |