Skip to content

Commit 3f401e7

Browse files
authored
Merge pull request #2 from TNanukem/dev
Algorithm comparison
2 parents c3a2dce + c9b33bd commit 3f401e7

21 files changed

+934
-464
lines changed

src/helpers/data.js

+39
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,45 @@ const Data = {
4242
req.session.next_page = "simulation";
4343
res.redirect("login");
4444
}
45+
},
46+
47+
async renderSimulationCompare(req, res){
48+
if(req.session.authenticated == true){
49+
try{
50+
var {rows} = await pool.query('SELECT name, version, id FROM algorithms WHERE id in (SELECT algorithm_id FROM development WHERE researcher_id = $1)', [req.session.user_id]);
51+
52+
algorithms = [];
53+
54+
for(i = 0; i < rows.length; i++){
55+
algorithms.push(String(rows[i].id)+'.'+rows[i].name + ' v ' + String(rows[i].version));
56+
}
57+
58+
var {rows} = await pool.query('SELECT parameters_id FROM configuration WHERE researcher_id = $1', [req.session.user_id]);
59+
60+
parameters = [];
61+
62+
for(i = 0; i < rows.length; i++){
63+
parameters.push(rows[i].parameters_id);
64+
}
65+
66+
var {rows} = await pool.query('SELECT doi FROM publications');
67+
68+
published = []
69+
70+
for(i = 0; i < rows.length; i++){
71+
published.push(rows[i].doi);
72+
}
73+
74+
75+
}catch(error){
76+
console.log(error)
77+
}
78+
res.render('simulation_compare', {algorithms: algorithms, parameters: parameters, published: published});
79+
}
80+
else {
81+
req.session.next_page = "simulation_compare";
82+
res.redirect("login");
83+
}
4584
}
4685

4786
}

src/helpers/simulation.js

+278-101
Large diffs are not rendered by default.

src/helpers/user.js

+5
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,10 @@ const User = {
146146
}
147147

148148
},
149+
150+
async logout(req, res){
151+
req.session.authenticated = false;
152+
res.redirect("/");
153+
},
149154
}
150155
module.exports = User;

src/index.js

+18
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ var upload = multer({
5757
app.use(express.static('public'));
5858
app.listen(3000);
5959

60+
app.use((req, res, next) => {
61+
res.locals.session = req.session;
62+
global.session = req.session;
63+
next();
64+
});
65+
66+
6067
// -------------------------- END OF CONFIGURATION -----------------------------
6168

6269

@@ -89,6 +96,13 @@ app.get('/need_confirmation', function(req, res){
8996
res.render('need_confirmation');
9097
})
9198

99+
// Logout page routing
100+
app.get('/logout', User.logout);
101+
102+
// Tutorial page routing
103+
app.get('/tutorial', function(req, res){
104+
res.render('tutorial')
105+
})
92106

93107
// Experiment configuration page routing
94108
app.get('/config', function(req, res) {
@@ -148,6 +162,10 @@ app.post('/algorithm', function(req, res){
148162
// Simulation page routing
149163
app.post('/simulation', Data.renderSimulation);
150164

165+
app.post('/simulation_compare', Data.renderSimulationCompare);
166+
167+
app.post('/simulation_compare_run', Simulation.runSimulationCompare);
168+
151169
app.post('/simulation_run', Simulation.runSimulation);
152170

153171
app.get('/downloadSimulation', Simulation.downloadSimulationResults);

src/public/css/config.css

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
body {
22
font-family: 'Open Sans', sans-serif;
3+
34
}
45

56
body div{
6-
float: left;
77
text-align: center;
88
}
99

@@ -15,6 +15,7 @@ body p{
1515
margin-bottom: -15px;
1616
text-align: center !important;
1717
font-size: 30px;
18+
z-index: -9999;
1819
}
1920

2021
input[type="checkbox"] {
@@ -26,6 +27,12 @@ input[type="text"] {
2627
text-align: center;
2728
}
2829

30+
div.col-md-6{
31+
width: 100%;
32+
text-align: center;
33+
float: right !important;
34+
}
35+
2936
div.checkbox_div{
3037
float:none !important;
3138
text-align: center !important;
@@ -50,7 +57,6 @@ div.checkbox_div input{
5057
.center input{
5158
text-align: center;
5259
float:none !important;
53-
margin-left: 90%;
5460
}
5561

5662
.icons {

src/public/css/tutorial.css

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/* img {
2+
zoom: 50%;
3+
} */
28.8 KB
Loading

src/public/images/configure.png

53.5 KB
Loading

src/public/images/simulation.png

43.8 KB
Loading
59.4 KB
Loading

src/public/js/checkboxes.js

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ function checkbox(id_check, id_div, id_text){
1313
text.style.display = "block";
1414
div.style.float = "initial";
1515
div.style.display = "none"
16+
text.style.marginLeft = "auto"
17+
text.style.marginRight = "auto"
1618
}
1719
}
1820

src/public/js/config_validator.js

+13
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,16 @@ function validation(id_check, exact, max, min){
1414
max.required = false;
1515
}
1616
}
17+
18+
function maxMinValidation(max, min){
19+
// var max = document.getElementById(max);
20+
// var min = document.getElementById(min);
21+
// window.alert(min.value + "vs" + max.value);
22+
// if(min.value >= max.value){
23+
// min.setCustomValidity("Minimun value has to be smaller than the maximum value");
24+
// window.alert(min.value + "vs" + max.value);
25+
// } else {
26+
// min.setCustomValidity("");
27+
// window.alert('tudo certo');
28+
// }
29+
}

src/public/js/database.js

+11
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,14 @@ function showParameters(value){
1414

1515
}
1616
}
17+
18+
function parameterSelection(checkbox, div){
19+
var check = document.getElementById(checkbox);
20+
var div = document.getElementById(div)
21+
22+
if(check.checked == true){
23+
div.style.display = "none";
24+
} else {
25+
div.style.display = "block";
26+
}
27+
}

src/public/js/pass_compare.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function comparePasswords(){
2+
var password = document.getElementById("InputPassword");
3+
var comparison = document.getElementById("ConfirmPassword");
4+
5+
if(password.value == comparison.value){
6+
comparison.setCustomValidity("");
7+
} else {
8+
comparison.setCustomValidity("The passwords must match");
9+
}
10+
}

0 commit comments

Comments
 (0)