Add a progress bar to the passive analytics data export functions.
This commit is contained in:
parent
40c61575d6
commit
82603b29c7
1 changed files with 12 additions and 0 deletions
|
|
@ -13,6 +13,7 @@ use WebGUI::Workflow;
|
||||||
use WebGUI::Workflow::Instance;
|
use WebGUI::Workflow::Instance;
|
||||||
use WebGUI::User;
|
use WebGUI::User;
|
||||||
use WebGUI::Text;
|
use WebGUI::Text;
|
||||||
|
use WebGUI::ProgressBar;
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
|
|
@ -84,15 +85,26 @@ The name of the file to create inside the storage object.
|
||||||
|
|
||||||
sub exportSomething {
|
sub exportSomething {
|
||||||
my ($session, $sth, $filename) = @_;
|
my ($session, $sth, $filename) = @_;
|
||||||
|
my $pb = WebGUI::ProgressBar->new($session);
|
||||||
|
my $i18n = WebGUI::International->new($session, 'Asset_Thingy');
|
||||||
|
$pb->start($i18n->get('export label'), $session->url->extras('adminConsole/passiveAnalytics.png'));
|
||||||
|
$pb->update($i18n->get('Creating column headers'));
|
||||||
my $storage = WebGUI::Storage->createTemp($session);
|
my $storage = WebGUI::Storage->createTemp($session);
|
||||||
my @columns = $sth->getColumnNames;
|
my @columns = $sth->getColumnNames;
|
||||||
my $csvData = WebGUI::Text::joinCSV( @columns ). "\n";
|
my $csvData = WebGUI::Text::joinCSV( @columns ). "\n";
|
||||||
|
$pb->update($i18n->get('Writing data'));
|
||||||
|
my $rowCounter=0;
|
||||||
while (my $row = $sth->hashRef()) {
|
while (my $row = $sth->hashRef()) {
|
||||||
my @row = @{ $row }{@columns};
|
my @row = @{ $row }{@columns};
|
||||||
$csvData .= WebGUI::Text::joinCSV(@row) . "\n";
|
$csvData .= WebGUI::Text::joinCSV(@row) . "\n";
|
||||||
|
if (! ++$rowCounter % 25) {
|
||||||
|
$pb->update($i18n->get('Writing data'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$storage->addFileFromScalar($filename, $csvData);
|
$storage->addFileFromScalar($filename, $csvData);
|
||||||
$session->http->setRedirect($storage->getUrl($filename));
|
$session->http->setRedirect($storage->getUrl($filename));
|
||||||
|
$pb->update(sprintf q|<a href="%s">%s</a>|, $session->url->page('op=passiveAnalytics;func=editRuleflow'), sprintf($i18n->get('Return to %s'), $i18n->get('Passive Analytics','PassiveAnalytics')));
|
||||||
|
return $pb->finish($storage->getUrl($filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue