@@ -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 | 1 | from django.conf.urls import url |
|
2 | 2 | |
|
3 | 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,22 +1,34 | |||
|
1 | 1 | from django import forms |
|
2 | from apps.main.models import Device | |
|
2 | 3 | from .models import CGSConfiguration |
|
3 | 4 | |
|
4 | 5 | class CGSConfigurationForm(forms.ModelForm): |
|
5 | 6 | #freq0.widget = te |
|
6 | 7 | def __init__(self, *args, **kwargs): |
|
7 | 8 | #request = kwargs.pop('request') |
|
8 | 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 | 21 | def clean(self): |
|
11 | # Custom validation to force an integer when type of unit = "Unit" | |
|
12 | form_data = self.cleaned_data | |
|
13 | if (form_data['freq0'] or form_data['freq1'] or form_data['freq2'] or form_data['freq3'] < 0): | |
|
14 | raise forms.ValidationError("Please introduce positive Number") | |
|
15 | ||
|
16 | return form_data | |
|
22 | return | |
|
23 | # # Custom validation to force an integer when type of unit = "Unit" | |
|
24 | # form_data = self.cleaned_data | |
|
25 | # if (form_data['freq0'] or form_data['freq1'] or form_data['freq2'] or form_data['freq3'] < 0): | |
|
26 | # raise forms.ValidationError("Please introduce positive Number") | |
|
27 | # | |
|
28 | # return form_data | |
|
17 | 29 | |
|
18 | 30 | class Meta: |
|
19 | 31 | model = CGSConfiguration |
|
20 | 32 | #exclude = ('freqs', 'clk_in', 'mult','div',) |
|
21 | 33 | # exclude = ('freqs',) |
|
22 | fields = ('freq0', 'freq1', 'freq2', 'freq3') | |
|
34 | fields = ('experiment', 'device', 'freq0', 'freq1', 'freq2', 'freq3') |
@@ -1,58 +1,53 | |||
|
1 | 1 | from django.shortcuts import render, render_to_response |
|
2 | 2 | from django.template import RequestContext |
|
3 | 3 | |
|
4 | 4 | from .forms import CGSConfigurationForm |
|
5 | 5 | from .models import CGSConfiguration |
|
6 | 6 | from apps.main.models import Device |
|
7 | 7 | # Create your views here. |
|
8 | 8 | |
|
9 | 9 | def configurate_frequencies(request, id=0): |
|
10 | kwargs = {} | |
|
10 | ||
|
11 | 11 | if id: |
|
12 | ||
|
13 | conf = CGSConfiguration.objects.get(pk=id) | |
|
14 | experiment = conf.experiment | |
|
15 | ||
|
16 | 12 | conf = CGSConfiguration.objects.get(pk=id) |
|
17 | 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 | 15 | for device in devices: |
|
20 |
if device['device_type__ |
|
|
16 | if device['device_type__name']=='cgs': | |
|
21 | 17 | device['active'] = 'active' |
|
22 | 18 | break |
|
23 | 19 | |
|
24 | 20 | device = device |
|
25 | 21 | form = CGSConfigurationForm(instance=conf) |
|
26 | 22 | else: |
|
27 | 23 | form = CGSConfigurationForm() |
|
28 | 24 | |
|
29 | 25 | data = { |
|
30 | 26 | 'form': form, |
|
31 | 27 | 'device': device, |
|
32 | 28 | 'devices':devices, |
|
33 | 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 | 37 | if request.method == 'POST': |
|
39 | 38 | form = CGSConfigurationForm(request.POST) #, initial={'purchase_request':purchase_request}) |
|
40 | 39 | if form.is_valid(): |
|
41 | 40 | instance = form.save(commit=False) |
|
42 | 41 | #if 'quote' in request.FILES: |
|
43 | 42 | # instance.quoe = request.FILES['quote'] |
|
44 | 43 | instance.save() |
|
45 | 44 | form.save_m2m() |
|
46 | 45 | msg = _(u'The frequencies have been activated successfully.') |
|
47 | 46 | messages.success(request, msg, fail_silently=True) |
|
48 | 47 | #return redirect(purchase_request.get_absolute_url()) |
|
49 | 48 | else: |
|
50 | 49 | form = CGSConfigurationForm() |
|
51 | 50 | |
|
52 | ||
|
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 | ||
|
51 | return render(request, 'cgs_conf.html', data) | |
|
57 | 52 | |
|
58 | 53 |
@@ -1,24 +1,36 | |||
|
1 | 1 | from django import forms |
|
2 | from apps.main.models import Device | |
|
2 | 3 | from .models import DDSConfiguration |
|
3 | 4 | |
|
4 | 5 | from django.core.validators import MinValueValidator, MaxValueValidator |
|
5 | 6 | |
|
6 | 7 | class DDSConfigurationForm(forms.ModelForm): |
|
7 | 8 | |
|
8 |
freq |
|
|
9 |
pha |
|
|
9 | frequency = forms.FloatField(label='Frequency (MHz)', validators=[MinValueValidator(0), MaxValueValidator(150)]) | |
|
10 | phase = forms.FloatField(label='Phase (Degrees)', validators=[MinValueValidator(0), MaxValueValidator(360)]) | |
|
10 | 11 | |
|
11 |
freq |
|
|
12 |
pha |
|
|
12 | frequency_mod = forms.FloatField(label='Frequency (MHz)', validators=[MinValueValidator(0), MaxValueValidator(150)], required=False) | |
|
13 | phase_mod = forms.FloatField(label='Phase (Degrees)', validators=[MinValueValidator(0), MaxValueValidator(360)], required=False) | |
|
13 | 14 | |
|
14 | 15 | def __init__(self, *args, **kwargs): |
|
15 | 16 | #request = kwargs.pop('request') |
|
16 | 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 | 30 | def clean(self): |
|
19 | 31 | # Custom validation to force an integer when type of unit = "Unit" |
|
20 | 32 | return |
|
21 | 33 | |
|
22 | 34 | class Meta: |
|
23 | 35 | model = DDSConfiguration |
|
24 | fields = ('clock', 'multiplier', 'modulation') | |
|
36 | fields = ('experiment', 'device', 'clock', 'multiplier', 'modulation') |
@@ -1,21 +1,31 | |||
|
1 | 1 | from django.db import models |
|
2 | 2 | from apps.main.models import Configuration |
|
3 | 3 | # Create your models here. |
|
4 | 4 | |
|
5 | 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 | 15 | class DDSConfiguration(Configuration): |
|
8 | 16 | |
|
9 |
clock = models.FloatField(verbose_name='Clock Master',validators=[MinValueValidator(5 |
|
|
10 |
multiplier = models.PositiveIntegerField(verbose_name='Multiplier',validators=[MinValueValidator( |
|
|
11 |
|
|
|
12 |
|
|
|
13 | frequency1 = models.PositiveIntegerField(verbose_name='Frequency 1',validators=[MinValueValidator(0), MaxValueValidator(2**32-1)], blank=True, null=True) | |
|
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) | |
|
17 | clock = models.FloatField(verbose_name='Clock Master (MHz)',validators=[MinValueValidator(5), MaxValueValidator(50)], blank=True, null=True) | |
|
18 | multiplier = models.PositiveIntegerField(verbose_name='Multiplier',validators=[MinValueValidator(1), MaxValueValidator(20)], default=4) | |
|
19 | freq_reg = models.PositiveIntegerField(verbose_name='Frequency (Binary)',validators=[MinValueValidator(0), MaxValueValidator(2**32-1)], blank=True, null=True) | |
|
20 | phase_reg = models.PositiveIntegerField(verbose_name='Phase (Binary)',validators=[MinValueValidator(0), MaxValueValidator(2**14-1)], blank=True, null=True) | |
|
21 | ||
|
16 | 22 | amplitude_chA = models.PositiveIntegerField(verbose_name='Amplitude CHA',validators=[MinValueValidator(0), MaxValueValidator(2**10-1)], blank=True, null=True) |
|
17 | 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 | 29 | class Meta: |
|
20 | 30 | db_table = 'dds_configurations' |
|
21 | 31 | No newline at end of file |
@@ -1,6 +1,6 | |||
|
1 | 1 | from django.conf.urls import url |
|
2 | 2 | |
|
3 | 3 | urlpatterns = ( |
|
4 |
url(r'^(?P<id_conf>-?\d+)/$', 'apps.dds.views.conf |
|
|
5 |
url(r'^(?P<id_conf>-?\d+)/edit/$', 'apps.dds.views. |
|
|
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.edit_dds_conf', name='url_edit_dds_conf'), | |
|
6 | 6 | ) |
@@ -1,57 +1,49 | |||
|
1 | 1 | # Create your views here. |
|
2 | 2 | |
|
3 | 3 | from django.shortcuts import redirect, render |
|
4 | 4 | |
|
5 | from apps.main.models import Device | |
|
6 | 5 | from .models import DDSConfiguration |
|
7 | 6 | from .forms import DDSConfigurationForm |
|
8 | 7 | # Create your views here. |
|
9 | 8 | |
|
10 |
def conf |
|
|
9 | def dds_conf(request, id_conf): | |
|
11 | 10 | |
|
12 | if 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) | |
|
11 | dev_conf = DDSConfiguration.objects.get(pk=id_conf) | |
|
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) | |
|
50 | form = DDSConfigurationForm(instance=conf) | |
|
36 | if request.method=='POST': | |
|
37 | form = DDSConfigurationForm(request.POST, instance=dev_conf) | |
|
51 | 38 | |
|
52 | 39 | if form.is_valid(): |
|
53 | 40 | form.save() |
|
54 | else: | |
|
55 | raise ValueError, "Error" | |
|
56 | ||
|
57 | return redirect('url_conf_dds', id_conf=id_conf) No newline at end of file | |
|
41 | return redirect('url_dds_conf', id_conf=id_conf) | |
|
42 | ||
|
43 | kwargs = {} | |
|
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 |
@@ -1,15 +1,15 | |||
|
1 | 1 | from django import forms |
|
2 | 2 | from apps.main.models import Device |
|
3 | 3 | from .models import JARSConfiguration |
|
4 | 4 | |
|
5 | 5 | class JARSConfigurationForm(forms.ModelForm): |
|
6 | 6 | def __init__(self, *args, **kwargs): |
|
7 | 7 | super(JARSConfigurationForm, self).__init__(*args, **kwargs) |
|
8 | 8 | instance = getattr(self, 'instance', None) |
|
9 | 9 | if instance and instance.pk: |
|
10 | 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 | 13 | class Meta: |
|
14 | 14 | model = JARSConfiguration |
|
15 | 15 | exclude = ('parameters', 'status') |
@@ -1,31 +1,31 | |||
|
1 | 1 | from django.shortcuts import render_to_response |
|
2 | 2 | from django.template import RequestContext |
|
3 | 3 | |
|
4 | 4 | from apps.main.models import Device |
|
5 | 5 | from .models import JARSConfiguration |
|
6 | 6 | from .forms import JARSConfigurationForm |
|
7 | 7 | # Create your views here. |
|
8 | 8 | |
|
9 | 9 | def jars_config(request, id): |
|
10 | 10 | |
|
11 | 11 | if id: |
|
12 | 12 | conf = JARSConfiguration.objects.get(pk=id) |
|
13 | 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 | 15 | for device in devices: |
|
16 |
if device['device_type__ |
|
|
16 | if device['device_type__name']=='jars': | |
|
17 | 17 | device['active'] = 'active' |
|
18 | 18 | form = JARSConfigurationForm(instance=conf) |
|
19 | 19 | else: |
|
20 | 20 | form = JARSConfigurationForm() |
|
21 | 21 | |
|
22 | 22 | kwargs = { |
|
23 | 23 | 'form': form, |
|
24 | 24 | 'devices':devices, |
|
25 | 25 | } |
|
26 | 26 | |
|
27 | 27 | return render_to_response('jars.html', kwargs, context_instance=RequestContext(request)) |
|
28 | 28 | |
|
29 | 29 | |
|
30 | 30 | |
|
31 | 31 |
@@ -1,8 +1,8 | |||
|
1 | 1 | from django.contrib import admin |
|
2 | from .models import Device, DeviceType, Experiment | |
|
2 | from .models import Device, DeviceType, Experiment, Campaign | |
|
3 | 3 | |
|
4 | 4 | # Register your models here. |
|
5 | ||
|
5 | admin.site.register(Campaign) | |
|
6 | 6 | admin.site.register(Experiment) |
|
7 | 7 | admin.site.register(Device) |
|
8 | 8 | admin.site.register(DeviceType) No newline at end of file |
@@ -1,37 +1,60 | |||
|
1 | 1 | from django import forms |
|
2 | 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 | 6 | def add_empty_choice(choices, pos=0, label='-----'): |
|
7 | 7 | if len(choices)>0: |
|
8 | 8 | choices = list(choices) |
|
9 | 9 | choices.insert(0, (0, label)) |
|
10 | 10 | return choices |
|
11 | 11 | else: |
|
12 | 12 | return [(0, label)] |
|
13 | 13 | |
|
14 | 14 | class DatepickerWidget(forms.widgets.TextInput): |
|
15 | 15 | def render(self, name, value, attrs=None): |
|
16 | 16 | input_html = super(DatepickerWidget, self).render(name, value, attrs) |
|
17 | 17 | html = '<div class="input-group date">'+input_html+'<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span></div>' |
|
18 | 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 | 27 | def __init__(self, *args, **kwargs): |
|
22 |
super( |
|
|
28 | super(CampaignForm, self).__init__(*args, **kwargs) | |
|
23 | 29 | self.fields['start_date'].widget = DatepickerWidget(self.fields['start_date'].widget.attrs) |
|
24 | 30 | self.fields['end_date'].widget = DatepickerWidget(self.fields['end_date'].widget.attrs) |
|
25 | 31 | |
|
26 | 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 | 45 | model = Experiment |
|
28 |
fields = ['name', ' |
|
|
46 | fields = ['campaign', 'name', 'start_time', 'end_time'] | |
|
29 | 47 | |
|
30 |
class |
|
|
48 | class DeviceForm(forms.ModelForm): | |
|
31 | 49 | class Meta: |
|
32 | 50 | model = Device |
|
33 | 51 | exclude = ['status'] |
|
34 | 52 | |
|
53 | class ConfigurationForm(forms.ModelForm): | |
|
54 | class Meta: | |
|
55 | model = Configuration | |
|
56 | fields = ['experiment', 'device'] | |
|
57 | ||
|
35 | 58 | class DeviceTypeForm(forms.Form): |
|
36 | 59 | device_type = forms.ChoiceField(choices=add_empty_choice(DeviceType.objects.all().order_by('name').values_list('id', 'name'))) |
|
37 | 60 |
@@ -1,69 +1,95 | |||
|
1 | 1 | from itertools import chain |
|
2 | 2 | from django.db import models |
|
3 | 3 | from polymorphic import PolymorphicModel |
|
4 | 4 | |
|
5 | 5 | STATES = ( |
|
6 | 6 | (0, 'Inactive'), |
|
7 | 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 | 22 | class DeviceType(models.Model): |
|
13 | 23 | |
|
14 |
name = models.CharField(max_length= |
|
|
15 | alias = models.CharField(max_length=40) | |
|
16 |
in |
|
|
17 | status = models.PositiveSmallIntegerField(default=1, choices=STATES) | |
|
24 | name = models.CharField(max_length = 10, choices = DEV_TYPES, default = 'rc') | |
|
25 | ||
|
26 | description = models.TextField(blank=True, null=True) | |
|
27 | ||
|
28 | # info = models.TextField(blank=True, null=True) | |
|
29 | # status = models.PositiveSmallIntegerField(default=1, choices=STATES) | |
|
18 | 30 | |
|
19 | 31 | class Meta: |
|
20 | db_table = 'device_types' | |
|
32 | db_table = 'db_device_types' | |
|
21 | 33 | |
|
22 | 34 | def __unicode__(self): |
|
23 |
return u'%s' % self. |
|
|
35 | return u'%s' % self.name | |
|
24 | 36 | |
|
25 | 37 | class Device(models.Model): |
|
26 | 38 | |
|
27 | 39 | device_type = models.ForeignKey(DeviceType) |
|
28 | 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 | 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 | 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 | 49 | class Meta: |
|
37 | db_table = 'devices' | |
|
50 | db_table = 'db_devices' | |
|
38 | 51 | |
|
39 | 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 | 70 | class Experiment(models.Model): |
|
43 | 71 | |
|
44 | name = models.CharField(max_length=40) | |
|
45 |
|
|
|
46 |
start_ |
|
|
47 |
end_ |
|
|
48 | template = models.BooleanField(default=False) | |
|
49 | status = models.PositiveSmallIntegerField(default=1, choices=STATES) | |
|
72 | campaign = models.ForeignKey(Campaign) | |
|
73 | name = models.CharField(max_length=40, default='') | |
|
74 | start_time = models.TimeField(default='00:00:00') | |
|
75 | end_time = models.TimeField(default='23:59:59') | |
|
50 | 76 | |
|
51 | 77 | class Meta: |
|
52 | db_table = 'experiments' | |
|
78 | db_table = 'db_experiments' | |
|
53 | 79 | |
|
54 | 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 | 83 | class Configuration(PolymorphicModel): |
|
58 | 84 | |
|
59 | 85 | experiment = models.ForeignKey(Experiment) |
|
60 | 86 | device = models.ForeignKey(Device) |
|
61 | parameters = models.TextField(default='{}') | |
|
62 | status = models.PositiveSmallIntegerField(default=1, choices=STATES) | |
|
87 | # parameters = models.TextField(default='{}') | |
|
88 | # status = models.PositiveSmallIntegerField(default=1, choices=STATES) | |
|
63 | 89 | |
|
64 | 90 | class Meta: |
|
65 | db_table = 'configurations' | |
|
91 | db_table = 'db_configurations' | |
|
66 | 92 | |
|
67 | 93 | def __unicode__(self): |
|
68 |
return u'%s |
|
|
94 | return u'%s [%s]' % (self.experiment.name, self.device.name) | |
|
69 | 95 | No newline at end of file |
@@ -1,112 +1,117 | |||
|
1 | 1 | <!DOCTYPE html> |
|
2 | 2 | {% load static %} |
|
3 | 3 | <html lang="en"> |
|
4 | 4 | <head> |
|
5 | 5 | <meta charset="utf-8"> |
|
6 | 6 | <title>{% block title %}Jicamarca Integrated Radar System:::::{% endblock %}</title> |
|
7 | 7 | <meta name="description" content=""> |
|
8 | 8 | <meta name="author" content=""> |
|
9 | 9 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
|
10 | 10 | {# bootstrap_css #} |
|
11 | 11 | <link href="{% static 'css/bootstrap-flatly.min.css' %}" media="screen" rel="stylesheet"> |
|
12 | 12 | <style type="text/css"> |
|
13 | 13 | body {padding-top: 60px} |
|
14 | 14 | .logo {padding-top: 5px; height: 50px} |
|
15 | 15 | .clickable-row {cursor: pointer;} |
|
16 | 16 | </style> |
|
17 | 17 | <!--[if lt IE 9]> |
|
18 | 18 | <script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script> |
|
19 | 19 | <![endif]--> |
|
20 | 20 | {% block extra-head %} |
|
21 | 21 | {% endblock %} |
|
22 | 22 | </head> |
|
23 | 23 | |
|
24 | 24 | <body> |
|
25 | 25 | |
|
26 | 26 | {% block main_menu %} |
|
27 | 27 | <nav class="navbar navbar-default navbar-fixed-top" role="banner"> |
|
28 | 28 | <div class="container-fluid"> |
|
29 | 29 | <div class="navbar-header"> |
|
30 | 30 | <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navigationbar"> |
|
31 | 31 | <span class="sr-only">Toggle navigation</span> |
|
32 | 32 | <span class="icon-bar"></span> |
|
33 | 33 | <span class="icon-bar"></span> |
|
34 | 34 | <span class="icon-bar"></span> |
|
35 | 35 | </button> |
|
36 | 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 | 37 | </div> |
|
38 | 38 | <div class="collapse navbar-collapse" id="navigationbar"> |
|
39 |
<ul class="nav navbar-nav"> |
|
|
40 |
<li class=" dropdown {% block |
|
|
39 | <ul class="nav navbar-nav"> | |
|
40 | <li class=" dropdown {% block camp-active %}{% endblock %}"><a href="{% url 'url_campaigns'%}">Campaigns</a> | |
|
41 | 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 | 47 | </li> |
|
44 | 48 | </ul> |
|
45 | 49 | <ul class="nav navbar-nav navbar-right"> |
|
46 | 50 | <li class="nav-divider"></li> |
|
47 | 51 | {% if user.is_authenticated %} |
|
48 | 52 | <li class="dropdown"> |
|
49 | 53 | <a href="#" class="dropdown-toggle" data-toggle="dropdown">Hi {{ user.username }}<span class="caret"></span></a> |
|
50 | 54 | <ul class="dropdown-menu" role="menu"> |
|
51 | 55 | <li><a href="#">Control Panel</a></li> |
|
52 | 56 | <li><a href="{% url 'django.contrib.auth.views.logout' %}">Logout</a></li> |
|
53 | 57 | </ul> |
|
54 | 58 | </li> |
|
55 | 59 | {% else %} |
|
56 | 60 | <li><a href="{% url 'django.contrib.auth.views.login' %}?next={{request.get_full_path}}">Login</a></li> |
|
57 | 61 | {% endif %} |
|
58 | 62 | </ul> |
|
59 | 63 | </div> |
|
60 | 64 | </div> |
|
61 | 65 | </nav> |
|
62 | 66 | <div style="clear: both;"></div> |
|
63 | 67 | {% endblock %} |
|
64 | 68 | |
|
65 | 69 | <div class="container"> |
|
66 | 70 | <div id="page" class="row" style="min-height:600px"> |
|
67 | 71 | |
|
68 | 72 | <div class="col-md-3 hidden-xs hidden-sm" role="complementary"> |
|
69 | 73 | <br><br> |
|
70 | 74 | <div id="sidebar"> |
|
71 | 75 | {% block sidebar%} |
|
72 | 76 | {% endblock %} |
|
73 | 77 | </div> |
|
74 | 78 | </div> |
|
75 | 79 | |
|
76 | 80 | <div class="col-md-9 col-xs-12" role="main"> |
|
77 | 81 | <div class="page-header"> |
|
78 | 82 | <h1>{% block content-title %}{% endblock %} <small>{% block content-suptitle %}{% endblock %}</small></h1> |
|
79 | 83 | <hr> |
|
80 | 84 | </div> |
|
81 | 85 | {% block content %} |
|
82 | 86 | {% endblock %} |
|
83 | 87 | <br> |
|
84 | 88 | {% block messages %} |
|
85 | 89 | {% endblock %} |
|
86 | 90 | </div> |
|
87 | 91 | |
|
88 | 92 | |
|
89 | 93 | </div><!--/row--> |
|
90 | 94 | </div> <!-- container --> |
|
91 | 95 | |
|
92 | 96 | <div id="debug">{{debug}}</div> |
|
93 | 97 | |
|
94 | 98 | {% block footer %} |
|
95 | 99 | <footer class="footer"> |
|
96 | 100 | <div class="container"> |
|
97 | 101 | <p><hr></p> |
|
98 | 102 | <p> |
|
99 | 103 | © <a href="http://jro.igp.gob.pe">Jicamarca Radio Observatory</a> - {% now "Y" %} |
|
100 | 104 | </p> |
|
101 | 105 | </div> |
|
102 | 106 | </footer> |
|
103 | 107 | {% endblock %} |
|
104 | 108 | |
|
105 | 109 | {# bootstrap_javascript jquery=True #} |
|
106 | 110 | <script src="{% static 'js/jquery.min.js' %}"></script> |
|
107 | 111 | <script src="{% static 'js/bootstrap.min.js' %}"></script> |
|
112 | ||
|
108 | 113 | {% block extra-js %} |
|
109 | 114 | {% endblock%} |
|
110 | 115 | </body> |
|
111 | 116 | </html> |
|
112 | 117 |
@@ -1,20 +1,26 | |||
|
1 | 1 | {% extends "base.html" %} |
|
2 | 2 | {% load bootstrap3 %} |
|
3 | {% block mainactive %}active{% endblock %} | |
|
3 | {% load static %} | |
|
4 | {% load main_tags %} | |
|
4 | 5 | |
|
5 |
{% block con |
|
|
6 | {% block content-suptitle %}{{device.device_type__name}}{% endblock %} | |
|
6 | {% block conf-active %}active{% endblock %} | |
|
7 | ||
|
8 | {% block content-title %}{{title}}{% endblock %} | |
|
9 | {% block content-suptitle %}{{suptitle}}{% endblock %} | |
|
7 | 10 | |
|
8 | 11 | {% block content %} |
|
9 | 12 | <form class="form" method="post" action=""> |
|
10 | {% csrf_token %} | |
|
11 | {% bootstrap_form form layout='horizontal' size='medium' %} | |
|
12 | <div style="clear: both;"></div> | |
|
13 | <br> | |
|
14 |
<button type="submit" class="btn btn-primary pull-right" |
|
|
13 | {% csrf_token %} | |
|
14 | {% bootstrap_form form layout='horizontal' size='medium' %} | |
|
15 | <div style="clear: both;"></div> | |
|
16 | <br> | |
|
17 | <button type="submit" class="btn btn-primary pull-right">{{button}}</button> | |
|
15 | 18 | </form> |
|
16 | 19 | {% endblock %} |
|
17 | 20 | |
|
18 | 21 | {% block sidebar%} |
|
19 | 22 | {% include "sidebar_devices.html" %} |
|
23 | {% endblock %} | |
|
24 | ||
|
25 | {% block extra-js%} | |
|
20 | 26 | {% endblock %} No newline at end of file |
@@ -1,53 +1,36 | |||
|
1 | 1 | {% extends "base.html" %} |
|
2 | 2 | {% load bootstrap3 %} |
|
3 | 3 | {% load static %} |
|
4 | 4 | {% load main_tags %} |
|
5 | 5 | |
|
6 | 6 | {% block dev-active %}active{% endblock %} |
|
7 | 7 | |
|
8 |
{% block content-title %} |
|
|
8 | {% block content-title %}{{title}}{% endblock %} | |
|
9 | 9 | {% block content-suptitle %}{{suptitle}}{% endblock %} |
|
10 | 10 | |
|
11 | 11 | {% block content %} |
|
12 | ||
|
13 | {% if form %} | |
|
14 | <form class="form" method="post" action="{{action}}"> | |
|
15 | {% csrf_token %} | |
|
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 %} | |
|
12 | <table class="table table-bordered"> | |
|
13 | {% for key in device_keys %} | |
|
14 | <tr><th>{{key|title}}</th><td>{{device|attr:key}}</td></tr> | |
|
15 | {% endfor %} | |
|
37 | 16 | </table> |
|
38 |
<button class="btn btn-primary pull-right" id="bt_ |
|
|
39 | {% endif %} | |
|
17 | <button class="btn btn-primary pull-right" id="bt_edit_device">Edit Device</button> | |
|
18 | <br></br> | |
|
19 | <br></br> | |
|
20 | {% endblock %} | |
|
40 | 21 | |
|
22 | {% block sidebar%} | |
|
23 | {% include "sidebar_devices.html" %} | |
|
41 | 24 | {% endblock %} |
|
42 | 25 | |
|
43 | 26 | {% block extra-js%} |
|
44 | <script type="text/javascript"> | |
|
45 | $(".clickable-row").click(function() { | |
|
46 | document.location = $(this).data("href"); | |
|
47 | }); | |
|
27 | <script src="{% static 'js/moment.min.js' %}"></script> | |
|
28 | <script src="{% static 'js/bootstrap-datetimepicker.min.js' %}"></script> | |
|
29 | <script type="text/javascript"> | |
|
48 | 30 | |
|
49 |
$("#bt_ |
|
|
50 |
document.location = " |
|
|
31 | $("#bt_edit_device").click(function() { | |
|
32 | document.location = "{% url 'url_edit_device' device.id%}"; | |
|
51 | 33 | }); |
|
34 | ||
|
52 | 35 | </script> |
|
53 | 36 | {% endblock %} No newline at end of file |
@@ -1,164 +1,83 | |||
|
1 | 1 | {% extends "base.html" %} |
|
2 | 2 | {% load bootstrap3 %} |
|
3 | 3 | {% load static %} |
|
4 | 4 | {% load main_tags %} |
|
5 | 5 | {% block extra-head %} |
|
6 | 6 | <link href="{% static 'css/bootstrap-datetimepicker.min.css' %}" media="screen" rel="stylesheet"> |
|
7 | 7 | {% endblock %} |
|
8 | 8 | |
|
9 | 9 | {% block exp-active %}active{% endblock %} |
|
10 | 10 | |
|
11 |
{% block content-title %} |
|
|
11 | {% block content-title %}{{title}}{% endblock %} | |
|
12 | 12 | {% block content-suptitle %}{{suptitle}}{% endblock %} |
|
13 | 13 | |
|
14 | 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 | 15 | <table class="table table-bordered"> |
|
25 | 16 | {% for key in experiment_keys %} |
|
26 | 17 | <tr><th>{{key|title}}</th><td>{{experiment|attr:key}}</td></tr> |
|
27 | 18 | {% endfor %} |
|
28 | 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 | 24 | <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> | |
|
25 | ||
|
52 | 26 | <div class="panel panel-default"> |
|
53 | 27 | <div class="panel-heading" role="tab" id="headingTwo"> |
|
54 | 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 |
|
|
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"> | |
|
29 | <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseThree"> | |
|
93 | 30 | Experiment's Devices |
|
94 | 31 | </a> |
|
95 | 32 | </h4> |
|
96 | 33 | </div> |
|
97 |
<div id="collapseT |
|
|
34 | <div id="collapseTwo" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingTwo"> | |
|
98 | 35 | <div class="panel-body"> |
|
99 | 36 | <table class="table table-hover"> |
|
100 | 37 | <tr> |
|
101 | 38 | <th>#</th> |
|
102 |
{% for |
|
|
103 |
<th>{{ |
|
|
39 | {% for key in configuration_keys %} | |
|
40 | <th>{{ key|title }}</th> | |
|
104 | 41 | {% endfor%} |
|
105 | 42 | </tr> |
|
106 |
{% for item in |
|
|
107 |
<tr class="clickable-row" data-href="/{{item.device_type__ |
|
|
43 | {% for item in configurations %} | |
|
44 | <tr class="clickable-row" data-href="/{{item.device__device_type__name}}/{{item.id}}/"> | |
|
108 | 45 | <td>{{ forloop.counter }}</td> |
|
109 |
{% for key in |
|
|
46 | {% for key in configuration_keys %} | |
|
110 | 47 | <td>{{ item|attr:key }}</td> |
|
111 | 48 | {% endfor %} |
|
112 | 49 | </tr> |
|
113 | 50 | {% endfor %} |
|
114 | 51 | </table> |
|
52 | <button class="btn btn-primary pull-right" id="bt_add_conf">{{button}}</button> | |
|
115 | 53 | </div> |
|
116 | 54 | </div> |
|
117 | 55 | </div> |
|
118 | 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 | 57 | {% endblock %} |
|
140 | 58 | |
|
141 | 59 | {% block sidebar%} |
|
142 | 60 | {% include "sidebar_devices.html" %} |
|
143 | 61 | {% endblock %} |
|
144 | 62 | |
|
145 | 63 | {% block extra-js%} |
|
146 | 64 | |
|
147 | 65 | <script src="{% static 'js/moment.min.js' %}"></script> |
|
148 | 66 | <script src="{% static 'js/bootstrap-datetimepicker.min.js' %}"></script> |
|
149 | 67 | <script type="text/javascript"> |
|
150 | 68 | $('.input-group.date').datetimepicker({"format": "YYYY-MM-DD HH:mm"}); |
|
151 | 69 | |
|
152 | 70 | $(".clickable-row").click(function() { |
|
153 | 71 | document.location = $(this).data("href"); |
|
154 | 72 | }); |
|
155 | 73 | |
|
156 |
$("#bt_ |
|
|
157 | document.location = "add"; | |
|
158 | }); | |
|
74 | $("#bt_edit_experiment").click(function() { | |
|
75 | document.location = "{% url 'url_edit_experiment' experiment.id%}"; | |
|
76 | }); | |
|
159 | 77 | |
|
160 |
$("# |
|
|
161 |
document.location = "{% url 'experiment |
|
|
78 | $("#bt_add_conf").click(function() { | |
|
79 | document.location = "{% url 'url_add_dev_conf' experiment.id%}"; | |
|
162 | 80 | }); |
|
81 | ||
|
163 | 82 | </script> |
|
164 | 83 | {% endblock %} No newline at end of file |
@@ -1,23 +1,23 | |||
|
1 | 1 | {% if experiment %} |
|
2 | 2 | <div class="panel panel-default"> |
|
3 | 3 | <div class="panel-heading"> |
|
4 | 4 | <h3>Experiment</h3> |
|
5 | 5 | </div> |
|
6 | 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 | 8 | </div> |
|
9 | 9 | </div> |
|
10 | 10 | {% endif %} |
|
11 | 11 | |
|
12 | 12 | {% if devices %} |
|
13 | 13 | <div class="panel panel-default"> |
|
14 | 14 | <div class="panel-heading"> |
|
15 | 15 | <h3>Devices</h3> |
|
16 | 16 | </div> |
|
17 | 17 | <div class="list-group"> |
|
18 | 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 | 20 | {% endfor %} |
|
21 | 21 | </div> |
|
22 | 22 | </div> |
|
23 | 23 | {% endif %} No newline at end of file |
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 |
|
|
2 | from django.template import RequestContext | |
|
3 | from .forms import NewExperimentForm, NewDeviceForm, DeviceTypeForm | |
|
1 | from django.shortcuts import render, redirect | |
|
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 | 12 | from apps.cgs.models import CGSConfiguration |
|
7 | 13 | from apps.jars.models import JARSConfiguration |
|
8 |
|
|
|
14 | from apps.usrp.models import USRPConfiguration | |
|
9 | 15 | from apps.abs.models import ABSConfiguration |
|
10 | 16 | from apps.rc.models import RCConfiguration |
|
11 | 17 | from apps.dds.models import DDSConfiguration |
|
12 | 18 | |
|
13 | 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 | 31 | 'rc': RCConfiguration, |
|
17 | 32 | 'dds': DDSConfiguration, |
|
18 | 33 | 'jars': JARSConfiguration, |
|
19 | 34 | 'cgs': CGSConfiguration, |
|
20 | 35 | 'abs': ABSConfiguration, |
|
36 | 'usrp': USRPConfiguration, | |
|
21 | 37 | } |
|
22 | 38 | |
|
23 | 39 | def index(request): |
|
24 | 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 | 65 | kwargs = {} |
|
30 | if id_exp: | |
|
31 | experiment = Experiment.objects.get(pk=id_exp) | |
|
32 | devices = Device.objects.filter(configuration__experiment=experiment) | |
|
33 | kwargs['experiment'] = experiment | |
|
34 | kwargs['experiment_keys'] = ['name', 'alias', 'start_date', 'end_date'] | |
|
66 | kwargs['device'] = device | |
|
67 | kwargs['device_keys'] = ['device_type', 'name', 'ip_address', 'port_address', 'description'] | |
|
68 | ||
|
69 | kwargs['title'] = 'Device' | |
|
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: | |
|
39 | subform = DeviceTypeForm(initial={'device_type':id_dev_type}) | |
|
40 | kwargs['keys'] = ['model', 'ip_address', 'status'] | |
|
41 | keys = ['id']+kwargs['keys'] | |
|
42 | kwargs['items'] = Device.objects.filter(device_type=id_dev_type).values(*keys) | |
|
43 | else: | |
|
44 | subform = DeviceTypeForm() | |
|
89 | kwargs = {} | |
|
90 | kwargs['form'] = form | |
|
91 | kwargs['title'] = 'Device' | |
|
92 | kwargs['suptitle'] = 'New' | |
|
93 | kwargs['button'] = 'Create' | |
|
45 | 94 | |
|
46 | kwargs['form'] = form | |
|
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)) | |
|
95 | return render(request, 'device_edit.html', kwargs) | |
|
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 | 104 | if request.method=='POST': |
|
65 | experiment = Experiment.objects.get(pk=id_exp) | |
|
66 | form = NewExperimentForm(request.POST, instance=experiment) | |
|
105 | form = DeviceForm(request.POST, instance=device) | |
|
106 | ||
|
67 | 107 | if form.is_valid(): |
|
68 | 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 | 185 | if request.method=='POST': |
|
73 | experiment = Experiment.objects.get(pk=id_exp) | |
|
74 | device = Device.objects.get(pk=request.POST['device']) | |
|
75 | model = MODELS[device.device_type.alias] | |
|
76 | conf = model(experiment=experiment, device=device) | |
|
77 | conf.save() | |
|
78 | return redirect('experiment', id_exp=id_exp) | |
|
186 | form = CampaignForm(request.POST, instance=campaign) | |
|
187 | ||
|
188 | if form.is_valid(): | |
|
189 | form.save() | |
|
190 | return redirect('url_campaign', id_camp=id_camp) | |
|
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 | 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 | 251 | if request.method == 'POST': |
|
83 |
form = |
|
|
252 | form = ExperimentForm(request.POST, initial={'campaign':id_camp}) | |
|
253 | ||
|
84 | 254 | if form.is_valid(): |
|
85 | 255 | experiment = form.save() |
|
86 | return redirect('experiment', id_exp=experiment.id) | |
|
87 |
|
|
|
88 | form = NewExperimentForm() | |
|
89 |
kwargs['form |
|
|
256 | return redirect('url_experiment', id_exp=experiment.id) | |
|
257 | ||
|
258 | kwargs = {} | |
|
259 | kwargs['form'] = form | |
|
90 | 260 | kwargs['title'] = 'Experiment' |
|
91 | 261 | kwargs['suptitle'] = 'New' |
|
92 |
kwargs[' |
|
|
93 | return render_to_response("experiment.html", kwargs, context_instance=RequestContext(request)) | |
|
94 | ||
|
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)) | |
|
262 | kwargs['button'] = 'Create' | |
|
263 | ||
|
264 | return render(request, 'experiment_edit.html', kwargs) | |
|
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 | 273 | if request.method=='POST': |
|
114 | device = Device.objects.get(pk=id_dev) | |
|
115 | form = NewDeviceForm(request.POST, instance=device) | |
|
274 | form = ExperimentForm(request.POST, instance=experiment) | |
|
275 | ||
|
116 | 276 | if form.is_valid(): |
|
117 | form.save() | |
|
118 | return redirect('devices') | |
|
277 | experiment = form.save() | |
|
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 | 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 | 328 | if request.method == 'POST': |
|
123 |
form = |
|
|
329 | form = ConfigurationForm(request.POST) | |
|
330 | ||
|
124 | 331 | if form.is_valid(): |
|
125 | form.save() | |
|
126 | return redirect('devices') | |
|
127 | else: | |
|
128 | form = NewDeviceForm() | |
|
332 | experiment = Experiment.objects.get(pk=request.POST['experiment']) | |
|
333 | device = Device.objects.get(pk=request.POST['device']) | |
|
334 | ||
|
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 | 346 | kwargs['form'] = form |
|
130 |
kwargs[' |
|
|
347 | kwargs['title'] = 'Configuration' | |
|
131 | 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 | 1 | from django.conf.urls import url |
|
2 | 2 | |
|
3 | 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 | 1 | from django.db import models |
|
2 | ||
|
2 | from apps.main.models import Configuration | |
|
3 | 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 | 1 | from django.conf.urls import url |
|
2 | 2 | |
|
3 | 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 | ) |
@@ -1,40 +1,31 | |||
|
1 | 1 | """radarsys URL Configuration |
|
2 | 2 | |
|
3 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: |
|
4 | 4 | https://docs.djangoproject.com/en/1.8/topics/http/urls/ |
|
5 | 5 | Examples: |
|
6 | 6 | Function views |
|
7 | 7 | 1. Add an import: from my_app import views |
|
8 | 8 | 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') |
|
9 | 9 | Class-based views |
|
10 | 10 | 1. Add an import: from other_app.views import Home |
|
11 | 11 | 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') |
|
12 | 12 | Including another URLconf |
|
13 | 13 | 1. Add an import: from blog import urls as blog_urls |
|
14 | 14 | 2. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) |
|
15 | 15 | """ |
|
16 | 16 | from django.conf.urls import include, url |
|
17 | 17 | from django.contrib import admin |
|
18 | 18 | |
|
19 | 19 | urlpatterns = [ |
|
20 | 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 | 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 | 24 | url(r'^rc/', include('apps.rc.urls')), |
|
34 | 25 | url(r'^dds/', include('apps.dds.urls')), |
|
35 | 26 | url(r'^cgs/', include('apps.cgs.urls')), |
|
36 | 27 | url(r'^jars/', include('apps.jars.urls')), |
|
37 | 28 | url(r'^usrp/', include('apps.usrp.urls')), |
|
38 | 29 | url(r'^abs/', include('apps.abs.urls')), |
|
39 | 30 | url(r'^misc/', include('apps.misc.urls')), |
|
40 | 31 | ] |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now