alter page title when viewing device details

This commit is contained in:
Oliver Gorwits
2012-12-10 19:15:50 +00:00
parent 20dc225443
commit 4dd6080a84
4 changed files with 20 additions and 10 deletions

View File

@@ -177,7 +177,7 @@ td {
margin-bottom: 10px; margin-bottom: 10px;
} }
.nd_device_name { #nd_device_name {
float: right; float: right;
margin-bottom: 0px; margin-bottom: 0px;
margin-top: 9px; margin-top: 9px;

View File

@@ -7,6 +7,12 @@ function do_search (event, tab) {
// stop form from submitting normally // stop form from submitting normally
event.preventDefault(); event.preventDefault();
// page title
var pgtitle = 'Netdisco';
if ($('#nd_device_name').text().length) {
var pgtitle = $('#nd_device_name').text() +' - '+ $('#'+ tab + '_link').text();
}
// each sidebar search form has a hidden copy of the main navbar search // each sidebar search form has a hidden copy of the main navbar search
// query. when the tab query takes place, copy the navbar locally, then // query. when the tab query takes place, copy the navbar locally, then
// replicate to all other tabs. // replicate to all other tabs.
@@ -42,10 +48,7 @@ function do_search (event, tab) {
is_from_history_plugin = 1; is_from_history_plugin = 1;
window.History.replaceState( window.History.replaceState(
{name: tab, fields: $(form).serializeArray()}, {name: tab, fields: $(form).serializeArray()},
'Netdisco ' pgtitle, uri_base + '/' + path + '?' + query
+ path.charAt(0).toUpperCase() + path.slice(1) + ' - '
+ tab.charAt(0).toUpperCase() + tab.slice(1),
uri_base + '/' + path + '?' + query
); );
is_from_history_plugin = 0; is_from_history_plugin = 0;
} }
@@ -98,14 +101,17 @@ function update_content(from, to) {
var to_form = '#' + to + '_form'; var to_form = '#' + to + '_form';
var from_form = '#' + from + '_form'; var from_form = '#' + from + '_form';
// page title
var pgtitle = 'Netdisco';
if ($('#nd_device_name').text().length) {
var pgtitle = $('#nd_device_name').text() +' - '+ $('#'+ to + '_link').text();
}
if (window.History && window.History.enabled && is_from_state_event == 0) { if (window.History && window.History.enabled && is_from_state_event == 0) {
is_from_history_plugin = 1; is_from_history_plugin = 1;
window.History.pushState( window.History.pushState(
{name: to, fields: $(to_form).serializeArray()}, {name: to, fields: $(to_form).serializeArray()},
'Netdisco ' pgtitle, uri_base + '/' + path + '?' + $(to_form).serialize()
+ path.charAt(0).toUpperCase() + path.slice(1) + ' - '
+ to.charAt(0).toUpperCase() + to.slice(1),
uri_base + '/' + path + '?' + $(to_form).serialize()
); );
is_from_history_plugin = 0; is_from_history_plugin = 0;
} }

View File

@@ -45,7 +45,7 @@
[% FOREACH tab IN vars.tabs %] [% FOREACH tab IN vars.tabs %]
<li[% ' class="active"' IF params.tab == tab.id %]><a id="[% tab.id %]_link" href="#[% tab.id %]_pane">[% tab.label %]</a></li> <li[% ' class="active"' IF params.tab == tab.id %]><a id="[% tab.id %]_link" href="#[% tab.id %]_pane">[% tab.label %]</a></li>
[% END %] [% END %]
<span class="nd_device_name">[% d.dns || d.name %]</span> <span id="nd_device_name">[% d.dns || d.name %]</span>
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
[% FOREACH tab IN vars.tabs %] [% FOREACH tab IN vars.tabs %]

View File

@@ -3,6 +3,10 @@
var path = 'device'; var path = 'device';
function inner_view_processing(tab) { function inner_view_processing(tab) {
// LT wanted the page title to reflect what's on the page :)
document.title = $('#nd_device_name').text()
+' - '+ $('#'+ tab + '_link').text();
// VLANs column list collapser trigger // VLANs column list collapser trigger
// it's a bit of a faff because we can't easily use Bootstrap's collapser // it's a bit of a faff because we can't easily use Bootstrap's collapser
$('.nd_collapse_vlans').toggle(function() { $('.nd_collapse_vlans').toggle(function() {