-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
635 lines (597 loc) · 20.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
<!DOCTYPE html>
<html>
<head>
<title>Covid-19 Curitiba</title>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.css"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.js"></script>
<style type="text/css">
body {
font-family: Helvetica Neue, Arial, sans-serif;
text-align: center;
overflow-x: hidden;
}
.jumbotron {
padding: 0rem 1rem;
background-color: transparent;
}
.wrapper {
max-width: 800px;
margin: 50px auto;
}
h1 {
font-weight: 200;
font-size: 3em;
margin: 0 0 0.1em 0;
}
h2 {
font-weight: 200;
font-size: 0.9em;
margin: 0 0 50px;
color: #999;
}
a {
/*margin-top: 50px;*/
display: block;
color: #3e95cd;
}
ul{
text-align: left;
padding: 1em;
}
li{
padding: 0.25em;
}
#controlPanel {
margin: 0 auto;
padding: 20px;
max-width: 500px;
}
.button {
height: 50px;
border-radius: 10px;
padding: 20px;
text-align: center;
margin: 25px auto;
display: block;
}
#traffic-light {
float: left;
background-color: #333;
border-radius: 40px;
margin: 0.5em;
padding: 20px;
border: 1px solid white;
}
.bulb {
height: 50px;
width: 50px;
background-color: #111;
border-radius: 50%;
margin: 25px auto;
transition: background 500ms;
}
.captionSpan {
height: 25px;
width: 25px;
background-color: #111;
border-radius: 50%;
/*display: inline-block;*/
float: left;
}
#outer{
border-radius: 40px;
height: auto;
display: inline-block;
background-color: #333;
}
#logged-content, #barra{
display: none;
}
.barra-usuario{
background: #a92439;
color: white;
}
.barra-usuario ul{
text-align: right;
}
.barra-usuario ul li{
display: inline-block;
}
.btn-primary {
color: #fff;
background-color: #a92439;
border-color: #941e31;
}
.btn-primary:hover {
color: #fff;
background-color: #e42c49;
border-color: #941e31;
}
</style>
</head>
<body>
<div class="barra-usuario" id="barra">
<ul>
<li id='username'></li>
<li><button type="submit" class="btn btn-default" onclick="logout()">Logout</button></li>
</ul>
</div>
<div class="jumbotron text-center">
<h1><img alt="PUCPR" style="width:280px;height:auto;" title="PUCPR" src="https://www.iasp.ws/media/imagegenerator/290x290/upscale(false)/canvascolor(0xffffffff)/2017_07_31-Pucpr.png">
</h1>
</div>
<div class="row" id="login-form" style="background: #d9d9e4; padding:1em;">
<div class="col-12">
<div class="wrapper">
<form action="" id="login-form">
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" id="email" placeholder="Seu Email">
</div>
<div class="form-group">
<label for="pwd">Senha:</label>
<input type="password" class="form-control" id="pwd" placeholder="Senha Fornecida">
</div>
<button type="submit" class="btn btn-primary">Enviar</button>
</form>
</div>
</div>
</div>
<div id="logged-content">
<div class="row" >
<div class="col-6">
<div class="wrapper">
<h1>Semáforo Covid-19</h1>
<h2>Estado do Covid-19 em Curitiba</h2>
<div id="outer">
<div id="traffic-light">
<div id="green" class="bulb"></div>
<div id="yellow" class="bulb"></div>
<div id="orange" class="bulb"></div>
<div id="red" class="bulb"></div>
</div>
</div>
<div>
<h2 id="captionSemaforo">Calculando ...</h2>
</div>
</div>
</div>
<div class="col-6">
<div class="wrapper">
<h1>Legenda Semáforo</h1>
<h2>Número de casos confirmados de covid-19 em Curitiba 2020</h2>
<div id="controlPanel">
<div id="greenCaption" class="button"><div class="captionSpan" style="background-color: green;"></div> rt <= 0.5</div>
<div id="yellowCaption" class="button"><div class="captionSpan" style="background-color: yellow;"></div>0.5 < rt < 1 E UTI dispo >= 30%</div>
<div id="yellowCaption" class="button"><div class="captionSpan" style="background-color: yellow;"></div>1.0 <= rt < 1.5 E UTI dispo >= 60%</div>
<div id="orangeCaption" class="button"><div class="captionSpan" style="background-color: orange;"></div>1.0 <= rt < 1.5 E 30% < UTI dispo < 60%</div>
<div id="orangeCaption" class="button"><div class="captionSpan" style="background-color: orange;"></div>0.5 < rt < 1 E UTI dispo >= 10%</div>
<div id="redCaption" class="button"><div class="captionSpan" style="background-color: red;"></div>Nenhuma das anteriores</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-6">
<div class="wrapper">
<h1>Casos Confirmados</h1>
<h2>Número de casos confirmados de covid-19 em Curitiba 2020</h2>
<canvas id="confirmados" width="1280" height="720" bcolor="#8a9ae6"></canvas>
</div>
</div>
<div class="col-6">
<div class="wrapper">
<h1>Número de Óbitos</h1>
<h2>Número de óbitos confirmados por covid-19 em Curitiba 2020</h2>
<canvas id="obitos" width="1280" height="720" bcolor="#d64119"></canvas>
</div>
</div>
</div>
<div class="row justify-content-md-center">
<div class="col-6">
<div class="wrapper">
<h1>Pessoas Recuperadas</h1>
<h2>Número de pessoas curadas do covid-19 em Curitiba 2020</h2>
<canvas id="recuperados" width="1280" height="720" bcolor="#479c81"></canvas>
</div>
</div>
</div>
<div class="row">
<div class="col-6">
<div class="wrapper">
<h1>Ocupação de Leitos</h1>
<h2>Ocupação de leitos no Leste do Paraná</h2>
<canvas id="ocupacao_uti_adulto" width="1280" height="720" bcolor="#ec5d04"></canvas>
</div>
</div>
<div class="col-6">
<div class="wrapper">
<h1>rt</h1>
<h2>Taxa de transmissão do covid-19 em Curitiba 2020</br>Métrica computada de acordo com Bettencourt et al. (2019)</h2>
<canvas id="rt_thompson" width="1600" height="900" bcolor="#ec5d04"></canvas>
</div>
</div>
</div>
<div class="row">
<div class="col-6">
<div class="wrapper">
<h1>Previsão de Casos Totais</h1>
<h2>Previsão do número de casos em Curitiba</h2>
<canvas id="previsao" width="1600" height="900" bcolor="#00ff00"></canvas>
</div>
</div>
<div class="col-6">
<div class="wrapper">
<h1>Previsão de Casos Diários</h1>
<h2>Previsão de novos casos diários em Curitiba</h2>
<canvas id="previsao_diario" width="1600" height="900" bcolor="#00ff00"></canvas>
</div>
</div>
</div>
<div class="wrapper">
<h1>Equipe Responsável:</h1>
<ul>
<li>Profa. Dra. Cristina Baena - PPGCS</li>
<li>Prof. Dr. Emerson Cabrera Paraiso - PPGIa</li>
<li>Prof. Dr. Fabio Duarte - PPGTU</li>
<li>Prof. Dr. Rodrigo Firmino – PPGTU</li>
<li>Profa. Dra. Paula Trevilatto – PRPPI</li>
</ul>
<h1>Colaboradores:</h1>
<ul>
<li>Prof. Dr. Jean Paul Barddal - PPGIa</li>
<li>Luiz Bernardo Kummer - doutorando PPGIa</li>
<li>Matheus Camilo da Silva - mestrando PPGIa</li>
</ul>
</div>
<div class="wrapper">
<h1>Referências e fontes de dados:</h1>
<ul>
<li><a href="https://doi.org/10.1101/2020.03.31.20048942">A Gaussian Model for the Time Development of SARS-COV-2 Corova Pandemic Disease.</a></li>
<li><a href="https://www.curitiba.pr.gov.br/">Prefeitura Municipal de Curitiba</a></li>
<li><a href="http://www.saude.pr.gov.br/modules/conteudo/conteudo.php?conteudo=3507">Secretaria de Saúde do Paraná</a></li>
<li><a href="https://reader.elsevier.com/reader/sd/pii/S1755436519300350?token=ADB1EAB019F625239F8E38D64D85F910E995C5DBB844881A5440A3A4B0FD20D9E0CC1EAC56FAAC24F7EE515B69221A67">THOMPSON, R. N. et al. Improved inference of time-varying reproduction numbers during infectious disease outbreaks. Epidemics, v. 29, p. 100356, 2019.</a></li>
<li><a href="https://journals.plos.org/plosone/article/comments?id=10.1371/journal.pone.0002185">BETTENCOURT, Luis MA; RIBEIRO, Ruy M. Real time bayesian estimation of the epidemic potential of emerging infectious diseases. PLoS One, v. 3, n. 5, p. e2185, 2008.</a></li>
</ul>
</div>
</div>
</div>
<script type="text/javascript">
const base_url = 'https://covid-19-puc-dashboard.herokuapp.com/'
// const base_url = 'http://localhost:8080/'
const TOKEN_KEY = "@Covid-Token";
const USERNAME_KEY = "@Covid-User";
const isAuthenticated = () => localStorage.getItem(TOKEN_KEY) !== null;
const getToken = () => localStorage.getItem(TOKEN_KEY);
const getUser = () => localStorage.getItem(USERNAME_KEY)
const login = (token,username) => {
localStorage.setItem(TOKEN_KEY, token);
localStorage.setItem(USERNAME_KEY, username)
};
const logout = () => {
localStorage.removeItem(TOKEN_KEY);
location.reload();
};
var form = document.getElementById("login-form");
form.addEventListener("submit", my_func, true);
// Verifica se esta logado
Authentication()
async function Authentication(){
if (isAuthenticated()){
axios.defaults.headers.common['Authorization'] = getToken();
// Verifica de o Token esta expirado
if (await isExpired()) {
alert("Sessão Expirada.\nPor favor faça o login novamente.")
logout()
}
document.getElementById('login-form').style.display = "none"
document.getElementById('logged-content').style.display = "inherit"
document.getElementById('username').innerHTML = "Bem vindo <i>"+getUser()+"</i>"
document.getElementById('barra').style.display = 'inherit'
defaultGreen()
defaultYellow()
defaultOrange()
defaultRed()
consulta_semaforo()
consulta("confirmados")
consulta("obitos")
consulta("recuperados")
consulta_barra("ocupacao_uti_adulto")
consulta_rt("rt_thompson","2")
consulta_previsao("previsao")
consulta_previsao_diario("previsao_diario")
}else {
document.getElementById('login-form').style.display = "inherit"
document.getElementById('logged-content').style.display = "none"
document.getElementById('barra').style.display = 'none'
}
}
async function my_func(event) {
event.preventDefault();
try {
var email = document.getElementById('email').value
var pwd = document.getElementById('pwd').value
const response = await axios.post(base_url,{email, senha:pwd});
// console.log(response.data)
login(response.data.token, response.data.email)
alert("Sucesso")
Authentication()
} catch (error) {
alert("Conta não cadastrada")
console.error(error);
}
};
async function isExpired(){
try {
const response = await axios.get(base_url);
if(response.data.success){
return false;
}
return true;
} catch (error) {
console.error(error);
}}
async function consulta_rt(campo, tipo){
try {
const response = await axios.get(base_url+'consulta_rt/'+tipo);
drawChartRT(campo, response.data)
} catch (error) {
alert("Erro: contatar a equipe de desenvolvimento.")
console.error(error);
}}
async function consulta_previsao(campo){
try {
const response = await axios.get(base_url+'previsao/');
drawChartPrevisao(response.data, campo)
} catch (error) {
console.error(error);
}}
async function consulta_previsao_diario(campo){
try {
const response = await axios.get(base_url+'previsao_diario/');
drawChartPrevisao(response.data, campo)
} catch (error) {
console.error(error);
}}
async function consulta(campo){
try {
const response = await axios.get(base_url+'consulta/'+campo);
drawChart(campo, response.data)
} catch (error) {
console.error(error);
}}
async function consulta_barra(campo){
try {
const response = await axios.get(base_url+'consulta/'+campo);
drawChart_barra(campo, response.data)
} catch (error) {
console.error(error);
}}
async function consulta_semaforo(){
try {
const response = await axios.get(base_url+'consulta_rt/2');
var rt_semaforo = response.data.valor[response.data.valor.length-1]
} catch (error) {
console.error(error);
}
try {
const response = await axios.get(base_url+'consulta/ocupacao_uti_adulto');
var ocupacao_semaforo = response.data.ocupacao_uti_adulto[response.data.ocupacao_uti_adulto.length-1]
} catch (error) {
console.error(error);
}
drawSemaforo(rt_semaforo,ocupacao_semaforo)
}
function drawChart(campo, dataset){
var ctx = document.getElementById(campo);
var borderColor = ctx.getAttribute("bcolor");
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: dataset.datas,
datasets: [
{
data: dataset[campo],
label: `${campo} em Curitiba`,
borderColor,
fill: false
},
]
}
});
}
function drawChart_barra(campo, dataset){
const datas = dataset.datas
const leitos = dataset[campo]
const final_leitos = []
const final_datas = []
for (var i = 0; i < leitos.length; i++) {
if (leitos[i] != "NULL"){
final_leitos.push(leitos[i])
final_datas.push(datas[i])
}
}
var ctx = document.getElementById(campo);
var backgroundColor = 'rgba(255, 99, 132, 0.2)';
var borderColor = 'rgba(255,99,132,1)';
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: final_datas,
datasets: [
{
data: final_leitos,
label: `Ocupação porcentagem:`,
backgroundColor,
borderColor,
borderWidth: 1
},
]
},
options: {
scales: {
yAxes: [{
ticks: {
min: 0,
max: 100,
callback: function(value){return value+ "%"}
},
scaleLabel: {
display: true,
labelString: "% de leitos UTI ocupados"
}
}]
}
}
});
}
function drawChartRT(campo, dataset){
var ctx = document.getElementById(campo);
var borderColor = ctx.getAttribute("bcolor");
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: dataset.datas,
datasets: [
{
data: dataset.valor,
label: `RT em Curitiba`,
borderColor,
fill: false
},
{
data: dataset.acima_95,
label: `Margem acima 95%`,
borderColor: "#b19cd9",
fill:'-1',
order: 4,
pointRadius:0
},
{
data: dataset.abaixo_95,
label: `Margem abaixo 95%`,
borderColor: "#b19cd9",
fill:'-2',
order: 4,
pointRadius:0
}
]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true,
stepSize: 1,
},
}]
},
}
});
}
function drawChartPrevisao(dataset, campo){
var ctx = document.getElementById(campo);
var borderColor = ctx.getAttribute("bcolor");
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: dataset.datas,
datasets: [
{
data: dataset.num_casos_funcao,
label: `Tendência dos dados`,
borderColor,
fill: false,
order: 1
},
{
data: dataset.num_casos,
label: `Número de casos em Curitiba`,
borderColor: "#000",
fill: true,
backgroundColor:"#000",
showLine: false,
order: 2
},
{
data: dataset.m_erro,
label: `Previsão próximos 7 dias`,
borderColor: "#ff0000",
fill:false,
order: 3
},
{
data: dataset.acima_95,
label: `Margem acima 95%`,
borderColor: "#b19cd9",
fill:'-1',
order: 4,
pointRadius:0
},
{
data: dataset.abaixo_95,
label: `Margem abaixo 95%`,
borderColor: "#b19cd9",
fill:'-2',
order: 4,
pointRadius:0
},
{
data: dataset.num_casos_media_movel_7_dias,
label: `Média Móvel de 7 Dias`,
borderColor: "#0052a3",
fill:'-1',
order: 4,
pointRadius:0
},
]
},
});
}
function defaultGreen() {
document.getElementById('green').style.backgroundColor = "rgba(0, 128, 0, 0.1)";
}
function defaultYellow() {
document.getElementById('yellow').style.backgroundColor = "rgba(255, 255, 0, 0.1)";
}
function defaultOrange() {
document.getElementById('orange').style.backgroundColor = "rgb(255, 165, 0, 0.1)";
}
function defaultRed() {
document.getElementById('red').style.backgroundColor = "rgb(255, 0, 0, 0.1)";
}
// function drawSemaforo(rt,ocupacao){
// if(rt <= 0.5){
// document.getElementById('green').style.backgroundColor = "rgba(0, 128, 0)";
// }else if(rt < 1 && ocupacao <= 70){
// document.getElementById('yellow').style.backgroundColor = "rgba(255, 255, 0)";
// }else if(rt >= 1 || ocupacao > 70){
// document.getElementById('orange').style.backgroundColor = "rgb(255, 165, 0)"
// }else{
// document.getElementById('red').style.backgroundColor = "rgb(255, 0, 0)";
// }
// document.getElementById("captionSemaforo").innerHTML = `<b>RT: </b>${rt} <b>Disponibilidade Leitos: </b> ${(100-ocupacao).toFixed(2)}%`;
// }
function drawSemaforo(rt,ocupacao){
if(rt <= 0.5){
document.getElementById('green').style.backgroundColor = "rgba(0, 128, 0)";
}else if((rt > 0.5 && rt < 1) && ocupacao <= 70){
document.getElementById('yellow').style.backgroundColor = "rgba(255, 255, 0)";
}else if((rt >= 1.0 && rt < 1.5) && ocupacao < 40){
document.getElementById('yellow').style.backgroundColor = "rgba(255, 255, 0)";
}else if((rt >= 1.0 && rt < 1.5) && (ocupacao >= 40 && ocupacao <= 70)){
document.getElementById('orange').style.backgroundColor = "rgb(255, 165, 0)"
}else if((rt > 0.5 && rt < 1.0) && (ocupacao < 90)){
document.getElementById('orange').style.backgroundColor = "rgb(255, 165, 0)"
}else{
document.getElementById('red').style.backgroundColor = "rgb(255, 0, 0)";
}
document.getElementById("captionSemaforo").innerHTML = `<b>RT: </b>${rt} <b>Disponibilidade Leitos: </b> ${(100-ocupacao).toFixed(2)}%`;
}
</script>
</body>
</html>