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
|
<%doc>
</%doc>
<& head.html, %opt &>
<INPUT TYPE="hidden" NAME="options" VALUE="community,version,ip_addr_change_to_new,timeout">
<& /elements/tr-select.html,
label => 'SNMP version',
field => 'version',
options => [ '', 'v1', 'v2c' ],
labels => { v1 => '1', v2c => '2c' },
curr_value => $part_export->option('version') &>
<& /elements/tr-input-text.html,
label => 'Community',
field => 'community',
curr_value => $curr_value->{'community'},
&>
<& /elements/tr-checkbox.html,
label => 'Send IP address changes to new address',
field => 'ip_addr_change_to_new',
value => 1,
curr_value => $part_export->option('ip_addr_change_to_new'),
&>
<& /elements/tr-input-text.html,
label => 'Timeout (seconds)',
field => 'timeout',
curr_value => $part_export->option('timeout'),
&>
</TABLE>
<script type="text/javascript">
function open_select_mib(obj) {
nd(1); // if there's already one open, close it
var rownum = obj.rownum;
var curr_oid = obj.form.elements['oid' + rownum].value || '';
var url = '<%$fsurl%>misc/select-mib-popup.html?' +
'callback=receive_mib;' +
'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(obj, rownum) {
//console.log(JSON.stringify(obj));
// we don't really need the numeric OID or any of the other properties
var oidfield = document.getElementById('oid'+rownum);
oidfield.value = obj.fullname;
document.getElementById('datatype'+rownum).value = obj.type;
oidfield.onchange(); //should be same as datatype, only need to run one
}
</script>
<table bgcolor="#cccccc" border=0 cellspacing=3>
<TR>
<TH>Action</TH>
<TH>Object</TH>
<TH>Type</TH>
<TH>Value</TH>
</TR>
<TR id="mytemplate">
<TD>
<SELECT NAME="action">
% foreach ('', qw(insert delete replace suspend unsuspend)) {
<OPTION VALUE="<%$_%>"><%$_%></OPTION>
% }
</SELECT>
</TD>
<TD>
<INPUT NAME="oid" ID="oid" SIZE="54">
<INPUT TYPE="button" VALUE="..." ID="openselector" onclick="open_select_mib(this)">
</TD>
<TD>
<INPUT TYPE="text" NAME="datatype" ID="datatype">
</TD>
<TD>
<INPUT NAME="value" ID="value" SIZE="30">
</TD>
</TR>
<& /elements/auto-table.html,
template_row => 'mytemplate',
fieldorder => ['action', 'oid', 'datatype', 'value'],
data => \@data,
&>
<INPUT TYPE="hidden" NAME="multi_options" VALUE="action,oid,datatype,value">
<& foot.html, %opt &>
<%init>
my %opt = @_;
my $part_export = $opt{part_export} || FS::part_export->new;
my $curr_value = {};
$curr_value->{'community'} = ($opt{'part_export'} && $opt{'part_export'}->exportnum)
? $part_export->option('community')
: $opt{'export_info'}->{'options'}->{'community'}->{'default'};
my @actions = split("\n", $part_export->option('action'));
my @oids = split("\n", $part_export->option('oid'));
my @types = split("\n", $part_export->option('datatype'));
my @values = split("\n", $part_export->option('value'));
my @data;
while (@actions or @oids or @values) {
my @thisrow = (shift(@actions), shift(@oids), shift(@types), shift(@values));
push @data, \@thisrow if grep length($_), @thisrow;
}
my $popup_name = 'popup-'.time."-$$-".rand() * 2**32;
</%init>
|