From: tla Date: Thu, 7 Nov 2013 12:44:55 +0000 (+0100) Subject: some bugfixes for Stemweb requests. For issue #29 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ed0ce314499c09f02a26f836cb5828919cc6f3fc;p=scpubgit%2Fstemmaweb.git some bugfixes for Stemweb requests. For issue #29 --- diff --git a/lib/stemmaweb/Controller/Stemweb.pm b/lib/stemmaweb/Controller/Stemweb.pm index f0ffa08..1a8a56e 100644 --- a/lib/stemmaweb/Controller/Stemweb.pm +++ b/lib/stemmaweb/Controller/Stemweb.pm @@ -1,7 +1,8 @@ package stemmaweb::Controller::Stemweb; use Moose; use namespace::autoclean; -use JSON qw/ from_json /; +use Encode qw/ decode_utf8 /; +use JSON qw/ decode_json encode_json from_json /; use LWP::UserAgent; use Safe::Isa; use TryCatch; @@ -129,16 +130,19 @@ sub request :Local :Args(0) { return_path => $return_uri->path, return_host => $return_uri->host_port, data => $t->collation->as_tsv, - userid => $c->user->email, + userid => $t->user->email, parameters => $reqparams }; # Call to the appropriate URL with the request parameters. + $DB::single = 1; my $ua = LWP::UserAgent->new(); my $resp = $ua->post( $STEMWEB_BASE_URL . "/algorithms/process/$algorithm/", 'Content-Type' => 'application/json; charset=utf-8', 'Content' => encode_json( $stemweb_request ) ); if( $resp->is_success ) { # Process it + $c->log->debug( 'Got a response from the server: ' + . decode_utf8( $stemweb_response ) ); my $stemweb_response = decode_json( $resp->content ); try { $t->set_stemweb_jobid( $stemweb_response->{jobid} ); @@ -153,7 +157,7 @@ sub request :Local :Args(0) { # The server was unavailable. return _json_error( $c, 503, "The Stemweb server is currently unreachable." ); } else { - return _json_error( $c, 500, "Stemweb error: " . $resp->status . " / " + return _json_error( $c, 500, "Stemweb error: " . $resp->code . " / " . $resp->content ); } } @@ -183,4 +187,4 @@ sub _json_error { return 0; } -1; \ No newline at end of file +1; diff --git a/root/js/componentload.js b/root/js/componentload.js index 0f98f35..e804204 100644 --- a/root/js/componentload.js +++ b/root/js/componentload.js @@ -511,7 +511,7 @@ $(document).ready( function() { optCtrl = $(''); } // Add the name and element ID - optCtrl.attr( 'name', argInfo.name ).attr( 'id', optId ); + optCtrl.attr( 'name', argInfo.key ).attr( 'id', optId ); // Append the label and the option itself to the form. $('#stemweb_runtime_options').append( optLabel ) .append( optCtrl ).append( $('
') ); @@ -527,8 +527,7 @@ $(document).ready( function() { }, }).ajaxError( function(event, jqXHR, ajaxSettings, thrownError) { $(event.target).parent().find('.ui-button').button("enable"); - if( ajaxSettings.url.indexOf( 'algorithms' ) > -1 - && ajaxSettings.type == 'POST' ) { + if( ajaxSettings.url.indexOf( 'stemweb/request' ) > -1 ) { display_error( jqXHR, $("#stemweb_run_status") ); } });