-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
292 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
function populate_team_overall(compid){ | ||
$('#comp_name').text('Loading Results ...'); | ||
|
||
$.ajax({ | ||
type: "GET", | ||
url: '/_get_comp_team_result/'+compid, | ||
contentType:"application/json", | ||
dataType: "json", | ||
success: function (json) { | ||
|
||
var compid = json.info.id; | ||
var taskNum = json.stats.valid_tasks | ||
console.log('taskNum='+taskNum); | ||
var columns = []; | ||
var idx = 0; | ||
// rankings | ||
//console.log(json.rankings); | ||
// json.rankings.forEach( function(item, index) { | ||
// columns.push({data: 'rankings.'+item.rank_id.toString(), title: '#', name: item.rank_id.toString(), className: "text-right", defaultContent: '', visible: false}); | ||
// }); | ||
columns.push({data: 'group', title:'Group', className: "text-right", defaultContent: '', visible: false}); | ||
columns.push({data: 'score', title:'Total', className: "text-right", defaultContent: '', visible: false}); | ||
columns.push({data: 'team_score', title:'Team Total', className: "text-right", defaultContent: '', visible: false}); | ||
columns.push({data: 'fai_id', title:'FAI', className: "text-right", defaultContent: '', visible: false}); | ||
columns.push({data: 'civl_id', title:'CIVL', className: "text-right", defaultContent: '', visible: false}); | ||
columns.push({data: 'name', title:'Name'}); | ||
columns.push({data: 'glider', title:'Equip'}); | ||
columns.push({data: 'glider_cert', title:'EN', defaultContent: '', visible: false}); | ||
columns.push({data: 'nat', title:'NAT', defaultContent: '', visible: false}); | ||
columns.push({data: 'sex', title:'Sex', defaultContent: '', visible: false}); | ||
columns.push({data: 'sponsor', title:'Sponsor'}); | ||
json.tasks.forEach( function(item, index) { | ||
let code = item.task_code | ||
console.log( item.task_code.toString() + ': ' + item.training.toString()); | ||
if ( !item.training ) { | ||
columns.push({data: 'results.'+code+'.score', title: code, className: "text-right", defaultContent: ''}); | ||
} | ||
}); | ||
$('#results_table').dataTable({ | ||
data: json.data, | ||
paging: false, | ||
searching: true, | ||
saveState: true, | ||
info: false, | ||
dom: 'lrtip', | ||
columns: columns, | ||
orderFixed: [[3, 'desc'],[2, 'desc']], | ||
rowGroup: {dataSrc: 'group'}, | ||
initComplete: function(settings) { | ||
var table= $('#results_table'); | ||
var rows = $("tr", table).length-1; | ||
var numCols = table.DataTable().columns().nodes().length; | ||
|
||
// comp info | ||
console.log(json.info); | ||
$('#comp_name').text(json.info.comp_name + " - Teams"); | ||
$('#comp_date').text(json.info.date_from + ' - ' + json.info.date_to); | ||
|
||
// some GAP parameters | ||
$('#formula tbody').append( | ||
"<tr><td>Director</td><td>" + json.info.MD_name + '</td></tr>' + | ||
"<tr><td>Location</td><td>" + json.info.comp_site + '</td></tr>' + | ||
"<tr><td>Formula</td><td>" + json.formula.formula + '</td></tr>' + | ||
"<tr><td>Overall Scoring</td><td>" + json.formula.overall_validity + ' (' + json.formula.validity_param*100 + ')</td></tr>' | ||
); | ||
if (json.formula.overall_validity == 'ftv') { | ||
$('#formula tbody').append("<tr><td>Total Validity</td><td>" + json.stats.tot_validity + '</td></tr>'); | ||
} | ||
$("#dhv option").remove(); // Remove all <option> child tags. | ||
// at the moment we provide the highest EN rating for a class and the overall_class_filter.js uses this. | ||
// if we want to be more specific and pass a list of all EN ratings inside a class we can do something like this: https://stackoverflow.com/questions/15759863/get-array-values-from-an-option-select-with-javascript-to-populate-text-fields | ||
$.each(json.rankings, function(index, item) { | ||
$("#dhv").append( | ||
$("<option></option>") | ||
.text(item.rank_name) | ||
.val(item.rank_id) | ||
); | ||
}); | ||
} | ||
}); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
function populate_team_task(task_id){ | ||
$(document).ready(function() { | ||
$('#task_result').dataTable({ | ||
ajax: '/_get_task_team_result/'+task_id, | ||
paging: false, | ||
searching: true, | ||
saveState: true, | ||
info: false, | ||
"dom": 'lrtip', | ||
columns: [ | ||
{data: 'group', title:'group'}, | ||
{data: 'team_score', title:'Team Total'}, | ||
{data: 'fai_id', title:'FAI'}, | ||
{data: 'civl_id', title:'CIVL'}, | ||
{data: 'glider', title:'Equip'}, | ||
{data: 'glider_cert', title:'EN'}, | ||
{data: 'name', title:'Name'}, | ||
{data: 'nat', title:'NAT'}, | ||
{data: 'sex', title:'Sex'}, | ||
{data: 'sponsor', title:'Sponsor'}, | ||
{data: 'score', title:'Total'} | ||
|
||
], | ||
|
||
orderFixed: [[1, 'desc'],[10, 'desc']], | ||
|
||
rowGroup: { | ||
dataSrc: ['group'] | ||
|
||
}, | ||
"columnDefs": [ | ||
{ | ||
"targets": [ 0, 1, 2, 3, 4, 5], | ||
"visible": false | ||
}, | ||
], | ||
"initComplete": function(settings, json) | ||
{ | ||
var table= $('#task_result'); | ||
var rows = $("tr", table).length-1; | ||
var numCols = $("th", table).length+6; | ||
|
||
// task info | ||
$('#comp_name').text(json.info.comp_name) | ||
$('#task_name').text(json.info.task_name + " - Teams"); | ||
$('#task_date').text(json.info.date); | ||
|
||
// some GAP parameters | ||
$('#formula tbody').append( | ||
"<tr><td>Director</td><td>" + json.info.MD_name + '</td></tr>' + | ||
"<tr><td>Location</td><td>" + json.info.comp_site + '</td></tr>' + | ||
"<tr><td>Formula</td><td>" + json.formula.formula_name + '</td></tr>' + | ||
"<tr><td>Overall Scoring</td><td>" + json.formula.overall_validity); | ||
if (json.formula.overall_validity == 'ftv') { | ||
$('#formula tbody').append( | ||
' (' + json.formula.validity_param*100 + ')</td></tr>' + | ||
"<tr><td>Total Validity</td><td>" + json.stats.total_validity + '</td></tr>'); | ||
} | ||
else { | ||
$('#formula tbody').append('</td></tr>'); | ||
} | ||
|
||
|
||
} | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{% extends "base.html"%} | ||
|
||
{% block page_title %} | ||
Competition Results - Team | ||
{% endblock %} | ||
|
||
{% block head %} | ||
<!-- CSS --> | ||
<link href='/static/css/task.css' rel='stylesheet'> | ||
<!-- JS --> | ||
<script type='text/javascript' src='/static/js/utils.js'></script> | ||
<script type='text/javascript' src='/static/js/microajax.minified.js'></script> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class='container-fluid'> | ||
<div class='row'> | ||
<div class='col col-md-7 comp_header mt-1'> | ||
<h2 id='comp_name'></h2> | ||
<h4 id='comp_date'></h4> | ||
<h4 id='comp_director'></h4> | ||
<select name='dhv' id='dhv' class='form-control col-md-4' placeholder='Class'> | ||
<option value='' selected>Open</option> | ||
<option value='A'>Novice</option> | ||
<option value='B'>Fun</option> | ||
<option value='C'>Sports</option> | ||
<option value='D'>Serial</option> | ||
<option value='CCC'>Competition</option> | ||
</select> | ||
</div> | ||
<div class='col col-md-5' class='parameters'> | ||
<table class='table table-sm' id='formula'> | ||
<thead class='thead-light' id='formula_hd'> | ||
<tr> | ||
<th>Information</th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
<tbody class='small' id='formula_bd'></tbody> | ||
</table> | ||
</div> | ||
</div> | ||
{% from "macros.html" import datatable with context %} | ||
{{ datatable('results_table') }} | ||
</div> | ||
{% endblock %} | ||
|
||
{% block js %} | ||
<script type='text/javascript' src='https://cdn.datatables.net/rowgroup/1.1.1/js/dataTables.rowGroup.min.js'></script> | ||
<script type='text/javascript' src='/static/js/enums.js'></script> | ||
<script type='text/javascript' src='/static/js/pop_team_overall.js'></script> | ||
<script src="{{ static_url_for('static', filename='js/class_filter.js') }}"></script> | ||
<script type='text/javascript'>populate_team_overall({{compid|tojson}})</script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{% extends "base.html"%} | ||
|
||
{% block page_title %} | ||
Task Result - Team | ||
{% endblock %} | ||
|
||
{% block head %} | ||
<!-- CSS --> | ||
<link href='/static/css/task.css' rel='stylesheet'> | ||
<!-- JS --> | ||
<script type='text/javascript' src='/static/js/utils.js'></script> | ||
<script type='text/javascript' src='/static/js/microajax.minified.js'></script> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class='container-fluid'> | ||
<div class='row'> | ||
<div class='col col-md-7 comp_header mt-1'> | ||
<h2 id='comp_name'></h2> | ||
<h2 id='task_name'></h2> | ||
<h4 id='task_date'></h4> | ||
</div> | ||
<div class='col col-md-5' class='parameters'> | ||
<table class='table table-sm' id='formula'> | ||
<thead class='thead-light' id='formula_hd'> | ||
<tr> | ||
<th>Information</th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
<tbody class='small' id='formula_bd'></tbody> | ||
</table> | ||
</div> | ||
</div> | ||
{% from "macros.html" import datatable with context %} | ||
{{ datatable('task_result') }} | ||
</div> | ||
{% endblock %} | ||
|
||
{% block js %} | ||
<script type='text/javascript' src='https://cdn.datatables.net/rowgroup/1.1.1/js/dataTables.rowGroup.min.js'></script> | ||
<script type='text/javascript' src='/static/js/enums.js'></script> | ||
<script type='text/javascript' src='/static/js/pop_team_task.js'></script> | ||
<script type='text/javascript'>populate_team_task({{taskid|tojson}})</script> | ||
{% endblock %} |