From 66bf13b7142aba3fbb6f77337ce96815de4de713 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Fri, 20 Sep 2013 22:34:35 +0100 Subject: [PATCH] "Undo" icon in device port sidebar to reset form to defaults Squashed commit of the following: commit 204f5627e03c5b657cc22ef2d178cf6d14a32aee Author: Oliver Gorwits Date: Fri Sep 20 22:33:32 2013 +0100 update undo icon link commit 49399301b98a97ad10eb806b8f0de5cb27cf17a1 Merge: 905a192 ce604ca Author: Oliver Gorwits Date: Fri Sep 20 21:04:56 2013 +0100 Merge branch 'master' into og-reset-cookie commit 905a192426c46ec66fd8fb1498917227604bf5cd Author: Oliver Gorwits Date: Fri Sep 20 21:04:18 2013 +0100 fix tooltip z-index bug, add undo icon commit 33775186347da188f6008253448f4841c688d785 Author: Oliver Gorwits Date: Fri Sep 13 08:36:16 2013 +0100 reset params used in query --- Netdisco/lib/App/Netdisco/Web/Device.pm | 34 ++++++++++++++++--------- Netdisco/share/public/css/netdisco.css | 13 ++++++++-- Netdisco/share/views/admintask.tt | 4 +-- Netdisco/share/views/device.tt | 8 ++++-- Netdisco/share/views/js/common.js | 8 +++++- Netdisco/share/views/report.tt | 4 +-- Netdisco/share/views/search.tt | 4 +-- 7 files changed, 52 insertions(+), 23 deletions(-) diff --git a/Netdisco/lib/App/Netdisco/Web/Device.pm b/Netdisco/lib/App/Netdisco/Web/Device.pm index 5fdc6f55..4e66ac27 100644 --- a/Netdisco/lib/App/Netdisco/Web/Device.pm +++ b/Netdisco/lib/App/Netdisco/Web/Device.pm @@ -59,7 +59,7 @@ hook 'before' => sub { my $cookie = cookie('nd_ports-form'); my $cdata = url_params_mixed($cookie); - if ($cdata and ref {} eq ref $cdata) { + if ($cdata and ref {} eq ref $cdata and not param('reset')) { foreach my $item (@{ var('port_columns') }) { my $key = $item->{name}; next unless defined $cdata->{$key} @@ -84,22 +84,32 @@ hook 'before' => sub { # copy ports form defaults into request query params if this is # a redirect from within the application (tab param is not set) - foreach my $col (@{ var('port_columns') }) { - next unless $col->{default} eq 'on'; - params->{$col->{name}} = 'checked' - if not param('tab') or param('tab') ne 'ports'; - } + if (param('reset') or not param('tab') or param('tab') ne 'ports') { + foreach my $col (@{ var('port_columns') }) { + delete params->{$col->{name}}; + params->{$col->{name}} = 'checked' + if $col->{default} eq 'on'; + } - foreach my $col (@{ var('connected_properties') }) { - next unless $col->{default} eq 'on'; - params->{$col->{name}} = 'checked' - if not param('tab') or param('tab') ne 'ports'; - } + foreach my $col (@{ var('connected_properties') }) { + delete params->{$col->{name}}; + params->{$col->{name}} = 'checked' + if $col->{default} eq 'on'; + } - if (not param('tab') or param('tab') ne 'ports') { + # not stored in the cookie params->{'age_num'} ||= 3; params->{'age_unit'} ||= 'months'; params->{'mac_format'} ||= 'IEEE'; + + if (param('reset')) { + params->{'age_num'} = 3; + params->{'age_unit'} = 'months'; + params->{'mac_format'} = 'IEEE'; + + # nuke the port params cookie + cookie('nd_ports-form' => '', expires => '-1 day'); + } } }; diff --git a/Netdisco/share/public/css/netdisco.css b/Netdisco/share/public/css/netdisco.css index 0e4e4707..d5f77577 100644 --- a/Netdisco/share/public/css/netdisco.css +++ b/Netdisco/share/public/css/netdisco.css @@ -340,7 +340,16 @@ td > form.nd_inline-form { .nd_sidebar-pin { float: left; - margin-top: 6px; + margin-top: 8px; + margin-left: -16px; + font-size: 15px; + color: #555; + cursor: pointer; +} + +.nd_sidebar-reset { + float: left; + margin-top: 27px; margin-left: -16px; font-size: 15px; color: #555; @@ -349,7 +358,7 @@ td > form.nd_inline-form { #nd_sidebar-toggle-img-in { float: left; - margin-top: -9px; + margin-top: -10px; margin-left: -16px; font-size: 15px; color: #555; diff --git a/Netdisco/share/views/admintask.tt b/Netdisco/share/views/admintask.tt index 07322d53..d246e2b9 100644 --- a/Netdisco/share/views/admintask.tt +++ b/Netdisco/share/views/admintask.tt @@ -4,9 +4,9 @@
+ rel="tooltip" data-placement="left" data-offset="5" data-title="Hide Sidebar" data-container="body"> + rel="tooltip" data-placement="left" data-offset="5" data-title="Unpin Sidebar" data-container="body">