Merge branch 'master' into og-reset-cookie

This commit is contained in:
Oliver Gorwits
2013-09-20 21:04:56 +01:00
23 changed files with 271 additions and 72 deletions

View File

@@ -200,6 +200,15 @@ td > form.nd_inline-form {
color: #6D5720;
}
/* reset to normal weight for the download as CSV icon */
#nd_csv-download {
font-weight: normal;
}
#nd_csv-download:hover {
text-decoration: none;
}
/* for the job control admin page play/pause links */
#nd_countdown-refresh:hover, #nd_countdown-control:hover {
text-decoration: none;

View File

@@ -36,6 +36,12 @@
<i id="nd_countdown-control-icon" class="text-success icon-play"></i></a>
<span id="nd_countdown"></span>
</span>
[% ELSIF task.provides_csv %]
<span id="nd_device-name">
<a id="nd_csv-download" href="#" download="netdisco.csv">
<i id="nd_csv-download-icon" class="text-info icon-file-text-alt icon-large"
rel="tooltip" data-placement="left" data-offset="5" data-title="Download as CSV"></i></a>
</span>
[% END %]
</ul>
<div class="tab-content">

View File

@@ -0,0 +1,11 @@
[% USE CSV -%]
[% CSV.dump([ 'Address' 'DNS' 'Interface' 'Description' 'Prefix' ]) %]
[% WHILE (row = results.next) %]
[% mylist = [] %]
[% FOREACH col IN [ row.alias row.dns row.port row.device_port.name row.subnet ] %]
[% mylist.push(col) %]
[% END %]
[% CSV.dump(mylist) %]
[% END %]

View File

@@ -0,0 +1,10 @@
[% USE CSV -%]
[% CSV.dump([ 'Channel' 'Count' ]) %]
[% WHILE (row = results.next) %]
[% mylist = [] %]
[% mylist.push(row.channel) %]
[% mylist.push(row.get_column('ch_count')) %]
[% CSV.dump(mylist) %]
[% END %]

View File

@@ -0,0 +1,13 @@
[% USE CSV -%]
[% CSV.dump([ 'Left Device' 'Port' 'Duplex' 'Right Device' 'Port' 'Duplex' ]) %]
[% WHILE (row = results.next) %]
[% mylist = [] %]
[% device_left = row.left_dns || row.left_ip %]
[% device_right = row.right_dns || row.right_ip %]
[% FOREACH col IN [ device_left row.left_port row.left_duplex.ucfirst device_right row.right_port row.right_duplex.ucfirst ] %]
[% mylist.push(col) %]
[% END %]
[% CSV.dump(mylist) %]
[% END %]

View File

@@ -0,0 +1,12 @@
[% USE CSV -%]
[% CSV.dump([ 'Device' 'Port' 'Description' 'Duplex' ]) %]
[% WHILE (row = results.next) %]
[% mylist = [] %]
[% device = row.device.dns || row.device.ip %]
[% FOREACH col IN [ device row.port row.name row.duplex.ucfirst ] %]
[% mylist.push(col) %]
[% END %]
[% CSV.dump(mylist) %]
[% END %]

View File

@@ -0,0 +1,12 @@
[% USE CSV -%]
[% CSV.dump([ 'Device' 'Total Ports' 'In Use' 'Shutdown' 'Free' ]) %]
[% WHILE (row = results.next) %]
[% mylist = [] %]
[% device = row.dns || row.ip %]
[% FOREACH col IN [ device row.port_count row.ports_in_use row.ports_shutdown row.ports_free ] %]
[% mylist.push(col) %]
[% END %]
[% CSV.dump(mylist) %]
[% END %]

View File

@@ -0,0 +1,12 @@
[% USE CSV -%]
[% CSV.dump(headers) %]
[% WHILE (row = results.next) %]
[% mylist = [] %]
[% device = row.dns || row.ip %]
[% FOREACH col IN [ device row.contact row.location row.name row.model row.os_ver row.ip row.serial] %]
[% mylist.push(col) %]
[% END %]
[% CSV.dump(mylist) %]
[% END %]

View File

@@ -0,0 +1,12 @@
[% USE CSV -%]
[% CSV.dump([ 'Description' 'Port' 'Name' 'Vlan' ]) %]
[% WHILE (row = results.next) %]
[% mylist = [] %]
[% myport = "$row.ip [ $row.port ] (" _ row.device.dns _ ")" IF row.device.dns %]
[% FOREACH col IN [ row.name myport row.descr row.vlan ] %]
[% mylist.push(col) %]
[% END %]
[% CSV.dump(mylist) %]
[% END %]

View File

@@ -0,0 +1,12 @@
[% USE CSV -%]
[% CSV.dump([ 'Vlan' 'Device' 'Description' 'Model' 'OS' 'Vendor' ]) %]
[% WHILE (row = results.next) %]
[% mylist = [] %]
[% device = row.dns || row.ip %]
[% FOREACH col IN [ row.vlan.vlan device row.vlan.description row.model row.os row.vendor ] %]
[% mylist.push(col) %]
[% END %]
[% CSV.dump(mylist) %]
[% END %]

View File

@@ -47,7 +47,12 @@
[% FOREACH tab IN settings._device_tabs %]
<li[% ' class="active"' IF params.tab == tab.tag %]><a id="[% tab.tag %]_link" href="#[% tab.tag %]_pane">[% tab.label %]</a></li>
[% END %]
<span id="nd_device-name">[% d.dns || d.name | html_entity %]</span>
<span id="nd_device-name">
[% d.dns || d.name | html_entity %]
<a id="nd_csv-download" href="#" download="netdisco.csv">&nbsp;
<i id="nd_csv-download-icon" class="text-info icon-file-text-alt icon-large"
rel="tooltip" data-placement="left" data-offset="5" data-title="Download as CSV"></i></a>
</span>
</ul>
<div class="tab-content">
[% FOREACH tab IN settings._device_tabs %]

View File

@@ -1,3 +1,23 @@
// csv download icon on any table page
// needs to be dynamically updated to use current search options
function update_csv_download_link (type, tab, show) {
var form = '#' + tab + '_form';
var query = $(form).serialize();
if (show == '1') {
$('#nd_csv-download')
.attr('href', '/ajax/content/' + type + '/' + tab + '?' + query)
.attr('download', 'netdisco-' + type + '-' + tab + '.csv')
.show();
}
else {
$('#nd_csv-download').hide();
}
}
// page title includes tab name and possibly device name
// this is nice for when you have multiple netdisco pages open in the
// browser
function update_page_title (tab) {
var pgtitle = 'Netdisco';
if ($('#nd_device-name').text().length) {
@@ -43,6 +63,7 @@
[% FOREACH tab IN settings._search_tabs %]
$('[% "#${tab.tag}_form" %]').submit(function (event) {
var pgtitle = update_page_title('[% tab.tag %]');
update_csv_download_link('search', '[% tab.tag %]', '[% tab.provides_csv %]');
update_browser_history('[% tab.tag %]', pgtitle);
copy_navbar_to_sidebar('[% tab.tag %]');
do_search(event, '[% tab.tag %]');
@@ -55,8 +76,10 @@
[% FOREACH tab IN settings._device_tabs %]
$('[% "#${tab.tag}_form" %]').submit(function (event) {
var pgtitle = update_page_title('[% tab.tag %]');
update_csv_download_link('device', '[% tab.tag %]', '[% tab.provides_csv %]');
update_browser_history('[% tab.tag %]', pgtitle);
copy_navbar_to_sidebar('[% tab.tag %]');
[% IF tab.tag == 'ports' %]
var cookie = $('#ports_form').find('input,select')
.not('#nd_port-query,input[name="q"],input[name="tab"]')
@@ -66,6 +89,7 @@
});
$.cookie('nd_ports-form', $.param(cookie) ,{ expires: 365 });
[% END %]
do_search(event, '[% tab.tag %]');
});
[% END %]
@@ -74,7 +98,8 @@
[% IF report %]
// for the report pages
$('[% "#${report.tag}_form" %]').submit(function (event) {
update_page_title('[% tab.tag %]');
update_page_title('[% report.tag %]');
update_csv_download_link('report', '[% report.tag %]', '1');
do_search(event, '[% report.tag %]');
});
[% END -%]
@@ -82,7 +107,8 @@
[% IF task %]
// for the admin pages
$('[% "#${task.tag}_form" %]').submit(function (event) {
update_page_title('[% tab.tag %]');
update_page_title('[% task.tag %]');
update_csv_download_link('task', '[% task.tag %]', '1');
do_search(event, '[% task.tag %]');
});
[% END %]

View File

@@ -28,6 +28,13 @@
<ul id="nd_search-results" class="nav nav-tabs">
<li class="active"><a id="[% report.tag %]_link" class="nd_single-tab"
href="#[% report.tag %]_pane">[% report.label %]</a></li>
[% IF report.provides_csv %]
<span id="nd_device-name">
<a id="nd_csv-download" href="#" download="netdisco.csv">
<i id="nd_csv-download-icon" class="text-info icon-file-text-alt icon-large"
rel="tooltip" data-placement="left" data-offset="5" data-title="Download as CSV"></i></a>
</span>
[% END %]
</ul>
<div class="tab-content">
<div class="tab-pane active" id="[% report.tag %]_pane"></div>

View File

@@ -32,6 +32,11 @@
[% FOREACH tab IN settings._search_tabs %]
<li[% ' class="active"' IF params.tab == tab.tag %]><a id="[% tab.tag %]_link" href="#[% tab.tag %]_pane">[% tab.label %]</a></li>
[% END %]
<span id="nd_device-name">
<a id="nd_csv-download" href="#" download="netdisco.csv">
<i id="nd_csv-download-icon" class="text-info icon-file-text-alt icon-large"
rel="tooltip" data-placement="left" data-offset="5" data-title="Download as CSV"></i></a>
</span>
</ul>
<div class="tab-content">
[% FOREACH tab IN settings._search_tabs %]