1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
<?php
/*
** Zabbix
** Copyright (C) 2001-2014 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
$httpWidget = new CWidget();
$createForm = new CForm('get');
$createForm->cleanItems();
$createForm->addVar('hostid', $this->data['hostid']);
if (empty($this->data['hostid'])) {
$createButton = new CSubmit('form', _('Create scenario (select host first)'));
$createButton->setEnabled(false);
$createForm->addItem($createButton);
}
else {
$createForm->addItem(new CSubmit('form', _('Create scenario')));
$httpWidget->addItem(get_header_host_table('web', $this->data['hostid']));
}
$httpWidget->addPageHeader(_('CONFIGURATION OF WEB MONITORING'), $createForm);
// header
$filterForm = new CForm('get');
$filterForm->addItem(array(_('Group').SPACE, $this->data['pageFilter']->getGroupsCB()));
$filterForm->addItem(array(SPACE._('Host').SPACE, $this->data['pageFilter']->getHostsCB()));
$httpWidget->addHeader(_('Scenarios'), $filterForm);
$httpWidget->addHeaderRowNumber(array(
'[ ',
new CLink($this->data['showDisabled'] ? _('Hide disabled scenarios') : _('Show disabled scenarios'),
'?showdisabled='.($this->data['showDisabled'] ? 0 : 1), null), ' ]'
));
// create form
$httpForm = new CForm();
$httpForm->setName('scenarios');
$httpForm->addVar('hostid', $this->data['hostid']);
$httpTable = new CTableInfo(_('No web scenarios found.'));
$httpTable->setHeader(array(
new CCheckBox('all_httptests', null, "checkAll('".$httpForm->getName()."', 'all_httptests', 'group_httptestid');"),
($this->data['hostid'] == 0) ? make_sorting_header(_('Host'), 'hostname') : null,
make_sorting_header(_('Name'), 'name'),
_('Number of steps'),
_('Update interval'),
make_sorting_header(_('Status'), 'status'))
);
foreach ($this->data['httpTests'] as $httpTestId => $httpTest) {
$name = array();
if (isset($this->data['parentTemplates'][$httpTestId])) {
$template = $this->data['parentTemplates'][$httpTestId];
$name[] = new CLink($template['name'], '?groupid=0&hostid='.$template['id'], 'unknown');
$name[] = NAME_DELIMITER;
}
$name[] = new CLink($httpTest['name'], '?form=update'.'&httptestid='.$httpTest['httptestid'].'&hostid='.$httpTest['hostid']);
$httpTable->addRow(array(
new CCheckBox('group_httptestid['.$httpTest['httptestid'].']', null, null, $httpTest['httptestid']),
($this->data['hostid'] > 0) ? null : $httpTest['hostname'],
$name,
$httpTest['stepscnt'],
$httpTest['delay'],
new CLink(
httptest_status2str($httpTest['status']),
'?group_httptestid[]='.$httpTest['httptestid'].
'&hostid='.$httpTest['hostid'].
'&go='.($httpTest['status'] ? 'activate' : 'disable'),
httptest_status2style($httpTest['status'])
)
));
}
// create go buttons
$goComboBox = new CComboBox('go');
$goOption = new CComboItem('activate', _('Enable selected'));
$goOption->setAttribute('confirm', _('Enable selected WEB scenarios?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('disable', _('Disable selected'));
$goOption->setAttribute('confirm',_('Disable selected WEB scenarios?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('clean_history', _('Clear history for selected'));
$goOption->setAttribute('confirm', _('Delete history of selected WEB scenarios?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('delete', _('Delete selected'));
$goOption->setAttribute('confirm', _('Delete selected WEB scenarios?'));
$goComboBox->addItem($goOption);
$goButton = new CSubmit('goButton', _('Go').' (0)');
$goButton->setAttribute('id', 'goButton');
zbx_add_post_js('chkbxRange.pageGoName = "group_httptestid";');
zbx_add_post_js('chkbxRange.prefix = "'.$this->data['hostid'].'";');
zbx_add_post_js('cookie.prefix = "'.$this->data['hostid'].'";');
// append table to form
$httpForm->addItem(array($this->data['paging'], $httpTable, $this->data['paging'], get_table_header(array($goComboBox, $goButton))));
// append form to widget
$httpWidget->addItem($httpForm);
return $httpWidget;
|