{% extends "base.html" %}

{% block body %}
<div class="container">
{% if session %}
<form action="{% url 'edit_session' project.pk session.pk %}" method="POST">
{% else %}
<form action="{% url 'new_session' project.pk %}" method="POST">
{% endif %}
{% csrf_token %}
    <table class="table table-striped table-bordered table-hover table-nonfluid">
        <tr>
            <td>{{ form.name.label_tag }}</td>
            <td>{{ form.name }}</td>
        </tr>
        <tr>
            <td>{{ form.description.label_tag }}</td>
            <td>{{ form.description }}</td>
        </tr>
        <tr id="dbms_row">
            <td>{{ form.dbms.label_tag }}</td>
            <td>{{ form.dbms }}</td>
        </tr>
        <tr id="cpu_row">
            <td>{{ form.cpu.label_tag }}</td>
            <td>{{ form.cpu }}</td>
        </tr>
        <tr id="memory_row">
            <td>{{ form.memory.label_tag }}</td>
            <td>{{ form.memory }}</td>
        </tr>
        <tr id="storage_row">
            <td>{{ form.storage.label_tag }}</td>
            <td>{{ form.storage }}</td>
        </tr>
        <tr id="storage_type_row">
            <td>{{ form.storage_type.label_tag }}</td>
            <td>{{ form.storage_type }}</td>
        </tr>
        <tr id="algorithm_row">
            <td>{{ form.algorithm.label_tag }}</td>
            <td>{{ form.algorithm }}</td>
        </tr>
        <tr>
            <td>{{ form.tuning_session.label_tag }}</td>
            <td>{{ form.tuning_session }}</td>
        </tr>
        <tr id="target_obj_row">
            <td>{{ form.target_objective.label_tag }}</td>
            <td>{{ form.target_objective }}</td>
        </tr>
        <tr id="hyperparameters_row">
            <td>{{ form.hyperparameters.label_tag }}</td>
            <td>{{ form.hyperparameters }}</td>
        </tr>
        <tr id="upload_code_row">
            <td>{{ form.gen_upload_code.label_tag }}</td>
            <td>{{ form.gen_upload_code }}</td>
        </tr>
    </table>
    <button class="btn btn-default" type="submit" name="id">Submit</button>
    {% if session %}
    <a class="btn btn-default" href="{% url 'session' project.pk session.pk %}">Cancel</a>
    {% else %}
    <a class="btn btn-default" href="{% url 'project_sessions' project.pk %}">Cancel</a>
    {% endif %}
</form>
</div>

<script language="javascript">
function show_content() {
	console.log("In show_content()")
	//$("#target_obj_row").toggle()
}

$(function() {
	if ("{{ session }}" != "None") {
	    $("#dbms_row").hide();
	    $("#cpu_row").hide();
	    $("#memory_row").hide();
	    $("#storage_row").hide();
	    $("#storage_type_row").hide();
	    $("#algorithm_row").hide();
	} else {
		$("#upload_code_row").hide();
	}
	
	/*if (document.getElementById('id_tuning_session').checked) {
		$("#target_obj_row").show()
	} else {
		$("#target_obj_row").hide()
	}*/
});
</script>

{% endblock body %}
