Skip to content

Commit

Permalink
Add "last 5 comments" to runs page
Browse files Browse the repository at this point in the history
Also add a /comments page with all comments on it

Fixes #396
  • Loading branch information
ihodes committed Jan 16, 2015
1 parent 7b4ee73 commit e75b967
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 42 deletions.
8 changes: 8 additions & 0 deletions cycledash/static/css/runs.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ form#submit {
#show-submit {
float: right;
}

/* Last comments list: */
a.all-comments {
font-size: 14px;
color: #adadad;
}

/* Runs table: */
.runs.table {
margin-top: 23px;
}
Expand Down
26 changes: 26 additions & 0 deletions cycledash/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,29 @@ section {
margin: auto;
}
img.cycle { float: right; }

.comments {
list-style: none;
}
.comments .run-id {
font-weight: bold;
}
.comments .run-id a {
color: black;
}
.comments .location {
padding-left: 7px;
}
.comments .summary {
padding-left: 20px;
}
.comments .summary:before {
content: '“';
font-size: 19px;
padding-right: 5px;
}
.comments .summary:after {
content: '”';
font-size: 19px;
padding-left: 5px;
}
13 changes: 13 additions & 0 deletions cycledash/templates/comments.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends "layouts/layout.html" %}
{%- from 'macros/nav.html' import nav -%}
{%- from 'macros/comments.html' import comment_list -%}

{% block body %}
{{ nav("runs") }}
<main>
<section>
<h1>All Comments</h1>
{{ comment_list(comments) }}
</section>
</main>
{% endblock %}
13 changes: 13 additions & 0 deletions cycledash/templates/macros/comments.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% macro comment_list(comments) -%}
<ul class="comments">
{% for comment in comments -%}
<li>
<span class="run-id">
<a href="/runs/{{ comment['vcf_id'] }}/examine">Run {{ comment['vcf_id'] }}</a>
</span>
<span class="location">{{ comment['contig'] }}:{{ comment['position'] }}</span>
<span class="summary">{{ comment['comment_text']|truncate(80)}}</span>
</li>
{% endfor -%}
</ul>
{%- endmacro %}
44 changes: 44 additions & 0 deletions cycledash/templates/macros/run_form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{% macro run_form() -%}
<form method="POST" action="/runs" role="form" id="submit">
<h2><button type="button" class="close" aria-hidden="true">&times;</button></h3>
<div class="form-group">
<label>Variant Caller Name:</label>
<input class="form-control" type="text" name="variantCallerName"
placeholder="Guacamole::Somatic">
</div>
<div class="form-group">
<label>Dataset Name:</label>
<input class="form-control" type="text" name="dataset"
placeholder="DREAM training chr20">
</div>
<div class="form-group">
<label>VCF Path:</label>
<input class="uploadable form-control" type="text" name="vcfPath"
placeholder="/data/somevcf.vcf">
</div>
<div class="form-group">
<label>Truth VCF Path:</label>
<input class="uploadable form-control" type="text" name="truthVcfPath"
placeholder="/data/true_somevcf.vcf">
</div>
<br/>
<h4>Optional <small>all paths should be HDFS paths to canonical data</small></h4>
<div class="form-group">
<label>Tumor BAM:</label>
<input class="form-control" type="text" name="tumorPath"
placeholder="/data/dream/tumor.chr20.bam">
</div>
<div class="form-group">
<label>Normal BAM:</label>
<input class="form-control" type="text" name="normalPath"
placeholder="/data/dream/normal.chr20.bam">
</div>
<div class="form-group">
<label>Notes, Config, Params:</label>
<textarea class="form-control" rows="3" name="params"
placeholder="command line parameters here"></textarea>
</div>

<button type="submit" class="btn btn-success btn-block">Submit New Run</button>
</form>
{%- endmacro -%}
48 changes: 7 additions & 41 deletions cycledash/templates/runs.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% extends "layouts/layout.html" %}
{%- from 'macros/nav.html' import nav -%}
{%- from 'macros/run_form.html' import run_form -%}
{%- from 'macros/comments.html' import comment_list -%}

{% block head %}
<link rel="stylesheet" href="static/css/runs.css">
Expand All @@ -9,48 +11,12 @@
{{ nav("runs") }}
<main>
<h2>Runs Directory <button id="show-submit" class="btn btn-default">Submit New Run</button></h2>
<form method="POST" action="/runs" role="form" id="submit">
<h2><button type="button" class="close" aria-hidden="true">&times;</button></h3>
<div class="form-group">
<label>Variant Caller Name:</label>
<input class="form-control" type="text" name="variantCallerName"
placeholder="Guacamole::Somatic">
</div>
<div class="form-group">
<label>Dataset Name:</label>
<input class="form-control" type="text" name="dataset"
placeholder="DREAM training chr20">
</div>
<div class="form-group">
<label>VCF Path:</label>
<input class="uploadable form-control" type="text" name="vcfPath"
placeholder="/data/somevcf.vcf">
</div>
<div class="form-group">
<label>Truth VCF Path:</label>
<input class="uploadable form-control" type="text" name="truthVcfPath"
placeholder="/data/true_somevcf.vcf">
</div>
<br/>
<h4>Optional <small>all paths should be HDFS paths to canonical data</small></h4>
<div class="form-group">
<label>Tumor BAM:</label>
<input class="form-control" type="text" name="tumorPath"
placeholder="/data/dream/tumor.chr20.bam">
</div>
<div class="form-group">
<label>Normal BAM:</label>
<input class="form-control" type="text" name="normalPath"
placeholder="/data/dream/normal.chr20.bam">
</div>
<div class="form-group">
<label>Notes, Config, Params:</label>
<textarea class="form-control" rows="3" name="params"
placeholder="command line parameters here"></textarea>
</div>
{{ run_form() }}

<button type="submit" class="btn btn-success btn-block">Submit New Run</button>
</form>
{% if last_comments -%}
<h4>Last {{ last_comments|length}} Comments: <a href="/comments" class="all-comments">(see all)</a></h4>
{{ comment_list(last_comments) }}
{%- endif %}

<table class="runs table condenses table-hover">
<thead>
Expand Down
15 changes: 14 additions & 1 deletion cycledash/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,13 @@ def runs():
q = select(vcfs.c + [num_comments]).select_from(joined).group_by(
vcfs.c.id).order_by(desc(vcfs.c.id))
vcfs = [dict(v) for v in con.execute(q).fetchall()]

q = select(user_comments.c).order_by(
desc(user_comments.c.last_modified)).limit(5)
last_comments = [dict(c) for c in con.execute(q).fetchall()]
if 'text/html' in request.accept_mimetypes:
return render_template('runs.html', runs=vcfs, run_kvs=RUN_ADDL_KVS)
return render_template('runs.html', runs=vcfs, run_kvs=RUN_ADDL_KVS,
last_comments=last_comments)
elif 'application/json' in request.accept_mimetypes:
return jsonify({'runs': vcfs})

Expand All @@ -92,6 +97,14 @@ def download_vcf(run_id):
return send_file(fd, as_attachment=True, attachment_filename=filename)


@app.route('/comments')
def all_comments():
with tables(db, 'user_comments') as (con, user_comments):
q = select(user_comments.c).order_by(
desc(user_comments.c.last_modified))
comments = [dict(c) for c in con.execute(q).fetchall()]
return render_template('comments.html', comments=comments)

@app.route('/runs/<vcf_id>/comments', methods=['GET', 'POST'])
def comments(vcf_id):
if request.method == 'POST':
Expand Down

0 comments on commit e75b967

Please sign in to comment.