diff options
author | Jonathan Prykop <jonathan@freeside.biz> | 2015-12-15 20:31:53 -0600 |
---|---|---|
committer | Jonathan Prykop <jonathan@freeside.biz> | 2015-12-15 20:31:53 -0600 |
commit | da6b5077952f9630f68363df66fa80efc8f1d5b7 (patch) | |
tree | c4b35718d5a76bb1bc19437d1bb0844703db9468 /httemplate/elements/broadband_snmp_get.html | |
parent | 08adf9b62500806763ff3a470228dfdd45494598 (diff) |
RT#39115: View SNMP info on svc_broadband service [got rid of dialog, displays inline]
Diffstat (limited to 'httemplate/elements/broadband_snmp_get.html')
-rw-r--r-- | httemplate/elements/broadband_snmp_get.html | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/httemplate/elements/broadband_snmp_get.html b/httemplate/elements/broadband_snmp_get.html new file mode 100644 index 000000000..d4cc4e49d --- /dev/null +++ b/httemplate/elements/broadband_snmp_get.html @@ -0,0 +1,56 @@ +<%doc> +Adds a table to display dynamically loaded snmp statistics based on broadband_snmp_get +export config. Performs necessary checks such that, if no such exports are configured +for the passed service, returns blank space (ie may be safely invoked even if no exports +are configured.) + + <& '/elements/broadband_snmp_get.html', svc => $svc &> + +</%doc> +% if (@snmp) { +<& '/elements/xmlhttp.html', + 'url' => $fsurl.'misc/xmlhttp-broadband_snmp_get.cgi', + 'subs' => [ 'broadband_snmp_get_request' ] + &> +<DIV ID="broadband_snmp_get"></DIV> +<SCRIPT> +function broadband_snmp_get (svcnum) { + document.getElementById('broadband_snmp_get').innerHTML = 'Loading SNMP...'; + broadband_snmp_get_request('svcnum',svcnum, + function (result) { + var objects = JSON.parse(result) || []; + if (objects.length) { + var table = document.createElement('table'); + for (i = 0; i < objects.length; i++) { + var row = document.createElement('tr'); + var obj = objects[i]; + if (obj.error) { + var cell = document.createElement('td'); + cell.colSpan = '2'; + cell.innerHTML = obj['error']; + row.appendChild(cell); + } else { + var cell = document.createElement('td'); + cell.innerHTML = obj['label']; + row.appendChild(cell); + cell = document.createElement('td'); + cell.innerHTML = obj['value']; + row.appendChild(cell); + } + table.appendChild(row); + } + var resultblock = document.getElementById('broadband_snmp_get'); + resultblock.innerHTML = ''; + resultblock.appendChild(table); + } // if objects.length + } // function + ); // broadband_snmp_get_request +} // broadband_snmp_get +broadband_snmp_get('<% $svcnum %>'); +</SCRIPT> +% } #if @snmp +<%init> +my(%opt) = @_; +my @snmp = $opt{'svc'}->cust_svc->part_svc->part_export('broadband_snmp_get'); +my $svcnum = $opt{'svc'}->svcnum; +</%init> |