@@ -1,108 +1,116 | |||||
1 | #igp-top{ |
|
1 | #igp-top{ | |
2 | height:35px; |
|
2 | height:35px; | |
3 | background-color: var(--primary); |
|
3 | background-color: var(--primary); | |
4 | } |
|
4 | } | |
5 |
|
5 | |||
6 | #igp-top .navbar{ |
|
6 | #igp-top .navbar{ | |
7 | padding: 0 0; |
|
7 | padding: 0 0; | |
8 | } |
|
8 | } | |
9 |
|
9 | |||
10 | .nav-social a { |
|
10 | .nav-social a { | |
11 | text-align: center; |
|
11 | text-align: center; | |
12 | line-height: 23px; |
|
12 | line-height: 23px; | |
13 | width: 25px; |
|
13 | width: 25px; | |
14 | margin-right: 10px; |
|
14 | margin-right: 10px; | |
15 | color: #fff !important; |
|
15 | color: #fff !important; | |
16 | } |
|
16 | } | |
17 |
|
17 | |||
18 | .nav-social a:hover{ |
|
18 | .nav-social a:hover{ | |
19 | background-color: #277ea0; |
|
19 | background-color: #277ea0; | |
20 | } |
|
20 | } | |
21 |
|
21 | |||
22 | .navbar { |
|
22 | .navbar { | |
23 | padding: 7px 0; |
|
23 | padding: 7px 0; | |
24 | } |
|
24 | } | |
25 |
|
25 | |||
26 | .navbar-toggler-icon { |
|
26 | .navbar-toggler-icon { | |
27 | font-size: 0.75em; |
|
27 | font-size: 0.75em; | |
28 | padding-top: 5px; |
|
28 | padding-top: 5px; | |
29 | } |
|
29 | } | |
30 |
|
30 | |||
31 | .nav-contacto{ |
|
31 | .nav-contacto{ | |
32 | margin-top: 5px; |
|
32 | margin-top: 5px; | |
33 | display: contents; |
|
33 | display: contents; | |
34 | } |
|
34 | } | |
35 |
|
35 | |||
36 | .nav-contacto li{ |
|
36 | .nav-contacto li{ | |
37 | font-size: 14px; |
|
37 | font-size: 14px; | |
38 | margin-left: 10px; |
|
38 | margin-left: 10px; | |
39 | display: inline; |
|
39 | display: inline; | |
40 | color: #fff; |
|
40 | color: #fff; | |
41 | } |
|
41 | } | |
42 |
|
42 | |||
43 | .nav-contacto ul>li:last-of-type { |
|
43 | .nav-contacto ul>li:last-of-type { | |
44 | padding-left: 10px; |
|
44 | padding-left: 10px; | |
45 | border-left: 1px solid white; |
|
45 | border-left: 1px solid white; | |
46 | } |
|
46 | } | |
47 |
|
47 | |||
48 | .nav-contacto li a{ |
|
48 | .nav-contacto li a{ | |
49 | color: #fff; |
|
49 | color: #fff; | |
50 | text-decoration: none; |
|
50 | text-decoration: none; | |
51 | } |
|
51 | } | |
52 |
|
52 | |||
53 | .navbar-igp-1 { |
|
53 | .navbar-igp-1 { | |
54 | display: contents; |
|
54 | display: contents; | |
55 | } |
|
55 | } | |
56 | .navbar-igp-1 .nav-link { |
|
56 | .navbar-igp-1 .nav-link { | |
57 | color: var(--secondary); |
|
57 | color: var(--secondary); | |
58 | display: inline; |
|
58 | display: inline; | |
59 | padding: 0; |
|
59 | padding: 0; | |
60 | } |
|
60 | } | |
61 |
|
61 | |||
62 | .navbar-igp-1 li.active a, |
|
62 | .navbar-igp-1 li.active a, | |
63 | .navbar-igp-1 li a:hover { |
|
63 | .navbar-igp-1 li a:hover { | |
64 | color: var(--tertiary); |
|
64 | color: var(--tertiary); | |
65 | } |
|
65 | } | |
66 |
|
66 | |||
67 | .navbar-igp-1 li:after { |
|
67 | .navbar-igp-1 li:after { | |
68 | content: '|'; |
|
68 | content: '|'; | |
69 | margin: 0.2em; |
|
69 | margin: 0.2em; | |
70 | } |
|
70 | } | |
71 |
|
71 | |||
72 | .navbar-igp-1 ul>li:last-of-type:after { |
|
72 | .navbar-igp-1 ul>li:last-of-type:after { | |
73 | margin-right: 0; |
|
73 | margin-right: 0; | |
74 | } |
|
74 | } | |
75 |
|
75 | |||
76 | #igp-bottom { |
|
76 | #igp-bottom { | |
77 | background-color: var(--bg-sections); |
|
77 | background-color: var(--bg-sections); | |
78 | border-bottom: var(--bd-sections); |
|
78 | border-bottom: var(--bd-sections); | |
79 | border-top: var(--bd-sections); |
|
79 | border-top: var(--bd-sections); | |
80 | } |
|
80 | } | |
81 | #igp-bottom .navbar { |
|
81 | #igp-bottom .navbar { | |
82 | padding: 7px 0; |
|
82 | padding: 7px 0; | |
83 | } |
|
83 | } | |
84 |
|
84 | |||
85 |
.navbar-igp-2 .nav-link |
|
85 | .navbar-igp-2 .nav-link{ | |
86 |
color: var(-- |
|
86 | color: var(--secondary); | |
87 | display: inline; |
|
87 | display: inline; | |
88 | padding: 0; |
|
88 | padding: 0; | |
89 | } |
|
89 | } | |
90 |
|
90 | |||
|
91 | .navbar-igp-2 ul>li:not(:first-of-type) a:hover{ | |||
|
92 | color: var(--secondary); | |||
|
93 | } | |||
|
94 | ||||
|
95 | .navbar-igp-2 li.active a { | |||
|
96 | color: var(--tertiary); | |||
|
97 | } | |||
|
98 | ||||
91 | .navbar-igp-2 ul>li:not(:first-of-type):before { |
|
99 | .navbar-igp-2 ul>li:not(:first-of-type):before { | |
92 | content: '|'; |
|
100 | content: '|'; | |
93 | margin: 0.2em; |
|
101 | margin: 0.2em; | |
94 | } |
|
102 | } | |
95 |
|
103 | |||
96 | .logo{ |
|
104 | .logo{ | |
97 | height: 40px; |
|
105 | height: 40px; | |
98 | padding-right: 0.5em; |
|
106 | padding-right: 0.5em; | |
99 | } |
|
107 | } | |
100 |
|
108 | |||
101 | @media (max-width: 768px){ |
|
109 | @media (max-width: 768px){ | |
102 | .logo{ |
|
110 | .logo{ | |
103 | height: 30px; |
|
111 | height: 30px; | |
104 | } |
|
112 | } | |
105 | .navbar-igp-1 li:after { |
|
113 | .navbar-igp-1 li:after { | |
106 | content: ''; |
|
114 | content: ''; | |
107 | } |
|
115 | } | |
108 | } No newline at end of file |
|
116 | } |
@@ -1,116 +1,121 | |||||
1 | {% load static %} {% load bootstrap4 %} |
|
1 | {% load static %} {% load bootstrap4 %} | |
2 | <div id="igp-top"> |
|
2 | <div id="igp-top"> | |
3 | <div class="container"> |
|
3 | <div class="container"> | |
4 | <nav class="navbar navbar-expand"> |
|
4 | <nav class="navbar navbar-expand"> | |
5 | <div class="nav-social"> |
|
5 | <div class="nav-social"> | |
6 | <ul class="navbar-nav mr-auto"> |
|
6 | <ul class="navbar-nav mr-auto"> | |
7 | <li class="nav-item"> |
|
7 | <li class="nav-item"> | |
8 | <a target="_blank" href="https://www.facebook.com/igp.peru" class="nav-link"> |
|
8 | <a target="_blank" href="https://www.facebook.com/igp.peru" class="nav-link"> | |
9 | <i class="fab fa-facebook-f"> |
|
9 | <i class="fab fa-facebook-f"> | |
10 | </i></a></li> |
|
10 | </i></a></li> | |
11 | <li class="nav-item"><a target="_blank" href="https://twitter.com/igp_peru" class="nav-link"> |
|
11 | <li class="nav-item"><a target="_blank" href="https://twitter.com/igp_peru" class="nav-link"> | |
12 | <i class="fab fa-twitter"> |
|
12 | <i class="fab fa-twitter"> | |
13 | </i></a></li> |
|
13 | </i></a></li> | |
14 | <li class="nav-item"><a target="_blank" |
|
14 | <li class="nav-item"><a target="_blank" | |
15 | href="https://www.linkedin.com/company/igpperu/" class="nav-link"> |
|
15 | href="https://www.linkedin.com/company/igpperu/" class="nav-link"> | |
16 | <i class="fab fa-linkedin-in"> |
|
16 | <i class="fab fa-linkedin-in"> | |
17 | </i></a></li> |
|
17 | </i></a></li> | |
18 | <li class="nav-item"><a target="_blank" |
|
18 | <li class="nav-item"><a target="_blank" | |
19 | href="https://www.instagram.com/igp.peru" class="nav-link"> |
|
19 | href="https://www.instagram.com/igp.peru" class="nav-link"> | |
20 | <i class="fab fa-instagram"> |
|
20 | <i class="fab fa-instagram"> | |
21 | </i></a></li> |
|
21 | </i></a></li> | |
22 | <li class="nav-item"><a target="_blank" |
|
22 | <li class="nav-item"><a target="_blank" | |
23 | href="https://www.youtube.com/igp_videos" class="nav-link"> |
|
23 | href="https://www.youtube.com/igp_videos" class="nav-link"> | |
24 | <i class="fab fa-youtube"> |
|
24 | <i class="fab fa-youtube"> | |
25 | </i></a></li> |
|
25 | </i></a></li> | |
26 | </ul> |
|
26 | </ul> | |
27 | </div> |
|
27 | </div> | |
28 | <div class="nav-contacto"> |
|
28 | <div class="nav-contacto"> | |
29 | <ul class="navbar-nav ml-auto"> |
|
29 | <ul class="navbar-nav ml-auto"> | |
30 | <li class="d-none d-lg-inline nav-item"> |
|
30 | <li class="d-none d-lg-inline nav-item"> | |
31 | <span><i class="fa fa-phone"> </i> (511) 3172313</span> |
|
31 | <span><i class="fa fa-phone"> </i> (511) 3172313</span> | |
32 | </li> |
|
32 | </li> | |
33 | <li class="d-none d-lg-inline nav-item"> |
|
33 | <li class="d-none d-lg-inline nav-item"> | |
34 | <a href="mailto:roj@igp.gob.pe"> |
|
34 | <a href="mailto:roj@igp.gob.pe"> | |
35 | <span><i class="fa fa-envelope"> </i> roj@igp.gob.pe</span> |
|
35 | <span><i class="fa fa-envelope"> </i> roj@igp.gob.pe</span> | |
36 | </a> |
|
36 | </a> | |
37 | </li> |
|
37 | </li> | |
38 | <li class="nav-item"> |
|
38 | <li class="nav-item"> | |
39 | <a href="/login"> |
|
39 | <a href="/login"> | |
40 | <span><i class="fas fa-user"> </i> Login</span> |
|
40 | <span><i class="fas fa-user"> </i> Login</span> | |
41 | </a> |
|
41 | </a> | |
42 | </li> |
|
42 | </li> | |
43 | </ul> |
|
43 | </ul> | |
44 | </div> |
|
44 | </div> | |
45 | </nav> |
|
45 | </nav> | |
46 | </div> |
|
46 | </div> | |
47 | </div> |
|
47 | </div> | |
48 |
|
48 | |||
49 | <div class="container"> |
|
49 | <div class="container"> | |
50 | <nav class="navbar navbar-expand-md"> |
|
50 | <nav class="navbar navbar-expand-md"> | |
51 | <ul class="navbar-nav mr-auto"> |
|
51 | <ul class="navbar-nav mr-auto"> | |
52 | <a class="nav-link" |
|
52 | <a class="nav-link" | |
53 | href="/"> |
|
53 | href="/"> | |
54 | <img class="logo img-fluid" src="{% static 'images/logo-minan.png' %}" |
|
54 | <img class="logo img-fluid" src="{% static 'images/logo-minan.png' %}" | |
55 | alt="Logo Minam IGP"> |
|
55 | alt="Logo Minam IGP"> | |
56 | <img class="logo img-fluid" src="{% static 'images/logo_igp_normal.png' %}" alt="Logo IGP"> |
|
56 | <img class="logo img-fluid" src="{% static 'images/logo_igp_normal.png' %}" alt="Logo IGP"> | |
57 | </a> |
|
57 | </a> | |
58 | </ul> |
|
58 | </ul> | |
59 | <button class="navbar-toggler" type="button" data-toggle="collapse" |
|
59 | <button class="navbar-toggler" type="button" data-toggle="collapse" | |
60 | data-target="#navbar-main" |
|
60 | data-target="#navbar-main" | |
61 | aria-controls="navbar-main" aria-expanded="false" |
|
61 | aria-controls="navbar-main" aria-expanded="false" | |
62 | aria-label="Toggle navigation"> |
|
62 | aria-label="Toggle navigation"> | |
63 | <span class="navbar-toggler-icon"> |
|
63 | <span class="navbar-toggler-icon"> | |
64 | <i class="fas fa-ellipsis-v" style="color:#444"></i> |
|
64 | <i class="fas fa-ellipsis-v" style="color:#444"></i> | |
65 | </span> |
|
65 | </span> | |
66 | </button> |
|
66 | </button> | |
67 | <div id="navbar-main" class="navbar-collapse collapse"> |
|
67 | <div id="navbar-main" class="navbar-collapse collapse"> | |
68 | <div class="navbar-igp-1"> |
|
68 | <div class="navbar-igp-1"> | |
69 | <ul class="navbar-nav ml-auto"> |
|
69 | <ul class="navbar-nav ml-auto"> | |
70 | <li class="nav-item {%if title == 'Home'%}active{%endif%}"> |
|
70 | <li class="nav-item {%if title == 'Home'%}active{%endif%}"> | |
71 | <a class="nav-link" |
|
71 | <a class="nav-link" | |
72 | href="{% url 'url_main' %}">Home</a> |
|
72 | href="{% url 'url_main' %}">Home</a> | |
73 | </li> |
|
73 | </li> | |
74 | <li class="nav-item {%if title == 'Tools'%}active{%endif%}"> |
|
74 | <li class="nav-item {%if title == 'Tools'%}active{%endif%}"> | |
75 | <a class="nav-link" |
|
75 | <a class="nav-link" | |
76 | href="{% url 'url_tools' %}">Tools</a> |
|
76 | href="{% url 'url_tools' %}">Tools</a> | |
77 | </li> |
|
77 | </li> | |
78 | <li class="nav-item {%if title == 'Reports'%}active{%endif%}"> |
|
78 | <li class="nav-item {%if title == 'Reports'%}active{%endif%}"> | |
79 | <a class="nav-link" |
|
79 | <a class="nav-link" | |
80 | href="{% url 'url_reports' %}">Reports</a> |
|
80 | href="{% url 'url_reports' %}">Reports</a> | |
81 | </li> |
|
81 | </li> | |
82 | <li class="nav-item {%if title == 'About'%}active{%endif%}"> |
|
82 | <li class="nav-item {%if title == 'About'%}active{%endif%}"> | |
83 | <a class="nav-link" |
|
83 | <a class="nav-link" | |
84 | href="{% url 'url_about' %}">About</a> |
|
84 | href="{% url 'url_about' %}">About</a> | |
85 | </li> |
|
85 | </li> | |
86 | <li class="nav-item"> |
|
86 | <li class="nav-item"> | |
87 | <a class="nav-link" href="http://jro.igp.gob.pe">JRO</a> |
|
87 | <a class="nav-link" href="http://jro.igp.gob.pe">JRO</a> | |
88 | </li> |
|
88 | </li> | |
89 | </ul> |
|
89 | </ul> | |
90 | </div> |
|
90 | </div> | |
91 | </div> |
|
91 | </div> | |
92 | </nav> |
|
92 | </nav> | |
93 | </div> |
|
93 | </div> | |
94 | <div id="igp-bottom"> |
|
94 | <div id="igp-bottom"> | |
95 | <div class="container"> |
|
95 | <div class="container"> | |
96 | <nav class="navbar navbar-expand"> |
|
96 | <nav class="navbar navbar-expand"> | |
97 | <div class="navbar-igp-2"> |
|
97 | <div class="navbar-igp-2"> | |
98 | <ul class="navbar-nav mr-auto"> |
|
98 | <ul class="navbar-nav mr-auto"> | |
99 | <li class="nav-item"> |
|
99 | <li class="nav-item active"> | |
100 | <a class="nav-link" |
|
100 | <a class="nav-link" | |
101 | href="https://www.gob.pe/igp"><span><i class="fas fa-home"> </i> IGP portal</span></a> |
|
101 | href="https://www.gob.pe/igp"><span><i class="fas fa-home"> </i> IGP portal</span></a> | |
102 | </li> |
|
102 | </li> | |
103 | <li class="nav-item"> |
|
103 | <li class="nav-item"> | |
104 | <a class="nav-link">Realtime at JRO</a> |
|
104 | <a class="nav-link" href="{% url 'url_main'%}">Realtime at JRO</a> | |
|
105 | </li> | |||
|
106 | {% if tag %} | |||
|
107 | <li class="nav-item"> | |||
|
108 | <a class="nav-link" href="{% url 'url_main' tag %}">{{tag | title}}</a> | |||
105 | </li> |
|
109 | </li> | |
|
110 | {% endif %} | |||
106 | {% if title != 'Home' %} |
|
111 | {% if title != 'Home' %} | |
107 | <li class="nav-item"> |
|
112 | <li class="nav-item"> | |
108 | <a class="nav-link">{{title}}</a> |
|
113 | <a class="nav-link">{{title}}</a> | |
109 | </li> |
|
114 | </li> | |
110 | {% endif %} |
|
115 | {% endif %} | |
111 | </ul> |
|
116 | </ul> | |
112 | </div> |
|
117 | </div> | |
113 | </nav> |
|
118 | </nav> | |
114 | </div> |
|
119 | </div> | |
115 | </div> |
|
120 | </div> | |
116 | <br> No newline at end of file |
|
121 | <br> |
@@ -1,239 +1,242 | |||||
1 | #!/usr/bin/python |
|
1 | #!/usr/bin/python | |
2 | # -*- coding: UTF-8 -*- |
|
2 | # -*- coding: UTF-8 -*- | |
3 |
|
3 | |||
4 |
|
4 | |||
5 | import os |
|
5 | import os | |
6 | import time |
|
6 | import time | |
7 | from datetime import datetime |
|
7 | from datetime import datetime | |
8 |
|
8 | |||
9 | from django import forms |
|
9 | from django import forms | |
10 | from django.contrib import messages |
|
10 | from django.contrib import messages | |
11 | from django.utils.safestring import mark_safe |
|
11 | from django.utils.safestring import mark_safe | |
12 | from django.shortcuts import render |
|
12 | from django.shortcuts import render | |
13 | from django.http import HttpResponse |
|
13 | from django.http import HttpResponse | |
14 |
|
14 | |||
15 | import mongoengine |
|
15 | import mongoengine | |
16 |
|
16 | |||
17 | from plotter.models import Experiment, ExpDetail, PlotMeta, PlotData |
|
17 | from plotter.models import Experiment, ExpDetail, PlotMeta, PlotData | |
18 |
|
18 | |||
19 | from utils.plots import skynoise_plot |
|
19 | from utils.plots import skynoise_plot | |
20 |
|
20 | |||
21 | host = os.environ.get('HOST_MONGO', 'localhost') |
|
21 | host = os.environ.get('HOST_MONGO', 'localhost') | |
22 | mongoengine.connect('dbplots', host=host, port=27017) |
|
22 | mongoengine.connect('dbplots', host=host, port=27017) | |
23 |
|
23 | |||
24 |
|
24 | |||
25 | # Forms |
|
25 | # Forms | |
26 | class SearchForm(forms.Form): |
|
26 | class SearchForm(forms.Form): | |
27 |
|
27 | |||
28 | experiment = forms.ChoiceField() |
|
28 | experiment = forms.ChoiceField() | |
29 | plot = forms.ChoiceField() |
|
29 | plot = forms.ChoiceField() | |
30 |
|
30 | |||
31 | def __init__(self, *args, **kwargs): |
|
31 | def __init__(self, *args, **kwargs): | |
32 |
|
32 | |||
33 | exp_choices = kwargs.pop('exp_choices', []) |
|
33 | exp_choices = kwargs.pop('exp_choices', []) | |
34 | plt_choices = kwargs.pop('plt_choices', []) |
|
34 | plt_choices = kwargs.pop('plt_choices', []) | |
35 | super(SearchForm, self).__init__(*args, **kwargs) |
|
35 | super(SearchForm, self).__init__(*args, **kwargs) | |
36 | self.fields['experiment'].choices = [(0, 'Select Experiment')] + exp_choices |
|
36 | self.fields['experiment'].choices = [(0, 'Select Experiment')] + exp_choices | |
37 | self.fields['plot'].choices = [(0, 'Select Plot')] + plt_choices |
|
37 | self.fields['plot'].choices = [(0, 'Select Plot')] + plt_choices | |
38 | # we use this class to change the parameter in Scatter plot using the function plotly.restyle in jroplot.js |
|
38 | # we use this class to change the parameter in Scatter plot using the function plotly.restyle in jroplot.js | |
39 | class ScatterSetupForm(forms.Form): |
|
39 | class ScatterSetupForm(forms.Form): | |
40 |
|
40 | |||
41 | plotdiv = forms.CharField(widget=forms.HiddenInput()) |
|
41 | plotdiv = forms.CharField(widget=forms.HiddenInput()) | |
42 | ymax = forms.CharField(initial=30) |
|
42 | ymax = forms.CharField(initial=30) | |
43 | ymin = forms.CharField(initial=10) |
|
43 | ymin = forms.CharField(initial=10) | |
44 |
|
44 | |||
45 | # we use this class to change the parameter in RTI plot using the function plotly.restyle in jroplot.js |
|
45 | # we use this class to change the parameter in RTI plot using the function plotly.restyle in jroplot.js | |
46 | class RTISetupForm(forms.Form): |
|
46 | class RTISetupForm(forms.Form): | |
47 |
|
47 | |||
48 | plotdiv = forms.CharField(widget=forms.HiddenInput()) |
|
48 | plotdiv = forms.CharField(widget=forms.HiddenInput()) | |
49 | colormap = forms.ChoiceField(choices=[('Jet', 'Jet'), ('Viridis', 'Viridis'), ('RdBu', 'RdBu')]) |
|
49 | colormap = forms.ChoiceField(choices=[('Jet', 'Jet'), ('Viridis', 'Viridis'), ('RdBu', 'RdBu')]) | |
50 | zmax = forms.CharField(initial=30) |
|
50 | zmax = forms.CharField(initial=30) | |
51 | zmin = forms.CharField(initial=10) |
|
51 | zmin = forms.CharField(initial=10) | |
52 | ymax = forms.CharField(initial=180) |
|
52 | ymax = forms.CharField(initial=180) | |
53 | ymin = forms.CharField(initial=80) |
|
53 | ymin = forms.CharField(initial=80) | |
54 |
|
54 | |||
55 | # we use this class to change the parameter in SPC plot using the function plotly.restyle in jroplot.js |
|
55 | # we use this class to change the parameter in SPC plot using the function plotly.restyle in jroplot.js | |
56 | class SPCSetupForm(forms.Form): |
|
56 | class SPCSetupForm(forms.Form): | |
57 |
|
57 | |||
58 | plotdiv = forms.CharField(widget=forms.HiddenInput()) |
|
58 | plotdiv = forms.CharField(widget=forms.HiddenInput()) | |
59 | colormap = forms.ChoiceField(choices=[('Jet', 'Jet'), ('Viridis', 'Viridis'), ('RdBu', 'RdBu')]) |
|
59 | colormap = forms.ChoiceField(choices=[('Jet', 'Jet'), ('Viridis', 'Viridis'), ('RdBu', 'RdBu')]) | |
60 | #como es un perfil xmin y xmax deben ser iguales a zmin y zmax |
|
60 | #como es un perfil xmin y xmax deben ser iguales a zmin y zmax | |
61 | xmax = forms.CharField(initial=30) |
|
61 | xmax = forms.CharField(initial=30) | |
62 | xmin = forms.CharField(initial=10) |
|
62 | xmin = forms.CharField(initial=10) | |
63 | #x2max = forms.CharField(initial=30) |
|
63 | #x2max = forms.CharField(initial=30) | |
64 | #x2min = forms.CharField(initial=10) |
|
64 | #x2min = forms.CharField(initial=10) | |
65 | ymax = forms.CharField(initial=180) |
|
65 | ymax = forms.CharField(initial=180) | |
66 | ymin = forms.CharField(initial=80) |
|
66 | ymin = forms.CharField(initial=80) | |
67 | zmax = forms.CharField(initial=30) |
|
67 | zmax = forms.CharField(initial=30) | |
68 | zmin = forms.CharField(initial=10) |
|
68 | zmin = forms.CharField(initial=10) | |
69 |
|
69 | |||
70 | # Create your views here. |
|
70 | # Create your views here. | |
71 | def main(request, tag=None): |
|
71 | def main(request, tag=None): | |
72 |
|
72 | |||
73 | kwargs = {} |
|
73 | kwargs = {} | |
74 | date = request.GET.get('date', datetime.now().strftime('%d-%m-%Y')) |
|
74 | date = request.GET.get('date', datetime.now().strftime('%d-%m-%Y')) | |
75 | exps = ExpDetail.objects(date=datetime.strptime(date, '%d-%m-%Y')) |
|
75 | exps = ExpDetail.objects(date=datetime.strptime(date, '%d-%m-%Y')) | |
76 |
|
76 | |||
77 | tmp = {} |
|
77 | tmp = {} | |
78 | for exp in exps: |
|
78 | for exp in exps: | |
79 | label = exp.tag.lower().strip() if exp.tag else 'other' |
|
79 | label = exp.tag.lower().strip() if exp.tag else 'other' | |
80 | if label in tmp: |
|
80 | if label in tmp: | |
81 | tmp[label] += 1 |
|
81 | tmp[label] += 1 | |
82 | else: |
|
82 | else: | |
83 | tmp[label] = 1 |
|
83 | tmp[label] = 1 | |
84 | tags = [] |
|
84 | tags = [] | |
85 |
|
85 | |||
86 | for key, value in tmp.items(): |
|
86 | for key, value in tmp.items(): | |
87 | if tag == key: |
|
87 | if tag == key: | |
88 | tags.append({'name': key, 'n': tmp[key], 'active': 'active'}) |
|
88 | tags.append({'name': key, 'n': tmp[key], 'active': 'active'}) | |
89 | else: |
|
89 | else: | |
90 | tags.append({'name': key, 'n': tmp[key]}) |
|
90 | tags.append({'name': key, 'n': tmp[key]}) | |
91 |
|
91 | |||
92 | kwargs['tags'] = tags |
|
92 | kwargs['tags'] = tags | |
93 |
|
93 | |||
94 | if tag: |
|
94 | if tag: | |
95 | experiments = [] |
|
95 | experiments = [] | |
96 | for exp in exps: |
|
96 | for exp in exps: | |
97 | label = exp.tag.lower().strip() if exp.tag else 'other' |
|
97 | label = exp.tag.lower().strip() if exp.tag else 'other' | |
98 | if label != tag: |
|
98 | if label != tag: | |
99 | continue |
|
99 | continue | |
100 | dum = {} |
|
100 | dum = {} | |
101 | dum['code'] = exp.experiment.code |
|
101 | dum['code'] = exp.experiment.code | |
102 | dum['plots'] = [] |
|
102 | dum['plots'] = [] | |
103 | dum['name'] = exp.experiment.name |
|
103 | dum['name'] = exp.experiment.name | |
104 | dt = datetime.now() |
|
104 | dt = datetime.now() | |
105 |
|
105 | |||
106 | t = time.mktime(dt.timetuple()) |
|
106 | t = time.mktime(dt.timetuple()) | |
107 | t -= 5*60*60 |
|
107 | t -= 5*60*60 | |
108 |
|
108 | |||
109 | if (t-exp['last_time']) > 6*exp['interval']: |
|
109 | if (t-exp['last_time']) > 6*exp['interval']: | |
110 | status = 'Offline' |
|
110 | status = 'Offline' | |
111 | clase = 'alertas-offline' |
|
111 | clase = 'alertas-offline' | |
112 | style = 'danger' |
|
112 | style = 'danger' | |
113 | lastDataDate = exp['last_time'] |
|
113 | lastDataDate = exp['last_time'] | |
114 | elif (t-exp['last_time']) > 3*exp['interval']: |
|
114 | elif (t-exp['last_time']) > 3*exp['interval']: | |
115 | status = 'Delayed' |
|
115 | status = 'Delayed' | |
116 | clase = 'alertas-delayed' |
|
116 | clase = 'alertas-delayed' | |
117 | style = 'warning' |
|
117 | style = 'warning' | |
118 | lastDataDate = exp['last_time'] |
|
118 | lastDataDate = exp['last_time'] | |
119 | else: |
|
119 | else: | |
120 | status = 'Online' |
|
120 | status = 'Online' | |
121 | clase = 'alertas-online' |
|
121 | clase = 'alertas-online' | |
122 | style = 'success' |
|
122 | style = 'success' | |
123 | lastDataDate = exp['last_time'] |
|
123 | lastDataDate = exp['last_time'] | |
124 |
|
124 | |||
125 | dum['status'] = status |
|
125 | dum['status'] = status | |
126 | dum['class'] = clase |
|
126 | dum['class'] = clase | |
127 | dum['style']= style |
|
127 | dum['style']= style | |
128 | dum['date']= datetime.utcfromtimestamp(lastDataDate) |
|
128 | dum['date']= datetime.utcfromtimestamp(lastDataDate) | |
129 | for plot in exp.plots(): |
|
129 | for plot in exp.plots(): | |
130 | dum['plots'].append({'plot': plot.plot, 'name': plot.plot.replace('_', ' ').title(), 'id':plot.id}) |
|
130 | dum['plots'].append({'plot': plot.plot, 'name': plot.plot.replace('_', ' ').title(), 'id':plot.id}) | |
131 | experiments.append(dum) |
|
131 | experiments.append(dum) | |
132 |
|
132 | |||
133 | kwargs['experiments'] = experiments |
|
133 | kwargs['experiments'] = experiments | |
|
134 | kwargs['tag'] = tag | |||
134 |
|
135 | |||
135 | kwargs['date'] = date |
|
136 | kwargs['date'] = date | |
136 | kwargs['title'] = 'Home' |
|
137 | kwargs['title'] = 'Home' | |
137 | kwargs['sidebar'] = True |
|
138 | kwargs['sidebar'] = True | |
138 |
|
139 | |||
139 | return render(request, 'home.html', kwargs) |
|
140 | return render(request, 'home.html', kwargs) | |
140 |
|
141 | |||
141 | def about(request): |
|
142 | def about(request): | |
142 | ''' |
|
143 | ''' | |
143 | ''' |
|
144 | ''' | |
144 | kwargs = { |
|
145 | kwargs = { | |
145 | 'title': 'About' |
|
146 | 'title': 'About' | |
146 | } |
|
147 | } | |
147 | return render(request, 'about.html', kwargs) |
|
148 | return render(request, 'about.html', kwargs) | |
148 |
|
149 | |||
149 |
|
150 | |||
150 | def tools(request): |
|
151 | def tools(request): | |
151 | ''' |
|
152 | ''' | |
152 | ''' |
|
153 | ''' | |
153 | kwargs = { |
|
154 | kwargs = { | |
154 | 'title': 'Tools' |
|
155 | 'title': 'Tools' | |
155 | } |
|
156 | } | |
156 | return render(request, 'tools.html', kwargs) |
|
157 | return render(request, 'tools.html', kwargs) | |
157 |
|
158 | |||
158 | def reports(request): |
|
159 | def reports(request): | |
159 | ''' |
|
160 | ''' | |
160 | ''' |
|
161 | ''' | |
161 | kwargs = { |
|
162 | kwargs = { | |
162 | 'title': 'Reports', |
|
163 | 'title': 'Reports', | |
163 | } |
|
164 | } | |
164 | return render(request, 'reports.html', kwargs) |
|
165 | return render(request, 'reports.html', kwargs) | |
165 |
|
166 | |||
166 | def plot(request, code=None, plot=None): |
|
167 | def plot(request, code=None, plot=None): | |
167 | ''' |
|
168 | ''' | |
168 | ''' |
|
169 | ''' | |
169 |
|
170 | |||
170 | realtime = False |
|
171 | realtime = False | |
171 | date = request.GET.get('date', None) |
|
172 | date = request.GET.get('date', None) | |
172 | if date is None: |
|
173 | if date is None: | |
173 | date = datetime.now().strftime('%d-%m-%Y') |
|
174 | date = datetime.now().strftime('%d-%m-%Y') | |
174 | realtime = True |
|
175 | realtime = True | |
175 | exp = Experiment.objects.get(code=int(code)) |
|
176 | exp = Experiment.objects.get(code=int(code)) | |
176 | detail = ExpDetail.objects.get(experiment=exp, date=datetime.strptime(date, '%d-%m-%Y')) |
|
177 | detail = ExpDetail.objects.get(experiment=exp, date=datetime.strptime(date, '%d-%m-%Y')) | |
177 | meta = PlotMeta.objects.get(exp_detail=detail, plot=plot) |
|
178 | meta = PlotMeta.objects.get(exp_detail=detail, plot=plot) | |
178 |
|
179 | tag = detail.tag.lower().strip() if detail.tag else 'other' | ||
|
180 | ||||
179 | kwargs = { |
|
181 | kwargs = { | |
180 | 'code': code, |
|
182 | 'code': code, | |
181 | 'plot': plot, |
|
183 | 'plot': plot, | |
182 | 'meta':meta, |
|
184 | 'meta':meta, | |
183 | 'date': date, |
|
185 | 'date': date, | |
184 | 'id': meta.pk, |
|
186 | 'id': meta.pk, | |
185 | 'realtime': realtime, |
|
187 | 'realtime': realtime, | |
186 | 'title': 'Home', |
|
188 | 'title': 'Home', | |
187 | 'name' : exp.name, |
|
189 | 'name' : exp.name, | |
188 | 'sidebar': True, |
|
190 | 'sidebar': True, | |
|
191 | 'tag' : tag, | |||
189 | 'plots': [] |
|
192 | 'plots': [] | |
190 | } |
|
193 | } | |
191 |
|
194 | |||
192 | for plt in detail.plots(): |
|
195 | for plt in detail.plots(): | |
193 | kwargs['plots'].append({'plot': plt.plot, 'name': plt.plot.replace('_', ' ').title()}) |
|
196 | kwargs['plots'].append({'plot': plt.plot, 'name': plt.plot.replace('_', ' ').title()}) | |
194 |
|
197 | |||
195 | # Logic to show my views |
|
198 | # Logic to show my views | |
196 | if meta.metadata['type'] == 'pcolorbuffer': |
|
199 | if meta.metadata['type'] == 'pcolorbuffer': | |
197 | kwargs['setup_form'] = RTISetupForm() |
|
200 | kwargs['setup_form'] = RTISetupForm() | |
198 | kwargs['fn_plot'] = 'PcolorBuffer' |
|
201 | kwargs['fn_plot'] = 'PcolorBuffer' | |
199 | return render(request, 'plot.html', kwargs) |
|
202 | return render(request, 'plot.html', kwargs) | |
200 | elif meta.metadata['type'] == 'pcolor': |
|
203 | elif meta.metadata['type'] == 'pcolor': | |
201 | kwargs['setup_form'] = SPCSetupForm() |
|
204 | kwargs['setup_form'] = SPCSetupForm() | |
202 | kwargs['fn_plot'] = 'Pcolor' |
|
205 | kwargs['fn_plot'] = 'Pcolor' | |
203 | return render(request, 'plot.html', kwargs) |
|
206 | return render(request, 'plot.html', kwargs) | |
204 | elif meta.metadata['type'] == 'scatterbuffer': |
|
207 | elif meta.metadata['type'] == 'scatterbuffer': | |
205 | kwargs['setup_form'] = ScatterSetupForm() |
|
208 | kwargs['setup_form'] = ScatterSetupForm() | |
206 | kwargs['fn_plot'] = 'ScatterBuffer' |
|
209 | kwargs['fn_plot'] = 'ScatterBuffer' | |
207 | return render(request, 'plot.html', kwargs) |
|
210 | return render(request, 'plot.html', kwargs) | |
208 | elif meta.metadata['type'] == 'image': |
|
211 | elif meta.metadata['type'] == 'image': | |
209 | kwargs['image'] = True |
|
212 | kwargs['image'] = True | |
210 | kwargs['fn_plot'] = 'StaticPlot' |
|
213 | kwargs['fn_plot'] = 'StaticPlot' | |
211 | return render(request, 'plot.html', kwargs) |
|
214 | return render(request, 'plot.html', kwargs) | |
212 | else: |
|
215 | else: | |
213 | return render(request, 'home.html', {}) |
|
216 | return render(request, 'home.html', {}) | |
214 |
|
217 | |||
215 | def plot_skynoise(request): |
|
218 | def plot_skynoise(request): | |
216 |
|
219 | |||
217 | date = request.GET.get('date', None) |
|
220 | date = request.GET.get('date', None) | |
218 | if date is None: |
|
221 | if date is None: | |
219 | date = datetime.now() |
|
222 | date = datetime.now() | |
220 | else: |
|
223 | else: | |
221 | date = datetime.strptime(date, '%Y-%m-%d') |
|
224 | date = datetime.strptime(date, '%Y-%m-%d') | |
222 |
|
225 | |||
223 | data = skynoise_plot(date.year, date.month, date.day) |
|
226 | data = skynoise_plot(date.year, date.month, date.day) | |
224 | response = HttpResponse(data.getvalue(), content_type='image/png') |
|
227 | response = HttpResponse(data.getvalue(), content_type='image/png') | |
225 |
|
228 | |||
226 | return response |
|
229 | return response | |
227 |
|
230 | |||
228 | def plot_overjro(request): |
|
231 | def plot_overjro(request): | |
229 |
|
232 | |||
230 | date = request.GET.get('date', None) |
|
233 | date = request.GET.get('date', None) | |
231 | if date is None: |
|
234 | if date is None: | |
232 | date = datetime.now() |
|
235 | date = datetime.now() | |
233 | else: |
|
236 | else: | |
234 | date = datetime.strptime(date, '%Y-%m-%d') |
|
237 | date = datetime.strptime(date, '%Y-%m-%d') | |
235 |
|
238 | |||
236 | data = skynoise_plot(date.year, date.month, date.day) |
|
239 | data = skynoise_plot(date.year, date.month, date.day) | |
237 | response = HttpResponse(data.getvalue(), content_type='image/png') |
|
240 | response = HttpResponse(data.getvalue(), content_type='image/png') | |
238 |
|
241 | |||
239 | return response No newline at end of file |
|
242 | return response |
General Comments 0
You need to be logged in to leave comments.
Login now