Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Field Science
datavis
Commits
64215ac0
Commit
64215ac0
authored
Nov 20, 2021
by
Porter Libby
Browse files
aesthetic changes, readability
parent
4d22041d
Changes
6
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
64215ac0
# IFS Datavis Tool 2
## v0.1.5
Project details have been migrated to the wiki located
[
HERE
](
https://code.cs.earlham.edu/field-science/datavis/-/wikis/home
)
index.js
View file @
64215ac0
console
.
log
(
"
\n
==================================
"
);
console
.
log
(
"
| IFS DATAVIS 2 |
"
);
console
.
log
(
"
==================================
\n
"
);
const
express
=
require
(
'
express
'
);
const
app
=
express
();
const
q
=
require
(
'
./queries
'
);
var
pjson
=
require
(
'
./package.json
'
);
var
path
=
require
(
'
path
'
);
var
rest
=
new
require
(
'
restful-api
'
)(
app
);
var
favicon
=
require
(
'
serve-favicon
'
);
const
app
=
express
();
var
rest
=
new
require
(
'
restful-api
'
)(
app
);
console
.
log
(
"
================================================================================
"
);
console
.
log
(
"
| |
"
);
console
.
log
(
"
|██ ██████ ██████ ██████ █████ ██████ █████ ██ ██ ██ ██████ ██████ |
"
);
console
.
log
(
"
|██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ |
"
);
console
.
log
(
"
|██ █████ ██████ ██ ██ ███████ ██ ███████ ██ ██ ██ ██████ █████ |
"
);
console
.
log
(
"
|██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ |
"
);
console
.
log
(
"
|██ ██ ██████ ██████ ██ ██ ██ ██ ██ ████ ██ ██████ ███████ |
"
);
console
.
log
(
"
| |
"
);
console
.
log
(
"
====================================================================== v
"
+
pjson
.
version
+
"
==
"
);
console
.
log
(
"
\n
"
);
app
.
set
(
'
view engine
'
,
'
ejs
'
);
app
.
get
(
'
/
'
,
function
(
req
,
res
)
{
...
...
@@ -30,6 +38,9 @@ app.get('/streamingshosts', q.getStreamingsHosts);
app
.
get
(
'
/streamingsplatforms
'
,
q
.
getStreamingsPlatforms
);
app
.
get
(
'
/streamingsdates
'
,
q
.
getStreamingsDates
);
app
.
get
(
'
/streamings
'
,
q
.
getStreamings
);
app
.
get
(
'
/v
'
,
function
(
res
,
req
){
req
.
status
(
200
).
json
(
pjson
.
version
);
});
// LISTEN
...
...
@@ -38,6 +49,6 @@ app.listen(9900, '0.0.0.0', function (err) {
console
.
log
(
err
)
return
}
console
.
log
(
'
Listening at http://localhost:
'
+
"
9900
"
+
'
\n
'
)
console
.
log
(
'
SERVER:
Listening at http://localhost:
'
+
"
9900
"
+
'
\n
'
)
})
package.json
View file @
64215ac0
{
"name"
:
"datavis"
,
"version"
:
"0.1.
5
"
,
"version"
:
"0.1.
6
"
,
"description"
:
"A tool for visualizing the data collected from the IFS Earlham trip"
,
"main"
:
"index.js"
,
"scripts"
:
{
...
...
public/js/main.js
View file @
64215ac0
...
...
@@ -9,6 +9,16 @@
function
ready
(){
switchToData
()
// set screen to data
$
.
ajax
({
type
:
'
GET
'
,
url
:
'
/v
'
,
success
:
function
(
response
)
{
document
.
getElementById
(
"
version-tag
"
).
innerText
=
"
IFS Datavis Tool v
"
+
response
;
},
error
:
function
(
xhr
,
status
,
err
)
{
console
.
log
(
xhr
.
responseText
);
}
});
base_url
=
document
.
location
.
href
;
// get base url
...
...
queries.js
View file @
64215ac0
...
...
@@ -2,6 +2,7 @@
#
# Datavis 2.0
# Porter Libby - 2019 - initial setup
# Porter Libby - 2021 - improve some systems for more flexibility
# pelibby16@earlham.edu
#
# Query functions for database
...
...
@@ -9,18 +10,36 @@
*/
// IMPORTANT: The .ENV file must be setup before running, see README for template
const
dotenv
=
require
(
'
dotenv
'
);
dotenv
.
config
();
const
Pool
=
require
(
'
pg
'
).
Pool
var
pool
=
null
;
if
(
process
.
env
.
DB_NAME
!=
null
&&
process
.
env
.
DB_HOST
!=
null
&&
process
.
env
.
DB_DATABASE
!=
null
&&
process
.
env
.
DB_PASSWORD
!=
null
&&
process
.
env
.
DB_PORT
!=
null
){
pool
=
new
Pool
({
user
:
`
${
process
.
env
.
DB_NAME
}
`
,
host
:
`
${
process
.
env
.
DB_HOST
}
`
,
database
:
`
${
process
.
env
.
DB_DATABASE
}
`
,
password
:
`
${
process
.
env
.
DB_PASSWORD
}
`
,
port
:
`
${
process
.
env
.
DB_PORT
}
`
,
})
}
const
pool
=
new
Pool
({
user
:
`
${
process
.
env
.
DB_NAME
}
`
,
host
:
`
${
process
.
env
.
DB_HOST
}
`
,
database
:
`
${
process
.
env
.
DB_DATABASE
}
`
,
password
:
`
${
process
.
env
.
DB_PASSWORD
}
`
,
port
:
`
${
process
.
env
.
DB_PORT
}
`
,
})
function
updatePool
(
user
,
host
,
database
,
password
,
port
){
if
(
user
!=
null
&&
host
!=
null
&&
database
!=
null
&&
password
!=
null
&&
port
!=
null
){
pool
=
new
Pool
({
user
:
`
${
process
.
env
.
DB_NAME
}
`
,
host
:
`
${
process
.
env
.
DB_HOST
}
`
,
database
:
`
${
process
.
env
.
DB_DATABASE
}
`
,
password
:
`
${
process
.
env
.
DB_PASSWORD
}
`
,
port
:
`
${
process
.
env
.
DB_PORT
}
`
,
})
console
.
log
(
"
DATABASE: Updating DB pool...
"
);
}
}
const
getTrips
=
(
request
,
response
)
=>
{
var
query
=
"
SELECT tripName, tripID,
"
...
...
@@ -213,11 +232,11 @@ function serverOut(querytext){
console
.
info
(
"
DATABASE:
"
+
querytext
+
"
\n
"
);
}
function
checkConnection
(){
console
.
log
(
'
D
atabase
: starting connection...
'
);
console
.
log
(
'
D
ATABASE
: starting connection...
'
);
pool
.
query
(
"
SELECT * FROM fieldday_trip;
"
,
(
error
,
results
)
=>
{
if
(
error
)
{
console
.
log
(
'
D
atabase
: connection to database failed, check .ENV file.
'
);
console
.
log
(
'
Halting...
'
);
console
.
log
(
'
D
ATABASE
: connection to database failed, check .ENV file.
'
);
console
.
log
(
'
SERVER:
Halting...
'
);
process
.
exit
(
1
);
}
else
{
console
.
log
(
'
Database: connection successful!
\n
'
);
...
...
views/index.ejs
View file @
64215ac0
...
...
@@ -113,7 +113,7 @@
<div
id=
'dataView'
>
<div
id=
'title'
>
<span
style=
'font-size:20px;'
>
IFS Datavis Tool v0.1.5
</span><br>
<span
id=
'version-tag'
style=
'font-size:20px;'
></span><br>
</div>
<div
id=
'data'
>
<div
class=
'data-catagory'
id=
'query_type'
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment