##// END OF EJS Templates
Task #99: Modulo web del JARS...
Fiorella Quino -
r130:36666b44dc7e
parent child
Show More
@@ -46,10 +46,10 class JARSConfiguration(Configuration):
46 acq_profiles = models.PositiveIntegerField(verbose_name='Acquired Profiles', validators=[MaxValueValidator(5000)], default=400)
46 acq_profiles = models.PositiveIntegerField(verbose_name='Acquired Profiles', validators=[MaxValueValidator(5000)], default=400)
47 profiles_block = models.PositiveIntegerField(verbose_name='Profiles Per Block', validators=[MaxValueValidator(5000)], default=400)
47 profiles_block = models.PositiveIntegerField(verbose_name='Profiles Per Block', validators=[MaxValueValidator(5000)], default=400)
48 fftpoints = models.PositiveIntegerField(verbose_name='FFT Points',default=16)
48 fftpoints = models.PositiveIntegerField(verbose_name='FFT Points',default=16)
49 incohe_integr = models.PositiveIntegerField(verbose_name='Incoherent Integrations',validators=[MinValueValidator(1)], default = 30)
49 incohe_integr = models.PositiveIntegerField(verbose_name='Incoherent Integrations',validators=[MinValueValidator(1)], default=30)
50 filter = models.ForeignKey(JARSfilter, on_delete=models.CASCADE, null=True, blank=True)
50 filter = models.ForeignKey(JARSfilter, on_delete=models.CASCADE, null=True, blank=True)
51 spectral_number = models.PositiveIntegerField(verbose_name='# Spectral Combinations',validators=[MinValueValidator(1)], null=True, blank=True)
51 spectral_number = models.PositiveIntegerField(verbose_name='# Spectral Combinations',validators=[MinValueValidator(1)], default=1)
52 spectral = models.CharField(verbose_name='Combinations', max_length=5000, default = '[0,0]')
52 spectral = models.CharField(verbose_name='Combinations', max_length=5000, default = '[0, 0],')
53 create_directory = models.BooleanField(verbose_name='Create Directory Per Day', default=True)
53 create_directory = models.BooleanField(verbose_name='Create Directory Per Day', default=True)
54 include_expname = models.BooleanField(verbose_name='Experiment Name in Directory', default=True)
54 include_expname = models.BooleanField(verbose_name='Experiment Name in Directory', default=True)
55 acq_link = models.BooleanField(verbose_name='Acquisition Link', default=True)
55 acq_link = models.BooleanField(verbose_name='Acquisition Link', default=True)
@@ -14,6 +14,10 $(document).ready(function() {
14 save_ch_dc = $("#id_save_ch_dc")
14 save_ch_dc = $("#id_save_ch_dc")
15 add_spec_button = $("#add_spectral_button")
15 add_spec_button = $("#add_spectral_button")
16 del_spec_button = $("#delete_spectral_button")
16 del_spec_button = $("#delete_spectral_button")
17 sel_spec_button = $("#self_spectral_button")
18 cro_spec_button = $("#cross_spectral_button")
19 all_spec_button = $("#all_spectral_button")
20
17 if (type == 0) {
21 if (type == 0) {
18 $(spectral_number).attr('readonly', true);
22 $(spectral_number).attr('readonly', true);
19 $(spectral).attr('readonly', true);
23 $(spectral).attr('readonly', true);
@@ -22,7 +26,9 $(document).ready(function() {
22 $(save_ch_dc).attr('readonly', true);
26 $(save_ch_dc).attr('readonly', true);
23 $(add_spec_button).attr('disabled', true);
27 $(add_spec_button).attr('disabled', true);
24 $(del_spec_button).attr('disabled', true);
28 $(del_spec_button).attr('disabled', true);
25
29 $(sel_spec_button).attr('disabled', true);
30 $(cro_spec_button).attr('disabled', true);
31 $(all_spec_button).attr('disabled', true);
26 }
32 }
27 else {
33 else {
28 $(spectral_number).attr('readonly', false);
34 $(spectral_number).attr('readonly', false);
@@ -32,6 +38,9 $(document).ready(function() {
32 $(save_ch_dc).attr('readonly', false);
38 $(save_ch_dc).attr('readonly', false);
33 $(add_spec_button).attr('disabled', false);
39 $(add_spec_button).attr('disabled', false);
34 $(del_spec_button).attr('disabled', false);
40 $(del_spec_button).attr('disabled', false);
41 $(sel_spec_button).attr('disabled', false);
42 $(cro_spec_button).attr('disabled', false);
43 $(all_spec_button).attr('disabled', false);
35 }
44 }
36 });
45 });
37
46
@@ -43,6 +52,10 $("#id_exp_type").change(function() {
43 save_ch_dc = $("#id_save_ch_dc")
52 save_ch_dc = $("#id_save_ch_dc")
44 add_spec_button = $("#add_spectral_button")
53 add_spec_button = $("#add_spectral_button")
45 del_spec_button = $("#delete_spectral_button")
54 del_spec_button = $("#delete_spectral_button")
55 sel_spec_button = $("#self_spectral_button")
56 cro_spec_button = $("#cross_spectral_button")
57 all_spec_button = $("#all_spectral_button")
58
46 if (type == 0) {
59 if (type == 0) {
47 $(spectral_number).attr('readonly', true);
60 $(spectral_number).attr('readonly', true);
48 $(spectral).attr('readonly', true);
61 $(spectral).attr('readonly', true);
@@ -51,7 +64,9 $("#id_exp_type").change(function() {
51 $(save_ch_dc).attr('readonly', true);
64 $(save_ch_dc).attr('readonly', true);
52 $(add_spec_button).attr('disabled', true);
65 $(add_spec_button).attr('disabled', true);
53 $(del_spec_button).attr('disabled', true);
66 $(del_spec_button).attr('disabled', true);
54
67 $(sel_spec_button).attr('disabled', true);
68 $(cro_spec_button).attr('disabled', true);
69 $(all_spec_button).attr('disabled', true);
55 }
70 }
56 else {
71 else {
57 $(spectral_number).attr('readonly', false);
72 $(spectral_number).attr('readonly', false);
@@ -61,43 +76,59 $("#id_exp_type").change(function() {
61 $(save_ch_dc).attr('readonly', false);
76 $(save_ch_dc).attr('readonly', false);
62 $(add_spec_button).attr('disabled', false);
77 $(add_spec_button).attr('disabled', false);
63 $(del_spec_button).attr('disabled', false);
78 $(del_spec_button).attr('disabled', false);
79 $(sel_spec_button).attr('disabled', false);
80 $(cro_spec_button).attr('disabled', false);
81 $(all_spec_button).attr('disabled', false);
64 }
82 }
65 });
83 });
66
84
85
86 $("#id_cards_number").on('change', function() {
87 var cards_number = $("#id_cards_number").val();
88 channels_number = $("#id_channels_number")
89 $(channels_number).val(cards_number*2)
90 updateChannelsNumber();
91 });
92
93
67 $("#id_channels_number").on('change', function() {
94 $("#id_channels_number").on('change', function() {
68 updateChannelsNumber();
95 updateChannelsNumber();
69 });
96 });
70
97
98
99 $("#id_spectral").on('change', function() {
100 updateSpectralNumber();
101 });
102
103
104 function updateSpectralNumber(){
105 var spectral_comb = $("#id_spectral").val();
106 var num = spectral_comb.length;
107 var cont = 0
108 for (i = 0; i < num; i++) {
109 if (spectral_comb[i] == "]"){
110 cont = cont + 1
111 }
112 }
113 $("#id_spectral_number").val(cont)
114 }
115
116
71 function updateChannelsNumber() {
117 function updateChannelsNumber() {
72
118
73 var channels_number = $("#id_channels_number").val();
119 var channels_number = $("#id_channels_number").val();
74 channels = $("#id_channels")
120 channels = $("#id_channels")
121 sequence = ""
75
122
76 if (channels_number == 1) {
123 for (i = 1; i <= channels_number; i++) {
77 $(channels).val('1')
124 if (i==1){
78 }
125 sequence = i.toString()
79 else if (channels_number == 2){
126 }
80 $(channels).val('1,2')
127 else{
81 }
128 sequence = sequence + "," + i.toString()
82 else if (channels_number == 3){
129 }
83 $(channels).val('1,2,3')
84 }
85 else if (channels_number == 4){
86 $(channels).val('1,2,3,4')
87 }
130 }
88 else if (channels_number == 5){
131 $(channels).val(sequence)
89 $(channels).val('1,2,3,4,5')
90 }
91 else if (channels_number == 6){
92 $(channels).val('1,2,3,4,5,6')
93 }
94 else if (channels_number == 7){
95 $(channels).val('1,2,3,5,6,7')
96 }
97 else {
98 $(channels).val('1,2,3,4,5,6,7,8')
99 }
100
101 }
132 }
102 </script>
133 </script>
103 {% endblock %} No newline at end of file
134 {% endblock %}
@@ -16,26 +16,32 class SpectralWidget(forms.widgets.TextInput):
16 disabled = 'disabled' if attrs.get('disabled', False) else ''
16 disabled = 'disabled' if attrs.get('disabled', False) else ''
17 name = attrs.get('name', label)
17 name = attrs.get('name', label)
18 if '[' in value:
18 if '[' in value:
19 value = ast.literal_eval(value)
19 if value[len(value)-1] == ",":
20 value = ast.literal_eval(value)
21 else:
22 value = value + ","
23 value = ast.literal_eval(value)
20
24
21 codes = value
25 codes = value
22 if not isinstance(value, list):
26 if not isinstance(value, list):
23 if len(value) > 1:
27 text=''
24 text=''
28 #lista = []
25 for val in value:
29 #if len(value) > 1:
26 text = text+str(val)+','
30 for val in value:
31 text = text+str(val)+','
32 #lista.append(val)
27 codes=text
33 codes=text
28 else:
34 else:
29 codes=value+","
35 codes=''
30
36
31 html = '''<textarea rows="5" {0} class="form-control" id="id_{1}" name="{2}" style="white-space:nowrap; overflow:scroll;">{3}</textarea>
37 html = '''<textarea rows="5" {0} class="form-control" id="id_{1}" name="{2}" style="white-space:nowrap; overflow:scroll;">{3}</textarea>
32 <input type="text" class="col-md-1 col-no-padding" id="num1" value=0>
38 <input type="text" class="col-md-1 col-no-padding" id="num1" value=0>
33 <input type="text" class="col-md-1 col-no-padding" id="num2" value=0>
39 <input type="text" class="col-md-1 col-no-padding" id="num2" value=0>
34 <button type="button" class="button" id="add_spectral_button"> Add </button>
40 <button type="button" class="button" id="add_spectral_button"> Add </button>
35 <button type="button" class="button" id="all_spectral_button"> All </button>
36 <button type="button" class="button" id="self_spectral_button"> Self </button>
37 <button type="button" class="button" id="cross_spectral_button"> Cross </button>
38 <button type="button" class="button" id="delete_spectral_button"> Delete </button>
41 <button type="button" class="button" id="delete_spectral_button"> Delete </button>
42 <button type="button" class="button pull-right" id="cross_spectral_button"> Cross </button>
43 <button type="button" class="button pull-right" id="self_spectral_button"> Self </button>
44 <button type="button" class="button pull-right" id="all_spectral_button"> All </button>
39 '''.format(disabled, label, name, codes)
45 '''.format(disabled, label, name, codes)
40
46
41 script = '''
47 script = '''
@@ -47,9 +53,13 class SpectralWidget(forms.widgets.TextInput):
47
53
48
54
49 $("#all_spectral_button").click(function(){{
55 $("#all_spectral_button").click(function(){{
50 alert(spectral_comb)
56 var sequence1 = selfSpectral()
57 var sequence2 = crossSpectral()
58 $("#id_spectral").val(sequence1+sequence2)
59 updateSpectralNumber()
51 }});
60 }});
52
61
62
53 $("#add_spectral_button").click(function(){{
63 $("#add_spectral_button").click(function(){{
54 var spectral_comb = $("#id_spectral").val();
64 var spectral_comb = $("#id_spectral").val();
55 var spectral_number1 = $("#num1").val();
65 var spectral_number1 = $("#num1").val();
@@ -59,9 +69,65 class SpectralWidget(forms.widgets.TextInput):
59 var n = spectral_comb.search(str);
69 var n = spectral_comb.search(str);
60 if (n==-1){
70 if (n==-1){
61 $("#id_spectral").val(spectral_comb+"["+$("#num1").val()+", "+$("#num2").val()+"],")
71 $("#id_spectral").val(spectral_comb+"["+$("#num1").val()+", "+$("#num2").val()+"],")
62 }
72 }
73 updateSpectralNumber()
74 }});
75
76
77 $("#self_spectral_button").click(function(){{
78 var sequence = selfSpectral()
79 $("#id_spectral").val(sequence)
80
81 updateSpectralNumber()
63 }});
82 }});
64
83
84 $("#cross_spectral_button").click(function(){{
85 var sequence = crossSpectral()
86 $("#id_spectral").val(sequence)
87
88 updateSpectralNumber()
89 }});
90
91
92 function selfSpectral() {
93 var channels = $("#id_channels").val();
94 var n = (channels.length)-1;
95 var num = parseInt(channels[n]);
96 sequence = ""
97 for (i = 0; i < num; i++) {
98 sequence = sequence + "[" + i.toString() + ", " + i.toString() + "],"
99 }
100 return sequence
101 }
102
103
104 function crossSpectral() {
105 var channels = $("#id_channels").val();
106 var n = (channels.length)-1;
107 var num = parseInt(channels[n]);
108 sequence = ""
109 for (i = 0; i < num; i++) {
110 for (j = i+1; j < num; j++) {
111 sequence = sequence + "[" + i.toString() + ", " + j.toString() + "],"
112 }
113 }
114 return sequence
115 }
116
117
118 function updateSpectralNumber(){
119 var spectral_comb = $("#id_spectral").val();
120 var num = spectral_comb.length;
121 var cont = 0
122 for (i = 0; i < num; i++) {
123 if (spectral_comb[i] == "]"){
124 cont = cont + 1
125 }
126 }
127 $("#id_spectral_number").val(cont)
128 }
129
130
65 $("#delete_spectral_button").click(function(){{
131 $("#delete_spectral_button").click(function(){{
66 var spectral_comb = $("#id_spectral").val();
132 var spectral_comb = $("#id_spectral").val();
67 var spectral_number1 = $("#num1").val();
133 var spectral_number1 = $("#num1").val();
@@ -86,9 +152,11 class SpectralWidget(forms.widgets.TextInput):
86 var tuple = "["+$("#num1").val()+", "+$("#num2").val()+"],"
152 var tuple = "["+$("#num1").val()+", "+$("#num2").val()+"],"
87 var txt = spectral_comb.replace(tuple,'');
153 var txt = spectral_comb.replace(tuple,'');
88 $("#id_spectral").val(txt)
154 $("#id_spectral").val(txt)
89 }
155 }
156 updateSpectralNumber()
90 }});
157 }});
91
158
159
92 }});
160 }});
93 </script>
161 </script>
94 '''
162 '''
General Comments 0
You need to be logged in to leave comments. Login now