Newer
Older
<!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' ) }}">
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<style type="text/css">
.icnml_button {
margin-top: 50px;
}
.icnml_button > div > a {
width: 60%;
margin-bottom: 10px;
}
</style>
<script type="text/javascript">
baseurl = "{{ baseurl }}";
submission_id = "{{ submission_id }}";
file_id = "{{ file[ 'uuid' ] }}";
var zones_array = new Array();
{% for zone in zones %}
zones_array.push( {{ zone[ 'pc' ] }} );
{% endfor %}
var data_columns = new Array();
{% for d in datacolumns %}
data_columns.push( "{{ d }}" );
{% endfor %}
var zonesData = {};
{% for zone in zones %}
zonesData[ "{{ zone[ 'pc' ] }}" ] = {
"tl_x": {{ zone[ 'tl_x' ] }},
"tl_y": {{ zone[ 'tl_y' ] }},
"br_x": {{ zone[ 'br_x' ] }},
"br_y": {{ zone[ 'br_y' ] }},
"angle": {{ zone[ 'angle' ] }}
};
{% endfor %}
var update_template_db = function()
{
var template = $( "#file_{{ file[ 'uuid' ] }}_template > select > option:checked" ).val();
$.ajax( {
url: "{{ url_for( 'submission.submission_tenprint_set_template', submission_id = submission_id, tenprint_id = file[ 'uuid' ] ) }}",
dataType: "json",
method: "POST",
data: {
template: template
},
success: function( data )
{
location.reload();
}
} );
}
var update_quality_db = function()
{
var quality = $( "#file_{{ file[ 'uuid' ] }}_quality > select > option:checked" ).val();
$.ajax( {
url: "{{ url_for( 'submission.submission_tenprint_set_quality', submission_id = submission_id, tenprint_id = file[ 'uuid' ] ) }}",
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
dataType: "json",
method: "POST",
data: {
quality: quality
},
success: function( data )
{
if( data.error )
toastr.error( "Error while saving the quality value" );
},
error: function( data )
{
toastr.error( "Network error" );
}
} );
}
var update_coordinates_informations = function()
{
svg_height = $( window ).height() - 100;
svg_width = svg_height * {{ svg_hw_factor }};
card_img_info = {
"right": svg_width * ( {{ card_info[ 'width_cm' ] }} * {{ img_info[ 'resolution' ] }} / 2.54 ) / ( {{ img_info[ 'width' ] }} ),
"bottom": svg_height * ( {{ card_info[ 'height_cm' ] }} * {{ img_info[ 'resolution' ] }} / 2.54 ) / ( {{ img_info[ 'height' ] }} ),
}
dpc = card_img_info[ "right" ] / {{ card_info[ 'width_cm' ] }};
}
var start_segmentation = function()
{
$( "#segmentation_button_span_text" ).text( "Segmenting..." );
$( "#segmentation_button" ).append(
$( "<span />" )
.attr( "id", "segmentation_button_span_spinner" )
.attr( "class", "ld ld-ring ld-cycle" )
.css( "position", "absolute" )
.css( "right", "20px" )
)
$( "#segmentation_button" ).off( "click" );
$.ajax( {
url: "{{ url_for( 'image.image_tenprint_segmentation', tenprint_id = file[ 'uuid' ] ) }}",
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
dataType: "json",
success: function( data )
{
$( "#segmentation_button_span_text" ).text( "Segementation updated" );
$( "#segmentation_button_span_spinner" ).remove();
},
error: function( data )
{
$( "#segmentation_button_span_text" ).text( "Error while segmenting..." );
$( "#segmentation_button_span_spinner" ).remove();
}
} );
}
var updateSVG = function()
{
$( "#template_svg_div" )
.css( "width", svg_width )
.css( "height", svg_height );
$( ".icnml_central" )
.css( "width", svg_width * 2 )
.css( "height", svg_height );
$( "#line_right_border" ).attr( "x1", card_img_info[ "right" ] );
$( "#line_right_border" ).attr( "x2", card_img_info[ "right" ] );
$( "#line_right_border" ).attr( "y2", svg_height );
$( "#line_bottom_border" ).attr( "x2", svg_width );
$( "#line_bottom_border" ).attr( "y1", card_img_info[ "bottom" ] );
$( "#line_bottom_border" ).attr( "y2", card_img_info[ "bottom" ] );
$( "#zoomed_image" ).attr( "width", svg_width );
$( "#zoomed_image" ).attr( "height", svg_height );
$( "#tp_polygones" ).empty();
for( var i = 0; i < zones_array.length; i++ )
{
var pc = zones_array[ i ];
var $svg = $( "#tp_polygones" );
var a = zonesData[ pc ][ "tl_x" ] * dpc + "," + zonesData[ pc ][ "tl_y" ] * dpc;
var b = zonesData[ pc ][ "br_x" ] * dpc + "," + zonesData[ pc ][ "tl_y" ] * dpc;
var c = zonesData[ pc ][ "br_x" ] * dpc + "," + zonesData[ pc ][ "br_y" ] * dpc;
var d = zonesData[ pc ][ "tl_x" ] * dpc + "," + zonesData[ pc ][ "br_y" ] * dpc;
var p = a + " " + b + " " + c + " " + d;
if( ! p.includes( "NaN" ) )
{
$( SVG( "polygon" ) )
.attr( "id", "pc_" + pc )
.attr( "points", p )
.attr( "fill", "rgb( 255, 0, 0 )" )
.attr( "fill-opacity", "0.1" )
.attr( "stroke", "red" )
.attr( "stroke-width", "1" )
.appendTo( $svg );
}
if( zonesData[ pc ][ "angle" ] == 0 )
{
$( SVG( "line" ) )
.attr( "id", "pc_" + pc + "_angle" )
.attr( "x1", zonesData[ pc ][ "tl_x" ] * dpc )
.attr( "y1", zonesData[ pc ][ "tl_y" ] * dpc + 20 )
.attr( "x2", zonesData[ pc ][ "br_x" ] * dpc )
.attr( "y2", zonesData[ pc ][ "tl_y" ] * dpc + 20 )
.attr( "stroke", "red" )
.attr( "stroke-width", "2" )
.attr( "stroke-opacity", "0.3" )
.appendTo( $svg );
} else if ( zonesData[ pc ][ "angle" ] == 90 ) {
$( SVG( "line" ) )
.attr( "id", "pc_" + pc + "_angle" )
.attr( "x1", zonesData[ pc ][ "br_x" ] * dpc - 20 )
.attr( "y1", zonesData[ pc ][ "tl_y" ] * dpc )
.attr( "x2", zonesData[ pc ][ "br_x" ] * dpc - 20 )
.attr( "y2", zonesData[ pc ][ "br_y" ] * dpc )
.attr( "stroke", "red" )
.attr( "stroke-width", "2" )
.attr( "stroke-opacity", "0.3" )
.appendTo( $svg );
} else if ( zonesData[ pc ][ "angle" ] == 180 ) {
$( SVG( "line" ) )
.attr( "id", "pc_" + pc + "_angle" )
.attr( "x1", zonesData[ pc ][ "br_x" ] * dpc )
.attr( "y1", zonesData[ pc ][ "br_y" ] * dpc - 20 )
.attr( "x2", zonesData[ pc ][ "tl_x" ] * dpc )
.attr( "y2", zonesData[ pc ][ "br_y" ] * dpc - 20 )
.attr( "stroke", "red" )
.attr( "stroke-width", "2" )
.attr( "stroke-opacity", "0.3" )
.appendTo( $svg );
} else if ( zonesData[ pc ][ "angle" ] == 270 ) {
$( SVG( "line" ) )
.attr( "id", "pc_" + pc + "_angle" )
.attr( "x1", zonesData[ pc ][ "tl_x" ] * dpc + 20 )
.attr( "y1", zonesData[ pc ][ "tl_y" ] * dpc )
.attr( "x2", zonesData[ pc ][ "tl_x" ] * dpc + 20 )
.attr( "y2", zonesData[ pc ][ "br_y" ] * dpc )
.attr( "stroke", "red" )
.attr( "stroke-width", "2" )
.attr( "stroke-opacity", "0.3" )
.appendTo( $svg );
}
}
}
var delete_tenprint = function()
{
$( "<div />" )
.attr( "id", "delete_confirmation" )
.text( "Do you really want to delete this tenprint card?" )
.dialog( {
title: "Confirm tenprint deletion",
modal: true,
buttons: {
"OK": function()
{
$.ajax( {
url: "{{ url_for( 'submission.submission_tenprint_delete', submission_id = submission_id, tenprint_id = file[ 'uuid' ] ) }}",
dataType: "json",
success: function( data )
{
$( "#delete_confirmation" ).remove();
window.location = "{{ url_for( 'submission.submission_tenprint_list', submission_id = submission_id ) }}";
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
},
error: function( data )
{
$( "#delete_confirmation" ).remove();
}
} );
},
"Cancel": function()
{
$( this ).dialog( "close" );
},
},
close: function()
{
$( this ).remove();
}
} );
}
</script>
</head>
<body class="icnml_main_layout">
{% include "header.html" %}
{% include navigation %}
<div class="icnml_content">
<div class="icnml_tp_oneperpage">
<form id="icnml_file_update_{{ file[ 'uuid' ] }}">
<div class="ui-widget-header ui-corner-top icnml_box_top">File '<span id="header_filename">{{ file[ 'uuid' ] }}</span>'</div>
<div class="ui-widget-content ui-corner-bottom icnml_box_content">
<div class="icnml_tp_cardbox">
<div id="template_svg_div">
<svg id="template_svg" width="100%" height="100%">
<image x="0" y="0" width="100%" height="100%" xlink:href="{{ url_for( 'image.image_file_serve', file_id = file[ 'uuid' ] ) }}"></image>
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
<g id="tp_polygones"></g>
<line id="line_right_border" x1="0" y1="0" x2="0" y2="0" style="stroke:rgb(0,0,255); stroke-width: 2" />
<line id="line_bottom_border" x1="0" y1="0" x2="0" y2="0" style="stroke:rgb(0,0,255); stroke-width: 2" />
</svg>
</div>
<div>
<div class="icnml_box_fields">
<div>Format</div>
<div>{{ file[ 'format' ] }}</div>
<div>Resolution</div>
<div>{{ file[ 'resolution' ] }} dpi</div>
<div>Width</div>
<div>{{ file[ 'width' ] }} px</div>
<div>Height</div>
<div>{{ file[ 'height' ] }} px</div>
<div>Size</div>
<div>{{ file[ 'size' ] }} Mo</div>
<div>Upload time</div>
<div id="file_{{ file[ 'uuid' ] }}_uploadtime">-</div>
<div>Template</div>
<div id="file_{{ file[ 'uuid' ] }}_template">
<select name="tenprint_template_select">
<option value="0" id="tenprint_template_none_option" selected>None</option>
{% for tenprint_template in tenprint_templates %}
<option value="{{ tenprint_template[ 'id' ] }}" id="{{ tenprint_template[ 'id' ] }}_option">
{{ tenprint_template[ 'name' ] }}
</option>
{% endfor %}
</select>
</div>
<div>Quality</div>
<div id="file_{{ file[ 'uuid' ] }}_quality">
<select name="tenprint_quality_select">
<option value="0" id="tenprint_quality_none_option" selected>None</option>
{% for quality_type in quality_type %}
<option value="{{ quality_type[ 'id' ] }}" id="tenprint_quality_{{ quality_type[ 'id' ] }}_option">
{{ quality_type[ 'name' ] }}
</option>
{% endfor %}
</select>
</div>
</div>
<div class="icnml_button">
<div id="segmentation_button_div">
<a class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" id="segmentation_button" role="button" aria-disabled="false">
<span class="ui-button-text" id="segmentation_button_span_text">Update segmentation</span>
</a>
</div>
<div id="go_to_segmentation_button_div">
<a class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" id="go_to_segmentation_button" href="{{ url_for( 'submission.admin_submission_tenprint_segments_list', submission_id = submission_id, tenprint_id = file[ 'uuid' ] ) }}">
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
<span class="ui-button-text" id="go_to_segmentation_button_span_text">Go to segments list</span>
</a>
</div>
<div id="delete_button_div" style="margin-top: 30px;">
<a class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" id="delete_button">
<span class="ui-button-text" id="delete_button_span_text">Delete tenprint card</span>
</a>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</body>
<script type="text/javascript">
window.addEventListener( "resize", function( event )
{
update_coordinates_informations();
updateSVG();
} );
update_coordinates_informations();
updateSVG();
{% for zone in zones %}
$( "#pc_{{ zone[ 'pc' ] }}" ).on( "click", function()
{
window.location = "{{ url_for( 'submission.submission_segment', submission_id = submission_id, tenprint_id = file[ 'uuid' ], pc = zone[ 'pc' ] ) }}";
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
} );
{% endfor %}
$( "#delete_button" ).on( "click", delete_tenprint );
$( "#file_{{ file[ 'uuid' ] }}_template > select" ).on( "change", update_template_db );
$( "#file_{{ file[ 'uuid' ] }}_quality > select" ).on( "change", update_quality_db );
$( "#{{ file[ 'template' ] }}_option" ).prop( "selected", true );
$( "#tenprint_quality_{{ file[ 'quality' ] }}_option" ).prop( "selected", true );
{% if file[ "template" ] == None or file[ "template" ] == 0 %}
$( "#segmentation_button" )
.removeClass( "ui-state-default" )
.addClass( "ui-state-disabled" );
$( "#go_to_segmentation_button" )
.removeClass( "ui-state-default" )
.addClass( "ui-state-disabled" );
{% endif %}
$( "#file_{{ file[ 'uuid' ] }}_uploadtime" )
.text( moment.utc( "{{ file[ 'creation_time' ] }}" ).local().format( "MMMM Do YYYY, HH:mm:ss" ) );
$( "#segmentation_button" ).on( "click", start_segmentation );
$( "#icnml_navigation_updatedonor" )
.addClass( "activated" );
$( "#navloc" ).append(
$( "<a />" )
.attr( "href", "{{ url_for( 'submission.admin_submission_list' ) }}" )
.text( "Submissions" )
)
.append(
$( "<span />" ).text( ">" )
)
.append(
$( "<a />" )
.attr( "href", "{{ url_for( 'submission.admin_tenprint_list', submission_id = submission_id ) }}" )