<%doc> Circuit Interface <%args> $id => undef; $edit => undef; $strand_sort => undef; $search => undef; $_action => undef; $sequence_list => undef; $user => $ui->get_current_user($r) <%attr> title => 'Circuit' section => 'Plant' <%init> my $DEBUG = 0; my $o = undef; my $editCircuit = 0; my $editStrand = 0; my @list; print "

    ", Dumper(%ARGS), "

" if $DEBUG; $o = Circuit->retrieve($id) if ($id && $id ne "NEW"); $editCircuit = 1 if ($id eq "NEW" || $edit eq "circuitinfo"); $editStrand = 1 if ($edit eq "strandinfo"); my $manager = $ui->get_permission_manager($r); if ( $_action ){ if ( $_action eq "SEARCH" ) { if ( length($search) ){ # remove spaces at beginning and end $search =~ s/^\s*(.*)\s*$/$1/; unless ( @list = Circuit->search_by_keyword($search) ){ print "

No results"; $m->abort; } my $num = scalar(@list); if ( $num == 1 ){ # Don't offer list. Just display this circuit $o = $list[0]; $id = $o->id; $search = undef; } }else{ print "

No search criteria"; $m->abort; } # code for inserting/updating # ----------------------------------------------------------------------------- }elsif( $_action eq "UPDATE_CIRCUIT" ){ my %update_info = (); print "ARGS is

    ", Dumper(%ARGS), "

" if $DEBUG; if (!(%update_info = $ui->form_to_db(%ARGS))) { $m->comp("error.mhtml", $ui->error()); } if ($update_info{Circuit}{id}) { $id = (keys %{$update_info{Circuit}{id}})[0]; $editCircuit = 0; } # Do this to 'flush' the values associated with the object # before redisplaying $o = undef; if ($id && $id ne "NEW") { $o = Circuit->retrieve($id); } }elsif( $_action eq "ADD_STRANDS" && $sequence_list ){ my @sequences; if ( ref($sequence_list) eq "ARRAY" ) { @sequences = @{$sequence_list}; }else { push(@sequences, $sequence_list); } if ( scalar @sequences ){ foreach my $seq ( @sequences ){ my @strands = split(/,/o, $seq); foreach my $strandid ( @strands ){ my $strand = CableStrand->retrieve($strandid); $strand->update({circuit_id=>$o}); } } }else{ $m->comp("error.mhtml", error=>"Empty sequence list"); } }elsif( $_action eq "UPDATE_SEQUENCES" ){ foreach my $key ( keys(%ARGS) ) { next if ($key !~ /^__unassign_(\d+)/o); my @strands = split(/,/o, $ARGS{"__sequence_" . $1}); foreach my $strandid ( @strands ){ my $strand = CableStrand->retrieve($strandid); $strand->update({circuit_id=>0}); } } } } # end insertion/update code # ----------------------------------------------------------------------------- % if ( $search && @list ){
<% scalar(@list) %> results for <% $search %>
<& /generic/sortresults.mhtml, object => \@list, view => "row", page => "circuit.html", withdelete => 1, withedit => 1 &>
% }elsif ( $o ){
% if ( $o->linkid ){ Circuit for Site Link: <% $o->linkid->name %> % }else{ Circuit ID: <% $o->cid %> % }
Circuit
% if ( $manager && $manager->can($user, 'access_admin_section', 'circuit:new') ){ [new] % } % if ( $manager && $manager->can($user, 'edit', $o) ){ [edit] % } % if ( $manager && $manager->can($user, 'delete', $o) ){ [delete] % } [text]
<& /generic/form.mhtml, table=>"Circuit", id=>$o->id, edit=>$edit &>
% my @interfaces = $o->interfaces;
Interfaces
% if ( $edit eq 'interfaces' ){
% }else{
% if ( $manager && $manager->can($user, 'edit', $o) ){ [edit] % } % if ( $manager && $manager->can($user, 'access_admin_section', 'circuit:add_interface') ){ [add] % }
% } <& /generic/sortresults.mhtml, object=>\@interfaces, withedit=>($edit eq 'interfaces')? 1 : 0 &>
<& display_sequence.mhtml, strands=>[$o->strands], table_view=>1 &> % if ( scalar($o->strands) ) {
% }

% # Allow the user to add strands to this circuit by backbone. % # First select a start site, then an end site, and then a backbone % # from the populated list. Hit submit and all strands for that backbone % # are associated with this circuit. % if ( $edit ne "strandinfo" ) {
% if ( $manager && $manager->can($user, 'access_admin_section', 'circuit:add_strand_sequences') ){

Add
<%perl> my @sites = Site->retrieve_all(); @sites = sort { $a->name cmp $b->name } @sites; Backbones connected from:
- TO -
Available Strand Sequence(s):
% } % } % my $cl; % if ( $o->vendor && int($cl = $o->vendor->contactlist) && $cl->contacts ){
<& /generic/contactlist.mhtml, id=>$cl->id, edit=>0, show_buttons=>0 &>
% }
%}