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
|
<%doc>
Quite a bit of false laziness with edit/elements/part_export/broadband_snmp.html
</%doc>
<& head.html, %opt &>
<INPUT TYPE="hidden" NAME="options" VALUE="snmp_community,snmp_version,snmp_timeout">
<& /elements/tr-select.html,
label => 'SNMP version',
field => 'snmp_version',
options => [ '1', '2c' ],
curr_value => $curr_value->{'snmp_version'}
&>
<& /elements/tr-input-text.html,
label => 'Community',
field => 'snmp_community',
curr_value => $curr_value->{'snmp_community'},
&>
<& /elements/tr-input-text.html,
label => 'Timeout (seconds)',
field => 'snmp_timeout',
curr_value => $curr_value->{'snmp_timeout'},
&>
</TABLE>
<script type="text/javascript">
function open_select_mib_get(obj) {
nd(1); // if there's already one open, close it
var rownum = obj.rownum;
var curr_oid = obj.form.elements['snmp_oid' + rownum].value || '';
var url = '<%$fsurl%>misc/select-mib-popup.html?' +
'callback=receive_mib_get;' +
'arg=' + rownum +
';curr_value=' + curr_oid;
overlib(
OLiframeContent(url, 550, 450, '<% $popup_name %>', 0, 'auto'),
CAPTION, 'Select MIB object', STICKY, AUTOSTATUSCAP,
MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK,
BGCOLOR, '#333399', CGCOLOR, '#333399',
CLOSETEXT, 'Close'
);
}
function receive_mib_get(obj, rownum) {
var oidfield = document.getElementById('snmp_oid'+rownum);
oidfield.value = obj.fullname;
oidfield.onchange();
}
</script>
<table bgcolor="#cccccc" border=0 cellspacing=3>
<TR><TH>Object Name</TH><TH>Object ID</TH></TR>
<TR id="broadband_snmp_get_template">
<TD>
<INPUT NAME="oid_name" ID="oid_name" SIZE="25">
</TD>
<TD>
<INPUT NAME="oid" ID="oid" SIZE="54">
<INPUT TYPE="button" VALUE="..." ID="openselector" onclick="open_select_mib_get(this)">
</TD>
</TR>
<& /elements/auto-table.html,
template_row => 'broadband_snmp_get_template',
fieldorder => ['oid_name','oid'],
data => \@data,
table => 'snmp',
&>
<INPUT TYPE="hidden" NAME="multi_options" VALUE="snmp_oid,snmp_oid_name">
<& foot.html, %opt &>
<%init>
my %opt = @_;
my $part_export = $opt{part_export} || FS::part_export->new;
my $curr_value = {};
foreach my $field ( qw(snmp_version snmp_community snmp_timeout) ) {
$curr_value->{$field} = ($opt{'part_export'} && $opt{'part_export'}->exportnum)
? $part_export->option($field)
: $opt{'export_info'}->{'options'}->{$field}->{'default'};
}
my @oids = split("\n", $part_export->option('snmp_oid'));
my @oid_names = split("\n", $part_export->option('snmp_oid_name'));
my @data;
while (@oids) {
my @thisrow = (shift(@oids));
my $name = shift(@oid_names);
push @data, [$name, \@thisrow] if grep length($_), @thisrow;
}
my $popup_name = 'popup-'.time."-$$-".rand() * 2**32;
</%init>
|