update docs on Fork
This commit is contained in:
parent
dcfce60b5e
commit
399aa5368b
2 changed files with 74 additions and 0 deletions
|
|
@ -27,6 +27,7 @@ status of.
|
||||||
|
|
||||||
sub doWork {
|
sub doWork {
|
||||||
my ($process, $data) = @_;
|
my ($process, $data) = @_;
|
||||||
|
# Update our status
|
||||||
$process->update("Starting...");
|
$process->update("Starting...");
|
||||||
...
|
...
|
||||||
$process->update("About half way done...");
|
$process->update("About half way done...");
|
||||||
|
|
@ -46,6 +47,7 @@ status of.
|
||||||
return 'redirect';
|
return 'redirect';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Display a page with the status of the fork
|
||||||
package WebGUI::Operation::Fork::DoWork;
|
package WebGUI::Operation::Fork::DoWork;
|
||||||
|
|
||||||
sub handler {
|
sub handler {
|
||||||
|
|
@ -56,6 +58,19 @@ status of.
|
||||||
# or better yet, an ajaxy page that polls.
|
# or better yet, an ajaxy page that polls.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# For ways of displaying status from a fork, see
|
||||||
|
# WebGUI::Fork::ProgressTree
|
||||||
|
# WebGUI::Fork::ProgressBar
|
||||||
|
|
||||||
|
=head1 SEE ALSO
|
||||||
|
|
||||||
|
=over 4
|
||||||
|
|
||||||
|
=item L<WebGUI::Fork::ProgressTree>
|
||||||
|
|
||||||
|
=item L<WebGUI::Fork::ProgressBar>
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
=head1 LEGAL
|
=head1 LEGAL
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,65 @@ WebGUI::Fork::ProgressTree
|
||||||
Renders an admin console page that polls ::Status to draw a friendly graphical
|
Renders an admin console page that polls ::Status to draw a friendly graphical
|
||||||
representation of how progress on a tree of assets is coming along.
|
representation of how progress on a tree of assets is coming along.
|
||||||
|
|
||||||
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
|
package MyClass;
|
||||||
|
|
||||||
|
# User has requested we do some work
|
||||||
|
sub www_doWork {
|
||||||
|
my ( $self ) = @_;
|
||||||
|
|
||||||
|
# Get the assets that need work
|
||||||
|
my @assetIds = ();
|
||||||
|
|
||||||
|
# Start the fork with our "doWork" sub
|
||||||
|
my $process = WebGUI::Fork->start(
|
||||||
|
$self->session, 'MyClass', 'doWork',
|
||||||
|
{ assetIds => \@assetIds },
|
||||||
|
);
|
||||||
|
|
||||||
|
# Get the URL for a status page
|
||||||
|
my $statusUrl = $process->contentPairs( 'ProgressTree', {
|
||||||
|
title => 'Doing Work',
|
||||||
|
icon => 'assets',
|
||||||
|
proceed => '/home?message=Work%20Done',
|
||||||
|
} );
|
||||||
|
|
||||||
|
# Go to the status page
|
||||||
|
$self->session->response->location( $statusUrl );
|
||||||
|
return 'redirect';
|
||||||
|
}
|
||||||
|
|
||||||
|
# Do the work of our WebGUI::Fork
|
||||||
|
sub doWork {
|
||||||
|
my ( $process, $args ) = @_;
|
||||||
|
# All the Assets we need to work on
|
||||||
|
my $assetIds = $args->{ assetIds };
|
||||||
|
|
||||||
|
# Build a tree and update process status
|
||||||
|
my $tree = WebGUI::ProgressTree->new( $process->session, $assetIds );
|
||||||
|
$process->update( sub { $tree->json } );
|
||||||
|
|
||||||
|
# Do the actual work
|
||||||
|
for my $id ( @$assetIds ) {
|
||||||
|
# ... Do something
|
||||||
|
|
||||||
|
# Update our tree and process again
|
||||||
|
$tree->update( $id, "Done!" );
|
||||||
|
$process->update( sub { $tree->json } );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
=head1 SEE ALSO
|
||||||
|
|
||||||
|
=over 4
|
||||||
|
|
||||||
|
=item WebGUI::ProgressTree
|
||||||
|
|
||||||
|
Stores the data for the asset tree we are working on
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
=head1 SUBROUTINES
|
=head1 SUBROUTINES
|
||||||
|
|
||||||
These subroutines are available from this package:
|
These subroutines are available from this package:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue