3 # Display hosts on which software packages are being managed, a form for
4 # finding existing packages and a form for installing more
6 require './cluster-software-lib.pl';
7 &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1);
9 # Display hosts on which software will be installed
10 print &ui_subheading($text{'index_hosts'});
11 @servers = &list_servers();
12 @hosts = &list_software_hosts();
13 if ($config{'sort_mode'} == 1) {
14 @hosts = sort { my ($as) = grep { $_->{'id'} == $a->{'id'} } @servers;
15 my ($bs) = grep { $_->{'id'} == $b->{'id'} } @servers;
16 lc($as->{'host'}) cmp lc($bs->{'host'}) } @hosts;
18 elsif ($config{'sort_mode'} == 2) {
19 @hosts = sort { my ($as) = grep { $_->{'id'} == $a->{'id'} } @servers;
20 my ($bs) = grep { $_->{'id'} == $b->{'id'} } @servers;
21 lc(&server_name($as)) cmp lc(&server_name($bs)) }@hosts;
25 local ($s) = grep { $_->{'id'} == $h->{'id'} } @servers;
27 local $count = @{$h->{'packages'}};
28 push(@titles, ($s->{'desc'} ? $s->{'desc'} :
29 $s->{'realhost'} ? "$s->{'realhost'}:$s->{'port'}" :
30 "$s->{'host'}:$s->{'port'}")."<br>".
31 &text('index_count', $count));
32 push(@links, "edit_host.cgi?id=$h->{'id'}");
33 push(@icons, "$gconfig{'webprefix'}/servers/images/$s->{'type'}.gif");
34 push(@installed, $count);
35 $gothost{$h->{'id'}}++;
38 if ($config{'table_mode'}) {
40 print &ui_columns_start([ $text{'index_thost'},
42 $text{'index_tcount'},
43 $text{'index_ttype'} ]);
45 local ($s) = grep { $_->{'id'} == $h->{'id'} } @servers;
47 local ($type) = grep { $_->[0] eq $s->{'type'} }
48 @servers::server_types;
49 print &ui_columns_row([
50 "<a href='edit_host.cgi?id=$h->{'id'}'>".
51 ($s->{'host'} || &get_system_hostname())."</a>",
53 scalar(@{$h->{'packages'}}),
57 print &ui_columns_end();
61 &icons_table(\@links, \@titles, \@icons);
65 print "<b>$text{'index_nohosts'}</b><p>\n";
69 # Show form for adding a server
70 print "<table width=100%><tr>\n";
71 @addservers = grep { !$gothost{$_->{'id'}} } @servers;
72 if (@addservers && $access{'add'}) {
73 print "<form action=add.cgi>\n";
74 print "<td width=33%>\n";
75 print "<input type=submit name=add value='$text{'index_add'}'>\n";
76 print "<select name=server>\n";
77 foreach $s (@addservers) {
78 print "<option value=$s->{'id'}>",
79 $s->{'desc'} || $s->{'realhost'} || $s->{'host'},"\n";
81 print "</select></td>\n";
85 # Show button for compare form
87 print "<form action=compare_form.cgi>\n";
88 print "<td align=center width=33%>\n";
89 print "<input type=submit value='$text{'index_compare'}'>\n";
94 # Show form for adding a group of servers
95 @groups = &servers::list_all_groups(\@servers);
96 if (@groups && $access{'add'}) {
97 print "<form action=add.cgi>\n";
98 print "<td align=right width=33%>\n";
99 print "<input type=submit name=gadd value='$text{'index_gadd'}'>\n";
100 print "<select name=group>\n";
101 foreach $g (@groups) {
102 print "<option>$g->{'name'}\n";
104 print "</select></td>\n";
107 print "</tr></table>\n";
110 # Display search form
112 print &ui_subheading($text{'index_installed'});
113 print "<table cellpadding=0 cellspacing=0 width=100%><tr><td>\n";
115 print "<form action=search.cgi>\n";
116 print "<input type=submit value=\"$text{'index_search'}\">\n";
117 print "<input name=search size=30>\n";
118 print "</form></td>\n";
120 print "<td align=right><form action=refresh.cgi>\n";
121 print "<input type=submit value=\"$text{'index_refresh'}\">\n";
122 &create_on_input(undef, 1, 1);
123 print "</form></td> </tr></table>\n";
125 # Display cross-cluster install form
127 print &ui_subheading($text{'index_install'});
128 print "$text{'index_installmsg'}<p>\n";
131 print &ui_form_start("install_pack.cgi?id=$upid", "form-data", undef,
132 &read_parse_mime_javascript($upid, [ "upload" ])),"\n";
135 push(@opts, [ 0, $text{'index_local'},
136 &ui_textbox("local", undef, 50)."\n".
137 &file_chooser_button("local", 0, 2) ]);
138 push(@opts, [ 1, $text{'index_uploaded'},
139 &ui_upload("upload", 50) ]);
140 push(@opts, [ 2, $text{'index_ftp'},
141 &ui_textbox("url", undef, 50)."<br>\n".
142 &ui_checkbox("down", 1, $text{'index_down'}, 0) ]);
143 if ($software::has_update_system) {
145 $software::text{$software::update_system.'_input'},
146 &ui_textbox("update", undef, 30)."\n".
147 &software::update_system_button("update",
148 $software::text{$software::update_system.'_find'})
151 print &ui_radio_table("source", 0, \@opts);
152 print &ui_submit($text{'index_installok'}),"\n";
153 print &ui_form_end();
156 &ui_print_footer("/", $text{'index'});