web/modules/rhn/RHN/DB/ChannelEditor.pm | 96 ----
web/modules/sniglets/Sniglets/ChannelEditor.pm | 48 --
web/modules/sniglets/Sniglets/ProbeReport.pm | 586 -------------------------
3 files changed, 730 deletions(-)
New commits:
commit e127e202b2dc3504816ed959a7e9e356285d24fc
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Mon Dec 14 15:08:04 2009 +0100
rhn-show-all-errata-checkbox not used anywhere, removing, as well as
show_all_errata_checkbox.
diff --git a/web/modules/sniglets/Sniglets/ChannelEditor.pm
b/web/modules/sniglets/Sniglets/ChannelEditor.pm
index 6c1f149..bfc32e5 100644
--- a/web/modules/sniglets/Sniglets/ChannelEditor.pm
+++ b/web/modules/sniglets/Sniglets/ChannelEditor.pm
@@ -34,7 +34,6 @@ sub register_tags {
$pxt->register_tag('rhn-channel-edit-form' => \&channel_edit_form);
$pxt->register_tag('rhn-channel-select-options' =>
\&channel_select_options);
$pxt->register_tag('rhn-if-package-list-modified' =>
\&if_package_list_modified);
- $pxt->register_tag('rhn-show-all-errata-checkbox' =>
\&show_all_errata_checkbox);
$pxt->register_tag('rhn-if-var' => \&if_var, -5);
$pxt->register_tag('rhn-clone-channel-form' =>
\&clone_channel_form);
@@ -821,15 +820,6 @@ sub if_var {
return $block;
}
-sub show_all_errata_checkbox {
- my $pxt = shift;
- my %attr = @_;
-
- return PXT::HTML->checkbox(-name => 'show_all_errata',
- -value => 1,
- -checked => $pxt->dirty_param('show_all_errata') ? 1 : 0);
-}
-
sub channel_sync_prompt {
my $pxt = shift;
my %params = @_;
commit 5a1819a223fd557b8629640d1905234968ce87f1
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Mon Dec 14 15:07:19 2009 +0100
rhn-if-packages-deleted-from-channels not used anywhere, removing, as well as
if_packages_deleted_from_channels.
diff --git a/web/modules/sniglets/Sniglets/ChannelEditor.pm
b/web/modules/sniglets/Sniglets/ChannelEditor.pm
index a4c4937..6c1f149 100644
--- a/web/modules/sniglets/Sniglets/ChannelEditor.pm
+++ b/web/modules/sniglets/Sniglets/ChannelEditor.pm
@@ -34,7 +34,6 @@ sub register_tags {
$pxt->register_tag('rhn-channel-edit-form' => \&channel_edit_form);
$pxt->register_tag('rhn-channel-select-options' =>
\&channel_select_options);
$pxt->register_tag('rhn-if-package-list-modified' =>
\&if_package_list_modified);
- $pxt->register_tag('rhn-if-packages-deleted-from-channels' =>
\&if_packages_deleted_from_channels);
$pxt->register_tag('rhn-show-all-errata-checkbox' =>
\&show_all_errata_checkbox);
$pxt->register_tag('rhn-if-var' => \&if_var, -5);
$pxt->register_tag('rhn-clone-channel-form' =>
\&clone_channel_form);
@@ -811,27 +810,6 @@ sub if_package_list_modified {
return '';
}
-sub if_packages_deleted_from_channels {
- my $pxt = shift;
- my %params = @_;
-
- my $block = $params{__block__};
-
- my $package_list_edited = $pxt->session->get('package_list_edited');
-
- my @channels = keys %{$package_list_edited};
-
- foreach my $cid (@channels) {
- my $edited = $package_list_edited->{$cid} || 0;
-
- if ((time - $edited) < 3600) {
- return $block;
- }
- }
-
- return '';
-}
-
sub if_var {
my $pxt = shift;
my %attr = @_;
commit b407b0269417db5800a4db2698e74fe58771f346
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Mon Dec 14 15:06:15 2009 +0100
Removal of verify_channel_family makes verify_org_family and verify_family_permissions
unused, removing as dead code.
diff --git a/web/modules/rhn/RHN/DB/ChannelEditor.pm
b/web/modules/rhn/RHN/DB/ChannelEditor.pm
index 57118c9..57e65f0 100644
--- a/web/modules/rhn/RHN/DB/ChannelEditor.pm
+++ b/web/modules/rhn/RHN/DB/ChannelEditor.pm
@@ -597,102 +597,6 @@ EOQ
$dbh->commit;
}
-#checks that org has a channelfamily associated with it. If not, creates one.
-sub verify_org_family {
-
- my $class = shift;
- my $org = shift or return;
-
- my $dbh = RHN::DB->connect();
-
- my $query =<<EOQ;
- SELECT CF.id
- FROM rhnChannelFamily CF
- WHERE CF.org_id = ?
-ORDER BY CF.id
-EOQ
-
- my $sth = $dbh->prepare($query);
-
- $sth->execute($org->id);
-
- my @cf_ids;
-
- while (my ($data) = $sth->fetchrow) {
- push @cf_ids, $data;
- }
-
- unless (@cf_ids) { #make a channelfamily for this org
-
- $query =<<EOQ;
-INSERT INTO rhnChannelFamily
- (id, name, label, org_id, product_url)
- VALUES (rhn_channel_family_id_seq.nextval, ?, ?, ?, ?)
-EOQ
-
- $sth = $dbh->prepare($query);
- $sth->execute($org->name . " (" . $org->id . ") " .
"Channel Family", "private-channel-family-".$org->id, $org->id,
"org_channel_family.pxt");
-
- $dbh->commit;
-
- }
-
- return;
-
-}
-
-#checks that org has a channelfamilypermission for it's channelfamily
-#grants them if it does not.
-#Takes an org object, and returns the rhnChannelFamily.id(s) added, if any.
-sub verify_family_permissions {
-
- my $class = shift;
- my $org = shift or return;
-
- my $dbh = RHN::DB->connect();
-
- my $query =<<EOQ;
- SELECT CF.id
- FROM rhnChannelFamily CF
- WHERE CF.org_id = ?
-AND NOT EXISTS (
- SELECT 1
- FROM rhnChannelFamilyPermissions CFP
- WHERE CFP.org_id = CF.org_id
- AND CFP.channel_family_id = CF.id)
-ORDER BY CF.id
-EOQ
-
- my $sth = $dbh->prepare($query);
-
- $sth->execute($org->id);
-
- my @cf_ids;
-
- while (my ($data) = $sth->fetchrow) {
- push @cf_ids, $data;
- }
-
- return unless @cf_ids;
-
- $query = <<EOQ;
-INSERT INTO rhnPrivateChannelFamily
- (channel_family_id, org_id, max_members, current_members)
- VALUES (?, ?, NULL, 0)
-EOQ
-
- $sth = $dbh->prepare($query);
-
- foreach my $cf_id (@cf_ids) {
- $sth->execute($cf_id, $org->id);
- }
-
- $dbh->commit;
-
- return @cf_ids;
-
-}
-
#pick the 'most likely' parent for a cloned channel by:
# 1) See if the org owns a clone of the original channel's parent
# 2) Otherwise, pick the actual parent of the original channel
commit 3a3295166cdc76be9dd844ad669e94e1dad8060c
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Mon Dec 14 15:04:44 2009 +0100
rhn-verify-channel-family not used anywhere, removing, as well as
verify_channel_family.
diff --git a/web/modules/sniglets/Sniglets/ChannelEditor.pm
b/web/modules/sniglets/Sniglets/ChannelEditor.pm
index 922751d..a4c4937 100644
--- a/web/modules/sniglets/Sniglets/ChannelEditor.pm
+++ b/web/modules/sniglets/Sniglets/ChannelEditor.pm
@@ -32,7 +32,6 @@ sub register_tags {
my $pxt = shift;
$pxt->register_tag('rhn-channel-edit-form' => \&channel_edit_form);
- $pxt->register_tag('rhn-verify-channel-family' =>
\&verify_channel_family);
$pxt->register_tag('rhn-channel-select-options' =>
\&channel_select_options);
$pxt->register_tag('rhn-if-package-list-modified' =>
\&if_package_list_modified);
$pxt->register_tag('rhn-if-packages-deleted-from-channels' =>
\&if_packages_deleted_from_channels);
@@ -676,21 +675,6 @@ sub channel_edit_form {
return $block;
}
-#ensure that the org that the logged-in use represents has a channelfamily,
-#and has permission to access that channelfamily.
-sub verify_channel_family {
-
- my $pxt = shift;
-
- my $org = $pxt->user->org or return;
-
- RHN::ChannelEditor->verify_org_family($org);
- RHN::ChannelEditor->verify_family_permissions($org);
-
- return;
-
-}
-
#output a list of channels to select packages from, including 'no channels', and
'any channel'
sub channel_select_options {
my $pxt = shift;
commit 04fdaeea5707378a4317dc60c7dd63a1fcc2b74e
Author: Jan Pazdziora <jpazdziora(a)redhat.com>
Date: Mon Dec 14 15:02:52 2009 +0100
Package Sniglets::ProbeReport is not used anywhere, removing as dead code.
diff --git a/web/modules/sniglets/Sniglets/ProbeReport.pm
b/web/modules/sniglets/Sniglets/ProbeReport.pm
deleted file mode 100644
index af8ebba..0000000
--- a/web/modules/sniglets/Sniglets/ProbeReport.pm
+++ /dev/null
@@ -1,586 +0,0 @@
-#
-# Copyright (c) 2008 Red Hat, Inc.
-#
-# This software is licensed to you under the GNU General Public License,
-# version 2 (GPLv2). There is NO WARRANTY for this software, express or
-# implied, including the implied warranties of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
-# along with this software; if not, see
-#
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
-#
-# Red Hat trademarks are not licensed under GPLv2. No permission is
-# granted to use or replicate Red Hat trademarks that are incorporated
-# in this software or its documentation.
-#
-
-use strict;
-
-package Sniglets::ProbeReport;
-
-use Data::Dumper;
-use URI::Escape;
-
-use RHN::DataSource;
-use RHN::Date;
-use RHN::SCDB;
-use RHN::TSDB;
-
-use Moon::Chart;
-use Moon::Dataset::Coordinate;
-use Moon::Dataset::Function;
-use Moon::Chart::TimeAxes;
-
-use Sniglets::ServerActions;
-
-use PXT::HTML;
-use PXT::Handlers;
-
-
-my $MAX_DISPLAY_ROWS = 100; # Max # of event logs rows to display
-
-
-###################
-sub register_tags {
-###################
- my $class = shift;
- my $pxt = shift;
-
- $pxt->register_tag('rhn-probe-current-state', \&probe_current_state);
- $pxt->register_tag('rhn-probe-report-setup', \&report_setup);
- $pxt->register_tag('rhn-probe-metrics-multiple',
\&probe_metrics_multiple);
- $pxt->register_tag('rhn-probe-report', \&probe_report);
- $pxt->register_tag('rhn-probe-tsdb-graph', \&tsdb_graph);
-}
-
-
-
-########################
-sub register_callbacks {
-########################
- my $class = shift;
- my $pxt = shift;
-
-}
-
-
-
-#########################
-sub probe_current_state {
-#########################
- my $pxt = shift;
- my %params = @_;
- my $block = $params{__block__};
- my $probe_id = $pxt->param('probe_id');
- my($html, $data);
-
-
- # Collect probe data from the database (REQUIRED)
- $data = RHN::DataSource::Simple->new(
- -querybase => 'probe_queries',
- -mode => 'probe',
- )->execute_full(-probe_id => $probe_id);
-
- my $probe = $data->[0];
-
- die("ERROR: No probe record for probe $probe_id!") unless ($probe);
-
- # Collect probe state data from the database (OPTIONAL)
- $data = RHN::DataSource::Simple->new(
- -querybase => 'probe_queries',
- -mode => 'probe_state',
- )->execute_full(-probe_id => $probe_id);
-
- my $pstate = $data->[0];
-
- unless ($pstate) {
- $pstate = {
- STATE => 'PENDING',
- OUTPUT => '(No probe state)',
- LAST_CHECK => '',
- };
- }
-
- if ($pstate->{'LAST_CHECK'}) {
- my $timestamp = new RHN::Date(-string => $pstate->{'LAST_CHECK'}, user
=> $pxt->user);
- my $css_class = '';
-
- if ($pstate->{'STATE'} eq 'CRITICAL') {
- $css_class = 'class="probe-status-critical"';
- }
- elsif ($pstate->{'STATE'} eq 'UNKNOWN') {
- $css_class = 'class="probe-status-unknown"';
- }
-
- # Display the probe state
- $html .= "<table class=\"details\">\n";
-
- $html .= "<tr>\n";
- $html .= "<th>Probe:</th>\n";
- $html .= "<td>" . $probe->{'DESCRIPTION'} .
"</td>\n";
- $html .= "</tr>\n";
-
- $html .= "<tr>\n";
- $html .= "<th>Status:</th>\n";
- $html .= sprintf("<td $css_class>%s - %s</td>\n",
$pstate->{'STATE'},
- $pstate->{'OUTPUT'});
- $html .= "</tr>\n";
-
- $html .= "<tr>\n";
- $html .= "<th>Last check:</th>\n";
- $html .= "<td>" . $timestamp->long_date_with_zone($pxt->user) .
"</td>\n";
- $html .= "</tr>\n";
-
- $html .= "</table>\n";
-
- }
- else {
- $html .= "<table class=\"details\">\n";
-
- $html .= "<tr>\n";
- $html .= "<th>NO CURRENT STATE FOUND</th>\n";
- $html .= "</tr>\n";
- $html .= "</table>\n";
-
- }
-
- return $html;
-}
-
-
-
-##################
-sub report_setup {
-##################
- my $pxt = shift;
- my %params = @_;
- my $block = $params{__block__};
- my $probe_id = $pxt->param('probe_id');
- my $submitted = $pxt->dirty_param('doit');
- my $html = '';
-
- # Create the various widgets
- my $start_widget = &Sniglets::ServerActions::date_pickbox($pxt,
- preserve => 1,
- prefix => 'start_',
- years => '0,-1,-2',
- );
-
- my $end_widget = &Sniglets::ServerActions::date_pickbox($pxt,
- preserve => 1,
- prefix => 'end_',
- years => '0,-1,-2',
- );
-
- # This will be undef if there are no metrics
- my $metrics_widget = &probe_metrics_multiple($pxt);
-
- my $graph_checked = $submitted ? $pxt->dirty_param('show_graph') : 1;
- my $graph_checkbox = PXT::HTML->checkbox(
- -checked => $graph_checked,
- -name => 'show_graph',
- );
-
- my $log_checked = $submitted ? $pxt->dirty_param('show_events') : 1;
- my $log_checkbox = PXT::HTML->checkbox(
- -checked => $log_checked,
- -name => 'show_events',
- );
-
- my $submit = PXT::HTML->submit(
- -name => "doit",
- -value => "Generate report",
- ) . "\n";
-
- my $old_min_y = $pxt->dirty_param('min_y');
- my $min_y_widget = PXT::HTML->text(
- -name => "min_y",
- -size => 5,
- -value => $old_min_y,
- ) . "\n";
-
- my $old_max_y = $pxt->dirty_param('max_y');
- my $max_y_widget = PXT::HTML->text(
- -name => "max_y",
- -size => 5,
- -value => $old_max_y,
- ) . "\n";
-
-
- # Display the probe report setup area
- $html .= "<table class=\"details\">\n";
-
- $html .= "<tr>\n";
- $html .= "<th>Start date:</th>\n";
- $html .= "<td>$start_widget</td>\n";
-
- $html .= "<td> </td>\n";
-
- if ($metrics_widget) {
- $html .= "<th rowspan='2'>Metrics:</th>\n";
- $html .= "<td rowspan='2'>$metrics_widget</td>\n";
- }
-
- $html .= "</tr>\n";
-
- $html .= "<tr>\n";
- $html .= "<th>End date:</th>\n";
- $html .= "<td>$end_widget</td>\n";
- $html .= "</tr>\n";
-
-
- if ($metrics_widget) {
- $html .= "<tr>\n";
- $html .= "<th>Show graph:</th>\n";
- $html .= "<td>$graph_checkbox</td>\n";
-
- if ($pxt->dirty_param('show_graph')) {
- $html .= "<td> </td>\n";
- $html .= "<th>Minimum Y value</th>\n";
- $html .= "<td>$min_y_widget</td>\n";
- }
- $html .= "</tr>\n";
- }
-
- $html .= "<tr>\n";
- $html .= "<th>Show event log:</th>\n";
- $html .= "<td>$log_checkbox</td>\n";
-
- if ($metrics_widget) {
- if ($pxt->dirty_param('show_graph')) {
- $html .= "<td> </td>\n";
- $html .= "<th>Maximum Y value</th>\n";
- $html .= "<td>$max_y_widget</td>\n";
- }
- }
-
- $html .= "</tr>\n";
-
-
-
- $html .= "<tr>\n";
- $html .= "<td>$submit</td>\n";
- $html .= "</tr>\n";
-
- $html .= "</table>\n";
-
- $html .= &PXT::Handlers::pxt_hidden_handler($pxt, name => "sid") .
"\n";
- $html .= &PXT::Handlers::pxt_hidden_handler($pxt, name => "probe_id")
. "\n";
-
-
- $html = &PXT::Handlers::pxt_form_handler($pxt,
- __block__ => $html,
- method => 'post',
- );
-
-
- return $html;
-}
-
-
-
-############################
-sub probe_metrics_multiple {
-############################
- my $pxt = shift;
- my %params = @_;
- my $block = $params{__block__};
- my $probe_id = $pxt->param('probe_id');
- my($html, %data);
-
- my @submitted_metrics = $pxt->dirty_param('metrics');
- my %checked; @checked{@submitted_metrics} = (1) x @submitted_metrics;
-
- # Collect probe data from the database
- my $data = RHN::DataSource::Simple->new(
- -querybase => 'probe_queries',
- -mode => 'probe_metrics',
- )->execute_full(-probe_id => $probe_id);
-
- my @metrics;
- foreach my $metric (@$data) {
- push(@metrics, [
- $metric->{'LABEL'},
- $metric->{'METRIC_ID'},
- $checked{$metric->{'METRIC_ID'}},
- ]
- );
- }
-
- if (@metrics) {
-
- return PXT::HTML->select(
- -name => 'metrics',
- -size => 3,
- -multiple => 1,
- -options => \@metrics,
- );
-
- } else {
-
- return undef;
-
- }
-
-}
-
-
-
-##################
-sub probe_report {
-##################
- my $pxt = shift;
- my %params = @_;
- my $org_id = $pxt->user->org_id;
- my $probe_id = $pxt->param('probe_id');
- my $sid = $pxt->param('sid');
- my $min_y = $pxt->dirty_param('min_y');
- my $max_y = $pxt->dirty_param('max_y');
- my $html;
-
- return $html unless ($pxt->dirty_param('doit'));
-
- my $show_graph = $pxt->dirty_param('show_graph');
- my $show_events = $pxt->dirty_param('show_events');
-
- if ($show_events or $show_graph) {
- my $start_date = Sniglets::ServerActions->parse_date_pickbox($pxt,
- prefix => 'start_',
- long_date => 0,
- );
- my $end_date = Sniglets::ServerActions->parse_date_pickbox($pxt,
- prefix => 'end_',
- long_date => 0,
- );
-
- if (not $start_date or not $end_date) {
-
- $pxt->push_message(local_alert => 'Please pick a valid start date.')
unless ($start_date);
- $pxt->push_message(local_alert => 'Please pick a valid end date.')
unless ($end_date);
-
- } elsif ($start_date >= $end_date) {
-
- $pxt->push_message(local_alert => 'Please select a start date earlier
than the end date.');
-
- } else {
-
- if ($show_graph) {
- my @metrics = $pxt->dirty_param('metrics');
- if (@metrics) {
- $html .= &graph_url(
- sid => $sid,
- org_id => $org_id,
- probe_id => $probe_id,
- start => $start_date,
- end => $end_date,
- min_y => $min_y,
- max_y => $max_y,
- metrics => \@metrics,
- ) . "\n";
- } else {
- $pxt->push_message(local_alert => 'Please select one or more metrics
to graph.');
- }
- }
-
- if ($show_events) {
- $html .= &event_log(
- pxt => $pxt,
- probe_id => $probe_id,
- start => $start_date,
- end => $end_date,
- );
- }
-
- }
-
-
- } else {
- $html .= "You probably want to select at least one of 'Show graph'
";
- $html .= "or 'Show event log'.";
- }
-
-
-
- return $html;
-}
-
-
-###############
-sub event_log {
-###############
- my %params = @_;
- my $pxt = $params{'pxt'};
- my $html = "<h2>Event log</h2>\n";
-
- my $results = RHN::SCDB->new()->fetch(
- probe_id => $params{'probe_id'},
- start => $params{'start'},
- end => $params{'end'},
- );
-
- if (@$results) {
-
- $html .= "<table class='list' width='96%'
align='center'>\n";
- $html .= "<tr>\n";
- $html .= "<th>Timestamp</th>\n";
- $html .= "<th>State</th>\n";
- $html .= "<th>Message</th>\n";
- $html .= "</tr>\n";
-
- for (my $i = 1; $i <= @$results; $i++) {
-
- my $rowstyle = ($i % 2 == 0) ? 'list-row-even' : 'list-row-odd';
-
- if ($i > $MAX_DISPLAY_ROWS) {
- my $left = @$results - $i + 1;
- $html .= "<tr class='$rowstyle'>\n";
- $html .= "<td nowrap='1' colspan='3'>\n";
- $html .= "(... $MAX_DISPLAY_ROWS entries displayed, ";
- $html .= "$left remaining entries not displayed)\n";
- $html .= "</td>\n";
- $html .= "</tr>\n";
- last;
- }
-
- my($time, $state, $escaped) = @{$results->[-$i]};
- my $msg = &uri_unescape($escaped);
- my $timestamp = new RHN::Date(-epoch => $time, user => $pxt->user);
-
- $html .= "<tr class='$rowstyle'>\n";
- $html .= "<td nowrap='1'>" .
$timestamp->long_date_with_zone($pxt->user) . "</td>\n";
- $html .= "<td align='center'>$state</td>\n";
- $html .= "<td>$msg</td>\n";
- $html .= "</tr>\n";
-
- }
- $html .= "</table>\n";
-
- } else {
-
- $html .= "No events this period\n";
-
- }
-
- return $html;
-
-}
-
-###############
-sub graph_url {
-###############
- my %p = @_;
- my $metrics = delete($p{'metrics'});
- my $html = "<h2>Time series</h2>\n";
-
- my @params;
- foreach my $key (keys %p) {
- push(@params, "$key=$p{$key}");
- }
-
- foreach my $metric (@$metrics) {
- my $params = join('&', @params, "metric=$metric");
- my $src = "graph.pxt?$params";
- $html .= PXT::HTML->img(-src => $src);
- }
-
- return '<div style="text-align: center">' . $html .
'</div>';
-}
-
-
-# Generate a time series graph
-################
-sub tsdb_graph {
-################
- my $pxt = shift;
- my $org_id = $pxt->user->org_id;
- my $probe_id = $pxt->param('probe_id');
- my $metric_id = $pxt->dirty_param('metric');
- my $min_y = $pxt->dirty_param('min_y');
- my $max_y = $pxt->dirty_param('max_y');
-
- # Fetch the dataset from the TSDB
- my $tsdata = RHN::TSDB->new()->fetch(
- org_id => $org_id,
- probe_id => $probe_id,
- metric => $metric_id,
- start => $pxt->dirty_param('start') - 600,
- end => $pxt->dirty_param('end') + 600,
- );
-
- # Fetch metric labels and units
- my $data = RHN::DataSource::Simple->new(
- -querybase => 'probe_queries',
- -mode => 'probe_metric',
- )->execute_full(
- -probe_id => $probe_id,
- -metric_id => $metric_id,
- );
-
-
- my $metric = $data->[0];
- die ("ERROR: No metric '$metric_id' for probe $probe_id") unless
($metric);
-
- my $sd = Moon::Dataset::Coordinate->new(
- -coords => $tsdata,
- -label => $metric->{'LABEL'},
- );
-
- my $no_data_image;
-
- if (@$tsdata) {
- $max_y = $sd->max_y unless (length($max_y));
- $min_y = $sd->min_y unless (length($min_y));
- } else {
- # No data, show prefab image w/ informative text
- $no_data_image = '/var/www/html/img/rhn-no-ts-data.png';
- }
-
- if (abs($max_y - $min_y) < 0.02 * $max_y) {
- $max_y = 2 * $max_y;
- $min_y = 0;
- }
-
-
- my $chart = new Moon::Chart(800, 250);
-
- $chart->add_dataset($sd->label, $sd);
-
- $chart->graph_stencil_min(0.05, 0.2);
-
- $chart->graph_stencil_max(0.97, 0.95);
-
- my $axes = new Moon::Chart::TimeAxes(undef, undef, undef, $pxt->user);
-
- $axes->set_bounds(
- [$pxt->dirty_param('start'), $min_y ],
- [$pxt->dirty_param('end') , $max_y * 1.01]
- );
-
- $chart->set_axes($axes);
-
- my $imgfile;
- if ($no_data_image) {
- $imgfile = $no_data_image;
- }
- else {
- $imgfile = "/tmp/mychart.$$.png";
- $chart->render_to_file($imgfile);
- }
-
- # Send that puppy
- $pxt->manual_content(1);
- $pxt->no_cache(1);
- $pxt->content_type('image/png');
- $pxt->header_out('Content-length' => -s $imgfile);
- $pxt->send_http_header;
-
- open(FILE, $imgfile) or die "Couldn't open $imgfile: $!";
- $pxt->send_fd(*FILE);
- close(FILE);
-
- unlink($imgfile) if not $no_data_image;
-
-
-}
-
-
-1;