summaryrefslogtreecommitdiffstats
path: root/dashboard/src/templates/config_bundle/steps/define_software.html
blob: ba1ff344e92efb36fcb5aeeee381f01185a08ba2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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
55
{% extends "config_bundle/steps/table_formset.html" %}

{% load bootstrap3 %}

{% block table %}
    <thead>
        <tr>
            <th>Device</th>
            <th>Image</th>
            <th>HeadNode</th>
        </tr>
    </thead>
    <tbody>
{% for form in formset %}
    <tr>
        <td>{% bootstrap_field form.host_name show_label=False %}</td>
        <td>{% bootstrap_field form.image show_label=False %}</td>
        <td class="table_hidden_input_parent">
            <input id="radio_{{forloop.counter}}" class="my_radio" type="radio" name="headnode" value="{{forloop.counter}}">
            {{ form.headnode }}
        </td>
    </tr>
{% endfor %}
{{formset.management_form}}

{% endblock table %}

{% block tablejs %}
<script>

    document.getElementById("radio_{{headnode}}").checked = true;

</script>
{% endblock tablejs %}


{% block onleave %}
var parents = document.getElementsByClassName("table_hidden_input_parent");
for(var i=0; i<parents.length; i++){
    var node = parents[i];
    var radio = node.getElementsByClassName("my_radio")[0];
    var checkbox = radio.nextElementSibling;
    if(radio.checked){
        checkbox.value = "True";
    }
}

var form = $("#table_formset");
var formData = form.serialize();
var req = new XMLHttpRequest();
req.open("POST", "/wf/workflow/", false);
req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
req.onerror = function() { alert("problem with form submission"); }
req.send(formData);
{% endblock onleave %}