Compare commits

..

No commits in common. "1fef5fd818eac01b0ab729a614b4ee27fc0d0366" and "3a54ce0d561e4169b4ce76a1ce2a8318133eb811" have entirely different histories.

6 changed files with 10 additions and 45 deletions

View file

@ -12,11 +12,11 @@ A web app designed to collect and display scores for sports
## Installation
This repository can be cloned and then pushed to Heroku/Dokku/etc.
This repository is designed to be pushed to Heroku/Dokku/etc.
### Requirements
- PostgreSQL (with an empty database created and an account to access it)
- PostgreSQL (with empty database created and an account to access it)
### Environment Variables
@ -32,8 +32,6 @@ This repository can be cloned and then pushed to Heroku/Dokku/etc.
This program uses Node.js/Express.js for the backend, PostgreSQL for the database (with node-postgres), and Passport.js for managing users and sessions.
To view the code, clone the repository and open it in VSCode/VSCodium.
### Structure
- `database` folder contains backend scripts for managing and storing data.
@ -46,7 +44,6 @@ To view the code, clone the repository and open it in VSCode/VSCodium.
- `auth.js` deals with logging in and out (`/auth/*`).
- `checkLoginStatus.js` contains functions for checking the login status of the current user.
- `data.js` sends various data to the client in JSON format (`/data/*`).
- `fetch.js` sends more specific data formatted for specific pages in JSON format (`/fetch/*`)
- `index.js` directs to the home page (`/`).
- `manage.js` contains various functions that allows the user to add and edit items through the web browser (`/manage/*`).
- `views` folder contains pug templates for each webpage, and a `layout` template for the base layout of each page.

View file

@ -1,6 +1,6 @@
{
"name": "score-tracker",
"version": "1.2.1",
"version": "1.0.3-pre",
"private": true,
"scripts": {
"start": "node ./bin/www"

View file

@ -15,7 +15,7 @@ async function initializeForm() {
let params = new URLSearchParams(location.search);
let divisionID = params.get('division');
if(divisionID) {
const division = await (await fetch(`/fetch/manage/division?division=${divisionID}`)).json();
const division = await Data.getDivision(divisionID);
nameTextbox.value = division.name;
@ -27,11 +27,7 @@ async function initializeForm() {
if(gender == 'female') genderDropdown.selectedIndex = 1;
else genderDropdown.selectedIndex = 2;
let data = {};
data.sports = [division.sport];
data.latestGame = {sportID : division.sportID };
Form.populateSports(sportDropdown, null, data);
Form.populateSports(sportDropdown, division.sportID);
Form.addHiddenValue('division', divisionID, submissionForm);
}

View file

@ -14,18 +14,14 @@ async function initializeForm() {
let params = new URLSearchParams(location.search);
let teamID = params.get('team');
if(teamID) {
const team = await (await fetch(`/fetch/manage/team?team=${teamID}`)).json();
const team = await Data.getTeam(teamID);
nameTextbox.value = team.name;
deleteButton.style.visibility = "visible";
deleteButton.disabled = false;
let data = {};
data.sports = [team.sport];
data.latestGame = {sportID : team.sportID };
Form.populateSports(sportDropdown, null, data);
Form.populateSports(sportDropdown, team.sportID);
Form.addHiddenValue('team', teamID, submissionForm);
}

View file

@ -98,7 +98,7 @@ router.get('/team', async function(req, res, next) {
console.error("ERROR: " + err.message);
res.status(500).send("An error has occurred");
}
});
})
router.get('/games', async function(req, res, next) {
try {

View file

@ -35,7 +35,7 @@ router.get('/index/dropdown', async function(req, res, next) {
seasonsData = await seasons.retrieveAll();
sportsData = await sports.retrieveAll();
gendersData = await genders.retrieveBySport(latestGame.sportID);
divisionsData = await divisions.retrieve(latestGame.sportID, latestGame.gender);
divisionsData = await divisions.retrieve(latestGame.sportID);
teamsData = await teams.retrieve(latestGame.sportID);
} else {
seasonsData = await seasons.retrieveAll();
@ -102,7 +102,7 @@ router.get('/submit', async function(req, res, next) {
seasonsData = await seasons.retrieveAll();
sportsData = await sports.retrieveAll();
gendersData = await genders.retrieveBySport(latestGame.sportID);
divisionsData = await divisions.retrieve(latestGame.sportID, latestGame.gender);
divisionsData = await divisions.retrieve(latestGame.sportID);
teamsData = await teams.retrieve(latestGame.sportID);
} else {
seasonsData = await seasons.retrieveAll();
@ -136,18 +136,6 @@ router.get('/manage/divisions', async function (req, res, next) {
res.json(data);
});
router.get('/manage/division', async function (req, res, next) {
try {
const divisionID = req.query.division;
const data = await divisions.getFromID(divisionID);
data.sport = await sports.getFromID(data.sportID);
res.json(data);
} catch(err) {
console.error("ERROR: " + err.message);
res.status(500).send("An error has occurred");
}
});
router.get('/manage/teams', async function (req, res, next) {
const data = await teams.retrieve();
@ -158,18 +146,6 @@ router.get('/manage/teams', async function (req, res, next) {
res.json(data);
});
router.get('/manage/team', async function (req, res, next) {
try {
const teamID = req.query.team;
const data = await teams.getFromID(teamID);
data.sport = await sports.getFromID(data.sportID);
res.json(data);
} catch(err) {
console.error("ERROR: " + err.message);
res.status(500).send("An error has occurred");
}
});
router.get('/manage/games', checkLoginStatus.user, async function (req, res, next) {
try{
const userIsAdmin = req.user[2];