@@ -0,0 +1,47 | |||||
|
1 | {% extends "dev_conf_edit.html" %} | |||
|
2 | {% load bootstrap3 %} | |||
|
3 | {% load static %} | |||
|
4 | {% load main_tags %} | |||
|
5 | ||||
|
6 | {% block extra-js%} | |||
|
7 | <script type="text/javascript"> | |||
|
8 | $("#id_exp_type").on('change', function() { | |||
|
9 | }); | |||
|
10 | ||||
|
11 | $("#id_channels_number").on('change', function() { | |||
|
12 | updateChannelsNumber(); | |||
|
13 | }); | |||
|
14 | ||||
|
15 | function updateChannelsNumber() { | |||
|
16 | ||||
|
17 | var channels_number = $("#id_channels_number").val(); | |||
|
18 | channels = $("#id_channels") | |||
|
19 | ||||
|
20 | if (channels_number == 1) { | |||
|
21 | $(channels).val('1') | |||
|
22 | } | |||
|
23 | else if (channels_number == 2){ | |||
|
24 | $(channels).val('1,2') | |||
|
25 | } | |||
|
26 | else if (channels_number == 3){ | |||
|
27 | $(channels).val('1,2,3') | |||
|
28 | } | |||
|
29 | else if (channels_number == 4){ | |||
|
30 | $(channels).val('1,2,3,4') | |||
|
31 | } | |||
|
32 | else if (channels_number == 5){ | |||
|
33 | $(channels).val('1,2,3,4,5') | |||
|
34 | } | |||
|
35 | else if (channels_number == 6){ | |||
|
36 | $(channels).val('1,2,3,4,5,6') | |||
|
37 | } | |||
|
38 | else if (channels_number == 7){ | |||
|
39 | $(channels).val('1,2,3,5,6,7') | |||
|
40 | } | |||
|
41 | else { | |||
|
42 | $(channels).val('1,2,3,4,5,6,7,8') | |||
|
43 | } | |||
|
44 | ||||
|
45 | } | |||
|
46 | </script> | |||
|
47 | {% endblock %} No newline at end of file |
@@ -0,0 +1,47 | |||||
|
1 | {% extends "dev_conf_edit.html" %} | |||
|
2 | {% load bootstrap3 %} | |||
|
3 | {% load static %} | |||
|
4 | {% load main_tags %} | |||
|
5 | ||||
|
6 | {% block extra-js%} | |||
|
7 | <script type="text/javascript"> | |||
|
8 | $("#id_exp_type").on('change', function() { | |||
|
9 | }); | |||
|
10 | ||||
|
11 | $("#id_channels_number").on('change', function() { | |||
|
12 | updateChannelsNumber(); | |||
|
13 | }); | |||
|
14 | ||||
|
15 | function updateChannelsNumber() { | |||
|
16 | ||||
|
17 | var channels_number = $("#id_channels_number").val(); | |||
|
18 | channels = $("#id_channels") | |||
|
19 | ||||
|
20 | if (channels_number == 1) { | |||
|
21 | $(channels).val('1') | |||
|
22 | } | |||
|
23 | else if (channels_number == 2){ | |||
|
24 | $(channels).val('1,2') | |||
|
25 | } | |||
|
26 | else if (channels_number == 3){ | |||
|
27 | $(channels).val('1,2,3') | |||
|
28 | } | |||
|
29 | else if (channels_number == 4){ | |||
|
30 | $(channels).val('1,2,3,4') | |||
|
31 | } | |||
|
32 | else if (channels_number == 5){ | |||
|
33 | $(channels).val('1,2,3,4,5') | |||
|
34 | } | |||
|
35 | else if (channels_number == 6){ | |||
|
36 | $(channels).val('1,2,3,4,5,6') | |||
|
37 | } | |||
|
38 | else if (channels_number == 7){ | |||
|
39 | $(channels).val('1,2,3,5,6,7') | |||
|
40 | } | |||
|
41 | else { | |||
|
42 | $(channels).val('1,2,3,4,5,6,7,8') | |||
|
43 | } | |||
|
44 | ||||
|
45 | } | |||
|
46 | </script> | |||
|
47 | {% endblock %} No newline at end of file |
@@ -1,67 +1,103 | |||||
1 | from django.shortcuts import render_to_response |
|
1 | from django.shortcuts import render_to_response | |
2 | from django.template import RequestContext |
|
2 | from django.template import RequestContext | |
3 | from django.shortcuts import redirect, render, get_object_or_404 |
|
3 | from django.shortcuts import redirect, render, get_object_or_404 | |
4 |
|
4 | |||
5 | from apps.main.models import Device |
|
5 | from apps.main.models import Device | |
6 | from apps.main.views import sidebar |
|
6 | from apps.main.views import sidebar | |
7 |
|
7 | |||
8 | from .models import JARSConfiguration |
|
8 | from .models import JARSConfiguration | |
9 | from .forms import JARSConfigurationForm |
|
9 | from .forms import JARSConfigurationForm | |
10 | # Create your views here. |
|
10 | # Create your views here. | |
11 |
|
11 | |||
12 | def jars_conf(request, id_conf): |
|
12 | def jars_conf(request, id_conf): | |
13 |
|
13 | |||
14 | conf = get_object_or_404(JARSConfiguration, pk=id_conf) |
|
14 | conf = get_object_or_404(JARSConfiguration, pk=id_conf) | |
15 |
|
15 | |||
16 | ip=conf.device.ip_address |
|
16 | ip=conf.device.ip_address | |
17 | port=conf.device.port_address |
|
17 | port=conf.device.port_address | |
18 |
|
18 | |||
19 | kwargs = {} |
|
19 | kwargs = {} | |
20 |
|
20 | |||
21 | kwargs['status'] = conf.device.get_status_display() |
|
21 | kwargs['status'] = conf.device.get_status_display() | |
22 |
|
22 | |||
23 |
|
23 | |||
24 | kwargs['dev_conf'] = conf |
|
24 | kwargs['dev_conf'] = conf | |
25 | kwargs['dev_conf_keys'] = ['experiment', 'device', |
|
25 | kwargs['dev_conf_keys'] = ['experiment', 'device', | |
26 | 'cards_number', 'channels_number', |
|
26 | 'cards_number', 'channels_number', | |
27 | 'rd_directory', 'create_directory', |
|
27 | 'rd_directory', 'create_directory', | |
28 | 'include_expname', 'raw_data_blocks', |
|
28 | 'include_expname', 'raw_data_blocks', | |
29 | 'acq_profiles', 'profiles_block'] |
|
29 | 'acq_profiles', 'profiles_block'] | |
30 |
|
30 | |||
31 | kwargs['title'] = 'JARS Configuration' |
|
31 | kwargs['title'] = 'JARS Configuration' | |
32 | kwargs['suptitle'] = 'Details' |
|
32 | kwargs['suptitle'] = 'Details' | |
33 |
|
33 | |||
34 | kwargs['button'] = 'Edit Configuration' |
|
34 | kwargs['button'] = 'Edit Configuration' | |
35 |
|
35 | |||
36 | kwargs['no_play'] = True |
|
36 | kwargs['no_play'] = True | |
37 |
|
37 | |||
38 | ###### SIDEBAR ###### |
|
38 | ###### SIDEBAR ###### | |
39 | kwargs.update(sidebar(conf=conf)) |
|
39 | kwargs.update(sidebar(conf=conf)) | |
40 |
|
40 | |||
41 | return render(request, 'jars_conf.html', kwargs) |
|
41 | return render(request, 'jars_conf.html', kwargs) | |
42 |
|
42 | |||
43 | def jars_conf_edit(request, id_conf): |
|
43 | def jars_conf_edit(request, id_conf): | |
44 |
|
44 | |||
45 | conf = get_object_or_404(JARSConfiguration, pk=id_conf) |
|
45 | conf = get_object_or_404(JARSConfiguration, pk=id_conf) | |
46 |
|
46 | |||
47 | if request.method=='GET': |
|
47 | if request.method=='GET': | |
48 | form = JARSConfigurationForm(instance=conf) |
|
48 | form = JARSConfigurationForm(instance=conf) | |
49 |
|
49 | |||
50 | if request.method=='POST': |
|
50 | if request.method=='POST': | |
51 | form = JARSConfigurationForm(request.POST, instance=conf) |
|
51 | form = JARSConfigurationForm(request.POST, instance=conf) | |
52 |
|
52 | |||
53 | if form.is_valid(): |
|
53 | if form.is_valid(): | |
54 | conf = form.save(commit=False) |
|
54 | conf = form.save(commit=False) | |
55 | conf.save() |
|
55 | conf.save() | |
56 | return redirect('url_jars_conf', id_conf=conf.id) |
|
56 | return redirect('url_jars_conf', id_conf=conf.id) | |
57 |
|
57 | |||
58 | ##ERRORS |
|
58 | ##ERRORS | |
59 |
|
59 | |||
60 | kwargs = {} |
|
60 | kwargs = {} | |
61 | kwargs['id_dev'] = conf.id |
|
61 | kwargs['id_dev'] = conf.id | |
62 | kwargs['form'] = form |
|
62 | kwargs['form'] = form | |
63 | kwargs['title'] = 'Device Configuration' |
|
63 | kwargs['title'] = 'Device Configuration' | |
64 | kwargs['suptitle'] = 'Edit' |
|
64 | kwargs['suptitle'] = 'Edit' | |
65 | kwargs['button'] = 'Save' |
|
65 | kwargs['button'] = 'Save' | |
66 |
|
66 | |||
67 | return render(request, 'jars_conf_edit.html', kwargs) |
|
67 | return render(request, 'jars_conf_edit.html', kwargs) | |
|
68 | ||||
|
69 | def jars_conf_edit_prueba(request, id_conf, type): | |||
|
70 | ||||
|
71 | conf = get_object_or_404(JARSConfiguration, pk=id_conf) | |||
|
72 | ||||
|
73 | if request.method=='GET': | |||
|
74 | if type == 'PDATA': | |||
|
75 | form = JARSConfigurationForm_Pro(instance=conf) | |||
|
76 | html = 'jars_conf_edit_pro.html' | |||
|
77 | else: | |||
|
78 | form = JarsConfigurationForm_Raw(instance=conf) | |||
|
79 | html = 'jars_conf_edit_raw.html' | |||
|
80 | ||||
|
81 | if request.method=='POST': | |||
|
82 | if type == 'PDATA': | |||
|
83 | form = JARSConfigurationForm_Pro(instance=conf) | |||
|
84 | html = 'jars_conf_edit_pro.html' | |||
|
85 | else: | |||
|
86 | form = JarsConfigurationForm_Raw(instance=conf) | |||
|
87 | html = 'jars_conf_edit_raw.html' | |||
|
88 | ||||
|
89 | if form.is_valid(): | |||
|
90 | conf = form.save(commit=False) | |||
|
91 | conf.save() | |||
|
92 | return redirect('url_jars_conf', id_conf=conf.id) | |||
|
93 | ||||
|
94 | ##ERRORS | |||
|
95 | ||||
|
96 | kwargs = {} | |||
|
97 | kwargs['id_dev'] = conf.id | |||
|
98 | kwargs['form'] = form | |||
|
99 | kwargs['title'] = 'Device Configuration' | |||
|
100 | kwargs['suptitle'] = 'Edit' | |||
|
101 | kwargs['button'] = 'Save' | |||
|
102 | ||||
|
103 | return render(request, html, kwargs) No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now