Zoomed graphs in 'icecast.pm' now honour the 'global_zoom' option, and they also use the function RRDs::graphv to fit better in the browser pop up window (only for RRDtool v1.3+)

This commit is contained in:
Jordi Sanfeliu 2015-02-03 16:11:04 +01:00
parent 128801ac18
commit 60551c334b
1 changed files with 32 additions and 6 deletions

View File

@ -228,6 +228,15 @@ sub icecast_cgi {
my $graph = $cgi->{graph};
my $silent = $cgi->{silent};
my $zoom = "--zoom=" . $config->{global_zoom};
my %rrd = (
'new' => \&RRDs::graphv,
'old' => \&RRDs::graph,
);
my $version = "new";
my $pic;
my $picz;
my $picz_width;
my $picz_height;
my $u = "";
my $width;
@ -266,6 +275,7 @@ sub icecast_cgi {
"#444444",
);
$version = "old" if $RRDs::VERSION < 1.3;
my $rrd = $config->{base_lib} . $package . ".rrd";
my $title = $config->{graph_title}->{$package};
my $PNG_DIR = $config->{base_dir} . "/" . $config->{imgs_dir};
@ -425,7 +435,7 @@ sub icecast_cgi {
push(@CDEF, "CDEF:wrongdata=allvalues,UN,INF,UNKN,IF");
}
($width, $height) = split('x', $config->{graph_size}->{medium});
RRDs::graph("$PNG_DIR" . "$PNG[$e * 2]",
$pic = $rrd{$version}->("$PNG_DIR" . "$PNG[$e * 2]",
"--title=$config->{graphs}->{_icecast1} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}",
"--imgformat=PNG",
@ -452,7 +462,7 @@ sub icecast_cgi {
print("ERROR: while graphing $PNG_DIR" . "$PNG[$e * 2]: $err\n") if $err;
if(lc($config->{enable_zoom}) eq "y") {
($width, $height) = split('x', $config->{graph_size}->{zoom});
RRDs::graph("$PNG_DIR" . "$PNGz[$e * 2]",
$picz = $rrd{$version}->("$PNG_DIR" . "$PNGz[$e * 2]",
"--title=$config->{graphs}->{_icecast1} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}",
"--imgformat=PNG",
@ -460,6 +470,7 @@ sub icecast_cgi {
"--width=$width",
"--height=$height",
@riglim,
$zoom,
@{$cgi->{version12}},
@{$colors->{graph_colors}},
"DEF:ice" . $e . "_mp0=$rrd:icecast" . $e . "_mp0_ls:AVERAGE",
@ -483,7 +494,14 @@ sub icecast_cgi {
print(" <a href=\"" . $config->{url} . "/" . $config->{imgs_dir} . $PNGz[$e * 2] . "\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG[$e * 2] . "' border='0'></a>\n");
}
else {
print(" <a href=\"javascript:void(window.open('" . $config->{url} . "/" . $config->{imgs_dir} . $PNGz[$e * 2] . "','','width=" . ($width + 115) . ",height=" . ($height + 100) . ",scrollbars=0,resizable=0'))\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG[$e * 2] . "' border='0'></a>\n");
if($version eq "new") {
$picz_width = $picz->{image_width} * $config->{global_zoom};
$picz_height = $picz->{image_height} * $config->{global_zoom};
} else {
$picz_width = $width + 115;
$picz_height = $height + 100;
}
print(" <a href=\"javascript:void(window.open('" . $config->{url} . "/" . $config->{imgs_dir} . $PNGz[$e * 2] . "','','width=" . $picz_width . ",height=" . $picz_height . ",scrollbars=0,resizable=0'))\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG[$e * 2] . "' border='0'></a>\n");
}
} else {
print(" <img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG[$e * 2] . "'>\n");
@ -519,7 +537,7 @@ sub icecast_cgi {
push(@CDEF, "CDEF:wrongdata=allvalues,UN,INF,UNKN,IF");
}
($width, $height) = split('x', $config->{graph_size}->{medium});
RRDs::graph("$PNG_DIR" . $PNG[$e * 2 + 1],
$pic = $rrd{$version}->("$PNG_DIR" . $PNG[$e * 2 + 1],
"--title=$config->{graphs}->{_icecast2} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}",
"--imgformat=PNG",
@ -546,7 +564,7 @@ sub icecast_cgi {
print("ERROR: while graphing $PNG_DIR" . $PNG[$e * 2 + 1] . ": $err\n") if $err;
if(lc($config->{enable_zoom}) eq "y") {
($width, $height) = split('x', $config->{graph_size}->{zoom});
RRDs::graph("$PNG_DIR" . $PNGz[$e * 2 + 1],
$picz = $rrd{$version}->("$PNG_DIR" . $PNGz[$e * 2 + 1],
"--title=$config->{graphs}->{_icecast2} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}",
"--imgformat=PNG",
@ -554,6 +572,7 @@ sub icecast_cgi {
"--width=$width",
"--height=$height",
@riglim,
$zoom,
@{$cgi->{version12}},
@{$colors->{graph_colors}},
"DEF:ice" . $e . "_mp0=$rrd:icecast" . $e . "_mp0_br:AVERAGE",
@ -577,7 +596,14 @@ sub icecast_cgi {
print(" <a href=\"" . $config->{url} . "/" . $config->{imgs_dir} . $PNGz[$e * 2 + 1] . "\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG[$e * 2 + 1] . "' border='0'></a>\n");
}
else {
print(" <a href=\"javascript:void(window.open('" . $config->{url} . "/" . $config->{imgs_dir} . $PNGz[$e * 2 + 1] . "','','width=" . ($width + 115) . ",height=" . ($height + 100) . ",scrollbars=0,resizable=0'))\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG[$e * 2 + 1] . "' border='0'></a>\n");
if($version eq "new") {
$picz_width = $picz->{image_width} * $config->{global_zoom};
$picz_height = $picz->{image_height} * $config->{global_zoom};
} else {
$picz_width = $width + 115;
$picz_height = $height + 100;
}
print(" <a href=\"javascript:void(window.open('" . $config->{url} . "/" . $config->{imgs_dir} . $PNGz[$e * 2 + 1] . "','','width=" . $picz_width . ",height=" . $picz_height . ",scrollbars=0,resizable=0'))\"><img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG[$e * 2 + 1] . "' border='0'></a>\n");
}
} else {
print(" <img src='" . $config->{url} . "/" . $config->{imgs_dir} . $PNG[$e * 2 + 1] . "'>\n");