Compare commits

...

12 Commits

Author SHA1 Message Date
Ethan Reece 1fef5fd818 Merge branch 'develop' into 'main'
Develop

See merge request sudoer777/score-tracker!17
2022-03-10 04:05:15 +00:00
sudoer777 84700c069f Update to v1.2.1 2022-03-09 21:03:20 -07:00
sudoer777 e231610fab Bugfix for listing divisions on index and submit pages 2022-03-09 21:02:43 -07:00
Ethan Reece bb9c583ed2 Merge branch 'testing' into 'main'
v1.2.0

See merge request sudoer777/score-tracker!16
2022-03-10 01:19:49 +00:00
Ethan Reece 46194f6e46 Merge branch 'develop' into 'testing'
v1.2.0

See merge request sudoer777/score-tracker!15
2022-03-10 01:16:52 +00:00
Ethan Reece 946316d4b5 Update package.json 2022-03-10 01:15:32 +00:00
Ethan Reece 8266b146ea Update .gitlab-ci.yml file 2022-03-10 01:13:52 +00:00
Ethan Reece 6ceeed1ef6 Update README.md 2022-03-10 01:08:05 +00:00
sudoer777 8d830735ff Add better loading for editing teams 2022-03-09 17:57:18 -07:00
sudoer777 29605613c0 Improve loading for editing divisions 2022-03-09 16:55:07 -07:00
Ethan Reece e6ffa52708 Merge branch 'develop' into 'testing'
Move v1.1 to testing

See merge request sudoer777/score-tracker!14
2021-12-07 18:29:48 +00:00
Ethan Reece 194b49a0f9 Rename from cvcs-score-tracker to score-tracker 2021-11-27 03:37:44 +00:00
6 changed files with 45 additions and 10 deletions

View File

@ -12,11 +12,11 @@ A web app designed to collect and display scores for sports
## Installation
This repository is designed to be pushed to Heroku/Dokku/etc.
This repository can be cloned and then pushed to Heroku/Dokku/etc.
### Requirements
- PostgreSQL (with empty database created and an account to access it)
- PostgreSQL (with an empty database created and an account to access it)
### Environment Variables
@ -32,6 +32,8 @@ This repository is designed to be 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.
@ -44,6 +46,7 @@ This program uses Node.js/Express.js for the backend, PostgreSQL for the databas
- `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.0.3-pre",
"version": "1.2.1",
"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 Data.getDivision(divisionID);
const division = await (await fetch(`/fetch/manage/division?division=${divisionID}`)).json();
nameTextbox.value = division.name;
@ -27,7 +27,11 @@ async function initializeForm() {
if(gender == 'female') genderDropdown.selectedIndex = 1;
else genderDropdown.selectedIndex = 2;
Form.populateSports(sportDropdown, division.sportID);
let data = {};
data.sports = [division.sport];
data.latestGame = {sportID : division.sportID };
Form.populateSports(sportDropdown, null, data);
Form.addHiddenValue('division', divisionID, submissionForm);
}

View File

@ -14,14 +14,18 @@ async function initializeForm() {
let params = new URLSearchParams(location.search);
let teamID = params.get('team');
if(teamID) {
const team = await Data.getTeam(teamID);
const team = await (await fetch(`/fetch/manage/team?team=${teamID}`)).json();
nameTextbox.value = team.name;
deleteButton.style.visibility = "visible";
deleteButton.disabled = false;
Form.populateSports(sportDropdown, team.sportID);
let data = {};
data.sports = [team.sport];
data.latestGame = {sportID : team.sportID };
Form.populateSports(sportDropdown, null, data);
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);
divisionsData = await divisions.retrieve(latestGame.sportID, latestGame.gender);
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);
divisionsData = await divisions.retrieve(latestGame.sportID, latestGame.gender);
teamsData = await teams.retrieve(latestGame.sportID);
} else {
seasonsData = await seasons.retrieveAll();
@ -136,6 +136,18 @@ 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();
@ -146,6 +158,18 @@ 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];