Skip to content

Commit 82603b2

Browse files
committedOct 13, 2011
Add a progress bar to the passive analytics data export functions.
1 parent 40c6157 commit 82603b2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
 

‎lib/WebGUI/PassiveAnalytics/Flow.pm

+12
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use WebGUI::Workflow;
1313
use WebGUI::Workflow::Instance;
1414
use WebGUI::User;
1515
use WebGUI::Text;
16+
use WebGUI::ProgressBar;
1617

1718
=head1 NAME
1819
@@ -84,15 +85,26 @@ The name of the file to create inside the storage object.
8485

8586
sub exportSomething {
8687
my ($session, $sth, $filename) = @_;
88+
my $pb = WebGUI::ProgressBar->new($session);
89+
my $i18n = WebGUI::International->new($session, 'Asset_Thingy');
90+
$pb->start($i18n->get('export label'), $session->url->extras('adminConsole/passiveAnalytics.png'));
91+
$pb->update($i18n->get('Creating column headers'));
8792
my $storage = WebGUI::Storage->createTemp($session);
8893
my @columns = $sth->getColumnNames;
8994
my $csvData = WebGUI::Text::joinCSV( @columns ). "\n";
95+
$pb->update($i18n->get('Writing data'));
96+
my $rowCounter=0;
9097
while (my $row = $sth->hashRef()) {
9198
my @row = @{ $row }{@columns};
9299
$csvData .= WebGUI::Text::joinCSV(@row) . "\n";
100+
if (! ++$rowCounter % 25) {
101+
$pb->update($i18n->get('Writing data'));
102+
}
93103
}
94104
$storage->addFileFromScalar($filename, $csvData);
95105
$session->http->setRedirect($storage->getUrl($filename));
106+
$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')));
107+
return $pb->finish($storage->getUrl($filename));
96108
}
97109

98110
#-------------------------------------------------------------------

0 commit comments

Comments
 (0)
Please sign in to comment.