diff --git a/Netdisco/lib/App/Netdisco/Web/Device.pm b/Netdisco/lib/App/Netdisco/Web/Device.pm index 5fdc6f55..099246ba 100644 --- a/Netdisco/lib/App/Netdisco/Web/Device.pm +++ b/Netdisco/lib/App/Netdisco/Web/Device.pm @@ -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'); + } } };