diff --git a/client/static/images/funnyLebron.jpg b/client/static/images/funnyLebron.jpg new file mode 100644 index 00000000..7ede65d0 Binary files /dev/null and b/client/static/images/funnyLebron.jpg differ diff --git a/client/static/partials/footer.ejs b/client/static/partials/footer.ejs index 518b57b3..03469738 100644 --- a/client/static/partials/footer.ejs +++ b/client/static/partials/footer.ejs @@ -9,7 +9,7 @@
diff --git a/client/static/scripts/data-collection.js b/client/static/scripts/data-collection.js index 0b23f32e..a531947e 100644 --- a/client/static/scripts/data-collection.js +++ b/client/static/scripts/data-collection.js @@ -18,6 +18,8 @@ const observer = new MutationObserver(function (mutations_list) { }) }) + +/* window.onunload = saveData socket.on("changeMatch", () => { @@ -27,93 +29,16 @@ socket.on("changeMatch", () => { requestPage(paths.dataCollection) } }) - +*/ +/* //given a TD's id and index in the auton-scoring table, it returns the corresponding TD in the teleop-scoring table function getCorrespondingTd(id, index) { const teleopConeButtons = document.getElementById("teleop-scoring").getElementsByClassName(id) //get all cone buttons in teleop const correspondingTd = teleopConeButtons.item(index) //the corresponding TD under teleop-scoring return correspondingTd //return the image in the TD } - -async function saveComments() { - return new Promise(async resolve => { - const match = document.getElementById("match-comment-selector").value - consoleLog("MATCH NUMBER: " + match) - const ogData = JSON.parse(localStorage.getItem("comments")) != null ? JSON.parse(localStorage.getItem("comments")) : {} - const data = {} - - data.matchNumber = match - data.GAME_TYPE = GAME_TYPE - data.YEAR = YEAR - data.COMP = COMP - data.type = "comments" - data.comments = {} - - Array.from(document.getElementById("comments-scroller").getElementsByClassName("input-container")).forEach(e => { - let info = e.querySelector(".comments-team") - let title = info.innerText - let team = title.split(" ")[0] - let text = e.querySelector("textarea").value - data.comments[team] = { - text: text, - alliance: info.getAttribute("alliance"), - position: info.getAttribute("pos") - } - }) - - ogData[match] = data - - consoleLog("DATA: ") - consoleLog(data) - - resolve(data) - }) -} - - -async function loadComments() { - return new Promise(async resolve => { - const data = JSON.parse(localStorage.getItem("comments")) != null ? JSON.parse(localStorage.getItem("comments"))[match] : {} - consoleLog("DATA: ") - consoleLog(data) - - Array.from(document.getElementById("comments-scroller").getElementsByClassName("input-container")).forEach(e => { - let title = e.querySelector(".comments-team").innerText - let team = title.split(" ")[0] - //e.querySelector("textarea").value = data.comments[team] - }) - - resolve(true) - }) -} - -async function sendComments() { - const data = await saveComments() - - consoleLog("-------CLIENT DATA------\n") - consoleLog(data) - - $.ajax({ - type: "POST", - contentType: "application/json", - url: paths.dataCollection, - data: JSON.stringify(data), - success: function (response) { - consoleLog(response) - alert("Comments saved") - requestPage(paths.matchListing) - const hoverButton = document.getElementById("hover-button") - const matchListingButton = document.getElementById("match-listing-btn") - moveToPage(hoverButton.getBoundingClientRect().left, matchListingButton.getBoundingClientRect().left, hoverButton) - setSelectedObject(matchListingButton) - }, - - error: function (jqXHR, textStatus, errorThrown) { - //consoleLog("Error\n" + errorThrown, jqXHR) - } - }) -} - +*/ +/* async function sendData() { const data = await saveData() consoleLog("-------SCOUTING DATA------\n") @@ -139,9 +64,8 @@ async function sendData() { }, }) } - - - +*/ +/* function loadData() { return new Promise(async (res, rej) => { const match = await getMatch() @@ -378,7 +302,8 @@ function loadData() { return res() }) } - +*/ +/* async function saveData() { return new Promise(async resolve => { const match = await getMatch() @@ -466,10 +391,8 @@ async function saveData() { resolve(data) }) } - -observer.observe(document.body, { subtree: false, childList: true }); - - +*/ +/* async function loadDataCollection() { const form = document.getElementById("match-number-form") @@ -576,6 +499,88 @@ async function loadDataCollection() { consoleLog("animating") animateCanvas() } +*/ + + +async function saveComments() { + return new Promise(async resolve => { + const match = document.getElementById("match-comment-selector").value + consoleLog("MATCH NUMBER: " + match) + const ogData = JSON.parse(localStorage.getItem("comments")) != null ? JSON.parse(localStorage.getItem("comments")) : {} + const data = {} + + data.matchNumber = match + data.GAME_TYPE = GAME_TYPE + data.YEAR = YEAR + data.COMP = COMP + data.type = "comments" + data.comments = {} + + Array.from(document.getElementById("comments-scroller").getElementsByClassName("input-container")).forEach(e => { + let info = e.querySelector(".comments-team") + let title = info.innerText + let team = title.split(" ")[0] + let text = e.querySelector("textarea").value + data.comments[team] = { + text: text, + alliance: info.getAttribute("alliance"), + position: info.getAttribute("pos") + } + }) + + ogData[match] = data + + consoleLog("DATA: ") + consoleLog(data) + + resolve(data) + }) +} + + +async function loadComments() { + return new Promise(async resolve => { + const data = JSON.parse(localStorage.getItem("comments")) != null ? JSON.parse(localStorage.getItem("comments"))[match] : {} + consoleLog("DATA: ") + consoleLog(data) + + Array.from(document.getElementById("comments-scroller").getElementsByClassName("input-container")).forEach(e => { + let title = e.querySelector(".comments-team").innerText + let team = title.split(" ")[0] + //e.querySelector("textarea").value = data.comments[team] + }) + + resolve(true) + }) +} +async function sendComments() { + const data = await saveComments() + + consoleLog("-------CLIENT DATA------\n") + consoleLog(data) + + $.ajax({ + type: "POST", + contentType: "application/json", + url: paths.dataCollection, + data: JSON.stringify(data), + success: function (response) { + consoleLog(response) + alert("Comments saved") + requestPage(paths.matchListing) + const hoverButton = document.getElementById("hover-button") + const matchListingButton = document.getElementById("match-listing-btn") + moveToPage(hoverButton.getBoundingClientRect().left, matchListingButton.getBoundingClientRect().left, hoverButton) + setSelectedObject(matchListingButton) + }, + + error: function (jqXHR, textStatus, errorThrown) { + //consoleLog("Error\n" + errorThrown, jqXHR) + } + }) +} + +observer.observe(document.body, { subtree: false, childList: true }); function loadCommentsPage() { const form = document.getElementById("comments-page") @@ -588,7 +593,7 @@ function loadCommentsPage() { sendComments() } } - +/* function onTabClick() { const currentPage = document.getElementsByClassName("selected")[0].getAttribute("page") const newPage = this.getAttribute("page") @@ -609,18 +614,20 @@ function onTabClick() { } } } +*/ function main() { + //alert("main called") consoleLog("selected page:") - consoleLog(document.getElementsByClassName("selected")) - if (document.getElementById("match-number-form")) { - loadDataCollection() - } + //consoleLog(document.getElementsByClassName("selected")) + // if (document.getElementById("match-number-form")) { + // loadDataCollection() + // } - if (document.getElementsByClassName("selected")[0].getAttribute("page") == "comments-page") { + //if (document.getElementsByClassName("selected")[0].getAttribute("page") == "comments-page") { loadCommentsPage() loadComments() - } + //} const matchSelector = document.getElementById("match-comment-selector") @@ -628,11 +635,11 @@ function main() { requestPage(paths.dataCollection + "?match=" + matchSelector.value + "&selectedPage=comments-page", {}, paths.dataCollection) }) - document.querySelector(`[page="scouting-page"]`).addEventListener("click", loadDataCollection) - document.querySelector(`[page="comments-page"]`).addEventListener("click", loadCommentsPage) + //document.querySelector(`[page="scouting-page"]`).addEventListener("click", loadDataCollection) + //document.querySelector(`[page="comments-page"]`).addEventListener("click", loadCommentsPage) - document.querySelector(`[page="scouting-page"]`).addEventListener("click", onTabClick) - document.querySelector(`[page="comments-page"]`).addEventListener("click", onTabClick) + //document.querySelector(`[page="scouting-page"]`).addEventListener("click", onTabClick) + //document.querySelector(`[page="comments-page"]`).addEventListener("click", onTabClick) const saveCommentsButton = document.getElementById("save-comments") saveCommentsButton.addEventListener("click", () => { diff --git a/client/templates/data-collection.ejs b/client/templates/data-collection.ejs index fe9f5772..7b21d27d 100644 --- a/client/templates/data-collection.ejs +++ b/client/templates/data-collection.ejs @@ -1,3 +1,4 @@ + @@ -16,7 +17,8 @@ - + + @@ -25,296 +27,8 @@
- <%if(assignment != null) {%> -
- - -
- - <% if(selectedPage == "scouting-page") {%> -
alliance-position=<%=assignment.gm_alliance_position%>> - <% }else {%> - alliance-position=<%=assignment.gm_alliance_position%> style="display:none"> - <%}%> - - -
- - <%= assignment.match_display%> - -
- - -
- > <%= assignment.team_display %> -
- - -
- -
-
- -
- - -
-
-
- -
- - - - -
- -
- - -
-
-
- -
-
- -
- -
- - - - - - - - - - -
Drag RowAction
-
-
- -
- Auton - Tech Fouls -
- - - -
-
- - -
- - -
-
- -
-
- -
- Algae Dislodged -
- - - -
-
- -
- Algae in Opposite Alliance Processor -
- - - -
-
- -
- Human Player Scored in Net -
- - - -
-
- -
- Human Player Shots Missed -
- - - -
-
- - - -
- - Stage Position - -
- Robot Endgame -
- - -
- - -
- - -
- - -
- - -
-
-
- -
- Climb Position -
- - -
- - -
- - -
- - -
-
-
- - -
- Teleop + Endgame - Fouls -
- - - -
-
- -
-
Teleop + Endgame - Tech Fouls
-
- - - -
-
- -
- Robot entered opponent barge area -
- - - -
-
- -
- Robot plays defense -
- - - -
-
- -
- robot has coral ground pickup -
- - - -
-
- -
- robot has algae ground pickup -
- - - -
-
- -
- Comments -
- -
-
-
- - - - -
- - <% if(selectedPage == "comments-page") {%> -
- <% }else {%> - - <%}%> - - <% } else {%> - -
- - -
- - -

A match isn't running or you aren't assigned to scout

-
- -
- <% } %> + +
diff --git a/client/templates/template.ejs b/client/templates/template.ejs index 8aec3087..2f574031 100644 --- a/client/templates/template.ejs +++ b/client/templates/template.ejs @@ -3,6 +3,7 @@ Team 695: Scoutify + diff --git a/server/routers/data-collection.js b/server/routers/data-collection.js index f1b4efa4..5e557e2c 100644 --- a/server/routers/data-collection.js +++ b/server/routers/data-collection.js @@ -20,12 +20,6 @@ async function getGameNumbers() { return parseData(gameNumbers) } -async function getSeventhScouter(username) { - const [error, dbRes] = await database.query(database.getSeventhScouter(username)) - const seventhScouterRes = parseData(dbRes) - return seventhScouterRes[0].cgua_user_id -} - async function getRunningMatch() { const [error, dbres] = await database.query(SQL`select * from teamsixn_scouting_dev.current_game;`) const runningMatchResults = parseData(dbres) @@ -35,6 +29,13 @@ async function getRunningMatch() { return 1 } +/* +async function getSeventhScouter(username) { + const [error, dbRes] = await database.query(database.getSeventhScouter(username)) + const seventhScouterRes = parseData(dbRes) + return seventhScouterRes[0].cgua_user_id +} + async function getAssignment(username) { const [error, dbres] = await database.query(database.getAssignedTeam(username)) const assignment = parseData(dbres)[0] @@ -116,7 +117,9 @@ async function updateData(info, isSeventh) { } } } +*/ +///* router.get("/", async function (req, res) { //only gets used if the url == data-collection const isAdmin = await checkAdmin(req) const username = req.cookies["username"] @@ -126,31 +129,31 @@ router.get("/", async function (req, res) { //only gets used if the url == data- const runningMatch = await getRunningMatch() let assignment = null - const seventhScouter = await getSeventhScouter(username) + // const seventhScouter = 1 //await getSeventhScouter(username) - if (seventhScouter == username) { //assign user a random team - assignment = await getRandomAssignment(username, runningMatch) - } - else { //not a seventh scouter - assignment = await getAssignment(username) - } + // if (seventhScouter == username) { //assign user a random team + // assignment = await getRandomAssignment(username, runningMatch) + // } + // else { //not a seventh scouter + // assignment = await getAssignment(username) + // } const gameNumbers = await getGameNumbers() const matchup = await getMatchup(match) - consoleLog("\nMATCH DATA: ") - consoleLog(matchup) + //consoleLog("\nMATCH DATA: ") + //consoleLog(matchup) return res.render("data-collection", { matches: gameNumbers, lastMatch: match, runningMatch: runningMatch, - assignment: assignment, + assignment: "false", isAdmin: isAdmin, matchup: matchup, selectedPage: selectedPage }) }) - +//*/ router.post("/", function (req, res) { const body = req.body @@ -159,17 +162,7 @@ router.post("/", function (req, res) { body.username = req.cookies["username"] consoleLog(body, "2025 data") - if (body.type == "scouting") { - const seventhScouter = getSeventhScouter(body.username) - if(seventhScouter != body.username) { - consoleLog("Received:") - consoleLog(body) - updateData(body) - } - else { - consoleLog("Seventh scouter found") - } - } else if (body.type == "comments") { + if (body.type == "comments") { consoleLog("comments:") consoleLog(body.comments) for (const [team, comment] of Object.entries(body.comments)) { diff --git a/server/routers/login.js b/server/routers/login.js index fe10b2d7..6dfd87ba 100755 --- a/server/routers/login.js +++ b/server/routers/login.js @@ -30,7 +30,7 @@ async function checkUser(body) { } - return false + return false //MAKE SURE TO CHANGE THIS BACK TO FALSE } function strongRandomString(chars, maxLen) { diff --git a/server/server.js b/server/server.js index 15d4e7a8..6e579c94 100644 --- a/server/server.js +++ b/server/server.js @@ -21,7 +21,11 @@ const routeDirectory = "routers" //ROUTERS const login = (await import(path.resolve(serverDirectory, routeDirectory, "login.js"))).default + + const dataCollection = (await import(path.resolve(serverDirectory, routeDirectory, "data-collection.js"))).default + + const teamSummary = (await import(path.resolve(serverDirectory, routeDirectory, "team-summary.js"))).default const matchStrategy = (await import(path.resolve(serverDirectory, routeDirectory, "match-strategy.js"))).default const allianceSelector = (await import(path.resolve(serverDirectory, routeDirectory, "alliance-selector.js"))).default @@ -167,8 +171,12 @@ app.use("/app", template) //LOGIN app.use("/login", login) //it makes the app use the login router's get and post methods. its a replacement for get and post for the specific path + +/******* */ //DATA COLLECTION app.use("/data-collection", dataCollection) +/******* */ + //TEAM SUMMARY app.use("/team-summary", teamSummary)