1<?php 2/* 3** Zabbix 4** Copyright (C) 2001-2021 Zabbix SIA 5** 6** This program is free software; you can redistribute it and/or modify 7** it under the terms of the GNU General Public License as published by 8** the Free Software Foundation; either version 2 of the License, or 9** (at your option) any later version. 10** 11** This program is distributed in the hope that it will be useful, 12** but WITHOUT ANY WARRANTY; without even the implied warranty of 13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14** GNU General Public License for more details. 15** 16** You should have received a copy of the GNU General Public License 17** along with this program; if not, write to the Free Software 18** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19**/ 20 21 22/** 23 * @var CView $this 24 */ 25?> 26 27<script type="text/x-jquery-tmpl" id="tag-row-tmpl"> 28 <?= renderTagTableRow('#{rowNum}', '', '', ['add_post_js' => false]) ?> 29</script> 30 31<script type="text/javascript"> 32 jQuery(function($) { 33 <?php if (CWebUser::getType() == USER_TYPE_SUPER_ADMIN): ?> 34 $('input[name=mass_update_groups]').on('change', function() { 35 $('#groups_').multiSelect('modify', { 36 'addNew': ($(this).val() == <?= ZBX_ACTION_ADD ?> || $(this).val() == <?= ZBX_ACTION_REPLACE ?>) 37 }); 38 }); 39 <?php endif ?> 40 41 $('#tags-table') 42 .dynamicRows({template: '#tag-row-tmpl'}) 43 .on('click', 'button.element-table-add', function() { 44 $('#tags-table .<?= ZBX_STYLE_TEXTAREA_FLEXIBLE ?>').textareaFlexible(); 45 }); 46 47 var mass_action_tpls = $('#mass_action_tpls'), 48 mass_clear_tpls = $('#mass_clear_tpls'); 49 50 mass_action_tpls.on('change', function() { 51 var action = mass_action_tpls.find('input[name="mass_action_tpls"]:checked').val(); 52 mass_clear_tpls.prop('disabled', action === '<?= ZBX_ACTION_ADD ?>'); 53 }).trigger('change'); 54 55 $('#inventory_mode').on('change', function() { 56 $('.formrow-inventory').toggle($(this).val() !== '<?php echo HOST_INVENTORY_DISABLED; ?>'); 57 }).trigger('change'); 58 59 $('#tls_connect, #tls_in_psk, #tls_in_cert').on('change', function() { 60 // If certificate is selected or checked. 61 if ($('input[name=tls_connect]:checked').val() == <?= HOST_ENCRYPTION_CERTIFICATE ?> 62 || $('#tls_in_cert').is(':checked')) { 63 $('#tls_issuer, #tls_subject').closest('tr').show(); 64 } 65 else { 66 $('#tls_issuer, #tls_subject').closest('tr').hide(); 67 } 68 69 // If PSK is selected or checked. 70 if ($('input[name=tls_connect]:checked').val() == <?= HOST_ENCRYPTION_PSK ?> 71 || $('#tls_in_psk').is(':checked')) { 72 $('#tls_psk, #tls_psk_identity').closest('tr').show(); 73 } 74 else { 75 $('#tls_psk, #tls_psk_identity').closest('tr').hide(); 76 } 77 }); 78 79 // Refresh field visibility on document load. 80 if (($('#tls_accept').val() & <?= HOST_ENCRYPTION_NONE ?>) == <?= HOST_ENCRYPTION_NONE ?>) { 81 $('#tls_in_none').prop('checked', true); 82 } 83 if (($('#tls_accept').val() & <?= HOST_ENCRYPTION_PSK ?>) == <?= HOST_ENCRYPTION_PSK ?>) { 84 $('#tls_in_psk').prop('checked', true); 85 } 86 if (($('#tls_accept').val() & <?= HOST_ENCRYPTION_CERTIFICATE ?>) == <?= HOST_ENCRYPTION_CERTIFICATE ?>) { 87 $('#tls_in_cert').prop('checked', true); 88 } 89 90 $('input[name=tls_connect]').trigger('change'); 91 92 // Depending on checkboxes, create a value for hidden field 'tls_accept'. 93 $('#hostForm').on('submit', function() { 94 var tls_accept = 0x00; 95 96 if ($('#tls_in_none').is(':checked')) { 97 tls_accept |= <?= HOST_ENCRYPTION_NONE ?>; 98 } 99 if ($('#tls_in_psk').is(':checked')) { 100 tls_accept |= <?= HOST_ENCRYPTION_PSK ?>; 101 } 102 if ($('#tls_in_cert').is(':checked')) { 103 tls_accept |= <?= HOST_ENCRYPTION_CERTIFICATE ?>; 104 } 105 106 $('#tls_accept').val(tls_accept); 107 }); 108 }); 109</script> 110