Add login/logout buttons
This commit is contained in:
parent
e277107b10
commit
872397d05e
16 changed files with 64 additions and 59 deletions
14
public/scripts/main.js
Normal file
14
public/scripts/main.js
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
const logInButton = document.getElementById('login-button');
|
||||||
|
const logOutButton = document.getElementById('logout-button');
|
||||||
|
|
||||||
|
if(logInButton) {
|
||||||
|
logInButton.addEventListener('click', () => {
|
||||||
|
window.location.href = "/auth/login";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if(logOutButton) {
|
||||||
|
logOutButton.addEventListener('click', () => {
|
||||||
|
window.location.href = "/auth/logout";
|
||||||
|
});
|
||||||
|
}
|
|
@ -25,8 +25,3 @@ tr {
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
}
|
}
|
||||||
|
|
||||||
#actions-div {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
margin-left: auto;
|
|
||||||
}
|
|
|
@ -23,3 +23,8 @@ a {
|
||||||
.send-to-right {
|
.send-to-right {
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#actions-div {
|
||||||
|
display: flex;
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
|
@ -3,7 +3,7 @@ var router = express.Router();
|
||||||
|
|
||||||
/* GET home page. */
|
/* GET home page. */
|
||||||
router.get('/', function(req, res, next) {
|
router.get('/', function(req, res, next) {
|
||||||
res.render('index', { title: 'View Scores' });
|
res.render('index', { title: 'View Scores', userLoggedIn: !!req.user });
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|
|
@ -30,14 +30,14 @@ function adminLoggedIn(req, res, next) {
|
||||||
|
|
||||||
|
|
||||||
router.get('/' ,userLoggedIn, function(req, res, next) {
|
router.get('/' ,userLoggedIn, function(req, res, next) {
|
||||||
if(req.user[2]) res.render('manage', { title: 'Score Management' });
|
if(req.user[2]) res.render('manage', { title: 'Score Management', userLoggedIn: !!req.user });
|
||||||
else res.render('manage/manage-nonadmin', { title: "My Games" });
|
else res.render('manage/manage-nonadmin', { title: "My Games", userLoggedIn: !!req.user });
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/game', userLoggedIn, function(req, res, next) {
|
router.get('/game', userLoggedIn, function(req, res, next) {
|
||||||
let title = req.query.game ? 'Edit Game' : 'Submit Score'
|
let title = req.query.game ? 'Edit Game' : 'Submit Score'
|
||||||
|
|
||||||
res.render('manage/addgame', { title });
|
res.render('manage/addgame', { title, userLoggedIn: !!req.user });
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post('/game', userLoggedIn, function(req, res, next) {
|
router.post('/game', userLoggedIn, function(req, res, next) {
|
||||||
|
@ -73,7 +73,7 @@ router.post('/game', userLoggedIn, function(req, res, next) {
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/season', adminLoggedIn, function(req, res, next) {
|
router.get('/season', adminLoggedIn, function(req, res, next) {
|
||||||
res.render('manage/addseason', { title: 'Add Season', currentYear : (new Date()).getFullYear() });
|
res.render('manage/addseason', { title: 'Add Season', currentYear : (new Date()).getFullYear(), userLoggedIn: !!req.user });
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post('/season', adminLoggedIn, function(req, res, next) {
|
router.post('/season', adminLoggedIn, function(req, res, next) {
|
||||||
|
@ -87,7 +87,7 @@ router.post('/season', adminLoggedIn, function(req, res, next) {
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get('/sport', adminLoggedIn, function(req, res, next) {
|
router.get('/sport', adminLoggedIn, function(req, res, next) {
|
||||||
res.render('manage/addsport', { title: 'Add Sport' });
|
res.render('manage/addsport', { title: 'Add Sport', userLoggedIn: !!req.user });
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post('/sport', adminLoggedIn, function(req, res, next) {
|
router.post('/sport', adminLoggedIn, function(req, res, next) {
|
||||||
|
@ -103,7 +103,7 @@ router.post('/sport', adminLoggedIn, function(req, res, next) {
|
||||||
router.get('/division', adminLoggedIn, function(req, res, next) {
|
router.get('/division', adminLoggedIn, function(req, res, next) {
|
||||||
let title = req.query.division ? 'Edit Division' : 'Add Division'
|
let title = req.query.division ? 'Edit Division' : 'Add Division'
|
||||||
|
|
||||||
res.render('manage/adddivision', { title });
|
res.render('manage/adddivision', { title, userLoggedIn: !!req.user });
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post('/division', adminLoggedIn, function(req, res, next) {
|
router.post('/division', adminLoggedIn, function(req, res, next) {
|
||||||
|
@ -134,7 +134,7 @@ router.post('/division', adminLoggedIn, function(req, res, next) {
|
||||||
router.get('/team', adminLoggedIn, function(req, res, next) {
|
router.get('/team', adminLoggedIn, function(req, res, next) {
|
||||||
let title = req.query.team ? 'Edit Team' : 'Add Team'
|
let title = req.query.team ? 'Edit Team' : 'Add Team'
|
||||||
|
|
||||||
res.render('manage/addteam', { title });
|
res.render('manage/addteam', { title, userLoggedIn: !!req.user });
|
||||||
});
|
});
|
||||||
|
|
||||||
router.post('/team', adminLoggedIn, function(req, res, next) {
|
router.post('/team', adminLoggedIn, function(req, res, next) {
|
||||||
|
@ -156,12 +156,12 @@ router.get('/account', userLoggedIn, (req, res, next) => {
|
||||||
if(userIsAdmin) {
|
if(userIsAdmin) {
|
||||||
let title = req.query.account ? 'Manage User' : 'Create User'
|
let title = req.query.account ? 'Manage User' : 'Create User'
|
||||||
|
|
||||||
res.render('accounts/createuser', { title });
|
res.render('accounts/createuser', { title, userLoggedIn: !!req.user });
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let title = 'Manage Account';
|
let title = 'Manage Account';
|
||||||
|
|
||||||
res.render('accounts/createuser', { title, accountID });
|
res.render('accounts/createuser', { title, accountID, userLoggedIn: !!req.user });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@ block stylesheets
|
||||||
link(rel='stylesheet', href='/stylesheets/form.css')
|
link(rel='stylesheet', href='/stylesheets/form.css')
|
||||||
|
|
||||||
block content
|
block content
|
||||||
div#mobile-view
|
|
||||||
h1 #{title}
|
|
||||||
form#submission-form(action='/manage/account', method='POST')
|
form#submission-form(action='/manage/account', method='POST')
|
||||||
if accountID
|
if accountID
|
||||||
input#account-id(type="hidden" name="account" value=accountID)
|
input#account-id(type="hidden" name="account" value=accountID)
|
||||||
|
|
|
@ -5,8 +5,6 @@ block stylesheets
|
||||||
link(rel='stylesheet', href='/stylesheets/form.css')
|
link(rel='stylesheet', href='/stylesheets/form.css')
|
||||||
|
|
||||||
block content
|
block content
|
||||||
div#mobile-view
|
|
||||||
h1 #{title}
|
|
||||||
form(action='/auth/login', method='POST')
|
form(action='/auth/login', method='POST')
|
||||||
span(class='form-section')
|
span(class='form-section')
|
||||||
label Email
|
label Email
|
||||||
|
|
|
@ -4,13 +4,13 @@ block stylesheets
|
||||||
link(rel='stylesheet', href='/stylesheets/index.css')
|
link(rel='stylesheet', href='/stylesheets/index.css')
|
||||||
link(rel='stylesheet', href='/stylesheets/form.css')
|
link(rel='stylesheet', href='/stylesheets/form.css')
|
||||||
|
|
||||||
|
block actions
|
||||||
|
if userLoggedIn
|
||||||
|
button#add-score-button Submit score
|
||||||
|
button#manage-button Manage scores
|
||||||
|
|
||||||
|
|
||||||
block content
|
block content
|
||||||
div#mobile-view
|
|
||||||
div#header-div
|
|
||||||
h1 Score Tracker
|
|
||||||
div#actions-div
|
|
||||||
button#add-score-button +
|
|
||||||
button#manage-button Manage
|
|
||||||
div
|
div
|
||||||
span(class='form-section')
|
span(class='form-section')
|
||||||
label Year
|
label Year
|
||||||
|
|
|
@ -1,10 +1,19 @@
|
||||||
doctype html
|
doctype html
|
||||||
html
|
html
|
||||||
head
|
head
|
||||||
title= title
|
title= title + ' - Score Tracker'
|
||||||
meta(name='viewport', content='width=device-width, initial-scale=1')
|
meta(name='viewport', content='width=device-width, initial-scale=1')
|
||||||
link(rel='stylesheet', href='/stylesheets/style.css')
|
link(rel='stylesheet', href='/stylesheets/style.css')
|
||||||
block stylesheets
|
block stylesheets
|
||||||
body
|
body
|
||||||
|
div#mobile-view
|
||||||
|
div#actions-div
|
||||||
|
block actions
|
||||||
|
if userLoggedIn
|
||||||
|
button#logout-button Log out
|
||||||
|
else if userLoggedIn !== undefined
|
||||||
|
button#login-button Log in
|
||||||
|
h1 #{title}
|
||||||
block content
|
block content
|
||||||
block scripts
|
block scripts
|
||||||
|
script(src='/scripts/main.js' type="module")
|
||||||
|
|
|
@ -5,8 +5,6 @@ block stylesheets
|
||||||
link(rel='stylesheet', href='/stylesheets/form.css')
|
link(rel='stylesheet', href='/stylesheets/form.css')
|
||||||
|
|
||||||
block content
|
block content
|
||||||
div#mobile-view
|
|
||||||
h1 Management Panel
|
|
||||||
div
|
div
|
||||||
span(class='form-section')
|
span(class='form-section')
|
||||||
label Category
|
label Category
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
extends layout
|
extends ../layout
|
||||||
|
|
||||||
block stylesheets
|
block stylesheets
|
||||||
link(rel='stylesheet', href='/stylesheets/submit.css')
|
link(rel='stylesheet', href='/stylesheets/submit.css')
|
||||||
link(rel='stylesheet', href='/stylesheets/form.css')
|
link(rel='stylesheet', href='/stylesheets/form.css')
|
||||||
|
|
||||||
block content
|
block content
|
||||||
div#mobile-view
|
|
||||||
h1 #{title}
|
|
||||||
form#submission-form(action='./division', method='POST')
|
form#submission-form(action='./division', method='POST')
|
||||||
span(class='form-section')
|
span(class='form-section')
|
||||||
label Sport
|
label Sport
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
extends layout
|
extends ../layout
|
||||||
|
|
||||||
block stylesheets
|
block stylesheets
|
||||||
link(rel='stylesheet', href='/stylesheets/submit.css')
|
link(rel='stylesheet', href='/stylesheets/submit.css')
|
||||||
link(rel='stylesheet', href='/stylesheets/form.css')
|
link(rel='stylesheet', href='/stylesheets/form.css')
|
||||||
|
|
||||||
block content
|
block content
|
||||||
div#mobile-view
|
|
||||||
h1 #{title}
|
|
||||||
form#submission-form(action='./game', method='POST')
|
form#submission-form(action='./game', method='POST')
|
||||||
span(class='form-section')
|
span(class='form-section')
|
||||||
label Year
|
label Year
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
extends layout
|
extends ../layout
|
||||||
|
|
||||||
block stylesheets
|
block stylesheets
|
||||||
link(rel='stylesheet', href='/stylesheets/submit.css')
|
link(rel='stylesheet', href='/stylesheets/submit.css')
|
||||||
link(rel='stylesheet', href='/stylesheets/form.css')
|
link(rel='stylesheet', href='/stylesheets/form.css')
|
||||||
|
|
||||||
block content
|
block content
|
||||||
div#mobile-view
|
|
||||||
h1 #{title}
|
|
||||||
form(action='./season', method='POST')
|
form(action='./season', method='POST')
|
||||||
span(class='form-section')
|
span(class='form-section')
|
||||||
label Ending year
|
label Ending year
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
extends layout
|
extends ../layout
|
||||||
|
|
||||||
block stylesheets
|
block stylesheets
|
||||||
link(rel='stylesheet', href='/stylesheets/submit.css')
|
link(rel='stylesheet', href='/stylesheets/submit.css')
|
||||||
link(rel='stylesheet', href='/stylesheets/form.css')
|
link(rel='stylesheet', href='/stylesheets/form.css')
|
||||||
|
|
||||||
block content
|
block content
|
||||||
div#mobile-view
|
|
||||||
h1#main-header Add Sport
|
|
||||||
form#submission-form(action='./sport', method='POST')
|
form#submission-form(action='./sport', method='POST')
|
||||||
span(class='form-section')
|
span(class='form-section')
|
||||||
label Sport name
|
label Sport name
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
extends layout
|
extends ../layout
|
||||||
|
|
||||||
block stylesheets
|
block stylesheets
|
||||||
link(rel='stylesheet', href='/stylesheets/submit.css')
|
link(rel='stylesheet', href='/stylesheets/submit.css')
|
||||||
link(rel='stylesheet', href='/stylesheets/form.css')
|
link(rel='stylesheet', href='/stylesheets/form.css')
|
||||||
|
|
||||||
block content
|
block content
|
||||||
div#mobile-view
|
|
||||||
h1 #{title}
|
|
||||||
form#submission-form(action='./team', method='POST')
|
form#submission-form(action='./team', method='POST')
|
||||||
span(class='form-section')
|
span(class='form-section')
|
||||||
label Sport
|
label Sport
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
extends layout
|
extends ../layout
|
||||||
|
|
||||||
block stylesheets
|
block stylesheets
|
||||||
link(rel='stylesheet', href='/stylesheets/manage.css')
|
link(rel='stylesheet', href='/stylesheets/manage.css')
|
||||||
link(rel='stylesheet', href='/stylesheets/form.css')
|
link(rel='stylesheet', href='/stylesheets/form.css')
|
||||||
|
|
||||||
block content
|
block content
|
||||||
div#mobile-view
|
|
||||||
h1 #{title}
|
|
||||||
span(class="flat-content")
|
span(class="flat-content")
|
||||||
button#add-new-button Add new...
|
button#add-new-button Add new...
|
||||||
button#manage-account-button(class="send-to-right") Manage account...
|
button#manage-account-button(class="send-to-right") Manage account...
|
||||||
|
|
Reference in a new issue