Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
explorviz-downloader
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ExplorViz
explorviz-github-archive
explorviz-downloader
Commits
c669dca6
Commit
c669dca6
authored
7 years ago
by
Josefine Wegert
Browse files
Options
Downloads
Patches
Plain Diff
clientCounter fixed
parent
a907921e
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
app.js
+1
-3
1 addition, 3 deletions
app.js
routes/download.js
+2
-4
2 additions, 4 deletions
routes/download.js
routes/home.js
+2
-6
2 additions, 6 deletions
routes/home.js
with
5 additions
and
13 deletions
app.js
+
1
−
3
View file @
c669dca6
...
@@ -42,10 +42,8 @@ app.set('zipFunctions', zipFunctions);
...
@@ -42,10 +42,8 @@ app.set('zipFunctions', zipFunctions);
//clientCounter holds the number of clients who wants to download files
//clientCounter holds the number of clients who wants to download files
let
clientCounter
=
0
;
let
clientCounter
=
0
;
app
.
set
(
'
clientCounter
'
,
clientCounter
);
app
.
locals
.
clientCounter
=
clientCounter
;
//routes
//routes
//app.use('/', home);
require
(
'
./routes/home.js
'
)(
app
);
require
(
'
./routes/home.js
'
)(
app
);
require
(
'
./routes/download.js
'
)(
app
);
require
(
'
./routes/download.js
'
)(
app
);
...
...
This diff is collapsed.
Click to expand it.
routes/download.js
+
2
−
4
View file @
c669dca6
...
@@ -6,7 +6,6 @@ module.exports= function(app){
...
@@ -6,7 +6,6 @@ module.exports= function(app){
const
downloadNames
=
app
.
get
(
'
downloadNames
'
);
const
downloadNames
=
app
.
get
(
'
downloadNames
'
);
const
downloadFiles
=
app
.
get
(
'
downloadFiles
'
);
const
downloadFiles
=
app
.
get
(
'
downloadFiles
'
);
let
clientCounter
=
app
.
get
(
'
clientCounter
'
);
const
clientFolder
=
app
.
get
(
'
clientFolder
'
);
const
clientFolder
=
app
.
get
(
'
clientFolder
'
);
const
backendFunctions
=
app
.
get
(
'
backendFunctions
'
);
const
backendFunctions
=
app
.
get
(
'
backendFunctions
'
);
const
frontendFunctions
=
app
.
get
(
'
frontendFunctions
'
);
const
frontendFunctions
=
app
.
get
(
'
frontendFunctions
'
);
...
@@ -16,18 +15,17 @@ const zipFunctions = app.get('zipFunctions');
...
@@ -16,18 +15,17 @@ const zipFunctions = app.get('zipFunctions');
app
.
get
(
'
/download
'
,
function
(
req
,
res
,
next
){
app
.
get
(
'
/download
'
,
function
(
req
,
res
,
next
){
const
checkedFiles
=
req
.
query
.
checkedFiles
.
split
(
'
,
'
);
const
checkedFiles
=
req
.
query
.
checkedFiles
.
split
(
'
,
'
);
let
clientName
;
let
clientName
;
let
clientCounter
=
req
.
app
.
locals
.
clientCounter
;
const
zip
=
new
JSZip
();
const
zip
=
new
JSZip
();
zip
.
file
(
"
README.txt
"
,
"
text for README
"
);
zip
.
file
(
"
README.txt
"
,
"
text for README
"
);
//holds promises for backend and/or frontend for synchronizing
//holds promises for backend and/or frontend for synchronizing
const
promiseArray
=
[]
const
promiseArray
=
[]
console
.
log
(
'
clientCounter, download:
'
,
clientCounter
);
//TODO handle multiple clients
//TODO handle multiple clients
if
(
clientCounter
>
5
){
if
(
clientCounter
>
5
){
res
.
render
(
'
tooManyClients
'
);
res
.
render
(
'
tooManyClients
'
);
}
else
{
}
else
{
clientName
=
'
client_
'
+
clientCounter
;
clientName
=
'
client_
'
+
clientCounter
;
console
.
log
(
'
clientCounter, download.makeClientFolder:
'
,
clientCounter
);
clientFolder
.
makeClientFolder
(
clientName
);
clientFolder
.
makeClientFolder
(
clientName
);
}
}
...
@@ -121,7 +119,7 @@ function createZip(zip){
...
@@ -121,7 +119,7 @@ function createZip(zip){
}).
on
(
'
finish
'
,
function
()
{
}).
on
(
'
finish
'
,
function
()
{
console
.
log
(
'
explorviz-builds.zip written.
'
);
console
.
log
(
'
explorviz-builds.zip written.
'
);
//client finishes everything except getting the download
//client finishes everything except getting the download
clientCounter
=
clientCounter
-
1
;
req
.
app
.
locals
.
clientCounter
=
clientCounter
-
1
;
res
.
download
(
'
explorviz-builds.zip
'
,
function
(
error
){
res
.
download
(
'
explorviz-builds.zip
'
,
function
(
error
){
if
(
error
){
if
(
error
){
let
response
=
let
response
=
...
...
This diff is collapsed.
Click to expand it.
routes/home.js
+
2
−
6
View file @
c669dca6
...
@@ -4,8 +4,6 @@ const express = require('express');
...
@@ -4,8 +4,6 @@ const express = require('express');
module
.
exports
=
function
(
app
){
module
.
exports
=
function
(
app
){
const
downloadNames
=
app
.
get
(
'
downloadNames
'
);
const
downloadNames
=
app
.
get
(
'
downloadNames
'
);
let
clientCounter
=
app
.
get
(
'
clientCounter
'
);
console
.
log
(
'
clientCounter, home:
'
,
clientCounter
);
//This route shows the homepage.
//This route shows the homepage.
app
.
get
(
'
/
'
,
function
(
req
,
res
){
app
.
get
(
'
/
'
,
function
(
req
,
res
){
...
@@ -15,12 +13,10 @@ app.get('/', function(req, res){
...
@@ -15,12 +13,10 @@ app.get('/', function(req, res){
//This route takes the checkedFiles the user selected on the homepage, shows the download page on which the actual download is triggered.
//This route takes the checkedFiles the user selected on the homepage, shows the download page on which the actual download is triggered.
app
.
post
(
'
/
'
,
function
(
req
,
res
,
next
){
app
.
post
(
'
/
'
,
function
(
req
,
res
,
next
){
const
checkedFiles
=
Object
.
keys
(
req
.
body
);
const
checkedFiles
=
Object
.
keys
(
req
.
body
);
let
clientCounter
=
req
.
app
.
locals
.
clientCounter
;
if
(
typeof
checkedFiles
!==
'
undefined
'
&&
checkedFiles
.
length
>
0
){
if
(
typeof
checkedFiles
!==
'
undefined
'
&&
checkedFiles
.
length
>
0
){
let
increasedClientCounter
=
clientCounter
+
1
;
req
.
app
.
locals
.
clientCounter
=
clientCounter
+
1
;
app
.
set
(
'
clientCounter
'
,
increasedClientCounter
);
console
.
log
(
'
clientCounter, home +1:
'
,
clientCounter
);
res
.
render
(
'
download
'
,
{
checkedFiles
:
checkedFiles
,
downloadFiles
:
downloadNames
});
res
.
render
(
'
download
'
,
{
checkedFiles
:
checkedFiles
,
downloadFiles
:
downloadNames
});
}
}
else
{
else
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment