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