return iso path
[pxelator] / lib / PXElator / html.pm
index 1303c07..f464c3e 100644 (file)
@@ -51,7 +51,6 @@ sub select {
                , qq|<select type=select name=$name>|
                , join("\n", map { my $selected = $_ eq $selected_option ? 'selected' : ''; qq|<option name=$_ $selected>$_</option>| } @_ )
                , qq|</select>|
-               , qq|</form>|
        );
 }
 
@@ -71,7 +70,7 @@ sub conf {
        my ($ip,$conf,$format) = @_;
        my @editable = splice(@_,3);
 
-       warn "# conf ",dump( $ip, $conf, $format, [ @editable ] );
+#      warn "# conf ",dump( $ip, $conf, $format, [ @editable ] );
 
        $format ||= 'inline';
 
@@ -84,28 +83,38 @@ sub conf {
                        ( $name, qq|<input name=$name value="$html" size=$size>| )
                } else {
                        if ( $name eq 'amt' ) {
-                               $html = qq|<a title="$html" href=http://$ip:16992/logon.htm>logon</a>|;
-
-                               $html .= qq| power: |
-                                       . ( amt::power_on($ip)
+                               my $amt_ip = amt::ip($ip,$html);
+                               # $html contains password!
+                               $html = qq|<a href=http://$amt_ip:16992/logon.htm target=$amt_ip>$amt_ip</a>|;
+
+                               if ( $format ne 'inline' ) {
+                                       my $power = amt::power_on($ip);
+                                       $html .= qq| power: |
+                                       . ( $power
                                                ? qq|<a href=/amt/PowerDown/$ip title="turn off">on</a>|
                                                : qq|<a href=/amt/PowerUp/$ip   title="turn on" >off</a>|
-                                       ) if $format ne 'inline';
+                                       );
+                                       client::conf( $ip, 'power' => $power ? 'on' : 'off' );
+                               }
                        } elsif ( $name eq 'ssh' ) {
                                $html =~ s{\s(\S{16}).+(\S{16})\s}{ $1..$2 };
                                chomp($html);
+                       } elsif ( $name eq 'kvm' ) {
+                               $html = qq|<a href="/start_stop/kvm?nr=$html">$html</a>|;
+                       } elsif ( $name eq 'munin' ) {
+                               $html = join("\n", map { my $url = $_; $url =~ s/-d\w+\.\w+$/.html/; qq|<a href="$url"><img src="$_"></a>| } split(/\s+/s,$html));
                        }
-                       $html = qq|<pre style="display: inline">$html</pre>|
+                       $html = qq|<tt>$html</tt>|
                        unless
                        $html =~ s{\b(\S+)\t(\S+)\t(\S+)\b}{<b title="$1/$2">$3</b> }gs;
                
                        if ( $format =~ /edit|table/ ) {
                                ( $name, $html );
                        } else {
-                               qq|<em>$name</em> $html<br>|
+                               qq|<div class="config $name"><em>$name</em> $html</div>|
                        }
                }
-       } sort keys %$conf;
+       } grep { length($conf->{$_}) > 0 } sort keys %$conf;
 
        $format eq 'inline' ? join("\n", @opts) : @opts;
 }