Skip to content
Snippets Groups Projects
Commit c2b049eb authored by Marco De Donno's avatar Marco De Donno
Browse files

Add the admin table summary page

parent 05cf080d
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,9 @@
<div id="icnml_navigation_adminsubmissions">
<a href="{{ url_for( 'submission.admin_submission_list' ) }}">Submissions</a>
</div>
<div id="icnml_navigation_adminsubmissionstable">
<a href="{{ url_for( 'submission.admin_submission_table' ) }}">Tables</a>
</div>
<div id="icnml_navigation_admintenprint">
<a href="{{ url_for( 'submission.admin_tenprint_list', submission_id = 'all' ) }}">Tenprint cards</a>
</div>
......
......@@ -1581,6 +1581,51 @@ def admin_submission_list():
donors = donors
)
@submission_view.route( "/admin/submission/table" )
@admin_required
def admin_submission_table():
sql = """
SELECT
submissions.id,
submissions.uuid,
users.username
FROM submissions
LEFT JOIN users ON submissions.donor_id = users.id
ORDER BY created_time DESC
"""
donors = config.db.query_fetchall( sql )
sql = """
SELECT
submissions.uuid,
files_type.name,
count( files.uuid ) AS nb
FROM files
INNER JOIN submissions ON files.folder = submissions.id
INNER JOIN files_type ON files.type = files_type.id
GROUP BY submissions.uuid, files_type.name
"""
counts = config.db.query_fetchall( sql )
sql = """
SELECT
submissions.uuid,
count( * ) AS nb
FROM files_segments
INNER JOIN files ON files_segments.tenprint = files.uuid
INNER JOIN submissions ON files.folder = submissions.id
GROUP BY submissions.uuid
"""
segments = config.db.query_fetchall( sql )
current_app.logger.info( "{} submissions found".format( len( donors ) ) )
return my_render_template(
"admin/submission_table.html",
donors = donors,
counts = counts,
segments = segments
)
@submission_view.route( "/admin/<submission_id>/tenprint/list" )
@admin_required
def admin_tenprint_list( submission_id = "all" ):
......
<!DOCTYPE html>
<html>
<head>
{% for src in js %}
<script type="text/javascript" src="{{ src }}"></script>
{% endfor %}
{% for src in css %}
<link type="text/css" rel="stylesheet" href="{{ src }}">
{% endfor %}
<script type="text/javascript" src="{{ url_for( 'files.send_app_files', subpath = 'functions.js' ) }}"></script>
<link type="text/css" rel="stylesheet" href="{{ url_for( 'files.send_app_files', subpath = 'app.css' ) }}">
<style>
#submissions_list > table {
width: 100%;
}
tr:nth-child( even ) {
background: rgb( 200, 200, 200 );
}
tr:nth-child( odd ) {
background: rgb( 222, 222, 222 );
}
</style>
<script type="text/javascript">
baseurl = "{{ baseurl }}";
var files_type_counts = {};
{% for donor in donors %}
files_type_counts[ "{{ donor[ 'uuid' ] }}" ] = {};
{% endfor %}
{% for c in counts %}
files_type_counts[ "{{ c[ 'uuid' ] }}" ][ "{{ c[ 'name' ] }}" ] = "{{ c[ 'nb' ] }}";
{% endfor %}
{% for s in segments %}
files_type_counts[ "{{ s[ 'uuid' ] }}" ][ "segments" ] = "{{ s[ 'nb' ] }}";
{% endfor %}
</script>
</head>
<body class="icnml_main_layout">
{% include "header.html" %}
{% include navigation %}
<div class="icnml_content">
<div id="submissions_list">
<table>
<tr>
<th>Donor</th>
<th>UUID</th>
<th>Marks</th>
<th>TP finger</th>
<th>TP palms</th>
<th>Segments</th>
</tr>
{% for donor in donors %}
<tr>
<td>{{ donor[ 'username' ] }}</td>
<td>{{ donor[ 'uuid' ] }}</td>
{% for c in [ 'mark_target', 'tenprint_card_front', 'tenprint_card_back', 'segments' ] %}
<td><span id="c_{{ donor[ 'uuid' ] }}_{{ c }}"></span></td>
{% endfor %}
</tr>
{% endfor %}
</table>
</div>
</div>
<script type="text/javascript">
{% for donor in donors %}
{% for c in [ 'mark_target', 'tenprint_card_front', 'tenprint_card_back', 'segments' ] %}
$( "#c_{{ donor[ 'uuid' ] }}_{{ c }}" ).text( files_type_counts[ "{{ donor[ 'uuid' ] }}" ][ "{{ c }}" ] );
{% endfor %}
{% endfor %}
$( "#icnml_navigation_adminsubmissionstable" )
.addClass( "activated" );
$( "#navloc" ).append(
$( "<span />" ).text( "Submissions" )
);
</script>
</body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment