Query button to retrieve Stemweb results now works. #29
tla [Thu, 7 Nov 2013 22:16:24 +0000 (23:16 +0100)]
lib/stemmaweb/Controller/Stemweb.pm
root/css/style.css
root/js/componentload.js
script/maketestdb.pl

index 990c1ee..cab3b2e 100644 (file)
@@ -84,7 +84,7 @@ indicate that the job is still running.
 sub query :Local :Args(1) {
        my( $self, $c, $jobid ) = @_;
        my $ua = LWP::UserAgent->new();
-       my $resp = $ua->get( $STEMWEB_BASE_URL . "/jobstatus/$jobid" );
+       my $resp = $ua->get( $STEMWEB_BASE_URL . "/algorithms/jobstatus/$jobid" );
        if( $resp->is_success ) {
                # Process it
                my $response = decode_utf8( $resp->content );
@@ -115,10 +115,15 @@ sub _process_stemweb_result {
        # TODO: Maybe get Stemweb to pass back the tradition ID...
        my $m = $c->model('Directory');
        my @traditions;
+       ## STUPID HACK: unless we load the possible tradition owners
+       ## within scope of the scan, they will not exist when the affected
+       ## tradition is saved.
+       my @users;
        $m->scan( sub{ push( @traditions, $_[0] )
                                        if $_[0]->$_isa('Text::Tradition')
                                        && $_[0]->has_stemweb_jobid 
                                        && $_[0]->stemweb_jobid eq $answer->{job_id}; 
+                       push( @users, $_[0] ) if $_[0]->$_isa('Text::Tradition::User');
                                } );
        if( @traditions == 1 ) {
                my $tradition = shift @traditions;
@@ -137,7 +142,7 @@ sub _process_stemweb_result {
                                        name => $_->identifier, 
                                        directed => _json_bool( !$_->is_undirected ),
                                        svg => $_->as_svg() } } 
-                               $stemmata;
+                               @$stemmata;
                        $c->stash->{'result'} = { 
                                'status' => 'success',
                                'stemmata' => \@steminfo };
index 83f7517..8bebe96 100644 (file)
@@ -190,7 +190,7 @@ div.pager_left_button.greyed_out, div.pager_left_button.greyed_out:hover {
     position: relative;
     top: 15px;
 }
-#run_stexaminer, #run_relater, #open_stemma_add, #open_stemma_edit, #open_stemweb_ui {
+#run_stexaminer, #run_relater, #open_stemma_add, #open_stemma_edit, #open_stemweb_ui, #query_stemweb_ui {
     height: 32px;
 }
 #stemma_pager {
@@ -239,4 +239,4 @@ div.pager_left_button.greyed_out, div.pager_left_button.greyed_out:hover {
 #new_file_label {
     float: left;
     padding-right: 8px;
-}
\ No newline at end of file
+}
index 838da46..378b24e 100644 (file)
@@ -137,8 +137,10 @@ function load_stemma( idx, editable ) {
        if( editable ) {
                if( selectedTextInfo.stemweb_jobid == 0 ) {
                        $('#open_stemweb_ui').show();
+                       $('#query_stemweb_ui').hide();
                } else {
                        $('#query_stemweb_ui').show();
+                       $('#open_stemweb_ui').hide();
                }
        }
        if( idx > -1 ) {
@@ -165,11 +167,12 @@ function query_stemweb_progress() {
                // Look for a status message, either success, running, or notfound.
                if( data.status === 'success' ) {
                        // Add the new stemmata to the textinfo and tell the user.
+                       selectedTextInfo.stemweb_jobid = 0;
                        if( data.stemmata.length > 0 ) {
                                stemmata = stemmata.concat( data.stemmata );
                                if( selectedStemmaID == -1 ) {
                                        // We have a stemma for the first time; load the first one.
-                                       load_stemma( 0 );
+                                       load_stemma( 0, true );
                                }
                                alert( 'You have one or more new stemmata!' );
                        } else {
@@ -497,6 +500,8 @@ $(document).ready( function() {
                                        // Job ID is in data.jobid. TODO do something with it.
                                        $(evt.target).button("enable");
                                        $('#stemma-edit-dialog').dialog('close');
+                                       // Reload the current stemma to rejigger the buttons
+                                       load_stemma( selectedStemmaID, true );
                                }, 'json' );
                        },
                        Cancel: function() {
index 389b8ec..db1b1e8 100755 (executable)
@@ -56,6 +56,7 @@ $t3->name( 'John verse' );
 $dir->store( $t3 );
 my $t4 = Text::Tradition->new( input => 'Self', file => 't/data/collatecorr.xml' );
 $t4->public( 1 );
+$t4->set_stemweb_jobid( '16' );
 $user->add_tradition( $t4 );
 $dir->store( $t4 );
 $dir->store( $user );