Customize page with streamer username

master
Dessa Simpson 2020-09-10 23:43:53 -07:00
parent b06c425352
commit 249a5911b4
3 changed files with 18 additions and 4 deletions

View File

@ -113,3 +113,8 @@ CREATE OR REPLACE VIEW vote_score_all_vw AS
UNION ALL SELECT * FROM vote_score_subscriber_vw UNION ALL SELECT * FROM vote_score_subscriber_vw
) AS union_vote_score ) AS union_vote_score
GROUP BY url; GROUP BY url;
CREATE OR REPLACE VIEW streamer_user_vw AS
SELECT users.userid as userid, users.displayname as displayname, users.imageurl as imageurl FROM streamer
LEFT JOIN users
ON streamer.userid = users.userid;

View File

@ -233,17 +233,26 @@ app.get("/callback", async (request, response) => {
// Frontend templates // Frontend templates
app.get("/", async (request, response) => { app.get("/", async (request, response) => {
if (request.session) await validateApiToken(request.session); if (request.session) await validateApiToken(request.session);
const getStreamerInfoQuery = {
name: "getStreamerInfo",
text: "SELECT displayname,imageurl FROM streamer_user_vw"
}
var streamerInfo = await db.query(getStreamerInfoQuery).then((result: pg.QueryResult) => result.rows[0]);;
if (!request.session || !request.session.user) { if (!request.session || !request.session.user) {
response.render('main.eta', { response.render('main.eta', {
loggedIn: false, loggedIn: false,
clientId: config.twitchClientId, clientId: config.twitchClientId,
urlPrefix: config.urlPrefix urlPrefix: config.urlPrefix,
streamerName: streamerInfo['displayname'],
streamerProfilePicture: streamerInfo['imageurl']
}); });
} else { } else {
response.render('main.eta', { response.render('main.eta', {
loggedIn: true, loggedIn: true,
userName: request.session.user.display_name, userName: request.session.user.display_name,
userProfilePicture: request.session.user.profile_image_url userProfilePicture: request.session.user.profile_image_url,
streamerName: streamerInfo['displayname'],
streamerProfilePicture: streamerInfo['imageurl']
}); });
} }
}); });

View File

@ -2,13 +2,13 @@
<html> <html>
<head> <head>
<link rel=stylesheet href=style.css /> <link rel=stylesheet href=style.css />
<title>Learn Request Queue</title> <title><%= it.streamerName %>'s Learn Request Queue</title>
<script>window.loggedIn = <%= it.loggedIn %></script> <script>window.loggedIn = <%= it.loggedIn %></script>
<script src="main.js" defer></script> <script src="main.js" defer></script>
</head> </head>
<body> <body>
<div id="topbar"> <div id="topbar">
<div id="logo">Learn Request Queue</div> <div id="logo"><%= it.streamerName %>'s Learn Request Queue</div>
<div id="nav-requests"><a href="/">Requests</a></div> <div id="nav-requests"><a href="/">Requests</a></div>
<%- if (it.loggedIn) { -%> <%- if (it.loggedIn) { -%>
<div id="nav-addrequest"><a href="#" onclick="openAddRequestModal()">Add Request</a></div> <div id="nav-addrequest"><a href="#" onclick="openAddRequestModal()">Add Request</a></div>