#!/usr/bin/perl -wT -I. use CGI; use Tinderbox3::Header; use Tinderbox3::DB; use Tinderbox3::InitialValues; use Tinderbox3::Login; use strict; # # Init # my $p = new CGI; my $dbh = get_dbh(); my ($login, $cookie) = check_session($p, $dbh); # For delete_machine Tinderbox3::DB::update_machine_action($p, $dbh, $login); # For delete_patch, stop_using_patch Tinderbox3::DB::update_patch_action($p, $dbh, $login); # For delete_bonsai Tinderbox3::DB::update_bonsai_action($p, $dbh, $login); # For edit_tree my $tree = Tinderbox3::DB::update_tree_action($p, $dbh, $login); # # Get the tree info to fill in the fields # my $tree_info; my %initial_machine_config; if (!$tree) { $tree_info = [ $Tinderbox3::InitialValues::field_short_names, $Tinderbox3::InitialValues::field_processors, $Tinderbox3::InitialValues::statuses, $Tinderbox3::InitialValues::min_row_size, $Tinderbox3::InitialValues::max_row_size, $Tinderbox3::InitialValues::default_tinderbox_view, $Tinderbox3::InitialValues::new_machines_visible, '', ]; %initial_machine_config = %Tinderbox3::InitialValues::initial_machine_config; } else { $tree_info = $dbh->selectrow_arrayref("SELECT field_short_names, field_processors, statuses, min_row_size, max_row_size, default_tinderbox_view, new_machines_visible, editors FROM tbox_tree WHERE tree_name = ?", undef, $tree); if (!defined($tree_info)) { die "Could not get tree!"; } my $sth = $dbh->prepare("SELECT name, value FROM tbox_initial_machine_config WHERE tree_name = ?"); $sth->execute($tree); while (my $row = $sth->fetchrow_arrayref) { $initial_machine_config{$row->[0]} = $row->[1]; } } # # Edit / Add tree form # header($p, $login, $cookie, ($tree ? "Edit $tree" : "Add Tree"), $tree); print < @{[$p->hidden(-name=>'tree', -default=>$tree, -override=>1)]}
Tree Name (this is the name used to identify the tree):@{[$p->textfield(-name=>'tree_name', -default=>$tree)]}
Status Short Names (bloat=Bl,pageload=Tp...)@{[$p->textfield(-name=>'field_short_names', -default=>$tree_info->[0], -size=>80)]}
Status Handlers (bloat=Graph,binary_url=URL...)@{[$p->textfield(-name=>'field_processors', -default=>$tree_info->[1], -size=>80)]}
Tree Statuses (open,closed...)@{[$p->textfield(-name=>'statuses', -default=>$tree_info->[2], -size=>80)]}
Min Row Size (minutes)@{[$p->textfield(-name=>'min_row_size', -default=>$tree_info->[3])]}
Max Row Size (minutes)@{[$p->textfield(-name=>'max_row_size', -default=>$tree_info->[4])]}
Tinderbox Page Size (minutes)@{[$p->textfield(-name=>'default_tinderbox_view', -default=>$tree_info->[5])]}
New Machines Visible By Default?[6] ? ' checked' : '']}>
Editor Privileges (list of emails)@{[$p->textfield(-name=>'editors', -default=>$tree_info->[9])]}

Initial .mozconfig:
@{[$p->textarea(-name=>'initial_machine_config0_val', -default=>$initial_machine_config{mozconfig}, -rows=>5, -columns => 100)]}

EOM print "

Initial Machine Config:
"; print "(Empty a line to delete it)
"; print "\n"; my $config_num = 1; while (my ($var, $value) = each %initial_machine_config) { if ($var ne "mozconfig") { print ""; print "\n"; $config_num++; } } foreach my $i ($config_num..($config_num+2)) { print ""; print "\n"; } print "
VarValue
", $p->textfield(-name=>"initial_machine_config$config_num", -default=>$var, -override=>1), "", $p->textfield(-name=>"initial_machine_config${config_num}_val", -default=>$value, -override=>1), "
", $p->textfield(-name=>"initial_machine_config$i", -override=>1), "", $p->textfield(-name=>"initial_machine_config${i}_val", -override=>1), "

\n"; if (!$login) { print login_fields(); } print < EOM # # If it's not new, have a list of patches and machines # if ($tree) { # Patch list print "\n"; my $sth = $dbh->prepare('SELECT patch_id, patch_name, in_use FROM tbox_patch WHERE tree_name = ?'); $sth->execute($tree); while (my $patch_info = $sth->fetchrow_arrayref) { my ($patch_class, $action, $action_name); if ($patch_info->[2]) { $patch_class = ""; $action = "stop_using_patch"; $action_name = "Obsolete"; } else { $patch_class = " class=obsolete"; $action = "start_using_patch"; $action_name = "Resurrect"; } print "\n"; } print "\n"; print "
Patches
$patch_info->[1] (Del | $action_name)
Upload Patch
\n"; # Machine list print "\n"; $sth = $dbh->prepare('SELECT machine_id, machine_name FROM tbox_machine WHERE tree_name = ?'); $sth->execute($tree); while (my $machine_info = $sth->fetchrow_arrayref) { print "\n"; } # XXX Add this feature in if you decide not to automatically allow machines # into the federation # print "\n"; print "
Machines
$machine_info->[1]
New Machine
\n"; # Machine list print "\n"; $sth = $dbh->prepare('SELECT bonsai_id, display_name FROM tbox_bonsai WHERE tree_name = ?'); $sth->execute($tree); while (my $bonsai_info = $sth->fetchrow_arrayref) { print "\n"; } print "\n"; print "
Bonsai Monitors
$bonsai_info->[1] (Del)
New Bonsai
\n"; } footer($p); $dbh->disconnect;