Commit f7668e7a authored by Matthieu Muffato's avatar Matthieu Muffato
Browse files

New tab for pipeline-wide parameters

parent 08965d07
......@@ -52,7 +52,7 @@
<!-- Remote DataTables.js -->
<script src="http://datatables.net/download/build/jquery.dataTables.min.js"></script>
<!-- DataTables -- column filters -->
<!-- DataTables - column filters -->
<script src="http://jquery-datatables-column-filter.googlecode.com/svn/trunk/media/js/jquery.dataTables.columnFilter.js"></script>
<!-- Local javascripts -->
......@@ -104,6 +104,7 @@
<li><a href="#main" data-toggle="tab">Diagram View</a></li>
<li><a href="#connection_summary" data-toggle="tab">Summary View</a></li>
<li><a href="#jobs" data-toggle="tab">Jobs</a></li>
<li><a href="#pipeline_wide_parameters" data-toggle="tab">Pipeline-wide parameters</a></li>
<li><a href="#resource_details" data-toggle="tab">Resources</a></li>
<li><a href="#views" data-toggle="tab">Bubbles View</a></li>
<li><a href="#logContainer" data-toggle="tab" id="log-tab">Log</a></li>
......@@ -150,6 +151,8 @@
<div id="jobs_table_div"></div>
</div>
<div id="pipeline_wide_parameters" class="tab-pane"></div>
<div id="resource_details" class="tab-pane"></div>
<div id="views" class="tab-pane">
......
......@@ -332,6 +332,9 @@ function onSuccess_dbConnect(res) {
// Showing the resources
fetch_resources();
// And the pipeline-wide parameters
fetch_and_setup_change_listener( "scripts/db_fetch_pipeline_params.pl", "scripts/db_update_nonobject.pl", "#pipeline_wide_parameters", ".update_pwp_param" );
// We load the jobs form
$.get('./scripts/db_jobs_form.pl', {url : guiHive.pipeline_url, version : guiHive.version} ,function(data) {
$('#jobs_form').html(data);
......@@ -396,6 +399,51 @@ function onSuccess_fetchResources(resourcesRes, analysis_id, fetch_url) {
listen_Resources(fetch_url);
}
function fetch_and_setup_change_listener(fetch_url, write_url, target_div, updatable_class, callback) {
function doFetch() {
$.ajax({
url : fetch_url,
type : "post",
data : "url=" + guiHive.pipeline_url + "&version=" + guiHive.version,
dataType : "json",
success : onFetchSuccess_handler,
error : function(resp,error) {log({err_msg : error})},
});
}
function onFetchSuccess_handler(resp) {
if (resp.status != "ok") {
log(resp);
} else {
$(target_div).html(resp.out_msg);
}
$(updatable_class).click( onClick_handler );
};
function onClick_handler(obj) {
$.ajax({
url : write_url,
type : "post",
data : buildURL(this),
dataType : "json",
async : false,
cache : false,
success : function(updateRes) {
if(updateRes.status !== "ok") {
log(updateRes);
};
},
complete : doFetch
});
}
doFetch();
}
function change_refresh_time() {
guiHive.monitorTimeout = $(this).val()
guiHive.refresh_data_timer.timer(guiHive.monitorTimeout/1000);
......@@ -720,6 +768,9 @@ function buildURL(obj) {
if ($(obj).attr("data-analysisID")) {
URL = URL.concat("&analysis_id="+$(obj).attr("data-analysisID"));
}
if ($(obj).attr("data-fields")) {
URL = URL.concat("&fields="+$(obj).attr("data-fields"));
}
return(URL);
}
......
#!/usr/bin/env perl
=pod
Copyright [1999-2014] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=cut
use strict;
use warnings;
use Bio::EnsEMBL::Hive::DBSQL::DBAdaptor;
use JSON;
use HTML::Template;
use Data::Dumper;
use lib ("./lib");
use hive_extended;
use msg;
use version_check;
my $json_data = shift @ARGV || '{"version":["62"],"url":["mysql://ensro@127.0.0.1:4306/mm14_protein_trees_78b"]}';
main($json_data);
sub main {
## Input
my $decoded_json = decode_json($json_data);
## Initialization
my $dbConn = check_db_versions_match($decoded_json);
my $response = msg->new();
my $all_params_hash;
eval {
$all_params_hash = $dbConn->get_PipelineWideParametersAdaptor()->fetch_param_hash();
$response->out_msg(formPipelineWideParameters($all_params_hash)) if $all_params_hash;
};
if ($@ or (not $all_params_hash)) {
$response->err_msg("I can't retrieve the pipeline-wide parameters: $@");
$response->status("FAILED");
}
print $response->toJSON;
}
sub formPipelineWideParameters {
my ($all_params_hash) = @_;
my $project_dir = $ENV{GUIHIVE_BASEDIR};
my $details_template = $project_dir . "static/pipeline_wide_parameters.html";
my $template = HTML::Template->new(filename => $details_template);
$template->param(%{ template_mappings_PARAMS($all_params_hash) });
return $template->output();
}
sub template_mappings_PARAMS {
my ($all_params_hash) = @_;
my $vals;
for my $param (sort keys %$all_params_hash) {
my $this_param_data = {
"key" => $param,
"parameterKeyID" => "p_$param",
"parameterValueID" => "v_$param",
"value" => stringify_if_needed($all_params_hash->{$param}),
"delete_parameter" => [{
"adaptor" => "PipelineWideParameters",
"method" => "remove",
"fields" => "param_name",
"parameterKeyID" => "p_$param",
}],
"change_parameter" => [{
"adaptor" => "PipelineWideParameters",
"method" => "update",
"fields" => "param_name,param_value",
"parameterKeyID" => "p_$param",
"parameterValueID" => "v_$param",
}],
};
push @{$vals->{existing_parameters}}, $this_param_data;
}
$vals->{new_parameter} = [{
"adaptor" => "PipelineWideParameters",
"method" => "store",
"fields" => "param_name,param_value",
}],
return $vals;
}
sub stringify_if_needed {
my ($scalar) = @_;
if (ref $scalar) {
local $Data::Dumper::Indent = 0; # we want everything on one line
local $Data::Dumper::Terse = 1; # and we want it without dummy variable names
local $Data::Dumper::Sortkeys = 1; # make stringification more deterministic
return Dumper($scalar);
}
return $scalar;
}
#!/usr/bin/env perl
=pod
Copyright [1999-2014] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=cut
use strict;
use warnings;
use Data::Dumper;
use Bio::EnsEMBL::Hive::DBSQL::DBAdaptor;
use JSON;
use URI::Escape;
use lib "./lib"; ## Only needed for local testing
use hive_extended;
use msg;
use version_check;
my $json_data = shift @ARGV || '{"adaptor":["PipelineWideParameters"],"method":["store"],"url":["mysql://ensro@127.0.0.1:4306/mm14_protein_trees_78"],"fields":["param_name,param_value"],"args":["a,2"],"version":["62"]}'
my $var = decode_json($json_data);
my $url = $var->{url}->[0];
my $args = uri_unescape($var->{args}->[0]);
my $adaptor_name = $var->{adaptor}->[0];
my $method = $var->{method}->[0];
my $version = $var->{version}->[0];
my $fields = $var->{fields}->[0];
my @fields = split(/,/,$fields);
my @args = split(/,/,$args,scalar(@fields));
##### This if is copied over from a script, but I don't know if it's really needed
# If we pass the 'NULL' string, then we undef the value to update a NULL mysql value:
if ((scalar @args == 1) && ($args[0] eq "NULL")) {
@args = undef;
}
my $dbConn = check_db_versions_match($var);
my $response = msg->new();
$adaptor_name = "get_".$adaptor_name."Adaptor";
my $adaptor = $dbConn->$adaptor_name;
warn Dumper(\@fields, \@args);
my %obj = ();
@obj{@fields} = @args;
warn Dumper(\%obj);
eval {
$adaptor->$method(\%obj);
};
$response->err_msg($@);
$response->status($response->err_msg) if ($@);
print $response->toJSON();
<!-- Copyright [1999-2014] Wellcome Trust Sanger Institute and the EMBL-European Bioinformatics Institute
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<table id="pw_param_table">
<tr>
<th>Name</th>
<th>Value</th>
<th></th>
<th></th>
</tr>
<TMPL_LOOP NAME=existing_parameters>
<tr>
<td><span id="<TMPL_VAR NAME=parameterKeyID>" data-value="<TMPL_VAR NAME=key>">
<TMPL_VAR NAME=key>
</span></td>
<td><input
id="<TMPL_VAR NAME=parameterValueID>"
type="text"
data-value="<TMPL_VAR NAME=value ESCAPE=HTML>"
value="<TMPL_VAR NAME=value ESCAPE=HTML>">
</td>
<TMPL_LOOP NAME=change_parameter>
<td class="button-cell"><a class="update_pwp_param btn btn-mini"
data-analysisID="<TMPL_VAR NAME=id>"
data-adaptor="<TMPL_VAR NAME=adaptor>"
data-method="<TMPL_VAR NAME=method>"
data-fields="<TMPL_VAR NAME=fields>"
data-linkTo="<TMPL_VAR NAME=parameterKeyID>,<TMPL_VAR NAME=parameterValueID>"><i class="icon-plus-sign"></i></a>
</td>
</TMPL_LOOP> <!-- change_paramter -->
<TMPL_LOOP NAME=delete_parameter>
<td class="button-cell"><a class="update_pwp_param btn btn-mini"
data-analysisID="<TMPL_VAR NAME=id>"
data-adaptor="<TMPL_VAR NAME=adaptor>"
data-method="<TMPL_VAR NAME=method>"
data-fields="<TMPL_VAR NAME=fields>"
data-linkTo="<TMPL_VAR NAME=parameterKeyID>"><i class="icon-minus-sign"></i></a>
</td>
</TMPL_LOOP> <!-- delete_parameter -->
</tr>
</TMPL_LOOP> <!-- existing_parameters -->
<TMPL_LOOP NAME=new_parameter>
<tr>
<td><input type="text" id="p_new_key" placeholder="new parameter's name"></td>
<td><input type="text" id="p_new_value" placeholder="new parameter's value"></td>
<td class="button-cell"><a class="update_pwp_param btn btn-mini"
data-analysisID="<TMPL_VAR NAME=id>"
data-adaptor="<TMPL_VAR NAME=adaptor>"
data-method="<TMPL_VAR NAME=method>"
data-fields="<TMPL_VAR NAME=fields>"
data-linkTo="p_new_key,p_new_value"><i class="icon-plus-sign"></i></a>
</td>
<td></td>
</tr>
</TMPL_LOOP> <!-- new parameter -->
</table>
<div class="footer_spacer"></div>
......@@ -228,6 +228,44 @@ html, body {
right : 5px;
}
/****************************/
/* pipeline-wide parameters */
/****************************/
#pw_param_table {
font-size : 12px;
background-color : #E6EBF0;
margin-left : 10px;
}
#pw_param_table th {
padding: 5px;
}
#pw_param_table tr td:first-child {
padding-left : 10px;
padding-right: 10px;
}
#pw_param_table tr td {
padding-bottom: 3px;
padding-top : 3px;
}
#pw_param_table tr:last-child td {
padding-top: 6px;
}
#pw_param_table tr td:nth-child(2) input {
width: 500px;
}
.footer_spacer {
height: 40px;
}
/******************/
/* resources table /
/******************/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment