Build a progress bar for exporting data from a Thing. Fixes bug #11925.
This commit is contained in:
parent
4f95507485
commit
dcae5190da
3 changed files with 37 additions and 7 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
- fixed #11922: Help tempalte is squatting on a good URL
|
- fixed #11922: Help tempalte is squatting on a good URL
|
||||||
- fixed #11923: Collaboration System Mail Cron Errors
|
- fixed #11923: Collaboration System Mail Cron Errors
|
||||||
- fixed #11925: Some problems in Thingy export (metaData values in CSV export)
|
- fixed #11925: Some problems in Thingy export (metaData values in CSV export)
|
||||||
|
- fixed #11925: Some problems in Thingy export (export times out on Things with many rows)
|
||||||
|
|
||||||
7.10.3
|
7.10.3
|
||||||
- fixed #11903: Unnecessary debug in Thingy
|
- fixed #11903: Unnecessary debug in Thingy
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ use WebGUI::DateTime;
|
||||||
use base 'WebGUI::Asset::Wobject';
|
use base 'WebGUI::Asset::Wobject';
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
use PerlIO::eol qw/NATIVE/;
|
use PerlIO::eol qw/NATIVE/;
|
||||||
|
use WebGUI::ProgressBar;
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -2686,6 +2687,11 @@ sub www_export {
|
||||||
my $thingProperties = $self->getThing($thingId);
|
my $thingProperties = $self->getThing($thingId);
|
||||||
return $session->privilege->insufficient() unless $self->hasPrivileges($thingProperties->{groupIdExport});
|
return $session->privilege->insufficient() unless $self->hasPrivileges($thingProperties->{groupIdExport});
|
||||||
|
|
||||||
|
my $i18n = WebGUI::International->new($session, 'Asset_Thingy');
|
||||||
|
my $pb = WebGUI::ProgressBar->new($session);
|
||||||
|
$pb->start($i18n->get('export label').' '.$thingProperties->{label}, $session->url->extras('assets/thingy.gif'));
|
||||||
|
$pb->update($i18n->get('Creating column headers'));
|
||||||
|
my $tempStorage = WebGUI::Storage->createTemp($session);
|
||||||
$fields = $session->db->read('select * from Thingy_fields where assetId =? and thingId = ? order by sequenceNumber',
|
$fields = $session->db->read('select * from Thingy_fields where assetId =? and thingId = ? order by sequenceNumber',
|
||||||
[$self->get("assetId"),$thingId]);
|
[$self->get("assetId"),$thingId]);
|
||||||
while (my $field = $fields->hashRef) {
|
while (my $field = $fields->hashRef) {
|
||||||
|
|
@ -2707,9 +2713,13 @@ sub www_export {
|
||||||
|
|
||||||
### Loop through the returned structure and put it through Text::CSV
|
### Loop through the returned structure and put it through Text::CSV
|
||||||
# Column heads
|
# Column heads
|
||||||
$out = WebGUI::Text::joinCSV(@fieldLabels);
|
my $csv_filename = 'export_'.$thingProperties->{label}.'.csv';
|
||||||
|
$tempStorage->addFileFromScalar($csv_filename, WebGUI::Text::joinCSV(@fieldLabels));
|
||||||
|
open my $CSV, '>', $tempStorage->getPath($csv_filename);
|
||||||
|
|
||||||
# Data lines
|
# Data lines
|
||||||
|
$pb->update($i18n->get('Writing data'));
|
||||||
|
my $rowCounter = 0;
|
||||||
while (my $data = $sth->hashRef) {
|
while (my $data = $sth->hashRef) {
|
||||||
my @fieldValues;
|
my @fieldValues;
|
||||||
foreach my $field (@fields){
|
foreach my $field (@fields){
|
||||||
|
|
@ -2723,14 +2733,15 @@ sub www_export {
|
||||||
push(@fieldValues,$data->{$metaDataField});
|
push(@fieldValues,$data->{$metaDataField});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$out .= "\n".WebGUI::Text::joinCSV( @fieldValues );
|
print $CSV "\n".WebGUI::Text::joinCSV( @fieldValues );
|
||||||
|
#if (! ++$rowCounter % 25) {
|
||||||
|
$pb->update($i18n->get('Writing data'));
|
||||||
|
#}
|
||||||
}
|
}
|
||||||
|
close $CSV;
|
||||||
$fileName = "export_".$thingProperties->{label}.".csv";
|
|
||||||
$self->session->http->setFilename($fileName,"application/octet-stream");
|
|
||||||
$self->session->http->sendHeader;
|
|
||||||
return $out;
|
|
||||||
|
|
||||||
|
$pb->update(sprintf q|<a href="%s">%s</a>|, $self->getUrl, sprintf($i18n->get('Return to %s'), $thingProperties->{label}));
|
||||||
|
return $pb->finish($tempStorage->getUrl($csv_filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -1127,6 +1127,24 @@ search has been done.|,
|
||||||
lastUpdated => 1231180362,
|
lastUpdated => 1231180362,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'Creating column headers' => {
|
||||||
|
message => q|Creating column headers.|,
|
||||||
|
lastUpdated => 1231180362,
|
||||||
|
context => q|Status message in the Export Thingy progress bar.|,
|
||||||
|
},
|
||||||
|
|
||||||
|
'Writing data' => {
|
||||||
|
message => q|Writing data.|,
|
||||||
|
lastUpdated => 1231180362,
|
||||||
|
context => q|Status message in the Export Thingy progress bar.|,
|
||||||
|
},
|
||||||
|
|
||||||
|
'Return to %s' => {
|
||||||
|
message => q|Return to %s.|,
|
||||||
|
lastUpdated => 1231180362,
|
||||||
|
context => q|Status message in the Export Thingy progress bar. %s is the name of the Thing that is being exported.|,
|
||||||
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue