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/javascript">
28	$(document).ready(function() {
29		var $form = $('form#housekeeping');
30
31		$form.on('submit', function() {
32			$form.trimValues(['#hk_events_trigger', '#hk_events_internal', '#hk_events_discovery', '#hk_events_autoreg',
33				'#hk_services', '#hk_audit', '#hk_sessions', '#hk_history', '#hk_trends'
34			]);
35		});
36
37		$('#hk_events_mode').change(function() {
38			$('#hk_events_trigger').prop('disabled', !this.checked);
39			$('#hk_events_internal').prop('disabled', !this.checked);
40			$('#hk_events_discovery').prop('disabled', !this.checked);
41			$('#hk_events_autoreg').prop('disabled', !this.checked);
42		});
43
44		$('#hk_services_mode').change(function() {
45			$('#hk_services').prop('disabled', !this.checked);
46		});
47
48		$('#hk_audit_mode').change(function() {
49			$('#hk_audit').prop('disabled', !this.checked);
50		});
51
52		$('#hk_sessions_mode').change(function() {
53			$('#hk_sessions').prop('disabled', !this.checked);
54		});
55
56		$('#hk_history_global').change(function() {
57			$('#hk_history').prop('disabled', !this.checked);
58		});
59
60		$('#hk_trends_global').change(function() {
61			$('#hk_trends').prop('disabled', !this.checked);
62		});
63
64		$('#compression_status').change(function() {
65			$('#compress_older').prop('disabled', !this.checked);
66		});
67
68		$("#resetDefaults").click(function() {
69			overlayDialogue({
70				'title': <?= json_encode(_('Reset confirmation')) ?>,
71				'content': $('<span>').text(<?= json_encode(_('Reset all fields to default values?')) ?>),
72				'buttons': [
73					{
74						'title': <?= json_encode(_('Cancel')) ?>,
75						'cancel': true,
76						'class': '<?= ZBX_STYLE_BTN_ALT ?>',
77						'action': function() {}
78					},
79					{
80						'title': <?= json_encode(_('Reset defaults')) ?>,
81						'focused': true,
82						'action': function() {
83							$('main')
84								.prev('.msg-bad')
85								.remove();
86
87							// events and alerts
88							$('#hk_events_mode')
89								.prop('checked',
90									<?= (DB::getDefault('config', 'hk_events_mode') == 1) ? 'true' : 'false' ?>
91								)
92								.change();
93							$('#hk_events_trigger').val("<?= DB::getDefault('config', 'hk_events_trigger') ?>");
94							$('#hk_events_internal').val("<?= DB::getDefault('config', 'hk_events_internal') ?>");
95							$('#hk_events_discovery').val("<?= DB::getDefault('config', 'hk_events_discovery') ?>");
96							$('#hk_events_autoreg').val("<?= DB::getDefault('config', 'hk_events_autoreg') ?>");
97							$('#hk_services_mode')
98								.prop('checked',
99									<?= (DB::getDefault('config', 'hk_services_mode') == 1) ? 'true' : 'false' ?>
100								)
101								.change();
102							$('#hk_services').val("<?= DB::getDefault('config', 'hk_services') ?>");
103
104							// audit
105							$('#hk_audit_mode')
106								.prop('checked',
107									<?= (DB::getDefault('config', 'hk_audit_mode') == 1) ? 'true' : 'false' ?>
108								)
109								.change();
110							$('#hk_audit').val("<?= DB::getDefault('config', 'hk_audit') ?>");
111
112							// user sessions
113							$('#hk_sessions_mode')
114								.prop('checked',
115									<?= (DB::getDefault('config', 'hk_sessions_mode') == 1) ? 'true' : 'false' ?>
116								)
117								.change();
118							$('#hk_sessions').val("<?= DB::getDefault('config', 'hk_sessions') ?>");
119
120							// history
121							$('#hk_history_mode').prop('checked',
122								<?= (DB::getDefault('config', 'hk_history_mode') == 1) ? 'true' : 'false' ?>
123							);
124							$('#hk_history_global')
125								.prop('checked',
126									<?= (DB::getDefault('config', 'hk_history_global') == 1) ? 'true' : 'false' ?>
127								)
128								.change();
129							$('#hk_history').val("<?= DB::getDefault('config', 'hk_history') ?>");
130
131							// trends
132							$('#hk_trends_mode').prop('checked',
133								<?= (DB::getDefault('config', 'hk_trends_mode') == 1) ? 'true' : 'false' ?>
134							);
135							$('#hk_trends_global')
136								.prop('checked',
137									<?= (DB::getDefault('config', 'hk_trends_global') == 1) ? 'true' : 'false' ?>
138								)
139								.change();
140							$('#hk_trends').val("<?= DB::getDefault('config', 'hk_trends') ?>");
141
142							// history and trends compression
143							$('#compression_status')
144								.prop('checked',
145									<?= (DB::getDefault('config', 'compression_status') == 1) ? 'true' : 'false' ?>
146								)
147								.change();
148							$('#compress_older').val("<?= DB::getDefault('config', 'compress_older') ?>");
149						}
150					}
151				]
152			}, this);
153		});
154	});
155</script>
156