@@ -0,0 +1,8 | |||||
|
1 | from django import forms | |||
|
2 | from .models import ABSConfiguration | |||
|
3 | ||||
|
4 | class ABSConfigurationForm(forms.ModelForm): | |||
|
5 | ||||
|
6 | class Meta: | |||
|
7 | model = ABSConfiguration | |||
|
8 | fields = ('experiment',) |
@@ -0,0 +1,1 | |||||
|
1 | {% extends "dev_conf.html" %} No newline at end of file |
@@ -0,0 +1,11 | |||||
|
1 | {% extends "dev_conf.html" %} | |||
|
2 | ||||
|
3 | {% block extra-js%} | |||
|
4 | <script type="text/javascript"> | |||
|
5 | ||||
|
6 | $("#bt_edit_device").click(function() { | |||
|
7 | document.location = "{% url 'url_edit_dds_conf' dev_conf.id%}"; | |||
|
8 | }); | |||
|
9 | ||||
|
10 | </script> | |||
|
11 | {% endblock %} No newline at end of file |
@@ -0,0 +1,1 | |||||
|
1 | {% extends "dev_conf_edit.html" %} No newline at end of file |
@@ -0,0 +1,96 | |||||
|
1 | {% extends "base.html" %} | |||
|
2 | {% load bootstrap3 %} | |||
|
3 | {% load static %} | |||
|
4 | {% load main_tags %} | |||
|
5 | {% block extra-head %} | |||
|
6 | <link href="{% static 'css/bootstrap-datetimepicker.min.css' %}" media="screen" rel="stylesheet"> | |||
|
7 | {% endblock %} | |||
|
8 | ||||
|
9 | {% block camp-active %}active{% endblock %} | |||
|
10 | ||||
|
11 | {% block content-title %}{{title}}{% endblock %} | |||
|
12 | {% block content-suptitle %}{{suptitle}}{% endblock %} | |||
|
13 | ||||
|
14 | {% block content %} | |||
|
15 | <table class="table table-bordered"> | |||
|
16 | {% for key in campaign_keys %} | |||
|
17 | <tr><th>{{key|title}}</th><td>{{campaign|attr:key}}</td></tr> | |||
|
18 | {% endfor %} | |||
|
19 | </table> | |||
|
20 | <hr> | |||
|
21 | ||||
|
22 | <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> | |||
|
23 | <div class="panel panel-default"> | |||
|
24 | <div class="panel-heading" role="tab" id="headingOne"> | |||
|
25 | <h4 class="panel-title"> | |||
|
26 | <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne"> | |||
|
27 | Edit Campaign Details | |||
|
28 | </a> | |||
|
29 | </h4> | |||
|
30 | </div> | |||
|
31 | <div id="collapseOne" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne"> | |||
|
32 | <div class="panel-body"> | |||
|
33 | <form class="form" method="post" action="{% url 'url_edit_campaign' campaign.id %}"> | |||
|
34 | {% csrf_token %} | |||
|
35 | {% bootstrap_form form layout='horizontal' size='medium' %} | |||
|
36 | <div style="clear: both;"></div> | |||
|
37 | <br> | |||
|
38 | <button type="submit" class="btn btn-primary pull-right" id="bt_update">Update</button> | |||
|
39 | </form> | |||
|
40 | </div> | |||
|
41 | </div> | |||
|
42 | </div> | |||
|
43 | <div class="panel panel-default"> | |||
|
44 | <div class="panel-heading" role="tab" id="headingTwo"> | |||
|
45 | <h4 class="panel-title"> | |||
|
46 | <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo"> | |||
|
47 | Experiment List | |||
|
48 | </a> | |||
|
49 | </h4> | |||
|
50 | </div> | |||
|
51 | ||||
|
52 | <div id="collapseTwo" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingTwo"> | |||
|
53 | <div class="panel-body"> | |||
|
54 | <table class="table table-hover"> | |||
|
55 | <tr> | |||
|
56 | <th>#</th> | |||
|
57 | {% for header in experiment_keys %} | |||
|
58 | <th>{{ header|title }}</th> | |||
|
59 | {% endfor%} | |||
|
60 | </tr> | |||
|
61 | {% for item in experiments %} | |||
|
62 | <tr class="clickable-row" data-href="{% url 'url_experiment' item.id %}"> | |||
|
63 | <td>{{ forloop.counter }}</td> | |||
|
64 | {% for key in experiment_keys %} | |||
|
65 | <td>{{ item|attr:key }}</td> | |||
|
66 | {% endfor %} | |||
|
67 | </tr> | |||
|
68 | {% endfor %} | |||
|
69 | </table> | |||
|
70 | <button class="btn btn-primary pull-right" id="bt_add">{{button}}</button> | |||
|
71 | </div> | |||
|
72 | </div> | |||
|
73 | </div> | |||
|
74 | </div> | |||
|
75 | {% endblock %} | |||
|
76 | ||||
|
77 | {% block sidebar%} | |||
|
78 | {% include "sidebar_devices.html" %} | |||
|
79 | {% endblock %} | |||
|
80 | ||||
|
81 | {% block extra-js%} | |||
|
82 | <script src="{% static 'js/moment.min.js' %}"></script> | |||
|
83 | <script src="{% static 'js/bootstrap-datetimepicker.min.js' %}"></script> | |||
|
84 | <script type="text/javascript"> | |||
|
85 | $('.input-group.date').datetimepicker({"format": "YYYY-MM-DD HH:mm"}); | |||
|
86 | ||||
|
87 | $("#bt_add").click(function() { | |||
|
88 | document.location = "{% url 'url_add_experiment' campaign.id%}"; | |||
|
89 | }); | |||
|
90 | ||||
|
91 | $(".clickable-row").click(function() { | |||
|
92 | document.location = $(this).data("href"); | |||
|
93 | }); | |||
|
94 | ||||
|
95 | </script> | |||
|
96 | {% endblock %} No newline at end of file |
@@ -0,0 +1,35 | |||||
|
1 | {% extends "base.html" %} | |||
|
2 | {% load bootstrap3 %} | |||
|
3 | {% load static %} | |||
|
4 | {% load main_tags %} | |||
|
5 | {% block extra-head %} | |||
|
6 | <link href="{% static 'css/bootstrap-datetimepicker.min.css' %}" media="screen" rel="stylesheet"> | |||
|
7 | {% endblock %} | |||
|
8 | ||||
|
9 | {% block camp-active %}active{% endblock %} | |||
|
10 | ||||
|
11 | {% block content-title %}{{title}}{% endblock %} | |||
|
12 | {% block content-suptitle %}{{suptitle}}{% endblock %} | |||
|
13 | ||||
|
14 | {% block content %} | |||
|
15 | <form class="form" method="post" action=""> | |||
|
16 | {% csrf_token %} | |||
|
17 | {% bootstrap_form form layout='horizontal' size='medium' %} | |||
|
18 | <div style="clear: both;"></div> | |||
|
19 | <br> | |||
|
20 | <button type="submit" class="btn btn-primary pull-right">{{button}}</button> | |||
|
21 | </form> | |||
|
22 | {% endblock %} | |||
|
23 | ||||
|
24 | {% block sidebar%} | |||
|
25 | {% include "sidebar_devices.html" %} | |||
|
26 | {% endblock %} | |||
|
27 | ||||
|
28 | {% block extra-js%} | |||
|
29 | <script src="{% static 'js/moment.min.js' %}"></script> | |||
|
30 | <script src="{% static 'js/bootstrap-datetimepicker.min.js' %}"></script> | |||
|
31 | <script type="text/javascript"> | |||
|
32 | $('.input-group.date').datetimepicker({"format": "YYYY-MM-DD HH:mm"}); | |||
|
33 | ||||
|
34 | </script> | |||
|
35 | {% endblock %} No newline at end of file |
@@ -0,0 +1,54 | |||||
|
1 | {% extends "base.html" %} | |||
|
2 | {% load bootstrap3 %} | |||
|
3 | {% load static %} | |||
|
4 | {% load main_tags %} | |||
|
5 | {% block extra-head %} | |||
|
6 | <link href="{% static 'css/bootstrap-datetimepicker.min.css' %}" media="screen" rel="stylesheet"> | |||
|
7 | {% endblock %} | |||
|
8 | ||||
|
9 | {% block camp-active %}active{% endblock %} | |||
|
10 | ||||
|
11 | {% block content-title %}{{title}}{% endblock %} | |||
|
12 | {% block content-suptitle %}{{suptitle}}{% endblock %} | |||
|
13 | ||||
|
14 | {% block content %} | |||
|
15 | <table class="table table-hover"> | |||
|
16 | <tr> | |||
|
17 | <th>#</th> | |||
|
18 | {% for key in campaign_keys %} | |||
|
19 | <th>{{ key|title }}</th> | |||
|
20 | {% endfor%} | |||
|
21 | </tr> | |||
|
22 | {% for campaign in campaigns %} | |||
|
23 | <tr class="clickable-row" data-href="{% url 'url_campaign' campaign.id %}"> | |||
|
24 | <td>{{ forloop.counter }}</td> | |||
|
25 | {% for key in campaign_keys %} | |||
|
26 | <td>{{ campaign|attr:key }}</td> | |||
|
27 | {% endfor %} | |||
|
28 | </tr> | |||
|
29 | {% endfor %} | |||
|
30 | </table> | |||
|
31 | <button class="btn btn-primary pull-right" id="bt_add">{{button}}</button> | |||
|
32 | {% endblock %} | |||
|
33 | ||||
|
34 | {% block sidebar%} | |||
|
35 | {% include "sidebar_devices.html" %} | |||
|
36 | {% endblock %} | |||
|
37 | ||||
|
38 | {% block extra-js%} | |||
|
39 | <script src="{% static 'js/moment.min.js' %}"></script> | |||
|
40 | <script src="{% static 'js/bootstrap-datetimepicker.min.js' %}"></script> | |||
|
41 | <script type="text/javascript"> | |||
|
42 | $('.input-group.date').datetimepicker({"format": "YYYY-MM-DD HH:mm"}); | |||
|
43 | $('.input-group.time').datetimepicker({"format": "HH:mm"}); | |||
|
44 | ||||
|
45 | $("#bt_add").click(function() { | |||
|
46 | document.location = "{% url 'url_add_campaign' %}"; | |||
|
47 | }); | |||
|
48 | ||||
|
49 | $(".clickable-row").click(function() { | |||
|
50 | document.location = $(this).data("href"); | |||
|
51 | }); | |||
|
52 | ||||
|
53 | </script> | |||
|
54 | {% endblock %} No newline at end of file |
@@ -0,0 +1,34 | |||||
|
1 | {% extends "base.html" %} | |||
|
2 | {% load bootstrap3 %} | |||
|
3 | {% load static %} | |||
|
4 | {% load main_tags %} | |||
|
5 | ||||
|
6 | {% block conf-active %}active{% endblock %} | |||
|
7 | ||||
|
8 | {% block content-title %}{{title}}{% endblock %} | |||
|
9 | {% block content-suptitle %}{{suptitle}}{% endblock %} | |||
|
10 | ||||
|
11 | {% block content %} | |||
|
12 | <table class="table table-bordered"> | |||
|
13 | {% for key in dev_conf_keys %} | |||
|
14 | <tr><th>{{key|title}}</th><td>{{dev_conf|attr:key}}</td></tr> | |||
|
15 | {% endfor %} | |||
|
16 | </table> | |||
|
17 | <button class="btn btn-primary pull-right" id="bt_edit_device">Edit Device Conf</button> | |||
|
18 | <br></br> | |||
|
19 | <br></br> | |||
|
20 | {% endblock %} | |||
|
21 | ||||
|
22 | {% block sidebar%} | |||
|
23 | {% include "sidebar_devices.html" %} | |||
|
24 | {% endblock %} | |||
|
25 | ||||
|
26 | {% block extra-js%} | |||
|
27 | <script type="text/javascript"> | |||
|
28 | ||||
|
29 | $("#bt_edit_device").click(function() { | |||
|
30 | document.location = "{% url 'url_edit_dev_conf' dev_conf.id%}"; | |||
|
31 | }); | |||
|
32 | ||||
|
33 | </script> | |||
|
34 | {% endblock %} No newline at end of file |
@@ -0,0 +1,54 | |||||
|
1 | {% extends "base.html" %} | |||
|
2 | {% load bootstrap3 %} | |||
|
3 | {% load static %} | |||
|
4 | {% load main_tags %} | |||
|
5 | {% block extra-head %} | |||
|
6 | <link href="{% static 'css/bootstrap-datetimepicker.min.css' %}" media="screen" rel="stylesheet"> | |||
|
7 | {% endblock %} | |||
|
8 | ||||
|
9 | {% block conf-active %}active{% endblock %} | |||
|
10 | ||||
|
11 | {% block content-title %}{{title}}{% endblock %} | |||
|
12 | {% block content-suptitle %}{{suptitle}}{% endblock %} | |||
|
13 | ||||
|
14 | {% block content %} | |||
|
15 | <table class="table table-hover"> | |||
|
16 | <tr> | |||
|
17 | <th>#</th> | |||
|
18 | {% for key in configuration_keys %} | |||
|
19 | <th>{{ key|title }}</th> | |||
|
20 | {% endfor%} | |||
|
21 | </tr> | |||
|
22 | {% for item in configurations %} | |||
|
23 | <tr class="clickable-row" data-href="/{{item.device__device_type__name}}/{{item.id}}/"> | |||
|
24 | <td>{{ forloop.counter }}</td> | |||
|
25 | {% for key in configuration_keys %} | |||
|
26 | <td>{{ item|attr:key }}</td> | |||
|
27 | {% endfor %} | |||
|
28 | </tr> | |||
|
29 | {% endfor %} | |||
|
30 | </table> | |||
|
31 | <button class="btn btn-primary pull-right" id="bt_add">{{button}}</button> | |||
|
32 | {% endblock %} | |||
|
33 | ||||
|
34 | {% block sidebar%} | |||
|
35 | {% include "sidebar_devices.html" %} | |||
|
36 | {% endblock %} | |||
|
37 | ||||
|
38 | {% block extra-js%} | |||
|
39 | <script src="{% static 'js/moment.min.js' %}"></script> | |||
|
40 | <script src="{% static 'js/bootstrap-datetimepicker.min.js' %}"></script> | |||
|
41 | <script type="text/javascript"> | |||
|
42 | $('.input-group.date').datetimepicker({"format": "YYYY-MM-DD HH:mm"}); | |||
|
43 | $('.input-group.time').datetimepicker({"format": "HH:mm"}); | |||
|
44 | ||||
|
45 | $("#bt_add").click(function() { | |||
|
46 | document.location = "{% url 'url_add_dev_conf' 0%}"; | |||
|
47 | }); | |||
|
48 | ||||
|
49 | $(".clickable-row").click(function() { | |||
|
50 | document.location = $(this).data("href"); | |||
|
51 | }); | |||
|
52 | ||||
|
53 | </script> | |||
|
54 | {% endblock %} No newline at end of file |
@@ -0,0 +1,29 | |||||
|
1 | {% extends "base.html" %} | |||
|
2 | {% load bootstrap3 %} | |||
|
3 | {% load static %} | |||
|
4 | {% load main_tags %} | |||
|
5 | {% block extra-head %} | |||
|
6 | <link href="{% static 'css/bootstrap-datetimepicker.min.css' %}" media="screen" rel="stylesheet"> | |||
|
7 | {% endblock %} | |||
|
8 | ||||
|
9 | {% block dev-active %}active{% endblock %} | |||
|
10 | ||||
|
11 | {% block content-title %}{{title}}{% endblock %} | |||
|
12 | {% block content-suptitle %}{{suptitle}}{% endblock %} | |||
|
13 | ||||
|
14 | {% block content %} | |||
|
15 | <form class="form" method="post" action=""> | |||
|
16 | {% csrf_token %} | |||
|
17 | {% bootstrap_form form layout='horizontal' size='medium' %} | |||
|
18 | <div style="clear: both;"></div> | |||
|
19 | <br> | |||
|
20 | <button type="submit" class="btn btn-primary pull-right">{{button}}</button> | |||
|
21 | </form> | |||
|
22 | {% endblock %} | |||
|
23 | ||||
|
24 | {% block sidebar%} | |||
|
25 | {% include "sidebar_devices.html" %} | |||
|
26 | {% endblock %} | |||
|
27 | ||||
|
28 | {% block extra-js%} | |||
|
29 | {% endblock %} No newline at end of file |
@@ -0,0 +1,54 | |||||
|
1 | {% extends "base.html" %} | |||
|
2 | {% load bootstrap3 %} | |||
|
3 | {% load static %} | |||
|
4 | {% load main_tags %} | |||
|
5 | {% block extra-head %} | |||
|
6 | <link href="{% static 'css/bootstrap-datetimepicker.min.css' %}" media="screen" rel="stylesheet"> | |||
|
7 | {% endblock %} | |||
|
8 | ||||
|
9 | {% block dev-active %}active{% endblock %} | |||
|
10 | ||||
|
11 | {% block content-title %}{{title}}{% endblock %} | |||
|
12 | {% block content-suptitle %}{{suptitle}}{% endblock %} | |||
|
13 | ||||
|
14 | {% block content %} | |||
|
15 | <table class="table table-hover"> | |||
|
16 | <tr> | |||
|
17 | <th>#</th> | |||
|
18 | {% for key in device_keys %} | |||
|
19 | <th>{{ key|title }}</th> | |||
|
20 | {% endfor%} | |||
|
21 | </tr> | |||
|
22 | {% for device in devices %} | |||
|
23 | <tr class="clickable-row" data-href="{% url 'url_device' device.id %}"> | |||
|
24 | <td>{{ forloop.counter }}</td> | |||
|
25 | {% for key in device_keys %} | |||
|
26 | <td>{{ device|attr:key }}</td> | |||
|
27 | {% endfor %} | |||
|
28 | </tr> | |||
|
29 | {% endfor %} | |||
|
30 | </table> | |||
|
31 | <button class="btn btn-primary pull-right" id="bt_add">{{button}}</button> | |||
|
32 | {% endblock %} | |||
|
33 | ||||
|
34 | {% block sidebar%} | |||
|
35 | {% include "sidebar_devices.html" %} | |||
|
36 | {% endblock %} | |||
|
37 | ||||
|
38 | {% block extra-js%} | |||
|
39 | <script src="{% static 'js/moment.min.js' %}"></script> | |||
|
40 | <script src="{% static 'js/bootstrap-datetimepicker.min.js' %}"></script> | |||
|
41 | <script type="text/javascript"> | |||
|
42 | $('.input-group.date').datetimepicker({"format": "YYYY-MM-DD HH:mm"}); | |||
|
43 | $('.input-group.time').datetimepicker({"format": "HH:mm"}); | |||
|
44 | ||||
|
45 | $("#bt_add").click(function() { | |||
|
46 | document.location = "{% url 'url_add_device' %}"; | |||
|
47 | }); | |||
|
48 | ||||
|
49 | $(".clickable-row").click(function() { | |||
|
50 | document.location = $(this).data("href"); | |||
|
51 | }); | |||
|
52 | ||||
|
53 | </script> | |||
|
54 | {% endblock %} No newline at end of file |
@@ -0,0 +1,167 | |||||
|
1 | {% extends "base.html" %} | |||
|
2 | {% load bootstrap3 %} | |||
|
3 | {% load static %} | |||
|
4 | {% load main_tags %} | |||
|
5 | {% block extra-head %} | |||
|
6 | <link href="{% static 'css/bootstrap-datetimepicker.min.css' %}" media="screen" rel="stylesheet"> | |||
|
7 | {% endblock %} | |||
|
8 | ||||
|
9 | {% block exp-active %}active{% endblock %} | |||
|
10 | ||||
|
11 | {% block content-title %}Experiment{% endblock %} | |||
|
12 | {% block content-suptitle %}{{suptitle}}{% endblock %} | |||
|
13 | ||||
|
14 | {% block content %} | |||
|
15 | {% if form_new %} | |||
|
16 | <form class="form" method="post" action=""> | |||
|
17 | {% csrf_token %} | |||
|
18 | {% bootstrap_form form_new layout='horizontal' size='medium' %} | |||
|
19 | <div style="clear: both;"></div> | |||
|
20 | <br> | |||
|
21 | <button type="submit" class="btn btn-primary pull-right">Create</button> | |||
|
22 | </form> | |||
|
23 | {% elif experiment %} | |||
|
24 | <table class="table table-bordered"> | |||
|
25 | {% for key in experiment_keys %} | |||
|
26 | <tr><th>{{key|title}}</th><td>{{experiment|attr:key}}</td></tr> | |||
|
27 | {% endfor %} | |||
|
28 | </table> | |||
|
29 | <hr> | |||
|
30 | ||||
|
31 | <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> | |||
|
32 | <div class="panel panel-default"> | |||
|
33 | <div class="panel-heading" role="tab" id="headingOne"> | |||
|
34 | <h4 class="panel-title"> | |||
|
35 | <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne"> | |||
|
36 | Edit Experiment Details | |||
|
37 | </a> | |||
|
38 | </h4> | |||
|
39 | </div> | |||
|
40 | <div id="collapseOne" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne"> | |||
|
41 | <div class="panel-body"> | |||
|
42 | <form class="form" method="post" action="{% url 'edit_experiment' id_exp %}"> | |||
|
43 | {% csrf_token %} | |||
|
44 | {% bootstrap_form form layout='horizontal' size='medium' %} | |||
|
45 | <div style="clear: both;"></div> | |||
|
46 | <br> | |||
|
47 | <button type="submit" class="btn btn-primary pull-right" id="bt_update">Update</button> | |||
|
48 | </form> | |||
|
49 | </div> | |||
|
50 | </div> | |||
|
51 | </div> | |||
|
52 | <div class="panel panel-default"> | |||
|
53 | <div class="panel-heading" role="tab" id="headingTwo"> | |||
|
54 | <h4 class="panel-title"> | |||
|
55 | <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo"> | |||
|
56 | Add Device to Experiment | |||
|
57 | </a> | |||
|
58 | </h4> | |||
|
59 | </div> | |||
|
60 | <div id="collapseTwo" class="panel-collapse collapse {%if id_dev_type%}in{%endif%}" role="tabpanel" aria-labelledby="headingTwo"> | |||
|
61 | <div class="panel-body"> | |||
|
62 | <form class="form" method="post" action="{% url 'experiment_add_device' id_exp %}"> | |||
|
63 | {% csrf_token %} | |||
|
64 | {% bootstrap_form subform layout='horizontal' size='medium' %} | |||
|
65 | <div style="clear: both;"></div> | |||
|
66 | <br> | |||
|
67 | <table class="table"> | |||
|
68 | <tr> | |||
|
69 | <th>#</th> | |||
|
70 | {% for header in keys %} | |||
|
71 | <th>{{ header|title }}</th> | |||
|
72 | {% endfor%} | |||
|
73 | </tr> | |||
|
74 | {% for item in items %} | |||
|
75 | <tr class="clickable-row" data-href="{%if base_url %}{{ base_url }}/{% endif %}{{ item.id }}"> | |||
|
76 | <td>{{ forloop.counter }}</td> | |||
|
77 | {% for key in keys %} | |||
|
78 | <td>{{ item|attr:key }}</td> | |||
|
79 | {% endfor %} | |||
|
80 | <td> | |||
|
81 | <input type="hidden" id="id_device" name="device" value="{{item.id}}"></input> | |||
|
82 | <button type="submit" class="btn btn-primary btn-sm">Add</button> | |||
|
83 | </td> | |||
|
84 | </tr> | |||
|
85 | {% endfor %} | |||
|
86 | </table> | |||
|
87 | <br> | |||
|
88 | </form> | |||
|
89 | </div> | |||
|
90 | </div> | |||
|
91 | </div> | |||
|
92 | <div class="panel panel-default"> | |||
|
93 | <div class="panel-heading" role="tab" id="headingThree"> | |||
|
94 | <h4 class="panel-title"> | |||
|
95 | <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree"> | |||
|
96 | Experiment's Devices | |||
|
97 | </a> | |||
|
98 | </h4> | |||
|
99 | </div> | |||
|
100 | <div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree"> | |||
|
101 | <div class="panel-body"> | |||
|
102 | <table class="table table-hover"> | |||
|
103 | <tr> | |||
|
104 | <th>#</th> | |||
|
105 | {% for header in device_keys %} | |||
|
106 | <th>{{ header|title }}</th> | |||
|
107 | {% endfor%} | |||
|
108 | </tr> | |||
|
109 | {% for item in devices %} | |||
|
110 | <tr class="clickable-row" data-href="/{{item.device_type__alias}}/{{item.configuration__id}}/"> | |||
|
111 | <td>{{ forloop.counter }}</td> | |||
|
112 | {% for key in device_keys %} | |||
|
113 | <td>{{ item|attr:key }}</td> | |||
|
114 | {% endfor %} | |||
|
115 | </tr> | |||
|
116 | {% endfor %} | |||
|
117 | </table> | |||
|
118 | </div> | |||
|
119 | </div> | |||
|
120 | </div> | |||
|
121 | </div> | |||
|
122 | {% else %} | |||
|
123 | <table class="table table-hover"> | |||
|
124 | <tr> | |||
|
125 | <th>#</th> | |||
|
126 | {% for header in keys %} | |||
|
127 | <th>{{ header|title }}</th> | |||
|
128 | {% endfor%} | |||
|
129 | </tr> | |||
|
130 | {% for item in items %} | |||
|
131 | <tr class="clickable-row" data-href="{%if base_url %}{{ base_url }}/{% endif %}{{ item.id }}"> | |||
|
132 | <td>{{ forloop.counter }}</td> | |||
|
133 | {% for key in keys %} | |||
|
134 | <td>{{ item|attr:key }}</td> | |||
|
135 | {% endfor %} | |||
|
136 | </tr> | |||
|
137 | {% endfor %} | |||
|
138 | </table> | |||
|
139 | <button class="btn btn-primary pull-right" id="bt_add">{{button}}</button> | |||
|
140 | {% endif %} | |||
|
141 | ||||
|
142 | {% endblock %} | |||
|
143 | ||||
|
144 | {% block sidebar%} | |||
|
145 | {% include "sidebar_devices.html" %} | |||
|
146 | {% endblock %} | |||
|
147 | ||||
|
148 | {% block extra-js%} | |||
|
149 | ||||
|
150 | <script src="{% static 'js/moment.min.js' %}"></script> | |||
|
151 | <script src="{% static 'js/bootstrap-datetimepicker.min.js' %}"></script> | |||
|
152 | <script type="text/javascript"> | |||
|
153 | $('.input-group.date').datetimepicker({"format": "YYYY-MM-DD HH:mm"}); | |||
|
154 | ||||
|
155 | $(".clickable-row").click(function() { | |||
|
156 | document.location = $(this).data("href"); | |||
|
157 | }); | |||
|
158 | ||||
|
159 | $("#bt_add").click(function() { | |||
|
160 | document.location = "add"; | |||
|
161 | }); | |||
|
162 | ||||
|
163 | $("#id_device_type").change(function() { | |||
|
164 | document.location = "{% url 'experiment' id_exp %}device/"+$(this).val(); | |||
|
165 | }); | |||
|
166 | </script> | |||
|
167 | {% endblock %} No newline at end of file |
@@ -0,0 +1,35 | |||||
|
1 | {% extends "base.html" %} | |||
|
2 | {% load bootstrap3 %} | |||
|
3 | {% load static %} | |||
|
4 | {% load main_tags %} | |||
|
5 | {% block extra-head %} | |||
|
6 | <link href="{% static 'css/bootstrap-datetimepicker.min.css' %}" media="screen" rel="stylesheet"> | |||
|
7 | {% endblock %} | |||
|
8 | ||||
|
9 | {% block exp-active %}active{% endblock %} | |||
|
10 | ||||
|
11 | {% block content-title %}{{title}}{% endblock %} | |||
|
12 | {% block content-suptitle %}{{suptitle}}{% endblock %} | |||
|
13 | ||||
|
14 | {% block content %} | |||
|
15 | <form class="form" method="post" action=""> | |||
|
16 | {% csrf_token %} | |||
|
17 | {% bootstrap_form form layout='horizontal' size='medium' %} | |||
|
18 | <div style="clear: both;"></div> | |||
|
19 | <br> | |||
|
20 | <button type="submit" class="btn btn-primary pull-right">{{button}}</button> | |||
|
21 | </form> | |||
|
22 | {% endblock %} | |||
|
23 | ||||
|
24 | {% block sidebar%} | |||
|
25 | {% include "sidebar_devices.html" %} | |||
|
26 | {% endblock %} | |||
|
27 | ||||
|
28 | {% block extra-js%} | |||
|
29 | ||||
|
30 | <script src="{% static 'js/moment.min.js' %}"></script> | |||
|
31 | <script src="{% static 'js/bootstrap-datetimepicker.min.js' %}"></script> | |||
|
32 | <script type="text/javascript"> | |||
|
33 | $('.input-group.date').datetimepicker({"format": "YYYY-MM-DD HH:mm"}); | |||
|
34 | </script> | |||
|
35 | {% endblock %} No newline at end of file |
@@ -0,0 +1,54 | |||||
|
1 | {% extends "base.html" %} | |||
|
2 | {% load bootstrap3 %} | |||
|
3 | {% load static %} | |||
|
4 | {% load main_tags %} | |||
|
5 | {% block extra-head %} | |||
|
6 | <link href="{% static 'css/bootstrap-datetimepicker.min.css' %}" media="screen" rel="stylesheet"> | |||
|
7 | {% endblock %} | |||
|
8 | ||||
|
9 | {% block exp-active %}active{% endblock %} | |||
|
10 | ||||
|
11 | {% block content-title %}{{title}}{% endblock %} | |||
|
12 | {% block content-suptitle %}{{suptitle}}{% endblock %} | |||
|
13 | ||||
|
14 | {% block content %} | |||
|
15 | <table class="table table-hover"> | |||
|
16 | <tr> | |||
|
17 | <th>#</th> | |||
|
18 | {% for key in experiment_keys %} | |||
|
19 | <th>{{ key|title }}</th> | |||
|
20 | {% endfor%} | |||
|
21 | </tr> | |||
|
22 | {% for experiment in experiments %} | |||
|
23 | <tr class="clickable-row" data-href="{% url 'url_experiment' experiment.id %}"> | |||
|
24 | <td>{{ forloop.counter }}</td> | |||
|
25 | {% for key in experiment_keys %} | |||
|
26 | <td>{{ experiment|attr:key }}</td> | |||
|
27 | {% endfor %} | |||
|
28 | </tr> | |||
|
29 | {% endfor %} | |||
|
30 | </table> | |||
|
31 | <button class="btn btn-primary pull-right" id="bt_add">{{button}}</button> | |||
|
32 | {% endblock %} | |||
|
33 | ||||
|
34 | {% block sidebar%} | |||
|
35 | {% include "sidebar_devices.html" %} | |||
|
36 | {% endblock %} | |||
|
37 | ||||
|
38 | {% block extra-js%} | |||
|
39 | ||||
|
40 | <script src="{% static 'js/moment.min.js' %}"></script> | |||
|
41 | <script src="{% static 'js/bootstrap-datetimepicker.min.js' %}"></script> | |||
|
42 | <script type="text/javascript"> | |||
|
43 | $('.input-group.date').datetimepicker({"format": "YYYY-MM-DD HH:mm"}); | |||
|
44 | ||||
|
45 | $(".clickable-row").click(function() { | |||
|
46 | document.location = $(this).data("href"); | |||
|
47 | }); | |||
|
48 | ||||
|
49 | $("#bt_add").click(function() { | |||
|
50 | document.location = "{% url 'url_add_experiment' 0 %}"; | |||
|
51 | }); | |||
|
52 | ||||
|
53 | </script> | |||
|
54 | {% endblock %} No newline at end of file |
@@ -0,0 +1,25 | |||||
|
1 | from django.conf.urls import url | |||
|
2 | ||||
|
3 | urlpatterns = ( | |||
|
4 | ||||
|
5 | url(r'^device/add/$', 'apps.main.views.add_device', name='url_add_device'), | |||
|
6 | url(r'^device/$', 'apps.main.views.devices', name='url_devices'), | |||
|
7 | url(r'^device/(?P<id_dev>-?\d+)/$', 'apps.main.views.device', name='url_device'), | |||
|
8 | url(r'^device/(?P<id_dev>-?\d+)/edit/$', 'apps.main.views.edit_device', name='url_edit_device'), | |||
|
9 | ||||
|
10 | url(r'^campaign/add/$', 'apps.main.views.add_campaign', name='url_add_campaign'), | |||
|
11 | url(r'^campaign/$', 'apps.main.views.campaigns', name='url_campaigns'), | |||
|
12 | url(r'^campaign/(?P<id_camp>-?\d+)/$', 'apps.main.views.campaign', name='url_campaign'), | |||
|
13 | url(r'^campaign/(?P<id_camp>-?\d+)/edit/$', 'apps.main.views.edit_campaign', name='url_edit_campaign'), | |||
|
14 | ||||
|
15 | url(r'^campaign/(?P<id_camp>-?\d+)/add_experiment/$', 'apps.main.views.add_experiment', name='url_add_experiment'), | |||
|
16 | url(r'^experiment/$', 'apps.main.views.experiments', name='url_experiments'), | |||
|
17 | url(r'^experiment/(?P<id_exp>-?\d+)/$', 'apps.main.views.experiment', name='url_experiment'), | |||
|
18 | url(r'^experiment/(?P<id_exp>-?\d+)/edit/$', 'apps.main.views.edit_experiment', name='url_edit_experiment'), | |||
|
19 | ||||
|
20 | url(r'^experiment/(?P<id_exp>-?\d+)/add_dev_conf/$', 'apps.main.views.add_dev_conf', name='url_add_dev_conf'), | |||
|
21 | url(r'^dev_conf/$', 'apps.main.views.dev_confs', name='url_dev_confs'), | |||
|
22 | url(r'^dev_conf/(?P<id_conf>-?\d+)/$', 'apps.main.views.dev_conf', name='url_dev_conf'), | |||
|
23 | url(r'^dev_conf/(?P<id_conf>-?\d+)/edit/$', 'apps.main.views.edit_dev_conf', name='url_edit_dev_conf'), | |||
|
24 | ||||
|
25 | ) |
@@ -0,0 +1,8 | |||||
|
1 | from django import forms | |||
|
2 | from .models import RCConfiguration | |||
|
3 | ||||
|
4 | class RCConfigurationForm(forms.ModelForm): | |||
|
5 | ||||
|
6 | class Meta: | |||
|
7 | model = RCConfiguration | |||
|
8 | fields = ('experiment',) |
@@ -0,0 +1,8 | |||||
|
1 | from django import forms | |||
|
2 | from .models import USRPConfiguration | |||
|
3 | ||||
|
4 | class USRPConfigurationForm(forms.ModelForm): | |||
|
5 | ||||
|
6 | class Meta: | |||
|
7 | model = USRPConfiguration | |||
|
8 | fields = ('device',) |
@@ -1,5 +1,6 | |||||
1 | from django.conf.urls import url |
|
1 | from django.conf.urls import url | |
2 |
|
2 | |||
3 | urlpatterns = ( |
|
3 | urlpatterns = ( | |
4 |
|
4 | url(r'^(?P<id_conf>-?\d+)/$', 'apps.main.views.dev_conf', name='url_abs_conf'), | ||
|
5 | url(r'^(?P<id_conf>-?\d+)/edit/$', 'apps.main.views.edit_dev_conf', name='url_edit_abs_conf'), | |||
5 | ) |
|
6 | ) |
@@ -1,4 +1,5 | |||||
1 | from django import forms |
|
1 | from django import forms | |
|
2 | from apps.main.models import Device | |||
2 | from .models import CGSConfiguration |
|
3 | from .models import CGSConfiguration | |
3 |
|
4 | |||
4 | class CGSConfigurationForm(forms.ModelForm): |
|
5 | class CGSConfigurationForm(forms.ModelForm): | |
@@ -7,16 +8,27 class CGSConfigurationForm(forms.ModelForm): | |||||
7 | #request = kwargs.pop('request') |
|
8 | #request = kwargs.pop('request') | |
8 | super(CGSConfigurationForm, self).__init__(*args, **kwargs) |
|
9 | super(CGSConfigurationForm, self).__init__(*args, **kwargs) | |
9 |
|
10 | |||
|
11 | instance = getattr(self, 'instance', None) | |||
|
12 | ||||
|
13 | if instance and instance.pk: | |||
|
14 | ||||
|
15 | devices = Device.objects.filter(device_type__name='cgs') | |||
|
16 | items = devices.values('id', 'name', 'device_type__name', 'ip_address') | |||
|
17 | ||||
|
18 | self.fields['experiment'].widget.attrs['readonly'] = True | |||
|
19 | self.fields['device'].widget.choices = [(item['id'], '[%s]: %s | %s' % (item['device_type__name'], item['name'], item['ip_address'])) for item in items] | |||
|
20 | ||||
10 | def clean(self): |
|
21 | def clean(self): | |
11 | # Custom validation to force an integer when type of unit = "Unit" |
|
22 | return | |
12 | form_data = self.cleaned_data |
|
23 | # # Custom validation to force an integer when type of unit = "Unit" | |
13 | if (form_data['freq0'] or form_data['freq1'] or form_data['freq2'] or form_data['freq3'] < 0): |
|
24 | # form_data = self.cleaned_data | |
14 | raise forms.ValidationError("Please introduce positive Number") |
|
25 | # if (form_data['freq0'] or form_data['freq1'] or form_data['freq2'] or form_data['freq3'] < 0): | |
15 |
|
26 | # raise forms.ValidationError("Please introduce positive Number") | ||
16 | return form_data |
|
27 | # | |
|
28 | # return form_data | |||
17 |
|
29 | |||
18 | class Meta: |
|
30 | class Meta: | |
19 | model = CGSConfiguration |
|
31 | model = CGSConfiguration | |
20 | #exclude = ('freqs', 'clk_in', 'mult','div',) |
|
32 | #exclude = ('freqs', 'clk_in', 'mult','div',) | |
21 | # exclude = ('freqs',) |
|
33 | # exclude = ('freqs',) | |
22 | fields = ('freq0', 'freq1', 'freq2', 'freq3') |
|
34 | fields = ('experiment', 'device', 'freq0', 'freq1', 'freq2', 'freq3') |
@@ -7,17 +7,13 from apps.main.models import Device | |||||
7 | # Create your views here. |
|
7 | # Create your views here. | |
8 |
|
8 | |||
9 | def configurate_frequencies(request, id=0): |
|
9 | def configurate_frequencies(request, id=0): | |
10 | kwargs = {} |
|
10 | ||
11 | if id: |
|
11 | if id: | |
12 |
|
||||
13 | conf = CGSConfiguration.objects.get(pk=id) |
|
|||
14 | experiment = conf.experiment |
|
|||
15 |
|
||||
16 | conf = CGSConfiguration.objects.get(pk=id) |
|
12 | conf = CGSConfiguration.objects.get(pk=id) | |
17 | devices = Device.objects.filter(configuration__experiment=conf.experiment) |
|
13 | devices = Device.objects.filter(configuration__experiment=conf.experiment) | |
18 |
devices = devices.values('configuration__id', ' |
|
14 | devices = devices.values('configuration__id', 'device_type__name') | |
19 | for device in devices: |
|
15 | for device in devices: | |
20 |
if device['device_type__ |
|
16 | if device['device_type__name']=='cgs': | |
21 | device['active'] = 'active' |
|
17 | device['active'] = 'active' | |
22 | break |
|
18 | break | |
23 |
|
19 | |||
@@ -31,10 +27,13 def configurate_frequencies(request, id=0): | |||||
31 | 'device': device, |
|
27 | 'device': device, | |
32 | 'devices':devices, |
|
28 | 'devices':devices, | |
33 | 'title': ('YAP'), |
|
29 | 'title': ('YAP'), | |
34 | 'experiment': experiment, |
|
30 | 'experiment': conf.experiment, | |
35 |
|
31 | |||
36 | } |
|
32 | } | |
37 |
|
33 | |||
|
34 | data['dev_conf'] = conf | |||
|
35 | data['dev_conf_keys'] = ['experiment', 'device'] | |||
|
36 | ||||
38 | if request.method == 'POST': |
|
37 | if request.method == 'POST': | |
39 | form = CGSConfigurationForm(request.POST) #, initial={'purchase_request':purchase_request}) |
|
38 | form = CGSConfigurationForm(request.POST) #, initial={'purchase_request':purchase_request}) | |
40 | if form.is_valid(): |
|
39 | if form.is_valid(): | |
@@ -49,10 +48,6 def configurate_frequencies(request, id=0): | |||||
49 | else: |
|
48 | else: | |
50 | form = CGSConfigurationForm() |
|
49 | form = CGSConfigurationForm() | |
51 |
|
50 | |||
52 |
|
51 | return render(request, 'cgs_conf.html', data) | ||
53 | return render_to_response('conf_cgs.html', data, context_instance=RequestContext(request)) |
|
|||
54 | #return render_to_response("index.html", kwargs, context_instance=RequestContext(request)) |
|
|||
55 | #return_to_response('index.html', {'title': 'Configura','form': form}, context_instance=RequestContext(request)) |
|
|||
56 |
|
||||
57 |
|
52 | |||
58 |
|
53 |
@@ -1,24 +1,36 | |||||
1 | from django import forms |
|
1 | from django import forms | |
|
2 | from apps.main.models import Device | |||
2 | from .models import DDSConfiguration |
|
3 | from .models import DDSConfiguration | |
3 |
|
4 | |||
4 | from django.core.validators import MinValueValidator, MaxValueValidator |
|
5 | from django.core.validators import MinValueValidator, MaxValueValidator | |
5 |
|
6 | |||
6 | class DDSConfigurationForm(forms.ModelForm): |
|
7 | class DDSConfigurationForm(forms.ModelForm): | |
7 |
|
8 | |||
8 |
freq |
|
9 | frequency = forms.FloatField(label='Frequency (MHz)', validators=[MinValueValidator(0), MaxValueValidator(150)]) | |
9 |
pha |
|
10 | phase = forms.FloatField(label='Phase (Degrees)', validators=[MinValueValidator(0), MaxValueValidator(360)]) | |
10 |
|
11 | |||
11 |
freq |
|
12 | frequency_mod = forms.FloatField(label='Frequency (MHz)', validators=[MinValueValidator(0), MaxValueValidator(150)], required=False) | |
12 |
pha |
|
13 | phase_mod = forms.FloatField(label='Phase (Degrees)', validators=[MinValueValidator(0), MaxValueValidator(360)], required=False) | |
13 |
|
14 | |||
14 | def __init__(self, *args, **kwargs): |
|
15 | def __init__(self, *args, **kwargs): | |
15 | #request = kwargs.pop('request') |
|
16 | #request = kwargs.pop('request') | |
16 | super(DDSConfigurationForm, self).__init__(*args, **kwargs) |
|
17 | super(DDSConfigurationForm, self).__init__(*args, **kwargs) | |
17 |
|
18 | |||
|
19 | instance = getattr(self, 'instance', None) | |||
|
20 | ||||
|
21 | if instance and instance.pk: | |||
|
22 | ||||
|
23 | devices = Device.objects.filter(device_type__name='dds') | |||
|
24 | items = devices.values('id', 'name', 'device_type__name', 'ip_address') | |||
|
25 | ||||
|
26 | self.fields['experiment'].widget.attrs['readonly'] = True | |||
|
27 | self.fields['device'].widget.choices = [(item['id'], '[%s]: %s | %s' % (item['device_type__name'], item['name'], item['ip_address'])) for item in items] | |||
|
28 | ||||
|
29 | ||||
18 | def clean(self): |
|
30 | def clean(self): | |
19 | # Custom validation to force an integer when type of unit = "Unit" |
|
31 | # Custom validation to force an integer when type of unit = "Unit" | |
20 | return |
|
32 | return | |
21 |
|
33 | |||
22 | class Meta: |
|
34 | class Meta: | |
23 | model = DDSConfiguration |
|
35 | model = DDSConfiguration | |
24 | fields = ('clock', 'multiplier', 'modulation') |
|
36 | fields = ('experiment', 'device', 'clock', 'multiplier', 'modulation') |
@@ -4,18 +4,28 from apps.main.models import Configuration | |||||
4 |
|
4 | |||
5 | from django.core.validators import MinValueValidator, MaxValueValidator |
|
5 | from django.core.validators import MinValueValidator, MaxValueValidator | |
6 |
|
6 | |||
|
7 | MOD_TYPES = ( | |||
|
8 | (None, 'Select a modulation type'), | |||
|
9 | (0, 'No modulation'), | |||
|
10 | (1, 'ASK'), | |||
|
11 | (2, 'FSK'), | |||
|
12 | (3, 'PSK'), | |||
|
13 | ) | |||
|
14 | ||||
7 | class DDSConfiguration(Configuration): |
|
15 | class DDSConfiguration(Configuration): | |
8 |
|
16 | |||
9 |
clock = models.FloatField(verbose_name='Clock Master',validators=[MinValueValidator(5 |
|
17 | clock = models.FloatField(verbose_name='Clock Master (MHz)',validators=[MinValueValidator(5), MaxValueValidator(50)], blank=True, null=True) | |
10 |
multiplier = models.PositiveIntegerField(verbose_name='Multiplier',validators=[MinValueValidator( |
|
18 | multiplier = models.PositiveIntegerField(verbose_name='Multiplier',validators=[MinValueValidator(1), MaxValueValidator(20)], default=4) | |
11 |
|
|
19 | freq_reg = models.PositiveIntegerField(verbose_name='Frequency (Binary)',validators=[MinValueValidator(0), MaxValueValidator(2**32-1)], blank=True, null=True) | |
12 |
|
|
20 | phase_reg = models.PositiveIntegerField(verbose_name='Phase (Binary)',validators=[MinValueValidator(0), MaxValueValidator(2**14-1)], blank=True, null=True) | |
13 | frequency1 = models.PositiveIntegerField(verbose_name='Frequency 1',validators=[MinValueValidator(0), MaxValueValidator(2**32-1)], blank=True, null=True) |
|
21 | ||
14 | phase0 = models.PositiveIntegerField(verbose_name='Phase 0',validators=[MinValueValidator(0), MaxValueValidator(2**14-1)], blank=True, null=True) |
|
|||
15 | phase1 = models.PositiveIntegerField(verbose_name='Phase 1',validators=[MinValueValidator(0), MaxValueValidator(2**14-1)], blank=True, null=True) |
|
|||
16 | amplitude_chA = models.PositiveIntegerField(verbose_name='Amplitude CHA',validators=[MinValueValidator(0), MaxValueValidator(2**10-1)], blank=True, null=True) |
|
22 | amplitude_chA = models.PositiveIntegerField(verbose_name='Amplitude CHA',validators=[MinValueValidator(0), MaxValueValidator(2**10-1)], blank=True, null=True) | |
17 | amplitude_chB = models.PositiveIntegerField(verbose_name='Amplitude CHB',validators=[MinValueValidator(0), MaxValueValidator(2**10-1)], blank=True, null=True) |
|
23 | amplitude_chB = models.PositiveIntegerField(verbose_name='Amplitude CHB',validators=[MinValueValidator(0), MaxValueValidator(2**10-1)], blank=True, null=True) | |
18 |
|
24 | |||
|
25 | modulation = models.PositiveIntegerField(choices = MOD_TYPES, default = 0) | |||
|
26 | freq_reg_mod = models.PositiveIntegerField(verbose_name='Frequency Mod (Binary)',validators=[MinValueValidator(0), MaxValueValidator(2**32-1)], blank=True, null=True) | |||
|
27 | phase_reg_mod = models.PositiveIntegerField(verbose_name='Phase Mod (Binary)',validators=[MinValueValidator(0), MaxValueValidator(2**14-1)], blank=True, null=True) | |||
|
28 | ||||
19 | class Meta: |
|
29 | class Meta: | |
20 | db_table = 'dds_configurations' |
|
30 | db_table = 'dds_configurations' | |
21 | No newline at end of file |
|
31 |
@@ -1,6 +1,6 | |||||
1 | from django.conf.urls import url |
|
1 | from django.conf.urls import url | |
2 |
|
2 | |||
3 | urlpatterns = ( |
|
3 | urlpatterns = ( | |
4 |
url(r'^(?P<id_conf>-?\d+)/$', 'apps.dds.views.conf |
|
4 | url(r'^(?P<id_conf>-?\d+)/$', 'apps.dds.views.dds_conf', name='url_dds_conf'), | |
5 |
url(r'^(?P<id_conf>-?\d+)/edit/$', 'apps.dds.views. |
|
5 | url(r'^(?P<id_conf>-?\d+)/edit/$', 'apps.dds.views.edit_dds_conf', name='url_edit_dds_conf'), | |
6 | ) |
|
6 | ) |
@@ -2,56 +2,48 | |||||
2 |
|
2 | |||
3 | from django.shortcuts import redirect, render |
|
3 | from django.shortcuts import redirect, render | |
4 |
|
4 | |||
5 | from apps.main.models import Device |
|
|||
6 | from .models import DDSConfiguration |
|
5 | from .models import DDSConfiguration | |
7 | from .forms import DDSConfigurationForm |
|
6 | from .forms import DDSConfigurationForm | |
8 | # Create your views here. |
|
7 | # Create your views here. | |
9 |
|
8 | |||
10 |
def conf |
|
9 | def dds_conf(request, id_conf): | |
11 |
|
10 | |||
12 | if id_conf: |
|
11 | dev_conf = DDSConfiguration.objects.get(pk=id_conf) | |
13 |
|
||||
14 | conf = DDSConfiguration.objects.get(pk=id_conf) |
|
|||
15 | form = DDSConfigurationForm(instance=conf) |
|
|||
16 | experiment = conf.experiment |
|
|||
17 |
|
||||
18 | devices = Device.objects.filter(configuration__experiment=experiment) |
|
|||
19 |
|
||||
20 | deviceList = devices.values('configuration__id', 'device_type__alias', 'device_type__name') |
|
|||
21 |
|
||||
22 | for thisDevice in deviceList: |
|
|||
23 | if thisDevice['configuration__id'] == conf.id: |
|
|||
24 | thisDevice['active'] = 'active' |
|
|||
25 | break |
|
|||
26 |
|
||||
27 | device = thisDevice |
|
|||
28 |
|
||||
29 | else: |
|
|||
30 | form = DDSConfigurationForm() |
|
|||
31 | device = '' |
|
|||
32 | experiment = '' |
|
|||
33 | devices = {} |
|
|||
34 |
|
||||
35 | kwargs = { |
|
|||
36 | 'form': form, |
|
|||
37 | 'device': device, |
|
|||
38 | 'experiment': experiment, |
|
|||
39 | 'devices': deviceList |
|
|||
40 | } |
|
|||
41 |
|
||||
42 | # return render_to_response('conf_dds.html', kwargs, context_instance=RequestContext(request)) |
|
|||
43 | return render(request, 'conf_dds.html', kwargs) |
|
|||
44 |
|
12 | |||
45 | def config_dds_edit(request, id_conf): |
|
13 | kwargs = {} | |
|
14 | kwargs['dev_conf'] = dev_conf | |||
|
15 | kwargs['dev_conf_keys'] = ['experiment', 'device', | |||
|
16 | 'clock', 'multiplier', | |||
|
17 | 'freq_reg', 'phase_reg', | |||
|
18 | 'amplitude_chA', 'amplitude_chB', | |||
|
19 | 'modulation', | |||
|
20 | 'freq_reg_mod', 'phase_reg_mod'] | |||
46 |
|
21 | |||
47 | if request.method=='POST': |
|
22 | kwargs['title'] = 'DDS Configuration' | |
|
23 | kwargs['suptitle'] = 'Details' | |||
|
24 | ||||
|
25 | kwargs['button'] = 'Edit Configuration' | |||
|
26 | ||||
|
27 | return render(request, 'dds_conf.html', kwargs) | |||
|
28 | ||||
|
29 | def edit_dds_conf(request, id_conf): | |||
|
30 | ||||
|
31 | dev_conf = DDSConfiguration.objects.get(pk=id_conf) | |||
|
32 | ||||
|
33 | if request.method=='GET': | |||
|
34 | form = DDSConfigurationForm(instance=dev_conf) | |||
48 |
|
35 | |||
49 | conf = DDSConfiguration.objects.get(pk=id_conf) |
|
36 | if request.method=='POST': | |
50 | form = DDSConfigurationForm(instance=conf) |
|
37 | form = DDSConfigurationForm(request.POST, instance=dev_conf) | |
51 |
|
38 | |||
52 | if form.is_valid(): |
|
39 | if form.is_valid(): | |
53 | form.save() |
|
40 | form.save() | |
54 | else: |
|
41 | return redirect('url_dds_conf', id_conf=id_conf) | |
55 | raise ValueError, "Error" |
|
42 | ||
56 |
|
43 | kwargs = {} | ||
57 | return redirect('url_conf_dds', id_conf=id_conf) No newline at end of file |
|
44 | kwargs['form'] = form | |
|
45 | kwargs['title'] = 'Device Configuration' | |||
|
46 | kwargs['suptitle'] = 'Edit' | |||
|
47 | kwargs['button'] = 'Update' | |||
|
48 | ||||
|
49 | return render(request, 'dds_conf_edit.html', kwargs) No newline at end of file |
@@ -8,7 +8,7 class JARSConfigurationForm(forms.ModelForm): | |||||
8 | instance = getattr(self, 'instance', None) |
|
8 | instance = getattr(self, 'instance', None) | |
9 | if instance and instance.pk: |
|
9 | if instance and instance.pk: | |
10 | self.fields['experiment'].widget.attrs['disabled'] = True |
|
10 | self.fields['experiment'].widget.attrs['disabled'] = True | |
11 |
self.fields['device'].widget.choices = [(item['id'], '%s |
|
11 | self.fields['device'].widget.choices = [(item['id'], '%s | %s' % (item['device_type__name'], item['ip_address'])) for item in Device.objects.filter(device_type__name='jars').values('id', 'device_type__name', 'ip_address')] | |
12 |
|
12 | |||
13 | class Meta: |
|
13 | class Meta: | |
14 | model = JARSConfiguration |
|
14 | model = JARSConfiguration |
@@ -11,9 +11,9 def jars_config(request, id): | |||||
11 | if id: |
|
11 | if id: | |
12 | conf = JARSConfiguration.objects.get(pk=id) |
|
12 | conf = JARSConfiguration.objects.get(pk=id) | |
13 | devices = Device.objects.filter(configuration__experiment=conf.experiment) |
|
13 | devices = Device.objects.filter(configuration__experiment=conf.experiment) | |
14 |
devices = devices.values('configuration__id', ' |
|
14 | devices = devices.values('configuration__id', 'device_type__name') | |
15 | for device in devices: |
|
15 | for device in devices: | |
16 |
if device['device_type__ |
|
16 | if device['device_type__name']=='jars': | |
17 | device['active'] = 'active' |
|
17 | device['active'] = 'active' | |
18 | form = JARSConfigurationForm(instance=conf) |
|
18 | form = JARSConfigurationForm(instance=conf) | |
19 | else: |
|
19 | else: |
@@ -1,8 +1,8 | |||||
1 | from django.contrib import admin |
|
1 | from django.contrib import admin | |
2 | from .models import Device, DeviceType, Experiment |
|
2 | from .models import Device, DeviceType, Experiment, Campaign | |
3 |
|
3 | |||
4 | # Register your models here. |
|
4 | # Register your models here. | |
5 |
|
5 | admin.site.register(Campaign) | ||
6 | admin.site.register(Experiment) |
|
6 | admin.site.register(Experiment) | |
7 | admin.site.register(Device) |
|
7 | admin.site.register(Device) | |
8 | admin.site.register(DeviceType) No newline at end of file |
|
8 | admin.site.register(DeviceType) |
@@ -1,7 +1,7 | |||||
1 | from django import forms |
|
1 | from django import forms | |
2 | from django.utils.safestring import mark_safe |
|
2 | from django.utils.safestring import mark_safe | |
3 |
|
3 | |||
4 | from .models import DeviceType, Device, Experiment |
|
4 | from .models import DeviceType, Device, Experiment, Campaign, Configuration | |
5 |
|
5 | |||
6 | def add_empty_choice(choices, pos=0, label='-----'): |
|
6 | def add_empty_choice(choices, pos=0, label='-----'): | |
7 | if len(choices)>0: |
|
7 | if len(choices)>0: | |
@@ -17,21 +17,44 class DatepickerWidget(forms.widgets.TextInput): | |||||
17 | html = '<div class="input-group date">'+input_html+'<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span></div>' |
|
17 | html = '<div class="input-group date">'+input_html+'<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span></div>' | |
18 | return mark_safe(html) |
|
18 | return mark_safe(html) | |
19 |
|
19 | |||
20 | class NewExperimentForm(forms.ModelForm): |
|
20 | class TimepickerWidget(forms.widgets.TextInput): | |
|
21 | def render(self, name, value, attrs=None): | |||
|
22 | input_html = super(TimepickerWidget, self).render(name, value, attrs) | |||
|
23 | html = '<div class="input-group time">'+input_html+'<span class="input-group-addon"><i class="glyphicon glyphicon-time"></i></span></div>' | |||
|
24 | return mark_safe(html) | |||
|
25 | ||||
|
26 | class CampaignForm(forms.ModelForm): | |||
21 | def __init__(self, *args, **kwargs): |
|
27 | def __init__(self, *args, **kwargs): | |
22 |
super( |
|
28 | super(CampaignForm, self).__init__(*args, **kwargs) | |
23 | self.fields['start_date'].widget = DatepickerWidget(self.fields['start_date'].widget.attrs) |
|
29 | self.fields['start_date'].widget = DatepickerWidget(self.fields['start_date'].widget.attrs) | |
24 | self.fields['end_date'].widget = DatepickerWidget(self.fields['end_date'].widget.attrs) |
|
30 | self.fields['end_date'].widget = DatepickerWidget(self.fields['end_date'].widget.attrs) | |
25 |
|
31 | |||
26 | class Meta: |
|
32 | class Meta: | |
|
33 | model = Campaign | |||
|
34 | fields = ['name', 'start_date', 'end_date', 'tags', 'description', 'template'] | |||
|
35 | ||||
|
36 | class ExperimentForm(forms.ModelForm): | |||
|
37 | def __init__(self, *args, **kwargs): | |||
|
38 | super(ExperimentForm, self).__init__(*args, **kwargs) | |||
|
39 | self.fields['start_time'].widget = TimepickerWidget(self.fields['start_time'].widget.attrs) | |||
|
40 | self.fields['end_time'].widget = TimepickerWidget(self.fields['end_time'].widget.attrs) | |||
|
41 | ||||
|
42 | self.fields['campaign'].widget.attrs['readonly'] = True | |||
|
43 | ||||
|
44 | class Meta: | |||
27 | model = Experiment |
|
45 | model = Experiment | |
28 |
fields = ['name', ' |
|
46 | fields = ['campaign', 'name', 'start_time', 'end_time'] | |
29 |
|
47 | |||
30 |
class |
|
48 | class DeviceForm(forms.ModelForm): | |
31 | class Meta: |
|
49 | class Meta: | |
32 | model = Device |
|
50 | model = Device | |
33 | exclude = ['status'] |
|
51 | exclude = ['status'] | |
34 |
|
52 | |||
|
53 | class ConfigurationForm(forms.ModelForm): | |||
|
54 | class Meta: | |||
|
55 | model = Configuration | |||
|
56 | fields = ['experiment', 'device'] | |||
|
57 | ||||
35 | class DeviceTypeForm(forms.Form): |
|
58 | class DeviceTypeForm(forms.Form): | |
36 | device_type = forms.ChoiceField(choices=add_empty_choice(DeviceType.objects.all().order_by('name').values_list('id', 'name'))) |
|
59 | device_type = forms.ChoiceField(choices=add_empty_choice(DeviceType.objects.all().order_by('name').values_list('id', 'name'))) | |
37 |
|
60 |
@@ -7,63 +7,89 STATES = ( | |||||
7 | (1, 'Active'), |
|
7 | (1, 'Active'), | |
8 | ) |
|
8 | ) | |
9 |
|
9 | |||
10 | # Create your models here. |
|
10 | DEV_TYPES = ( | |
|
11 | ('', 'Select a device type'), | |||
|
12 | ('rc', 'Radar Controller'), | |||
|
13 | ('dds', 'Direct Digital Synthesizer'), | |||
|
14 | ('jars', 'Jicamarca Radar System'), | |||
|
15 | ('usrp', 'Universal Software Radio Peripheral'), | |||
|
16 | ('cgs', 'Clock Generator System'), | |||
|
17 | ('abs', 'Automatic Beam Switching'), | |||
|
18 | ) | |||
11 |
|
19 | |||
|
20 | # Create your models here. | |||
|
21 | ||||
12 | class DeviceType(models.Model): |
|
22 | class DeviceType(models.Model): | |
13 |
|
23 | |||
14 |
name = models.CharField(max_length= |
|
24 | name = models.CharField(max_length = 10, choices = DEV_TYPES, default = 'rc') | |
15 | alias = models.CharField(max_length=40) |
|
25 | ||
16 |
in |
|
26 | description = models.TextField(blank=True, null=True) | |
17 | status = models.PositiveSmallIntegerField(default=1, choices=STATES) |
|
27 | ||
|
28 | # info = models.TextField(blank=True, null=True) | |||
|
29 | # status = models.PositiveSmallIntegerField(default=1, choices=STATES) | |||
18 |
|
30 | |||
19 | class Meta: |
|
31 | class Meta: | |
20 | db_table = 'device_types' |
|
32 | db_table = 'db_device_types' | |
21 |
|
33 | |||
22 | def __unicode__(self): |
|
34 | def __unicode__(self): | |
23 |
return u'%s' % self. |
|
35 | return u'%s' % self.name | |
24 |
|
36 | |||
25 | class Device(models.Model): |
|
37 | class Device(models.Model): | |
26 |
|
38 | |||
27 | device_type = models.ForeignKey(DeviceType) |
|
39 | device_type = models.ForeignKey(DeviceType) | |
28 | name = models.CharField(max_length=40, default='') |
|
40 | name = models.CharField(max_length=40, default='') | |
29 | model = models.CharField(max_length=40, default='') |
|
|||
30 | serial_number = models.CharField(max_length=40, default='') |
|
|||
31 | ip_address = models.GenericIPAddressField(protocol='IPv4', default='0.0.0.0') |
|
41 | ip_address = models.GenericIPAddressField(protocol='IPv4', default='0.0.0.0') | |
32 | mac_address = models.CharField(max_length = 20, null=True, blank=True) |
|
42 | port_address = models.PositiveSmallIntegerField(default=2000) | |
33 | description = models.TextField(blank=True, null=True) |
|
43 | description = models.TextField(blank=True, null=True) | |
34 | status = models.PositiveSmallIntegerField(default=1, choices=STATES) |
|
44 | ||
|
45 | # serial_number = models.CharField(max_length=40, default='') | |||
|
46 | # mac_address = models.CharField(max_length = 20, null=True, blank=True) | |||
|
47 | # status = models.PositiveSmallIntegerField(default=1, choices=STATES) | |||
35 |
|
48 | |||
36 | class Meta: |
|
49 | class Meta: | |
37 | db_table = 'devices' |
|
50 | db_table = 'db_devices' | |
38 |
|
51 | |||
39 | def __unicode__(self): |
|
52 | def __unicode__(self): | |
40 |
return u'%s |
|
53 | return u'[%s]: %s | %s' % (self.device_type.name, self.name, self.ip_address) | |
|
54 | ||||
|
55 | class Campaign(models.Model): | |||
|
56 | ||||
|
57 | name = models.CharField(max_length=40, unique=True) | |||
|
58 | start_date = models.DateTimeField(blank=True, null=True) | |||
|
59 | end_date = models.DateTimeField(blank=True, null=True) | |||
|
60 | tags = models.CharField(max_length=40) | |||
|
61 | description = models.TextField(blank=True, null=True) | |||
|
62 | template = models.BooleanField(default=False) | |||
|
63 | ||||
|
64 | class Meta: | |||
|
65 | db_table = 'db_campaigns' | |||
|
66 | ||||
|
67 | def __unicode__(self): | |||
|
68 | return u'%s: %s - %s' % (self.name, self.start_date.date(), self.end_date.date()) | |||
41 |
|
69 | |||
42 | class Experiment(models.Model): |
|
70 | class Experiment(models.Model): | |
43 |
|
71 | |||
44 | name = models.CharField(max_length=40) |
|
72 | campaign = models.ForeignKey(Campaign) | |
45 |
|
|
73 | name = models.CharField(max_length=40, default='') | |
46 |
start_ |
|
74 | start_time = models.TimeField(default='00:00:00') | |
47 |
end_ |
|
75 | end_time = models.TimeField(default='23:59:59') | |
48 | template = models.BooleanField(default=False) |
|
|||
49 | status = models.PositiveSmallIntegerField(default=1, choices=STATES) |
|
|||
50 |
|
76 | |||
51 | class Meta: |
|
77 | class Meta: | |
52 | db_table = 'experiments' |
|
78 | db_table = 'db_experiments' | |
53 |
|
79 | |||
54 | def __unicode__(self): |
|
80 | def __unicode__(self): | |
55 |
return u'%s: %s - %s' % (self. |
|
81 | return u'[%s]: %s: %s - %s' % (self.campaign.name, self.name, self.start_time, self.end_time) | |
56 |
|
82 | |||
57 | class Configuration(PolymorphicModel): |
|
83 | class Configuration(PolymorphicModel): | |
58 |
|
84 | |||
59 | experiment = models.ForeignKey(Experiment) |
|
85 | experiment = models.ForeignKey(Experiment) | |
60 | device = models.ForeignKey(Device) |
|
86 | device = models.ForeignKey(Device) | |
61 | parameters = models.TextField(default='{}') |
|
87 | # parameters = models.TextField(default='{}') | |
62 | status = models.PositiveSmallIntegerField(default=1, choices=STATES) |
|
88 | # status = models.PositiveSmallIntegerField(default=1, choices=STATES) | |
63 |
|
89 | |||
64 | class Meta: |
|
90 | class Meta: | |
65 | db_table = 'configurations' |
|
91 | db_table = 'db_configurations' | |
66 |
|
92 | |||
67 | def __unicode__(self): |
|
93 | def __unicode__(self): | |
68 |
return u'%s |
|
94 | return u'%s [%s]' % (self.experiment.name, self.device.name) | |
69 | No newline at end of file |
|
95 |
@@ -36,10 +36,14 | |||||
36 | <a class="navbar-brand" href="{% url 'index' %}" style="padding-top:1px"><img class="logo" alt="JRO" src="{% static "images/logo-jro-white-trans.png" %}"></a> |
|
36 | <a class="navbar-brand" href="{% url 'index' %}" style="padding-top:1px"><img class="logo" alt="JRO" src="{% static "images/logo-jro-white-trans.png" %}"></a> | |
37 | </div> |
|
37 | </div> | |
38 | <div class="collapse navbar-collapse" id="navigationbar"> |
|
38 | <div class="collapse navbar-collapse" id="navigationbar"> | |
39 |
<ul class="nav navbar-nav"> |
|
39 | <ul class="nav navbar-nav"> | |
40 |
<li class=" dropdown {% block |
|
40 | <li class=" dropdown {% block camp-active %}{% endblock %}"><a href="{% url 'url_campaigns'%}">Campaigns</a> | |
41 | </li> |
|
41 | </li> | |
42 |
<li class=" dropdown {% block |
|
42 | <li class=" dropdown {% block exp-active %}{% endblock %}"><a href="{% url 'url_experiments'%}">Experiments</a> | |
|
43 | </li> | |||
|
44 | <li class=" dropdown {% block dev-active %}{% endblock %}"><a href="{% url 'url_devices'%}">Devices</a> | |||
|
45 | </li> | |||
|
46 | <li class=" dropdown {% block conf-active %}{% endblock %}"><a href="{% url 'url_dev_confs'%}">Device Configurations</a> | |||
43 | </li> |
|
47 | </li> | |
44 | </ul> |
|
48 | </ul> | |
45 | <ul class="nav navbar-nav navbar-right"> |
|
49 | <ul class="nav navbar-nav navbar-right"> | |
@@ -105,6 +109,7 | |||||
105 | {# bootstrap_javascript jquery=True #} |
|
109 | {# bootstrap_javascript jquery=True #} | |
106 | <script src="{% static 'js/jquery.min.js' %}"></script> |
|
110 | <script src="{% static 'js/jquery.min.js' %}"></script> | |
107 | <script src="{% static 'js/bootstrap.min.js' %}"></script> |
|
111 | <script src="{% static 'js/bootstrap.min.js' %}"></script> | |
|
112 | ||||
108 | {% block extra-js %} |
|
113 | {% block extra-js %} | |
109 | {% endblock%} |
|
114 | {% endblock%} | |
110 | </body> |
|
115 | </body> |
@@ -1,20 +1,26 | |||||
1 | {% extends "base.html" %} |
|
1 | {% extends "base.html" %} | |
2 | {% load bootstrap3 %} |
|
2 | {% load bootstrap3 %} | |
3 | {% block mainactive %}active{% endblock %} |
|
3 | {% load static %} | |
|
4 | {% load main_tags %} | |||
4 |
|
5 | |||
5 |
{% block con |
|
6 | {% block conf-active %}active{% endblock %} | |
6 | {% block content-suptitle %}{{device.device_type__name}}{% endblock %} |
|
7 | ||
|
8 | {% block content-title %}{{title}}{% endblock %} | |||
|
9 | {% block content-suptitle %}{{suptitle}}{% endblock %} | |||
7 |
|
10 | |||
8 | {% block content %} |
|
11 | {% block content %} | |
9 | <form class="form" method="post" action=""> |
|
12 | <form class="form" method="post" action=""> | |
10 | {% csrf_token %} |
|
13 | {% csrf_token %} | |
11 | {% bootstrap_form form layout='horizontal' size='medium' %} |
|
14 | {% bootstrap_form form layout='horizontal' size='medium' %} | |
12 | <div style="clear: both;"></div> |
|
15 | <div style="clear: both;"></div> | |
13 | <br> |
|
16 | <br> | |
14 |
<button type="submit" class="btn btn-primary pull-right" |
|
17 | <button type="submit" class="btn btn-primary pull-right">{{button}}</button> | |
15 | </form> |
|
18 | </form> | |
16 | {% endblock %} |
|
19 | {% endblock %} | |
17 |
|
20 | |||
18 | {% block sidebar%} |
|
21 | {% block sidebar%} | |
19 | {% include "sidebar_devices.html" %} |
|
22 | {% include "sidebar_devices.html" %} | |
|
23 | {% endblock %} | |||
|
24 | ||||
|
25 | {% block extra-js%} | |||
20 | {% endblock %} No newline at end of file |
|
26 | {% endblock %} |
@@ -5,49 +5,32 | |||||
5 |
|
5 | |||
6 | {% block dev-active %}active{% endblock %} |
|
6 | {% block dev-active %}active{% endblock %} | |
7 |
|
7 | |||
8 |
{% block content-title %} |
|
8 | {% block content-title %}{{title}}{% endblock %} | |
9 | {% block content-suptitle %}{{suptitle}}{% endblock %} |
|
9 | {% block content-suptitle %}{{suptitle}}{% endblock %} | |
10 |
|
10 | |||
11 | {% block content %} |
|
11 | {% block content %} | |
12 |
|
12 | <table class="table table-bordered"> | ||
13 | {% if form %} |
|
13 | {% for key in device_keys %} | |
14 | <form class="form" method="post" action="{{action}}"> |
|
14 | <tr><th>{{key|title}}</th><td>{{device|attr:key}}</td></tr> | |
15 | {% csrf_token %} |
|
15 | {% endfor %} | |
16 | {% bootstrap_form form layout='horizontal' size='medium' %} |
|
|||
17 | <div style="clear: both;"></div> |
|
|||
18 | <br> |
|
|||
19 | <button type="submit" class="btn btn-primary pull-right">{{button}}</button> |
|
|||
20 | </form> |
|
|||
21 | {% else %} |
|
|||
22 | <table class="table table-hover"> |
|
|||
23 | <tr> |
|
|||
24 | <th>#</th> |
|
|||
25 | {% for header in keys %} |
|
|||
26 | <th>{{ header|title }}</th> |
|
|||
27 | {% endfor%} |
|
|||
28 | </tr> |
|
|||
29 | {% for item in items %} |
|
|||
30 | <tr class="clickable-row" data-href="{%if base_url %}{{ base_url }}/{% endif %}{{ item.id }}"> |
|
|||
31 | <td>{{ forloop.counter }}</td> |
|
|||
32 | {% for key in keys %} |
|
|||
33 | <td>{{ item|attr:key }}</td> |
|
|||
34 | {% endfor %} |
|
|||
35 | </tr> |
|
|||
36 | {% endfor %} |
|
|||
37 | </table> |
|
16 | </table> | |
38 |
<button class="btn btn-primary pull-right" id="bt_ |
|
17 | <button class="btn btn-primary pull-right" id="bt_edit_device">Edit Device</button> | |
39 | {% endif %} |
|
18 | <br></br> | |
|
19 | <br></br> | |||
|
20 | {% endblock %} | |||
40 |
|
21 | |||
|
22 | {% block sidebar%} | |||
|
23 | {% include "sidebar_devices.html" %} | |||
41 | {% endblock %} |
|
24 | {% endblock %} | |
42 |
|
25 | |||
43 | {% block extra-js%} |
|
26 | {% block extra-js%} | |
44 | <script type="text/javascript"> |
|
27 | <script src="{% static 'js/moment.min.js' %}"></script> | |
45 | $(".clickable-row").click(function() { |
|
28 | <script src="{% static 'js/bootstrap-datetimepicker.min.js' %}"></script> | |
46 | document.location = $(this).data("href"); |
|
29 | <script type="text/javascript"> | |
47 | }); |
|
|||
48 |
|
30 | |||
49 |
$("#bt_ |
|
31 | $("#bt_edit_device").click(function() { | |
50 |
document.location = " |
|
32 | document.location = "{% url 'url_edit_device' device.id%}"; | |
51 | }); |
|
33 | }); | |
|
34 | ||||
52 | </script> |
|
35 | </script> | |
53 | {% endblock %} No newline at end of file |
|
36 | {% endblock %} |
@@ -8,134 +8,52 | |||||
8 |
|
8 | |||
9 | {% block exp-active %}active{% endblock %} |
|
9 | {% block exp-active %}active{% endblock %} | |
10 |
|
10 | |||
11 |
{% block content-title %} |
|
11 | {% block content-title %}{{title}}{% endblock %} | |
12 | {% block content-suptitle %}{{suptitle}}{% endblock %} |
|
12 | {% block content-suptitle %}{{suptitle}}{% endblock %} | |
13 |
|
13 | |||
14 | {% block content %} |
|
14 | {% block content %} | |
15 | {% if form_new %} |
|
|||
16 | <form class="form" method="post" action=""> |
|
|||
17 | {% csrf_token %} |
|
|||
18 | {% bootstrap_form form_new layout='horizontal' size='medium' %} |
|
|||
19 | <div style="clear: both;"></div> |
|
|||
20 | <br> |
|
|||
21 | <button type="submit" class="btn btn-primary pull-right">Create</button> |
|
|||
22 | </form> |
|
|||
23 | {% elif experiment %} |
|
|||
24 | <table class="table table-bordered"> |
|
15 | <table class="table table-bordered"> | |
25 | {% for key in experiment_keys %} |
|
16 | {% for key in experiment_keys %} | |
26 | <tr><th>{{key|title}}</th><td>{{experiment|attr:key}}</td></tr> |
|
17 | <tr><th>{{key|title}}</th><td>{{experiment|attr:key}}</td></tr> | |
27 | {% endfor %} |
|
18 | {% endfor %} | |
28 | </table> |
|
19 | </table> | |
29 | <hr> |
|
20 | <button class="btn btn-primary pull-right" id="bt_edit_experiment">Edit Experiment</button> | |
|
21 | <br></br> | |||
|
22 | <br></br> | |||
30 |
|
23 | |||
31 | <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> |
|
24 | <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"> | |
32 | <div class="panel panel-default"> |
|
25 | ||
33 | <div class="panel-heading" role="tab" id="headingOne"> |
|
|||
34 | <h4 class="panel-title"> |
|
|||
35 | <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne"> |
|
|||
36 | Edit Experiment Details |
|
|||
37 | </a> |
|
|||
38 | </h4> |
|
|||
39 | </div> |
|
|||
40 | <div id="collapseOne" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne"> |
|
|||
41 | <div class="panel-body"> |
|
|||
42 | <form class="form" method="post" action="{% url 'edit_experiment' id_exp %}"> |
|
|||
43 | {% csrf_token %} |
|
|||
44 | {% bootstrap_form form layout='horizontal' size='medium' %} |
|
|||
45 | <div style="clear: both;"></div> |
|
|||
46 | <br> |
|
|||
47 | <button type="submit" class="btn btn-primary pull-right" id="bt_update">Update</button> |
|
|||
48 | </form> |
|
|||
49 | </div> |
|
|||
50 | </div> |
|
|||
51 | </div> |
|
|||
52 | <div class="panel panel-default"> |
|
26 | <div class="panel panel-default"> | |
53 | <div class="panel-heading" role="tab" id="headingTwo"> |
|
27 | <div class="panel-heading" role="tab" id="headingTwo"> | |
54 | <h4 class="panel-title"> |
|
28 | <h4 class="panel-title"> | |
55 |
<a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseT |
|
29 | <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseThree"> | |
56 | Add Device to Experiment |
|
|||
57 | </a> |
|
|||
58 | </h4> |
|
|||
59 | </div> |
|
|||
60 | <div id="collapseTwo" class="panel-collapse collapse {%if id_dev_type%}in{%endif%}" role="tabpanel" aria-labelledby="headingTwo"> |
|
|||
61 | <div class="panel-body"> |
|
|||
62 | <form class="form" method="post" action="{% url 'experiment_add_device' id_exp %}"> |
|
|||
63 | {% csrf_token %} |
|
|||
64 | {% bootstrap_form subform layout='horizontal' size='medium' %} |
|
|||
65 | <div style="clear: both;"></div> |
|
|||
66 | <br> |
|
|||
67 | <table class="table"> |
|
|||
68 | <tr> |
|
|||
69 | <th>#</th> |
|
|||
70 | {% for header in keys %} |
|
|||
71 | <th>{{ header|title }}</th> |
|
|||
72 | {% endfor%} |
|
|||
73 | </tr> |
|
|||
74 | {% for item in items %} |
|
|||
75 | <tr class="clickable-row" data-href="{%if base_url %}{{ base_url }}/{% endif %}{{ item.id }}"> |
|
|||
76 | <td>{{ forloop.counter }}</td> |
|
|||
77 | {% for key in keys %} |
|
|||
78 | <td>{{ item|attr:key }}</td> |
|
|||
79 | {% endfor %} |
|
|||
80 | <td><input type="hidden" id="id_device" name="device" value="{{item.id}}"></input><button type="submit" class="btn btn-primary btn-sm">Add</button></td> |
|
|||
81 | </tr> |
|
|||
82 | {% endfor %} |
|
|||
83 | </table> |
|
|||
84 | <br> |
|
|||
85 | </form> |
|
|||
86 | </div> |
|
|||
87 | </div> |
|
|||
88 | </div> |
|
|||
89 | <div class="panel panel-default"> |
|
|||
90 | <div class="panel-heading" role="tab" id="headingThree"> |
|
|||
91 | <h4 class="panel-title"> |
|
|||
92 | <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree"> |
|
|||
93 | Experiment's Devices |
|
30 | Experiment's Devices | |
94 | </a> |
|
31 | </a> | |
95 | </h4> |
|
32 | </h4> | |
96 | </div> |
|
33 | </div> | |
97 |
<div id="collapseT |
|
34 | <div id="collapseTwo" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingTwo"> | |
98 | <div class="panel-body"> |
|
35 | <div class="panel-body"> | |
99 | <table class="table table-hover"> |
|
36 | <table class="table table-hover"> | |
100 | <tr> |
|
37 | <tr> | |
101 | <th>#</th> |
|
38 | <th>#</th> | |
102 |
{% for |
|
39 | {% for key in configuration_keys %} | |
103 |
<th>{{ |
|
40 | <th>{{ key|title }}</th> | |
104 | {% endfor%} |
|
41 | {% endfor%} | |
105 | </tr> |
|
42 | </tr> | |
106 |
{% for item in |
|
43 | {% for item in configurations %} | |
107 |
<tr class="clickable-row" data-href="/{{item.device_type__ |
|
44 | <tr class="clickable-row" data-href="/{{item.device__device_type__name}}/{{item.id}}/"> | |
108 | <td>{{ forloop.counter }}</td> |
|
45 | <td>{{ forloop.counter }}</td> | |
109 |
{% for key in |
|
46 | {% for key in configuration_keys %} | |
110 | <td>{{ item|attr:key }}</td> |
|
47 | <td>{{ item|attr:key }}</td> | |
111 | {% endfor %} |
|
48 | {% endfor %} | |
112 | </tr> |
|
49 | </tr> | |
113 | {% endfor %} |
|
50 | {% endfor %} | |
114 | </table> |
|
51 | </table> | |
|
52 | <button class="btn btn-primary pull-right" id="bt_add_conf">{{button}}</button> | |||
115 | </div> |
|
53 | </div> | |
116 | </div> |
|
54 | </div> | |
117 | </div> |
|
55 | </div> | |
118 | </div> |
|
56 | </div> | |
119 | {% else %} |
|
|||
120 | <table class="table table-hover"> |
|
|||
121 | <tr> |
|
|||
122 | <th>#</th> |
|
|||
123 | {% for header in keys %} |
|
|||
124 | <th>{{ header|title }}</th> |
|
|||
125 | {% endfor%} |
|
|||
126 | </tr> |
|
|||
127 | {% for item in items %} |
|
|||
128 | <tr class="clickable-row" data-href="{%if base_url %}{{ base_url }}/{% endif %}{{ item.id }}"> |
|
|||
129 | <td>{{ forloop.counter }}</td> |
|
|||
130 | {% for key in keys %} |
|
|||
131 | <td>{{ item|attr:key }}</td> |
|
|||
132 | {% endfor %} |
|
|||
133 | </tr> |
|
|||
134 | {% endfor %} |
|
|||
135 | </table> |
|
|||
136 | <button class="btn btn-primary pull-right" id="bt_add">{{button}}</button> |
|
|||
137 | {% endif %} |
|
|||
138 |
|
||||
139 | {% endblock %} |
|
57 | {% endblock %} | |
140 |
|
58 | |||
141 | {% block sidebar%} |
|
59 | {% block sidebar%} | |
@@ -153,12 +71,13 | |||||
153 | document.location = $(this).data("href"); |
|
71 | document.location = $(this).data("href"); | |
154 | }); |
|
72 | }); | |
155 |
|
73 | |||
156 |
$("#bt_ |
|
74 | $("#bt_edit_experiment").click(function() { | |
157 | document.location = "add"; |
|
75 | document.location = "{% url 'url_edit_experiment' experiment.id%}"; | |
158 | }); |
|
76 | }); | |
159 |
|
77 | |||
160 |
$("# |
|
78 | $("#bt_add_conf").click(function() { | |
161 |
document.location = "{% url 'experiment |
|
79 | document.location = "{% url 'url_add_dev_conf' experiment.id%}"; | |
162 | }); |
|
80 | }); | |
|
81 | ||||
163 | </script> |
|
82 | </script> | |
164 | {% endblock %} No newline at end of file |
|
83 | {% endblock %} |
@@ -4,7 +4,7 | |||||
4 | <h3>Experiment</h3> |
|
4 | <h3>Experiment</h3> | |
5 | </div> |
|
5 | </div> | |
6 | <div class="list-group"> |
|
6 | <div class="list-group"> | |
7 |
<a href="{% url 'experiment' experiment.id %}" class="list-group-item active" >{{ experiment. |
|
7 | <a href="{% url 'url_experiment' experiment.id %}" class="list-group-item active" >{{ experiment.name }}</a> | |
8 | </div> |
|
8 | </div> | |
9 | </div> |
|
9 | </div> | |
10 | {% endif %} |
|
10 | {% endif %} | |
@@ -16,7 +16,7 | |||||
16 | </div> |
|
16 | </div> | |
17 | <div class="list-group"> |
|
17 | <div class="list-group"> | |
18 | {% for item in devices %} |
|
18 | {% for item in devices %} | |
19 |
<a href="/{{item.device_type__ |
|
19 | <a href="/{{item.device_type__name}}/{{item.configuration__id}}/" class="list-group-item {{item.active}}">{{item.device_type__alias}}</a> | |
20 | {% endfor %} |
|
20 | {% endfor %} | |
21 | </div> |
|
21 | </div> | |
22 | </div> |
|
22 | </div> |
This diff has been collapsed as it changes many lines, (533 lines changed) Show them Hide them | |||||
@@ -1,133 +1,494 | |||||
1 |
from django.shortcuts import re |
|
1 | from django.shortcuts import render, redirect | |
2 | from django.template import RequestContext |
|
|||
3 | from .forms import NewExperimentForm, NewDeviceForm, DeviceTypeForm |
|
|||
4 |
|
2 | |||
5 |
from . |
|
3 | from .forms import CampaignForm, ExperimentForm, DeviceForm, ConfigurationForm | |
|
4 | from apps.cgs.forms import CGSConfigurationForm | |||
|
5 | from apps.jars.forms import JARSConfigurationForm | |||
|
6 | from apps.usrp.forms import USRPConfigurationForm | |||
|
7 | from apps.abs.forms import ABSConfigurationForm | |||
|
8 | from apps.rc.forms import RCConfigurationForm | |||
|
9 | from apps.dds.forms import DDSConfigurationForm | |||
|
10 | ||||
|
11 | from .models import Campaign, Experiment, Device, Configuration | |||
6 | from apps.cgs.models import CGSConfiguration |
|
12 | from apps.cgs.models import CGSConfiguration | |
7 | from apps.jars.models import JARSConfiguration |
|
13 | from apps.jars.models import JARSConfiguration | |
8 |
|
|
14 | from apps.usrp.models import USRPConfiguration | |
9 | from apps.abs.models import ABSConfiguration |
|
15 | from apps.abs.models import ABSConfiguration | |
10 | from apps.rc.models import RCConfiguration |
|
16 | from apps.rc.models import RCConfiguration | |
11 | from apps.dds.models import DDSConfiguration |
|
17 | from apps.dds.models import DDSConfiguration | |
12 |
|
18 | |||
13 | # Create your views here. |
|
19 | # Create your views here. | |
14 |
|
20 | |||
15 | MODELS = { |
|
21 | CONF_FORMS = { | |
|
22 | 'rc': RCConfigurationForm, | |||
|
23 | 'dds': DDSConfigurationForm, | |||
|
24 | 'jars': JARSConfigurationForm, | |||
|
25 | 'cgs': CGSConfigurationForm, | |||
|
26 | 'abs': ABSConfigurationForm, | |||
|
27 | 'usrp': USRPConfigurationForm, | |||
|
28 | } | |||
|
29 | ||||
|
30 | CONF_MODELS = { | |||
16 | 'rc': RCConfiguration, |
|
31 | 'rc': RCConfiguration, | |
17 | 'dds': DDSConfiguration, |
|
32 | 'dds': DDSConfiguration, | |
18 | 'jars': JARSConfiguration, |
|
33 | 'jars': JARSConfiguration, | |
19 | 'cgs': CGSConfiguration, |
|
34 | 'cgs': CGSConfiguration, | |
20 | 'abs': ABSConfiguration, |
|
35 | 'abs': ABSConfiguration, | |
|
36 | 'usrp': USRPConfiguration, | |||
21 | } |
|
37 | } | |
22 |
|
38 | |||
23 | def index(request): |
|
39 | def index(request): | |
24 | kwargs = {} |
|
40 | kwargs = {} | |
25 |
|
41 | |||
26 | return render_to_response("index.html", kwargs, context_instance=RequestContext(request)) |
|
42 | return render(request, 'index.html', kwargs) | |
|
43 | ||||
|
44 | def devices(request): | |||
|
45 | ||||
|
46 | devices = Device.objects.all().order_by('device_type__name') | |||
|
47 | ||||
|
48 | keys = ['id', 'device_type__name', 'name', 'ip_address'] | |||
|
49 | ||||
|
50 | kwargs = {} | |||
|
51 | kwargs['device_keys'] = keys[1:] | |||
|
52 | kwargs['devices'] = devices.values(*keys) | |||
|
53 | kwargs['title'] = 'Device' | |||
|
54 | kwargs['suptitle'] = 'List' | |||
|
55 | kwargs['button'] = 'New Device' | |||
|
56 | ||||
|
57 | return render(request, 'devices.html', kwargs) | |||
27 |
|
58 | |||
28 |
def |
|
59 | def device(request, id_dev): | |
|
60 | ||||
|
61 | device = Device.objects.get(pk=id_dev) | |||
|
62 | ||||
|
63 | # form = DeviceForm(instance=device) | |||
|
64 | ||||
29 | kwargs = {} |
|
65 | kwargs = {} | |
30 | if id_exp: |
|
66 | kwargs['device'] = device | |
31 | experiment = Experiment.objects.get(pk=id_exp) |
|
67 | kwargs['device_keys'] = ['device_type', 'name', 'ip_address', 'port_address', 'description'] | |
32 | devices = Device.objects.filter(configuration__experiment=experiment) |
|
68 | ||
33 | kwargs['experiment'] = experiment |
|
69 | kwargs['title'] = 'Device' | |
34 | kwargs['experiment_keys'] = ['name', 'alias', 'start_date', 'end_date'] |
|
70 | kwargs['suptitle'] = 'Details' | |
|
71 | ||||
|
72 | # kwargs['form'] = form | |||
|
73 | kwargs['button'] = 'Add Device' | |||
|
74 | ||||
|
75 | return render(request, 'device.html', kwargs) | |||
|
76 | ||||
|
77 | def add_device(request): | |||
|
78 | ||||
|
79 | if request.method == 'GET': | |||
|
80 | form = DeviceForm() | |||
|
81 | ||||
|
82 | if request.method == 'POST': | |||
|
83 | form = DeviceForm(request.POST) | |||
35 |
|
84 | |||
36 | form = NewExperimentForm(instance=experiment) |
|
85 | if form.is_valid(): | |
|
86 | form.save() | |||
|
87 | return redirect('url_devices') | |||
37 |
|
88 | |||
38 | if id_dev_type: |
|
89 | kwargs = {} | |
39 | subform = DeviceTypeForm(initial={'device_type':id_dev_type}) |
|
90 | kwargs['form'] = form | |
40 | kwargs['keys'] = ['model', 'ip_address', 'status'] |
|
91 | kwargs['title'] = 'Device' | |
41 | keys = ['id']+kwargs['keys'] |
|
92 | kwargs['suptitle'] = 'New' | |
42 | kwargs['items'] = Device.objects.filter(device_type=id_dev_type).values(*keys) |
|
93 | kwargs['button'] = 'Create' | |
43 | else: |
|
|||
44 | subform = DeviceTypeForm() |
|
|||
45 |
|
94 | |||
46 | kwargs['form'] = form |
|
95 | return render(request, 'device_edit.html', kwargs) | |
47 | kwargs['subform'] = subform |
|
|||
48 | kwargs['device_keys'] = ['device_type__name', 'model', 'ip_address', 'status'] |
|
|||
49 | kwargs['devices'] = devices.values('device_type__name', 'model', 'ip_address', 'status', 'device_type__alias', 'configuration__id') |
|
|||
50 | kwargs['suptitle'] = 'Detail' |
|
|||
51 | else: |
|
|||
52 | experiments = Experiment.objects.all().order_by('start_date') |
|
|||
53 | kwargs['keys'] = ['name', 'start_date', 'end_date'] |
|
|||
54 | keys = ['id']+kwargs['keys'] |
|
|||
55 | kwargs['items'] = experiments.values(*keys) |
|
|||
56 | kwargs['suptitle'] = 'List' |
|
|||
57 | kwargs['button'] = 'Add Experiment' |
|
|||
58 |
|
||||
59 | kwargs['id_dev_type'] = id_dev_type |
|
|||
60 | kwargs['id_exp'] = id_exp |
|
|||
61 | return render_to_response("experiment.html", kwargs, context_instance=RequestContext(request)) |
|
|||
62 |
|
96 | |||
63 |
def edit_ |
|
97 | def edit_device(request, id_dev): | |
|
98 | ||||
|
99 | device = Device.objects.get(pk=id_dev) | |||
|
100 | ||||
|
101 | if request.method=='GET': | |||
|
102 | form = DeviceForm(instance=device) | |||
|
103 | ||||
64 | if request.method=='POST': |
|
104 | if request.method=='POST': | |
65 | experiment = Experiment.objects.get(pk=id_exp) |
|
105 | form = DeviceForm(request.POST, instance=device) | |
66 | form = NewExperimentForm(request.POST, instance=experiment) |
|
106 | ||
67 | if form.is_valid(): |
|
107 | if form.is_valid(): | |
68 | form.save() |
|
108 | form.save() | |
69 | return redirect('experiment', id_exp=id_exp) |
|
109 | return redirect('url_devices') | |
|
110 | ||||
|
111 | kwargs = {} | |||
|
112 | kwargs['form'] = form | |||
|
113 | kwargs['title'] = 'Device' | |||
|
114 | kwargs['suptitle'] = 'Edit' | |||
|
115 | kwargs['button'] = 'Update' | |||
|
116 | ||||
|
117 | return render(request, 'device_edit.html', kwargs) | |||
70 |
|
118 | |||
71 | def experiment_add_device(request, id_exp): |
|
119 | def campaigns(request): | |
|
120 | ||||
|
121 | campaigns = Campaign.objects.all().order_by('start_date') | |||
|
122 | ||||
|
123 | keys = ['id', 'name', 'start_date', 'end_date'] | |||
|
124 | ||||
|
125 | kwargs = {} | |||
|
126 | kwargs['campaign_keys'] = keys[1:] | |||
|
127 | kwargs['campaigns'] = campaigns.values(*keys) | |||
|
128 | kwargs['title'] = 'Campaign' | |||
|
129 | kwargs['suptitle'] = 'List' | |||
|
130 | kwargs['button'] = 'New Campaign' | |||
|
131 | ||||
|
132 | return render(request, 'campaigns.html', kwargs) | |||
|
133 | ||||
|
134 | def campaign(request, id_camp): | |||
|
135 | ||||
|
136 | campaign = Campaign.objects.get(pk=id_camp) | |||
|
137 | experiments = Experiment.objects.filter(campaign=campaign) | |||
|
138 | ||||
|
139 | form = CampaignForm(instance=campaign) | |||
|
140 | ||||
|
141 | kwargs = {} | |||
|
142 | kwargs['campaign'] = campaign | |||
|
143 | kwargs['campaign_keys'] = ['name', 'start_date', 'end_date', 'tags', 'description'] | |||
|
144 | ||||
|
145 | keys = ['id', 'name', 'start_time', 'end_time'] | |||
|
146 | ||||
|
147 | kwargs['experiment_keys'] = keys[1:] | |||
|
148 | kwargs['experiments'] = experiments.values(*keys) | |||
|
149 | ||||
|
150 | kwargs['title'] = 'Campaign' | |||
|
151 | kwargs['suptitle'] = 'Details' | |||
|
152 | ||||
|
153 | kwargs['form'] = form | |||
|
154 | kwargs['button'] = 'Add Experiment' | |||
|
155 | ||||
|
156 | return render(request, 'campaign.html', kwargs) | |||
|
157 | ||||
|
158 | def add_campaign(request): | |||
|
159 | ||||
|
160 | if request.method == 'GET': | |||
|
161 | form = CampaignForm() | |||
|
162 | ||||
|
163 | if request.method == 'POST': | |||
|
164 | form = CampaignForm(request.POST) | |||
|
165 | ||||
|
166 | if form.is_valid(): | |||
|
167 | campaign = form.save() | |||
|
168 | return redirect('url_campaign', id_camp=campaign.id) | |||
|
169 | ||||
|
170 | kwargs = {} | |||
|
171 | kwargs['form'] = form | |||
|
172 | kwargs['title'] = 'Campaign' | |||
|
173 | kwargs['suptitle'] = 'New' | |||
|
174 | kwargs['button'] = 'Create' | |||
|
175 | ||||
|
176 | return render(request, 'campaign_edit.html', kwargs) | |||
|
177 | ||||
|
178 | def edit_campaign(request, id_camp): | |||
|
179 | ||||
|
180 | campaign = Campaign.objects.get(pk=id_camp) | |||
|
181 | ||||
|
182 | if request.method=='GET': | |||
|
183 | form = CampaignForm(instance=campaign) | |||
|
184 | ||||
72 | if request.method=='POST': |
|
185 | if request.method=='POST': | |
73 | experiment = Experiment.objects.get(pk=id_exp) |
|
186 | form = CampaignForm(request.POST, instance=campaign) | |
74 | device = Device.objects.get(pk=request.POST['device']) |
|
187 | ||
75 | model = MODELS[device.device_type.alias] |
|
188 | if form.is_valid(): | |
76 | conf = model(experiment=experiment, device=device) |
|
189 | form.save() | |
77 | conf.save() |
|
190 | return redirect('url_campaign', id_camp=id_camp) | |
78 | return redirect('experiment', id_exp=id_exp) |
|
191 | ||
|
192 | kwargs = {} | |||
|
193 | kwargs['form'] = form | |||
|
194 | kwargs['title'] = 'Campaign' | |||
|
195 | kwargs['suptitle'] = 'Edit' | |||
|
196 | kwargs['button'] = 'Update' | |||
|
197 | ||||
|
198 | return render(request, 'campaign_edit.html', kwargs) | |||
79 |
|
199 | |||
80 |
def |
|
200 | def experiments(request): | |
|
201 | ||||
|
202 | campaigns = Experiment.objects.all().order_by('start_time') | |||
|
203 | ||||
|
204 | keys = ['id', 'campaign__name', 'name', 'start_time', 'end_time'] | |||
|
205 | ||||
81 | kwargs = {} |
|
206 | kwargs = {} | |
|
207 | ||||
|
208 | kwargs['experiment_keys'] = keys[1:] | |||
|
209 | kwargs['experiments'] = campaigns.values(*keys) | |||
|
210 | ||||
|
211 | kwargs['title'] = 'Experiment' | |||
|
212 | kwargs['suptitle'] = 'List' | |||
|
213 | kwargs['button'] = 'New Experiment' | |||
|
214 | ||||
|
215 | return render(request, 'experiments.html', kwargs) | |||
|
216 | ||||
|
217 | def experiment(request, id_exp): | |||
|
218 | ||||
|
219 | experiment = Experiment.objects.get(pk=id_exp) | |||
|
220 | campaign = Campaign.objects.get(pk = experiment.campaign.id) | |||
|
221 | configurations = Configuration.objects.filter(experiment=experiment) | |||
|
222 | ||||
|
223 | # form = ExperimentForm(instance=experiment) | |||
|
224 | ||||
|
225 | kwargs = {} | |||
|
226 | ||||
|
227 | kwargs['campaign_keys'] = ['name', 'start_date', 'end_date', 'tags', 'description'] | |||
|
228 | kwargs['campaign'] = campaign | |||
|
229 | ||||
|
230 | kwargs['experiment_keys'] = ['campaign', 'name', 'start_time', 'end_time'] | |||
|
231 | kwargs['experiment'] = experiment | |||
|
232 | ||||
|
233 | keys = ['id', 'device__name', 'device__device_type__name', 'device__ip_address'] | |||
|
234 | ||||
|
235 | kwargs['configuration_keys'] = keys[1:] | |||
|
236 | kwargs['configurations'] = configurations.values(*keys) | |||
|
237 | ||||
|
238 | kwargs['title'] = 'Experiment' | |||
|
239 | kwargs['suptitle'] = 'Details' | |||
|
240 | ||||
|
241 | # kwargs['form'] = form | |||
|
242 | kwargs['button'] = 'Add Device' | |||
|
243 | ||||
|
244 | return render(request, 'experiment.html', kwargs) | |||
|
245 | ||||
|
246 | def add_experiment(request, id_camp=0): | |||
|
247 | ||||
|
248 | if request.method == 'GET': | |||
|
249 | form = ExperimentForm(initial={'campaign':id_camp}) | |||
|
250 | ||||
82 | if request.method == 'POST': |
|
251 | if request.method == 'POST': | |
83 |
form = |
|
252 | form = ExperimentForm(request.POST, initial={'campaign':id_camp}) | |
|
253 | ||||
84 | if form.is_valid(): |
|
254 | if form.is_valid(): | |
85 | experiment = form.save() |
|
255 | experiment = form.save() | |
86 | return redirect('experiment', id_exp=experiment.id) |
|
256 | return redirect('url_experiment', id_exp=experiment.id) | |
87 |
|
|
257 | ||
88 | form = NewExperimentForm() |
|
258 | kwargs = {} | |
89 |
kwargs['form |
|
259 | kwargs['form'] = form | |
90 | kwargs['title'] = 'Experiment' |
|
260 | kwargs['title'] = 'Experiment' | |
91 | kwargs['suptitle'] = 'New' |
|
261 | kwargs['suptitle'] = 'New' | |
92 |
kwargs[' |
|
262 | kwargs['button'] = 'Create' | |
93 | return render_to_response("experiment.html", kwargs, context_instance=RequestContext(request)) |
|
263 | ||
94 |
|
264 | return render(request, 'experiment_edit.html', kwargs) | ||
95 | def device(request, id_dev=0): |
|
|||
96 | kwargs = {} |
|
|||
97 | if id_dev: |
|
|||
98 | device = Device.objects.get(pk=id_dev) |
|
|||
99 | kwargs['form'] = NewDeviceForm(instance=device) |
|
|||
100 | kwargs['action'] = 'edit/' |
|
|||
101 | kwargs['button'] = 'Update' |
|
|||
102 | kwargs['suptitle'] = 'Detail' |
|
|||
103 | else: |
|
|||
104 | devices = Device.objects.all() |
|
|||
105 | kwargs['keys'] = ['device_type__name', 'model', 'serial_number', 'ip_address', 'status'] |
|
|||
106 | keys = ['id']+kwargs['keys'] |
|
|||
107 | kwargs['items'] = devices.values(*keys) |
|
|||
108 | kwargs['suptitle'] = 'List' |
|
|||
109 | kwargs['button'] = 'Add Device' |
|
|||
110 | return render_to_response("device.html", kwargs, context_instance=RequestContext(request)) |
|
|||
111 |
|
265 | |||
112 |
def edit_ |
|
266 | def edit_experiment(request, id_exp): | |
|
267 | ||||
|
268 | experiment = Experiment.objects.get(pk=id_exp) | |||
|
269 | ||||
|
270 | if request.method == 'GET': | |||
|
271 | form = ExperimentForm(instance=experiment) | |||
|
272 | ||||
113 | if request.method=='POST': |
|
273 | if request.method=='POST': | |
114 | device = Device.objects.get(pk=id_dev) |
|
274 | form = ExperimentForm(request.POST, instance=experiment) | |
115 | form = NewDeviceForm(request.POST, instance=device) |
|
275 | ||
116 | if form.is_valid(): |
|
276 | if form.is_valid(): | |
117 | form.save() |
|
277 | experiment = form.save() | |
118 | return redirect('devices') |
|
278 | return redirect('url_experiment', id_exp=experiment.id) | |
|
279 | ||||
|
280 | kwargs = {} | |||
|
281 | kwargs['form'] = form | |||
|
282 | kwargs['title'] = 'Experiment' | |||
|
283 | kwargs['suptitle'] = 'Edit' | |||
|
284 | kwargs['button'] = 'Update' | |||
|
285 | ||||
|
286 | return render(request, 'experiment_edit.html', kwargs) | |||
119 |
|
287 | |||
120 |
def |
|
288 | def dev_confs(request): | |
|
289 | ||||
|
290 | configurations = Configuration.objects.all().order_by('device__device_type') | |||
|
291 | ||||
|
292 | keys = ['id', 'device__device_type__name', 'device__name', 'experiment__campaign__name', 'experiment__name'] | |||
|
293 | ||||
|
294 | kwargs = {} | |||
|
295 | ||||
|
296 | kwargs['configuration_keys'] = keys[1:] | |||
|
297 | kwargs['configurations'] = configurations.values(*keys) | |||
|
298 | ||||
|
299 | kwargs['title'] = 'Configurations' | |||
|
300 | kwargs['suptitle'] = 'List' | |||
|
301 | kwargs['button'] = 'New Configuration' | |||
|
302 | ||||
|
303 | return render(request, 'dev_confs.html', kwargs) | |||
|
304 | ||||
|
305 | def dev_conf(request, id_conf): | |||
|
306 | ||||
|
307 | conf = Configuration.objects.get(pk=id_conf) | |||
|
308 | ||||
|
309 | DevConfModel = CONF_MODELS[conf.device.device_type.name] | |||
|
310 | dev_conf = DevConfModel.objects.get(pk=id_conf) | |||
|
311 | ||||
121 | kwargs = {} |
|
312 | kwargs = {} | |
|
313 | kwargs['dev_conf'] = dev_conf | |||
|
314 | kwargs['dev_conf_keys'] = ['experiment', 'device'] | |||
|
315 | ||||
|
316 | kwargs['title'] = 'Configuration' | |||
|
317 | kwargs['suptitle'] = 'Details' | |||
|
318 | ||||
|
319 | kwargs['button'] = 'Edit Configuration' | |||
|
320 | ||||
|
321 | return render(request, 'dev_conf.html', kwargs) | |||
|
322 | ||||
|
323 | def add_dev_conf(request, id_exp=0): | |||
|
324 | ||||
|
325 | if request.method == 'GET': | |||
|
326 | form = ConfigurationForm(initial={'experiment':id_exp}) | |||
|
327 | ||||
122 | if request.method == 'POST': |
|
328 | if request.method == 'POST': | |
123 |
form = |
|
329 | form = ConfigurationForm(request.POST) | |
|
330 | ||||
124 | if form.is_valid(): |
|
331 | if form.is_valid(): | |
125 | form.save() |
|
332 | experiment = Experiment.objects.get(pk=request.POST['experiment']) | |
126 | return redirect('devices') |
|
333 | device = Device.objects.get(pk=request.POST['device']) | |
127 | else: |
|
334 | ||
128 | form = NewDeviceForm() |
|
335 | exp_devices = Device.objects.filter(configuration__experiment=experiment) | |
|
336 | ||||
|
337 | if device.id not in exp_devices.values('id',): | |||
|
338 | ||||
|
339 | DevConfModel = CONF_MODELS[device.device_type.name] | |||
|
340 | conf = DevConfModel(experiment=experiment, device=device) | |||
|
341 | conf.save() | |||
|
342 | ||||
|
343 | return redirect('url_experiment', id_exp=experiment.id) | |||
|
344 | ||||
|
345 | kwargs = {} | |||
129 | kwargs['form'] = form |
|
346 | kwargs['form'] = form | |
130 |
kwargs[' |
|
347 | kwargs['title'] = 'Configuration' | |
131 | kwargs['suptitle'] = 'New' |
|
348 | kwargs['suptitle'] = 'New' | |
132 | return render_to_response("device.html", kwargs, context_instance=RequestContext(request)) |
|
349 | kwargs['button'] = 'Create' | |
|
350 | ||||
|
351 | return render(request, 'dev_conf_edit.html', kwargs) | |||
|
352 | ||||
|
353 | def edit_dev_conf(request, id_conf): | |||
|
354 | ||||
|
355 | conf = Configuration.objects.get(pk=id_conf) | |||
|
356 | ||||
|
357 | DevConfModel = CONF_MODELS[conf.device.device_type.name] | |||
|
358 | DevConfForm = CONF_FORMS[conf.device.device_type.name] | |||
|
359 | ||||
|
360 | dev_conf = DevConfModel.objects.get(pk=id_conf) | |||
|
361 | ||||
|
362 | if request.method=='GET': | |||
|
363 | form = DevConfForm(instance=dev_conf) | |||
|
364 | ||||
|
365 | if request.method=='POST': | |||
|
366 | form = DevConfForm(request.POST, instance=dev_conf) | |||
|
367 | ||||
|
368 | if form.is_valid(): | |||
|
369 | form.save() | |||
|
370 | return redirect('url_dev_conf', id_conf=id_conf) | |||
|
371 | ||||
|
372 | kwargs = {} | |||
|
373 | kwargs['form'] = form | |||
|
374 | kwargs['title'] = 'Device Configuration' | |||
|
375 | kwargs['suptitle'] = 'Edit' | |||
|
376 | kwargs['button'] = 'Update' | |||
|
377 | ||||
|
378 | return render(request, 'dev_conf_edit.html', kwargs) | |||
|
379 | ||||
|
380 | ||||
|
381 | # def experiment(request, id_exp=0, id_dev_type=0): | |||
|
382 | # kwargs = {} | |||
|
383 | # if id_exp: | |||
|
384 | # experiment = Experiment.objects.get(pk=id_exp) | |||
|
385 | # devices = Configuration.objects.filter(configuration__experiment=experiment) | |||
|
386 | # kwargs['experiment'] = experiment | |||
|
387 | # kwargs['experiment_keys'] = ['campaign', 'name', 'start_time', 'end_time'] | |||
|
388 | # | |||
|
389 | # form = ExperimentForm(instance=experiment) | |||
|
390 | # | |||
|
391 | # if id_dev_type: | |||
|
392 | # subform = DeviceTypeForm(initial={'device_type':id_dev_type}) | |||
|
393 | # kwargs['keys'] = ['ip_address'] | |||
|
394 | # keys = ['id']+kwargs['keys'] | |||
|
395 | # kwargs['items'] = Device.objects.filter(device_type=id_dev_type).values(*keys) | |||
|
396 | # else: | |||
|
397 | # subform = DeviceTypeForm() | |||
|
398 | # | |||
|
399 | # kwargs['form'] = form | |||
|
400 | # kwargs['subform'] = subform | |||
|
401 | # kwargs['device_keys'] = ['device_type__name', 'ip_address'] | |||
|
402 | # kwargs['devices'] = devices.values('device_type__name', 'ip_address', 'configuration__id') | |||
|
403 | # kwargs['suptitle'] = 'Detail' | |||
|
404 | # else: | |||
|
405 | # experiments = Experiment.objects.all().order_by('start_time') | |||
|
406 | # kwargs['keys'] = ['name', 'start_time', 'end_time'] | |||
|
407 | # keys = ['id']+kwargs['keys'] | |||
|
408 | # kwargs['items'] = experiments.values(*keys) | |||
|
409 | # kwargs['suptitle'] = 'List' | |||
|
410 | # kwargs['button'] = 'Add Experiment' | |||
|
411 | # | |||
|
412 | # kwargs['id_dev_type'] = id_dev_type | |||
|
413 | # kwargs['id_exp'] = id_exp | |||
|
414 | # return render_to_response("experiment.html", kwargs, context_instance=RequestContext(request)) | |||
|
415 | ||||
|
416 | # def edit_experiment(request, id_exp): | |||
|
417 | # if request.method=='POST': | |||
|
418 | # experiment = Experiment.objects.get(pk=id_exp) | |||
|
419 | # form = ExperimentForm(request.POST, instance=experiment) | |||
|
420 | # if form.is_valid(): | |||
|
421 | # form.save() | |||
|
422 | # return redirect('experiment', id_exp=id_exp) | |||
|
423 | ||||
|
424 | # def experiment_add_device(request, id_exp): | |||
|
425 | # if request.method=='POST': | |||
|
426 | # experiment = Experiment.objects.get(pk=id_exp) | |||
|
427 | # | |||
|
428 | # exp_devices = Device.objects.filter(configuration__experiment=experiment) | |||
|
429 | # | |||
|
430 | # device = Device.objects.get(pk=request.POST['device']) | |||
|
431 | # | |||
|
432 | # if device.id in exp_devices.values('id',): | |||
|
433 | # return redirect('experiment', id_exp=id_exp) | |||
|
434 | # | |||
|
435 | # model = MODELS[device.device_type.alias] | |||
|
436 | # conf = model(experiment=experiment, device=device) | |||
|
437 | # conf.save() | |||
|
438 | # return redirect('experiment', id_exp=id_exp) | |||
|
439 | ||||
|
440 | # def add_experiment(request): | |||
|
441 | # | |||
|
442 | # kwargs = {} | |||
|
443 | # if request.method == 'POST': | |||
|
444 | # form = ExperimentForm(request.POST) | |||
|
445 | # if form.is_valid(): | |||
|
446 | # experiment = form.save() | |||
|
447 | # return redirect('experiment', id_exp=experiment.id) | |||
|
448 | # else: | |||
|
449 | # form = ExperimentForm() | |||
|
450 | # kwargs['form_new'] = form | |||
|
451 | # kwargs['title'] = 'Experiment' | |||
|
452 | # kwargs['suptitle'] = 'New' | |||
|
453 | # kwargs['id_exp'] = 0 | |||
|
454 | # return render_to_response("experiment.html", kwargs, context_instance=RequestContext(request)) | |||
|
455 | ||||
|
456 | # def device(request, id_dev=0): | |||
|
457 | # kwargs = {} | |||
|
458 | # if id_dev: | |||
|
459 | # device = Device.objects.get(pk=id_dev) | |||
|
460 | # kwargs['form'] = DeviceForm(instance=device) | |||
|
461 | # kwargs['action'] = 'edit/' | |||
|
462 | # kwargs['button'] = 'Update' | |||
|
463 | # kwargs['suptitle'] = 'Detail' | |||
|
464 | # else: | |||
|
465 | # devices = Device.objects.all() | |||
|
466 | # kwargs['keys'] = ['device_type__name', 'ip_address'] | |||
|
467 | # keys = ['id']+kwargs['keys'] | |||
|
468 | # kwargs['items'] = devices.values(*keys) | |||
|
469 | # kwargs['suptitle'] = 'List' | |||
|
470 | # kwargs['button'] = 'Add Device' | |||
|
471 | # return render_to_response("device.html", kwargs, context_instance=RequestContext(request)) | |||
|
472 | # | |||
|
473 | # def edit_device(request, id_dev): | |||
|
474 | # if request.method=='POST': | |||
|
475 | # device = Device.objects.get(pk=id_dev) | |||
|
476 | # form = DeviceForm(request.POST, instance=device) | |||
|
477 | # if form.is_valid(): | |||
|
478 | # form.save() | |||
|
479 | # return redirect('devices') | |||
|
480 | # | |||
|
481 | # def add_device(request): | |||
|
482 | # kwargs = {} | |||
|
483 | # if request.method == 'POST': | |||
|
484 | # form = DeviceForm(request.POST) | |||
|
485 | # if form.is_valid(): | |||
|
486 | # form.save() | |||
|
487 | # return redirect('devices') | |||
|
488 | # else: | |||
|
489 | # form = DeviceForm() | |||
|
490 | # kwargs['form'] = form | |||
|
491 | # kwargs['button'] = 'Create' | |||
|
492 | # kwargs['suptitle'] = 'New' | |||
|
493 | # return render_to_response("device.html", kwargs, context_instance=RequestContext(request)) | |||
133 |
|
494 |
@@ -1,5 +1,6 | |||||
1 | from django.conf.urls import url |
|
1 | from django.conf.urls import url | |
2 |
|
2 | |||
3 | urlpatterns = ( |
|
3 | urlpatterns = ( | |
4 |
|
4 | url(r'^(?P<id_conf>-?\d+)/$', 'apps.main.views.dev_conf', name='url_rc_conf'), | ||
|
5 | url(r'^(?P<id_conf>-?\d+)/edit/$', 'apps.main.views.edit_dev_conf', name='url_edit_rc_conf'), | |||
5 | ) |
|
6 | ) |
@@ -1,3 +1,9 | |||||
1 | from django.db import models |
|
1 | from django.db import models | |
2 |
|
2 | from apps.main.models import Configuration | ||
3 | # Create your models here. |
|
3 | # Create your models here. | |
|
4 | ||||
|
5 | class USRPConfiguration(Configuration): | |||
|
6 | ||||
|
7 | ||||
|
8 | class Meta: | |||
|
9 | db_table = 'usrp_configurations' No newline at end of file |
@@ -1,5 +1,6 | |||||
1 | from django.conf.urls import url |
|
1 | from django.conf.urls import url | |
2 |
|
2 | |||
3 | urlpatterns = ( |
|
3 | urlpatterns = ( | |
4 |
|
4 | url(r'^(?P<id_conf>-?\d+)/$', 'apps.main.views.dev_conf', name='url_usrp_conf'), | ||
|
5 | url(r'^(?P<id_conf>-?\d+)/edit/$', 'apps.main.views.edit_dev_conf', name='url_edit_usrp_conf'), | |||
5 | ) |
|
6 | ) |
@@ -18,18 +18,9 from django.contrib import admin | |||||
18 |
|
18 | |||
19 | urlpatterns = [ |
|
19 | urlpatterns = [ | |
20 | url(r'^$', 'apps.main.views.index', name='index'), |
|
20 | url(r'^$', 'apps.main.views.index', name='index'), | |
21 | url(r'^experiment/$', 'apps.main.views.experiment', name='experiments'), |
|
|||
22 | url(r'^experiment/add/$', 'apps.main.views.add_experiment', name='add_experiment'), |
|
|||
23 | url(r'^experiment/(?P<id_exp>-?\d+)/$', 'apps.main.views.experiment', name='experiment'), |
|
|||
24 | url(r'^experiment/(?P<id_exp>-?\d+)/edit/$', 'apps.main.views.edit_experiment', name='edit_experiment'), |
|
|||
25 | url(r'^experiment/(?P<id_exp>-?\d+)/device/(?P<id_dev_type>-?\d+)/$', 'apps.main.views.experiment', name='experiment_device'), |
|
|||
26 | url(r'^experiment/(?P<id_exp>-?\d+)/add_device/$', 'apps.main.views.experiment_add_device', name='experiment_add_device'), |
|
|||
27 | url(r'^device/$', 'apps.main.views.device', name='devices'), |
|
|||
28 | url(r'^device/(?P<id_dev>-?\d+)/$', 'apps.main.views.device'), |
|
|||
29 | url(r'^device/(?P<id_dev>-?\d+)/edit/$', 'apps.main.views.edit_device', name='edit_device'), |
|
|||
30 | url(r'^device/add/$', 'apps.main.views.add_device', name='add_device'), |
|
|||
31 | url(r'^admin/', include(admin.site.urls)), |
|
21 | url(r'^admin/', include(admin.site.urls)), | |
32 |
url(r'^accounts/', include('apps.accounts.urls')), |
|
22 | url(r'^accounts/', include('apps.accounts.urls')), | |
|
23 | url(r'^', include('apps.main.urls')), | |||
33 | url(r'^rc/', include('apps.rc.urls')), |
|
24 | url(r'^rc/', include('apps.rc.urls')), | |
34 | url(r'^dds/', include('apps.dds.urls')), |
|
25 | url(r'^dds/', include('apps.dds.urls')), | |
35 | url(r'^cgs/', include('apps.cgs.urls')), |
|
26 | url(r'^cgs/', include('apps.cgs.urls')), |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now