<%doc> -- Device tasks -- % <%attr> title => 'Device Tasks' % % %####################################################################### %# %# Args section %# %####################################################################### <%args> $device_search => undef $zone_id => undef $ip_search => undef $mac_search => undef $user => $ui->get_current_user($r); $submit => undef $show_tasks => undef $showheader => 1 % % % %####################################################################### %# %# INIT section %# %####################################################################### % <%init> my $DEBUG = 0; print '%ARGS is
', Dumper(%ARGS), '

' if $DEBUG; my $IPV4 = Netdot->get_ipv4_regex(); my $IPV6 = Netdot->get_ipv6_regex(); my $MAC = Netdot->get_mac_regex(); my @list; $show_tasks = $show_tasks || $user->getAttribute("SHOW_TASKS"); if ( $show_tasks eq "" ) { $user->setAttribute($r, "SHOW_TASKS", "show"); $show_tasks = "show"; } *print_showtaskslink = $m->comp('SELF:.sub_print_showtaskslink'); my $hideheader = 'style="display:none"' if ( !$showheader ); $ARGS{show_tasks} = $show_tasks; <%perl> if ( $device_search ){ # Get rid of spaces $device_search =~ s/\s+//g; if ( $device_search =~ /$MAC/ ){ $m->comp('.show_tasks', %ARGS, user=>$user); $m->comp('/management/mac.html', search=>$device_search, dowindow=>1 ); }elsif ( $device_search =~ /$IPV4|$IPV6/ ){ if ( scalar(@list = Device->search(name=>$device_search)) == 1 ){ my $o = $list[0]; my $id = $o->id; $m->comp('/management/device.html', id => $id, user=>$user ); }else{ $m->comp('/management/address_tasks.html', submit=>1, search_address=>$device_search, user=>$user, dowindow=>1 ); } }else{ $m->comp('.show_tasks', %ARGS, user=>$user); my %args = (name=>$device_search); $args{zone} = $zone_id if $zone_id; unless ( (@list = Device->search_like(%args)) ){ $m->comp('/generic/no_search_results.html', search=>$device_search); } if ( scalar(@list) == 1 ){ # Don't offer list. Just display device my $o = $list[0]; my $id = $o->id; $m->comp('/management/device.html', id => $id, user=>$user ); }else{ $m->comp('/generic/show_search_results.mhtml', search=>$device_search, list=>\@list, dowindow=>1 ); } } }else{ $m->comp('.show_tasks', %ARGS, user=>$user); } %################################################################ %# show_tasks sub-component %################################################################ <%def .show_tasks> <%args> $show_tasks => undef $hideheader => undef $device_search => undef $ip_search => undef $mac_search => undef $view => 'search' $zone_id => undef $user <%init> my @communities = @{Netdot->config->get('DEFAULT_SNMPCOMMUNITIES')}; my @all_zones = Zone->retrieve_all(); my $manager = $ui->get_permission_manager($r);
>
Device Tasks
% if ( $manager && $manager->can($user, 'access_admin_section', 'device_tasks:new') ){ % if ( $view eq 'search' ){ [new] % }elsif ( $view eq 'new' ){ [search] % } % } % print_showtaskslink($show_tasks);
">
% if ( $view eq 'search' ){
Find Devices

% }elsif ( $view eq 'new' ){
Discover Device

% if ( $ui->config->get('DEFAULT_SNMPVERSION') == 3 ){
% }else{ % if ( $ui->config->get('DEFAULT_SNMPVERSION') == 3 ){
Add Device manually

% }