Skip to content
Commits on Source (6)
...@@ -49,6 +49,7 @@ try: ...@@ -49,6 +49,7 @@ try:
pianosendpoint = os.environ.get( "PIANOS_ENDPOINT", "/pianos" ) pianosendpoint = os.environ.get( "PIANOS_ENDPOINT", "/pianos" )
except: except:
pianosdb = None pianosdb = None
pianosendpoint = None
dburl = os.environ.get( "DB_URL", "pgsql://icnml:icnml@db:5432/icnml" ) dburl = os.environ.get( "DB_URL", "pgsql://icnml:icnml@db:5432/icnml" )
db = Database( dburl ) db = Database( dburl )
...@@ -67,15 +68,20 @@ sender = os.environ.get( "SMTP_SENDER", "icnml@unil.ch" ) ...@@ -67,15 +68,20 @@ sender = os.environ.get( "SMTP_SENDER", "icnml@unil.ch" )
POPPLER_PATH = os.environ.get( "POPPLER_PATH", "" ) POPPLER_PATH = os.environ.get( "POPPLER_PATH", "" )
SESSION_COOKIE_SECURE = True if envtype != "DEV":
SESSION_COOKIE_SAMESITE = "Strict" SESSION_COOKIE_SECURE = True
SESSION_COOKIE_SAMESITE = "Strict"
domain = "https://icnml.unil.ch"
RP_ID = "icnml.unil.ch"
else:
domain = "http://localhost"
RP_ID = "localhost"
domain = "https://icnml.unil.ch"
baseurl = os.environ.get( "BASEURL", "" ) baseurl = os.environ.get( "BASEURL", "" )
fulldomain = domain + baseurl fulldomain = domain + baseurl
cdn = fulldomain + "/cdn" cdn = fulldomain + "/cdn"
RP_ID = "icnml.unil.ch"
ORIGIN = domain ORIGIN = domain
rp_name = "ICNML" rp_name = "ICNML"
......
...@@ -71,6 +71,8 @@ INSERT INTO public.pc (id, name) VALUES (11, 'Right thumb slap'); ...@@ -71,6 +71,8 @@ INSERT INTO public.pc (id, name) VALUES (11, 'Right thumb slap');
INSERT INTO public.pc (id, name) VALUES (12, 'Left thumb slap'); INSERT INTO public.pc (id, name) VALUES (12, 'Left thumb slap');
INSERT INTO public.pc (id, name) VALUES (13, 'Right control slap'); INSERT INTO public.pc (id, name) VALUES (13, 'Right control slap');
INSERT INTO public.pc (id, name) VALUES (14, 'Left control slap'); INSERT INTO public.pc (id, name) VALUES (14, 'Left control slap');
INSERT INTO public.pc (id, name) VALUES (22, 'Right writer palm');
INSERT INTO public.pc (id, name) VALUES (24, 'Left writer palm');
INSERT INTO public.pc (id, name) VALUES (1000, 'All rolled'); INSERT INTO public.pc (id, name) VALUES (1000, 'All rolled');
......
#!/usr/bin/python #!/usr/bin/python
# -*- coding: UTF-8 -*- # -*- coding: UTF-8 -*-
from flask import Blueprint from _collections import defaultdict
import json import json
from const import pfsp from flask import Blueprint
import config
import config
from const import pfsp
from utils.decorator import login_required from utils.decorator import login_required
from utils.template import my_render_template from utils.template import my_render_template
from MDmisc.RecursiveDefaultDict import edefaultdict, defDict
trainer_view = Blueprint( "trainer", __name__, template_folder = "templates" ) trainer_view = Blueprint( "trainer", __name__, template_folder = "templates" )
@trainer_view.route( "/trainer/search" ) @trainer_view.route( "/trainer/search" )
...@@ -21,18 +23,40 @@ def search(): ...@@ -21,18 +23,40 @@ def search():
""" """
sql = """ sql = """
SELECT SELECT
mark_info.*, files.id,
files.uuid,
mark_info.pfsp,
mark_info.detection_technic,
mark_info.surface,
files.note, files.note,
submissions.uuid AS submission_uuid,
users.username users.username
FROM mark_info FROM files
INNER JOIN files ON mark_info.uuid = files.uuid LEFT JOIN mark_info ON mark_info.uuid = files.uuid
LEFT JOIN submissions ON files.folder = submissions.id LEFT JOIN submissions ON files.folder = submissions.id
LEFT JOIN users ON submissions.donor_id = users.id LEFT JOIN users ON submissions.donor_id = users.id
ORDER BY id ASC WHERE ( files.type = 3 OR files.type = 4 )
ORDER BY files.id ASC
""" """
marks = config.db.query_fetchall( sql ) marks = config.db.query_fetchall( sql )
sql = """
SELECT
submissions.uuid AS submissions_uuid,
segments_locations.fpc,
segments_locations.tenprint_id
FROM segments_locations
INNER JOIN files ON segments_locations.tenprint_id = files.uuid
LEFT JOIN submissions ON files.folder = submissions.id
ORDER BY fpc
"""
ref_list = config.db.query_fetchall( sql )
refs = defDict()
for ref in ref_list:
refs[ ref[ "submissions_uuid" ] ][ ref[ "fpc" ] ] = ref[ "tenprint_id" ]
all_detection_technics = config.db.query_fetchall( "SELECT * FROM detection_technics ORDER BY name ASC" ) all_detection_technics = config.db.query_fetchall( "SELECT * FROM detection_technics ORDER BY name ASC" )
surfaces = config.db.query_fetchall( "SELECT * FROM surfaces ORDER BY name ASC" ) surfaces = config.db.query_fetchall( "SELECT * FROM surfaces ORDER BY name ASC" )
...@@ -46,9 +70,30 @@ def search(): ...@@ -46,9 +70,30 @@ def search():
v[ "username" ] = v[ "username" ].replace( "_", " " ) v[ "username" ] = v[ "username" ].replace( "_", " " )
# PFSP zones to fpc
pfsp2fpc = defaultdict( list )
for pfc in xrange( 1, 11 ):
for loc in [ "tip", "distal" ]:
pfsp2fpc[ "F{}-{}".format( pfc, loc ) ].append( pfc )
pfsp2fpc[ "F1-tip" ].append( 11 )
pfsp2fpc[ "F1-distal" ].append( 11 )
pfsp2fpc[ "F6-tip" ].append( 12 )
pfsp2fpc[ "F6-distal" ].append( 12 )
for side, fpc in [ ( "Right", 25 ), ( "Left", 27 ) ]:
for z in [ "grasp", "carpal_delta_area", "wrist_bracelet", "thenar", "hypothenar", "interdigital", "writer_palm" ]:
pfsp2fpc[ "{}-{}".format( side, z ) ].append( fpc )
pfsp2fpc[ "Right-writer_palm" ].append( 22 )
pfsp2fpc[ "Left-writer_palm" ].append( 24 )
#
return my_render_template( return my_render_template(
"trainer/search.html", "trainer/search.html",
marks = marks, marks = marks,
refs = refs,
pfsp2fpc = pfsp2fpc,
all_detection_technics = all_detection_technics, all_detection_technics = all_detection_technics,
surfaces = surfaces, surfaces = surfaces,
all_pfsp = pfsp.zones all_pfsp = pfsp.zones
......
...@@ -63,6 +63,20 @@ ...@@ -63,6 +63,20 @@
grid-column-gap: 20px; grid-column-gap: 20px;
grid-template-columns: auto 1fr; grid-template-columns: auto 1fr;
} }
.icnml_mark_detail {
display: grid;
grid-gap: 10px;
grid-template-columns: 1fr 1fr;
height: 100%;
}
#icnml_mark_detail_left,
#icnml_mark_detail_right {
height: 100%;
background-size: contain;
background-position: center;
background-repeat: no-repeat;
}
</style> </style>
<script type="text/javascript"> <script type="text/javascript">
...@@ -74,6 +88,7 @@ ...@@ -74,6 +88,7 @@
"uuid": "{{ mark[ 'uuid' ] }}", "uuid": "{{ mark[ 'uuid' ] }}",
"id": "{{ mark[ 'id' ] }}", "id": "{{ mark[ 'id' ] }}",
"pfsp": "{{ mark[ 'pfsp' ] }}".split( "," ), "pfsp": "{{ mark[ 'pfsp' ] }}".split( "," ),
"submission_uuid": "{{ mark[ 'submission_uuid' ] }}",
"dt": "{{ mark[ 'detection_technic' ] }}".split( "," ), "dt": "{{ mark[ 'detection_technic' ] }}".split( "," ),
"surface": "{{ mark[ 'surface' ] }}".split( "," ), "surface": "{{ mark[ 'surface' ] }}".split( "," ),
"note": "{{ mark[ 'note' ] | default( '', true ) }}" "note": "{{ mark[ 'note' ] | default( '', true ) }}"
...@@ -99,6 +114,16 @@ ...@@ -99,6 +114,16 @@
pfsp_sel[ "{{ pfsp[ 'desc' ] }}" ] = tmp; pfsp_sel[ "{{ pfsp[ 'desc' ] }}" ] = tmp;
{% endfor %} {% endfor %}
var pfsp2fpc = {};
{% for pfsp, fpc in pfsp2fpc.iteritems() %}
pfsp2fpc[ "{{ pfsp }}" ] = [];
{% for f in fpc %}
pfsp2fpc[ "{{ pfsp }}" ].push( "{{ f }}" );
{% endfor %}
{% endfor %}
var update_filter_detection = function( arg ) var update_filter_detection = function( arg )
{ {
var selected = $( this ).val(); var selected = $( this ).val();
...@@ -177,6 +202,78 @@ ...@@ -177,6 +202,78 @@
} }
} ); } );
} }
var mark_details = function( event )
{
var target = event.currentTarget.id.replace( "outer_div_mark_", "" );
var target_ref = [];
var target_fpc = [];
_.forEach( marks[ target ][ "pfsp" ], function( pfsp )
{
_.forEach( pfsp2fpc[ pfsp ], function( fpc )
{
target_ref.push( refs[ marks[ target ][ "submission_uuid" ] ][ fpc ] );
target_fpc.push( fpc );
} );
} );
target_ref = target_ref[ 0 ];
target_fpc = target_fpc[ 0 ];
$( "<div />" )
.attr( "id", "mark_details_dialog" )
.append(
$( "<div/>" )
.attr( "class", "icnml_mark_detail" )
.append(
$( "<div/>" )
.append( $( "<div />" )
.attr( "id", "icnml_mark_detail_left" )
.attr( "style", "background-image:url( {{ url_for( 'image.image_file_serve', file_id = 'uuid' ) }} )".replace( "uuid", target ) )
)
)
.append(
$( "<div/>" )
.attr( "id", "icnml_mark_detail_right" )
.attr( "style", "background-image:url( {{ url_for( 'image.image_segment_serve', tenprint_id = 'uuid', pc = 'fpc' ) }} )".replace( "uuid", target_ref ).replace( "fpc", target_fpc ) )
)
)
.dialog( {
title: "Details about the mark 'Mark " + marks[ target ][ 'id' ] + "'",
modal: true,
resizable: false,
width: $( window ).width() * 0.8,
height: $( window ).height() * 0.8,
buttons: {
"OK": function(){
$( this ).dialog( "close" );
}
},
close: function()
{
$( this ).remove();
},
open: function()
{
$( ".ui-widget-overlay" ).bind( "click", function()
{
$( "#mark_details_dialog" ).dialog( "close" );
} );
}
} );
}
var refs = {};
{% for submission_id, value in refs.iteritems() %}
var tmp = {};
{% for fpc, tenprint_id in value.iteritems() %}
tmp[ "{{ fpc }}" ] = "{{ tenprint_id }}";
{% endfor %}
refs[ "{{ submission_id }}" ] = tmp;
{% endfor %}
</script> </script>
</head> </head>
<body class="icnml_main_layout"> <body class="icnml_main_layout">
...@@ -293,6 +390,8 @@ ...@@ -293,6 +390,8 @@
$( "#filter_notes_input" ).on( "keyup", update_filter_note ); $( "#filter_notes_input" ).on( "keyup", update_filter_note );
$( ".mark_outer" ).on( "click", mark_details );
$( "#icnml_navigation_trainersearch" ) $( "#icnml_navigation_trainersearch" )
.addClass( "activated" ); .addClass( "activated" );
</script> </script>
......