Skip to content
Snippets Groups Projects
Commit 8e9fc1e7 authored by Josefine Wegert's avatar Josefine Wegert
Browse files

views created, labels are taken from file

parent df6c840f
No related branches found
No related tags found
No related merge requests found
...@@ -7,9 +7,12 @@ var fs = require('fs'); ...@@ -7,9 +7,12 @@ var fs = require('fs');
var path = require('path'); var path = require('path');
var Zip = require('node-zip'); var Zip = require('node-zip');
var exphbs = require('express-handlebars');
var logger = require('morgan');
//load names of available download files
var downloadFiles = require('./downloadFiles.json');
var downloadNames = Object.keys(downloadFiles);
var app = express(); var app = express();
...@@ -17,53 +20,32 @@ app.use(bodyParser.urlencoded({ ...@@ -17,53 +20,32 @@ app.use(bodyParser.urlencoded({
extended: true extended: true
})); }));
app.use(bodyParser.json()); app.use(bodyParser.json());
app.use(logger("short"));
//set handlebars as view engine
app.engine('.hbs', exphbs({extname: '.hbs'}));
app.set('view engine', '.hbs');
app.get('/', function(req, res){ app.get('/', function(req, res){
res.render('home', {downloadFiles: downloadNames});
var html = '<form action="/" method="post">' +
'Choose your builds:<br>' +
'<input type="checkbox" name="frontend" value="frontend">Frontend<br>' +
'<input type="checkbox" name="backend" value="backend">Backend<br>' +
'<br>' +
'<button type="submit">Create Build & Download Zip</button>' +
'</form>';
res.send(html);
}); });
app.post('/waiting', function(req, res){
var test; console.log("frontend in /waiting", req.body['explorviz-ui-backend']);
var checkedFiles = Object.keys(req.body);
app.post('/', function(req, res){ console.log("checkedFiles", checkedFiles);
res.render('download', {test: checkedFiles});
console.log(req.body);
test = req.body.frontend;
var html =
'Your download is being prepared. This may take a moment. ' +
'Do not close the window.' +
'<script> location.href="/download" </script>';
// discouraged by WC3
//'<meta http-equiv="refresh" content="1; url=/download" />';
res.send(html);
}); });
app.get('/download', function(req, res){ app.get('/download', function(req, res){
console.log("frontend in /download", req.body);
console.log(test); // if (typeof req.body.backend !== 'undefined'){
console.log("inside backend branch");
exec('cd /home/akr/eclipse-workspace/explorviz-ui-backend && mvn compile war:war', (error, stdout, stderr) => { exec('cd /home/jweg/git/explorviz-ui-backend && mvn compile war:war', (error, stdout, stderr) => {
var response = var response =
'There was an error during your build. ' + 'There was an error during your build. ' +
...@@ -85,7 +67,7 @@ app.get('/download', function(req, res){ ...@@ -85,7 +67,7 @@ app.get('/download', function(req, res){
zip.file('README.txt', fs.readFileSync(path.join(__dirname, 'README.txt'))); zip.file('README.txt', fs.readFileSync(path.join(__dirname, 'README.txt')));
zip.file('explorviz-backend.war', zip.file('explorviz-backend.war',
fs.readFileSync('/home/akr/eclipse-workspace/explorviz-ui-backend/target/explorviz-ui-backend-1.0-SNAPSHOT.war')); fs.readFileSync('/home/jweg/git/explorviz-ui-backend/target/explorviz-ui-backend-1.0-SNAPSHOT.war'));
var options = {base64: false, compression:'DEFLATE'}; var options = {base64: false, compression:'DEFLATE'};
...@@ -108,7 +90,16 @@ app.get('/download', function(req, res){ ...@@ -108,7 +90,16 @@ app.get('/download', function(req, res){
}); });
}); });
// }
// else if (typeof req.body.frontend !== 'undefined'){
// console.log("inside frontend branch");
// res.send(req.body.frontend);
// } else {
// console.log("inside else branch");
// res.send("nix ausgewählt");
// }
}); });
app.listen(8080); app.listen(8080);
console.log("Downloader started on port 8080.");
\ No newline at end of file
{ "explorviz-ui-frontend": "https://github.com/ExplorViz/explorviz-ui-frontend.git",
"explorviz-ui-backend": "https://github.com/ExplorViz/explorviz-ui-backend.git",
"explorviz-frontend-plugin-example": "https://github.com/ExplorViz/explorviz-frontend-plugin-example.git",
"explorviz-backend-plugin-example": "https://github.com/ExplorViz/explorviz-backend-plugin-example.git"
}
\ No newline at end of file
...@@ -13,7 +13,9 @@ ...@@ -13,7 +13,9 @@
"body-parser": "^1.17.1", "body-parser": "^1.17.1",
"child_process": "^1.0.2", "child_process": "^1.0.2",
"express": "^4.15.2", "express": "^4.15.2",
"express-handlebars": "^3.0.0",
"fs": "0.0.1-security", "fs": "0.0.1-security",
"morgan": "^1.8.2",
"node-zip": "^1.1.1", "node-zip": "^1.1.1",
"path": "^0.12.7" "path": "^0.12.7"
} }
......
<div class="container">Your download is being prepared. This may take a moment. Do not close the window.</div>
<script> location.href="/download" </script>
<form action="/waiting" method="post">
Choose which files to compile into your custom build of ExplorViz:<br>
{{#each downloadFiles as |item|}}
<input type="checkbox" name={{item}} value={{item}}>{{item}}<br>
{{/each}}
<br>
<a >
<button type="submit">Create Build and Download Zip</a>
</form>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment