105 lines
3.2 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
2020-02-17 13:25:14 -05:00
<title>Protocol Builder Mock Configuration</title>
2020-05-24 23:05:57 -04:00
<base href="/">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://use.typekit.net/kwp6dli.css">
{% assets 'app_scss' %}
2020-05-24 23:05:57 -04:00
<link href="{{ base_href + ASSET_URL }}" rel="stylesheet" type="text/css">
{% endassets %}
2020-05-24 23:05:57 -04:00
<link rel="shortcut icon" href="{{ base_href + url_for('static', filename='favicon.ico') }}">
</head>
<body>
<h2>{{ title }}</h2>
<p>{{ details|safe }}</p>
{% if 'Edit Study Details' in title %}
<div>Upload CSV</div>
<form action="{{ csv_action }}" method="post" enctype=multipart/form-data>
{{ form.csrf_token() }}
<input type=file name=file>
<input type=submit value=Upload label="Upload CSV">
</form>
{% endif %}
<form action="{{ action }}" method="post">
{{ form.csrf_token() }}
{% for field in form if field.name != "csrf_token" %}
<div class="form-field {{ field.widget.input_type }}">
<div class="form-field-label">{{ field.label() }}:</div>
<div class="form-field-input">{{ field }}</div>
<div class="form-field-help">{{ description_map[field.name] }}</div>
{% for error in field.errors %}
<div class="form-field-error">{{ error }}</div>
{% endfor %}
</div>
{% endfor %}
<button class="btn btn-primary" type="submit">Submit</button>
2020-05-25 11:41:39 -04:00
<a href="{{ url_for('index') }}" class="btn btn-default">Cancel</a>
</form>
<div id="ldap-live-search"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script>
$(document).ready(function () {
clearLiveSearch();
$('#NETBADGEID').keyup(function (event) {
let val = $('#NETBADGEID').val();
{# limit how often we serach LDAP #}
if (val.length == 0) {
clearLiveSearch();
} else if ((val.length > 2) && (val.length % 2 == 1)) {
SearchLDAP(event);
}
});
$('#ldap-live-search').on('click', '.ldap-user', function() {
UpdateUserField(this);
});
function SearchLDAP(event) {
let current_val = $('#NETBADGEID').val();
let url = "{{base_href}}/search_ldap/" + current_val;
$.ajax({
url: url,
cache: false,
dataType: "json",
success: function (result) {
updateLiveSearch(result);
}
});
}
function updateLiveSearch(result) {
$('#ldap-live-search').empty();
$('#ldap-live-search').show();
$('#NETBADGEID').parent().append($('#ldap-live-search'));
for(let row in result) {
let uid = result[row]['uid'];
let display_name = result[row]['display_name'];
let row_div = "<div><span class='ldap-user' id='" + uid + "'>" + display_name + "</span></div>";
$('#ldap-live-search').append(row_div);
}
}
function UpdateUserField(obj) {
$('#NETBADGEID').val(obj.id);
clearLiveSearch();
}
function clearLiveSearch() {
$('#ldap-live-search').empty();
$('#ldap-live-search').hide();
}
});
</script>
</body>
</html>