Skip to content

Commit

Permalink
Merge pull request #2 from TNanukem/dev
Browse files Browse the repository at this point in the history
Algorithm comparison
  • Loading branch information
TNanukem authored Mar 22, 2020
2 parents c3a2dce + c9b33bd commit 3f401e7
Show file tree
Hide file tree
Showing 21 changed files with 934 additions and 464 deletions.
39 changes: 39 additions & 0 deletions src/helpers/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,45 @@ const Data = {
req.session.next_page = "simulation";
res.redirect("login");
}
},

async renderSimulationCompare(req, res){
if(req.session.authenticated == true){
try{
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]);

algorithms = [];

for(i = 0; i < rows.length; i++){
algorithms.push(String(rows[i].id)+'.'+rows[i].name + ' v ' + String(rows[i].version));
}

var {rows} = await pool.query('SELECT parameters_id FROM configuration WHERE researcher_id = $1', [req.session.user_id]);

parameters = [];

for(i = 0; i < rows.length; i++){
parameters.push(rows[i].parameters_id);
}

var {rows} = await pool.query('SELECT doi FROM publications');

published = []

for(i = 0; i < rows.length; i++){
published.push(rows[i].doi);
}


}catch(error){
console.log(error)
}
res.render('simulation_compare', {algorithms: algorithms, parameters: parameters, published: published});
}
else {
req.session.next_page = "simulation_compare";
res.redirect("login");
}
}

}
Expand Down
379 changes: 278 additions & 101 deletions src/helpers/simulation.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/helpers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,10 @@ const User = {
}

},

async logout(req, res){
req.session.authenticated = false;
res.redirect("/");
},
}
module.exports = User;
18 changes: 18 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ var upload = multer({
app.use(express.static('public'));
app.listen(3000);

app.use((req, res, next) => {
res.locals.session = req.session;
global.session = req.session;
next();
});


// -------------------------- END OF CONFIGURATION -----------------------------


Expand Down Expand Up @@ -89,6 +96,13 @@ app.get('/need_confirmation', function(req, res){
res.render('need_confirmation');
})

// Logout page routing
app.get('/logout', User.logout);

// Tutorial page routing
app.get('/tutorial', function(req, res){
res.render('tutorial')
})

// Experiment configuration page routing
app.get('/config', function(req, res) {
Expand Down Expand Up @@ -148,6 +162,10 @@ app.post('/algorithm', function(req, res){
// Simulation page routing
app.post('/simulation', Data.renderSimulation);

app.post('/simulation_compare', Data.renderSimulationCompare);

app.post('/simulation_compare_run', Simulation.runSimulationCompare);

app.post('/simulation_run', Simulation.runSimulation);

app.get('/downloadSimulation', Simulation.downloadSimulationResults);
Expand Down
10 changes: 8 additions & 2 deletions src/public/css/config.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
body {
font-family: 'Open Sans', sans-serif;

}

body div{
float: left;
text-align: center;
}

Expand All @@ -15,6 +15,7 @@ body p{
margin-bottom: -15px;
text-align: center !important;
font-size: 30px;
z-index: -9999;
}

input[type="checkbox"] {
Expand All @@ -26,6 +27,12 @@ input[type="text"] {
text-align: center;
}

div.col-md-6{
width: 100%;
text-align: center;
float: right !important;
}

div.checkbox_div{
float:none !important;
text-align: center !important;
Expand All @@ -50,7 +57,6 @@ div.checkbox_div input{
.center input{
text-align: center;
float:none !important;
margin-left: 90%;
}

.icons {
Expand Down
3 changes: 3 additions & 0 deletions src/public/css/tutorial.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* img {
zoom: 50%;
} */
Binary file added src/public/images/algorithm_upload.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/public/images/configure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/public/images/simulation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/public/images/simulation_compare.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/public/js/checkboxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ function checkbox(id_check, id_div, id_text){
text.style.display = "block";
div.style.float = "initial";
div.style.display = "none"
text.style.marginLeft = "auto"
text.style.marginRight = "auto"
}
}

Expand Down
13 changes: 13 additions & 0 deletions src/public/js/config_validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,16 @@ function validation(id_check, exact, max, min){
max.required = false;
}
}

function maxMinValidation(max, min){
// var max = document.getElementById(max);
// var min = document.getElementById(min);
// window.alert(min.value + "vs" + max.value);
// if(min.value >= max.value){
// min.setCustomValidity("Minimun value has to be smaller than the maximum value");
// window.alert(min.value + "vs" + max.value);
// } else {
// min.setCustomValidity("");
// window.alert('tudo certo');
// }
}
11 changes: 11 additions & 0 deletions src/public/js/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,14 @@ function showParameters(value){

}
}

function parameterSelection(checkbox, div){
var check = document.getElementById(checkbox);
var div = document.getElementById(div)

if(check.checked == true){
div.style.display = "none";
} else {
div.style.display = "block";
}
}
10 changes: 10 additions & 0 deletions src/public/js/pass_compare.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function comparePasswords(){
var password = document.getElementById("InputPassword");
var comparison = document.getElementById("ConfirmPassword");

if(password.value == comparison.value){
comparison.setCustomValidity("");
} else {
comparison.setCustomValidity("The passwords must match");
}
}
Loading

0 comments on commit 3f401e7

Please sign in to comment.