Skip to content

Fix 1505 #2036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions qiita_db/test/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,14 +450,26 @@ def test_user_artifacts(self):
qdb.artifact.Artifact(7)]}
self.assertEqual(obs, exp)

def test_jobs(self):
def test_jobs_all(self):
PJ = qdb.processing_job.ProcessingJob
ignore_status = []
# generates expected jobs
jobs = qdb.user.User('shared@foo.bar').jobs()
jobs = qdb.user.User('shared@foo.bar').jobs(ignore_status)
self.assertEqual(jobs, [
PJ('d19f76ee-274e-4c1b-b3a2-a12d73507c55'),
PJ('b72369f9-a886-4193-8d3d-f7b504168e75')])

# no jobs
self.assertEqual(qdb.user.User('admin@foo.bar').jobs(
ignore_status), [])

def test_jobs_defaults(self):
PJ = qdb.processing_job.ProcessingJob
# generates expected jobs
jobs = qdb.user.User('shared@foo.bar').jobs()
self.assertEqual(jobs, [
PJ('d19f76ee-274e-4c1b-b3a2-a12d73507c55')])

# no jobs
self.assertEqual(qdb.user.User('admin@foo.bar').jobs(), [])

Expand Down
26 changes: 23 additions & 3 deletions qiita_db/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,23 +661,43 @@ def delete_messages(self, messages):
qdb.sql_connection.TRN.add(sql)
qdb.sql_connection.TRN.execute()

def jobs(self):
def jobs(self, ignore_status=['success']):
"""Return jobs created by the user

Parameters
----------
ignore_status, list of str
don't retieve jobs that have one of these status

Returns
-------
list of ProcessingJob

"""
with qdb.sql_connection.TRN:
sql_info = [self._id]
sql = """SELECT processing_job_id
FROM qiita.processing_job
LEFT JOIN qiita.processing_job_status
USING (processing_job_status_id)
WHERE email = %s
ORDER BY heartbeat DESC"""
"""

if ignore_status:
sql_info = [self._id, tuple(ignore_status)]
sql += " AND processing_job_status NOT IN %s"
else:
sql_info = [self._id]

sql += """
ORDER BY CASE processing_job_status
WHEN 'in_construction' THEN 1
WHEN 'running' THEN 2
WHEN 'queued' THEN 3
WHEN 'waiting' THEN 4
WHEN 'error' THEN 5
WHEN 'success' THEN 6
END, heartbeat DESC"""

qdb.sql_connection.TRN.add(sql, sql_info)
return [qdb.processing_job.ProcessingJob(p[0])
for p in qdb.sql_connection.TRN.execute_fetchindex()]
Expand Down
20 changes: 2 additions & 18 deletions qiita_pet/handlers/api_proxy/tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,8 @@ def test_user_jobs_get_req(self):
'threads': 1,
'sortmerna_coverage': 0.97},
'name': 'Pick closed-reference OTUs',
'processing_job_workflow_id': ''},
{'id': 'b72369f9-a886-4193-8d3d-f7b504168e75',
'status': 'success',
'heartbeat': '2015-11-22 21:15:00',
'params': {
'max_barcode_errors': 1.5,
'sequence_max_n': 0,
'max_bad_run_length': 3,
'phred_offset': u'auto',
'rev_comp': False,
'phred_quality_threshold': 3,
'input_data': 1,
'rev_comp_barcode': False,
'rev_comp_mapping_barcodes': True,
'min_per_read_length_fraction': 0.75,
'barcode_type': u'golay_12'},
'name': 'Split libraries FASTQ',
'processing_job_workflow_id': 1}]}
'step': 'generating demux file',
'processing_job_workflow_id': ''}]}
self.assertEqual(obs, exp)


Expand Down
15 changes: 8 additions & 7 deletions qiita_pet/handlers/api_proxy/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@


@execute_as_transaction
def user_jobs_get_req(user):
def user_jobs_get_req(user, limit=30):
"""Gets the json of jobs

Parameters
----------
prep_id : int
PrepTemplate id to get info for
user_id : str
User requesting the sample template info
user : User
The user from which you want to return all jobs
limit : int, optional
Maximum jobs to send, negative values will return all

Returns
-------
dict of objects
{'status': status,
'message': message,
'template': {sample: {column: value, ...}, ...}
'template': {{column: value, ...}, ...}
"""

response = []
for j in user.jobs():
for i, j in enumerate(user.jobs()):
name = j.command.name
hb = j.heartbeat
hb = "" if hb is None else hb.strftime("%Y-%m-%d %H:%M:%S")
Expand All @@ -42,6 +42,7 @@ def user_jobs_get_req(user):
'params': j.parameters.values,
'status': j.status,
'heartbeat': hb,
'step': j.step,
'processing_job_workflow_id': wid})

return {'status': 'success',
Expand Down
20 changes: 20 additions & 0 deletions qiita_pet/static/css/style.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
#qiita-main {
position: relative;
height: 100%;
width: 100%;
}
#qiita-processing {
position: absolute;
height: 100%;
width: 0%;
right: 0;
top: 0;
}
#template-content{
padding: 10px;
height: 100%;
width: 100%;
}

td.more-info-processing-jobs{
cursor: pointer;
background: url('../img//details_open.png') no-repeat center center;
}
tr.shown td.more-info-processing-jobs {
background: url('../img//details_close.png') no-repeat center center;
}

/* table in the study description that holds the investigation type elements */
.investigation-type-table td {
padding-top: 6px;
Expand Down
Binary file added qiita_pet/static/img/details_close.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added qiita_pet/static/img/details_open.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 52 additions & 2 deletions qiita_pet/static/js/qiita.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,50 @@ function bootstrapAlert(message, severity, timeout){
alertDiv.append('<p style="text-align:center">Need help? Send us an <a href="mailto:qiita.help@gmail.com">email</a>.</p>');
}

$('body').prepend(alertDiv);
$('#qiita-main').prepend(alertDiv);

if(timeout > 0) {
window.setTimeout(function() { $('#alert-message').alert('close'); }, timeout);
}
}

function format_extra_info_processing_jobs ( data ) {
// `data` is the original data object for the row
// 0: blank +/- button
// 1: heartbeat
// 2: name
// 3: status
// 4: step
// 5: id
// 6: params
// 7: processing_job_workflow_id

let row = '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">'+
'<tr>'+
'<td><b>ID:</b></td>'+
'<td>'+ data[5] +'</td>'+
'</tr>'+
'<tr>'+
'<td colspan="2"><h5>Parameters:</h5>'+ data[6] +'</td>'+
'</tr>';
if (data[7] !== '' && data[3] === 'in_construction') {
row += '<tr>'+
'<td colspan="2">'+
'<button class="btn btn-danger btn-sm" onclick="remove_job(\''+ data[5] + "', '" + data[7] +'\');">'+
'<span class="glyphicon glyphicon-trash"></span></button>'+
'</td>'
'</tr>';
}
row += '</table>';

return row
}


function show_hide(div) {
$('#' + div).toggle();
}


function delete_analysis(aname, analysis_id) {
if (confirm('Are you sure you want to delete analysis: ' + aname + '?')) {
var form = $("<form>")
Expand All @@ -58,3 +90,21 @@ function delete_analysis(aname, analysis_id) {
form.submit();
}
}

function show_hide_process_list() {
if ($("#qiita-main").width() == $("#qiita-main").parent().width()) {
// let's update the job list
processing_jobs_vue.update_processing_job_data();
$("#qiita-main").width("76%");
$("#user-studies-table").width("76%");
$("#studies-table").width("76%");
$("#qiita-processing").width("24%");
$("#qiita-processing").show();
} else {
$("#qiita-main").width("100%");
$("#user-studies-table").width("100%");
$("#studies-table").width("100%");
$("#qiita-processing").width("0%");
$("#qiita-processing").hide();
}
}
8 changes: 8 additions & 0 deletions qiita_pet/static/vendor/js/vue.min.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions qiita_pet/templates/admin_approval.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{% extends sitebase.html %}
{% block head %}
<link rel="stylesheet" href="{% raw qiita_config.portal_dir %}/static/vendor/css/jquery.dataTables.css" type="text/css">
<script src="{% raw qiita_config.portal_dir %}/static/vendor/js/jquery.dataTables.min.js" type="text/javascript"></script>

<script type="text/javascript">
$(document).ready(function() {
Expand Down
4 changes: 0 additions & 4 deletions qiita_pet/templates/error_log.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
{% from future.utils import viewitems %}
{% from qiita_core.qiita_settings import qiita_config %}

<link rel="stylesheet" href="{% raw qiita_config.portal_dir %}/static/vendor/css/jquery.dataTables.css" type="text/css">

<script src="{% raw qiita_config.portal_dir %}/static/vendor/js/jquery.dataTables.min.js"></script>

<script type="text/javascript">
$(document).ready(function() {
$('#error-table').dataTable({"order": [[1, "asc"]]});
Expand Down
2 changes: 1 addition & 1 deletion qiita_pet/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% end %}

{%block content %}
<div id="jumbotron" class="jumbotron">
<div id="jumbotron" class="jumbotron" style="border-radius: 10px; padding: 30px">
<h1>{% raw portal_styling.index_header%}</h1>
{% raw portal_styling.index_text%}
</div>
Expand Down
10 changes: 2 additions & 8 deletions qiita_pet/templates/list_studies.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,10 @@
<link rel="stylesheet" href="{% raw qiita_config.portal_dir %}/static/vendor/css/select2.min.css" type="text/css">

<style>
#alert-message {
position: fixed;
top: 50px;
left: 40px;
z-index:100;
}
td.details-control {
cursor: pointer;
}
</style>
<script src="{% raw qiita_config.portal_dir %}/static/vendor/js/jquery.dataTables.min.js"></script>
<script src="{% raw qiita_config.portal_dir %}/static/vendor/js/jquery.dataTables.plugin.natural.js"></script>
<script src="{% raw qiita_config.portal_dir %}/static/vendor/js/moi.js"></script>
<script src="{% raw qiita_config.portal_dir %}/static/vendor/js/select2.min.js"></script>
<script src="{% raw qiita_config.portal_dir %}/static/js/sharing.js"></script>
Expand Down Expand Up @@ -302,6 +294,8 @@ <h3 class="gray-msg">Other Studies</h3>
</tr>
</thead>
</table>
</div>
</div>
<!--Abstract Modal-->
<div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" id="study-abstract-modal">
<div class="modal-dialog modal-med">
Expand Down
9 changes: 0 additions & 9 deletions qiita_pet/templates/portals_edit.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{% extends sitebase.html%}

{%block head%}
<link rel="stylesheet" href="{% raw qiita_config.portal_dir %}/static/vendor/css/jquery.dataTables.css" type="text/css">
<style type="text/css">
.navlist li
{
Expand All @@ -11,15 +10,7 @@
.portal-select {
width: 15em;
}
#alert-message {
position: fixed;
top: 55px;
left:30%;
z-index:100;
white-space: nowrap;
}
</style>
<script src="{% raw qiita_config.portal_dir %}/static/vendor/js/jquery.dataTables.min.js"></script>
<script type="text/javascript">
function check_submit(action) {
//disable submit buttons
Expand Down
Loading