##// 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 46 acq_profiles = models.PositiveIntegerField(verbose_name='Acquired Profiles', validators=[MaxValueValidator(5000)], default=400)
47 47 profiles_block = models.PositiveIntegerField(verbose_name='Profiles Per Block', validators=[MaxValueValidator(5000)], default=400)
48 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 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)
52 spectral = models.CharField(verbose_name='Combinations', max_length=5000, default = '[0,0]')
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],')
53 53 create_directory = models.BooleanField(verbose_name='Create Directory Per Day', default=True)
54 54 include_expname = models.BooleanField(verbose_name='Experiment Name in Directory', default=True)
55 55 acq_link = models.BooleanField(verbose_name='Acquisition Link', default=True)
@@ -14,6 +14,10 $(document).ready(function() {
14 14 save_ch_dc = $("#id_save_ch_dc")
15 15 add_spec_button = $("#add_spectral_button")
16 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 21 if (type == 0) {
18 22 $(spectral_number).attr('readonly', true);
19 23 $(spectral).attr('readonly', true);
@@ -22,7 +26,9 $(document).ready(function() {
22 26 $(save_ch_dc).attr('readonly', true);
23 27 $(add_spec_button).attr('disabled', true);
24 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 33 else {
28 34 $(spectral_number).attr('readonly', false);
@@ -32,6 +38,9 $(document).ready(function() {
32 38 $(save_ch_dc).attr('readonly', false);
33 39 $(add_spec_button).attr('disabled', false);
34 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 52 save_ch_dc = $("#id_save_ch_dc")
44 53 add_spec_button = $("#add_spectral_button")
45 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 59 if (type == 0) {
47 60 $(spectral_number).attr('readonly', true);
48 61 $(spectral).attr('readonly', true);
@@ -51,7 +64,9 $("#id_exp_type").change(function() {
51 64 $(save_ch_dc).attr('readonly', true);
52 65 $(add_spec_button).attr('disabled', true);
53 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 71 else {
57 72 $(spectral_number).attr('readonly', false);
@@ -61,43 +76,59 $("#id_exp_type").change(function() {
61 76 $(save_ch_dc).attr('readonly', false);
62 77 $(add_spec_button).attr('disabled', false);
63 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 94 $("#id_channels_number").on('change', function() {
68 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 117 function updateChannelsNumber() {
72 118
73 119 var channels_number = $("#id_channels_number").val();
74 120 channels = $("#id_channels")
121 sequence = ""
75 122
76 if (channels_number == 1) {
77 $(channels).val('1')
78 }
79 else if (channels_number == 2){
80 $(channels).val('1,2')
81 }
82 else if (channels_number == 3){
83 $(channels).val('1,2,3')
84 }
85 else if (channels_number == 4){
86 $(channels).val('1,2,3,4')
123 for (i = 1; i <= channels_number; i++) {
124 if (i==1){
125 sequence = i.toString()
126 }
127 else{
128 sequence = sequence + "," + i.toString()
129 }
87 130 }
88 else if (channels_number == 5){
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
131 $(channels).val(sequence)
101 132 }
102 133 </script>
103 134 {% endblock %} No newline at end of file
@@ -16,26 +16,32 class SpectralWidget(forms.widgets.TextInput):
16 16 disabled = 'disabled' if attrs.get('disabled', False) else ''
17 17 name = attrs.get('name', label)
18 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 25 codes = value
22 26 if not isinstance(value, list):
23 if len(value) > 1:
24 text=''
25 for val in value:
26 text = text+str(val)+','
27 text=''
28 #lista = []
29 #if len(value) > 1:
30 for val in value:
31 text = text+str(val)+','
32 #lista.append(val)
27 33 codes=text
28 34 else:
29 codes=value+","
35 codes=''
30 36
31 37 html = '''<textarea rows="5" {0} class="form-control" id="id_{1}" name="{2}" style="white-space:nowrap; overflow:scroll;">{3}</textarea>
32 38 <input type="text" class="col-md-1 col-no-padding" id="num1" value=0>
33 39 <input type="text" class="col-md-1 col-no-padding" id="num2" value=0>
34 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 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 45 '''.format(disabled, label, name, codes)
40 46
41 47 script = '''
@@ -47,9 +53,13 class SpectralWidget(forms.widgets.TextInput):
47 53
48 54
49 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 63 $("#add_spectral_button").click(function(){{
54 64 var spectral_comb = $("#id_spectral").val();
55 65 var spectral_number1 = $("#num1").val();
@@ -59,9 +69,65 class SpectralWidget(forms.widgets.TextInput):
59 69 var n = spectral_comb.search(str);
60 70 if (n==-1){
61 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 131 $("#delete_spectral_button").click(function(){{
66 132 var spectral_comb = $("#id_spectral").val();
67 133 var spectral_number1 = $("#num1").val();
@@ -86,9 +152,11 class SpectralWidget(forms.widgets.TextInput):
86 152 var tuple = "["+$("#num1").val()+", "+$("#num2").val()+"],"
87 153 var txt = spectral_comb.replace(tuple,'');
88 154 $("#id_spectral").val(txt)
89 }
155 }
156 updateSpectralNumber()
90 157 }});
91 158
159
92 160 }});
93 161 </script>
94 162 '''
General Comments 0
You need to be logged in to leave comments. Login now