-
Notifications
You must be signed in to change notification settings - Fork 91
/
GeneralConfigForm.php
168 lines (164 loc) · 6.76 KB
/
GeneralConfigForm.php
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
namespace Icinga\Module\Grafana\Forms\Config;
use Icinga\Application\Config;
use Icinga\Forms\ConfigForm;
class GeneralConfigForm extends ConfigForm
{
/**
* Initialize this form
*/
public function init()
{
$this->setName('form_config_grafana_general');
$this->setSubmitLabel('Save Changes');
}
/**
* {@inheritdoc}
*/
public function createElements(array $formData)
{
$this->addElement(
'text',
'grafana_username',
array(
'label' => $this->translate('Username'),
'description' => $this->translate('The HTTP Basic Auth user name used to access Grafana.')
)
);
$this->addElement(
'password',
'grafana_password',
array(
'renderPassword' => true,
'label' => $this->translate('Password'),
'description' => $this->translate('The HTTP Basic Auth password used to access Grafana.')
)
);
$this->addElement(
'text',
'grafana_host',
array(
'placeholder' => 'example server.name:3000',
'label' => $this->translate('Host'),
'description' => $this->translate('Host name of the Grafana server.'),
'required' => true
)
);
$this->addElement(
'select',
'grafana_protocol',
array(
'label' => 'Protocol',
'multiOptions' => array(
'http' => $this->translate('Unsecure: http'),
'https' => $this->translate('Secure: https'),
),
'description' => $this->translate('Protocol used to access Grafana.'),
'class' => 'autosubmit',
)
);
$this->addElement(
'text',
'grafana_height',
array(
'value' => '280',
'label' => $this->translate('Graph height'),
'description' => $this->translate('The default graph height in pixels.')
)
);
$this->addElement(
'text',
'grafana_width',
array(
'value' => '640',
'label' => $this->translate('Graph width'),
'description' => $this->translate('The default graph width in pixels.')
)
);
$this->addElement(
'select',
'grafana_timerange',
array(
'label' => $this->translate('Timerange'),
'multiOptions' => array(
'' => $this->translate('Use default'),
'5m' => $this->translate('Last 5 minutes'),
'15m' => $this->translate('Last 15 minutes'),
'30m' => $this->translate('Last 30 minutes'),
'1h' => $this->translate('Last 1 hour'),
'3h' => $this->translate('Last 3 hours'),
'6h' => $this->translate('Last 6 hours'),
'8h' => $this->translate('Last 8 hours'),
'12h' => $this->translate('Last 12 hours'),
'24h' => $this->translate('Last 24 hours'),
'2d' => $this->translate('Last 2 days'),
'7d' => $this->translate('Last 7 days'),
'30d' => $this->translate('Last 30 days'),
'60d' => $this->translate('Last 60 days'),
'6M' => $this->translate('Last 6 months'),
'1y' => $this->translate('Last 1 year'),
'2y' => $this->translate('Last 2 years'),
),
'description' => $this->translate('The default timerange to use for the graphs.')
)
);
$this->addElement(
'select',
'grafana_enableLink',
array(
'label' => $this->translate('Enable link'),
'multiOptions' => array(
'yes' => $this->translate('Yes'),
'no' => $this->translate('No'),
),
'description' => $this->translate('Image is an link to the dashboard on the Grafana server.')
)
);
$this->addElement(
'text',
'grafana_defaultdashboard',
array(
'value' => 'icinga2-default',
'label' => $this->translate('Default dashboard'),
'description' => $this->translate('Name of the default dashboard.'),
)
);
$this->addElement(
'select',
'grafana_defaultdashboardstore',
array(
'label' => $this->translate('Datasource Backend'),
'multiOptions' => array(
'db' => $this->translate('Database'),
'file' => $this->translate('File'),
),
'description' => $this->translate('Grafana Backend Type.')
)
);
$this->addElement(
'select',
'grafana_datasource',
array(
'label' => $this->translate('Datasource Type'),
'multiOptions' => array(
'influxdb' => $this->translate('InfluxDB'),
'graphite' => $this->translate('Graphite'),
'pnp' => $this->translate('PNP'),
),
'description' => $this->translate('Grafana Datasource Type.')
)
);
$this->addElement(
'select',
'grafana_accessmode',
array(
'label' => $this->translate('Grafana access'),
'multiOptions' => array(
'direct' => $this->translate('Direct'),
'proxy' => $this->translate('Proxy'),
),
'description' => $this->translate('User access Grafana directly or module proxies graphs.')
)
);
}
}