Skip to content

Commit

Permalink
V5.1.0 web (#46)
Browse files Browse the repository at this point in the history
* scout app 5.1.0

* fix one-off error

* data viewer explicit failure

* shit

* data dump endpoint

* fix data dump

* rustfmt

* update web view

* fix season
  • Loading branch information
JayAgra authored Mar 6, 2024
1 parent 0b717b6 commit a8e991b
Show file tree
Hide file tree
Showing 10 changed files with 224 additions and 57 deletions.
28 changes: 16 additions & 12 deletions static/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@
<body class="gruvbox" style="width: 100vw;">
<script>themeHandle()</script>
<form id="form_content" style="display: block; width: 100vw;">
<h1 class="w3">bearTracks<br><span class="gametitle">CRESCENDO</span></h1>
<div class="VStack" style="align-items: center;">
<div class="VStack form_pages" style="align-items: center; display: flex;">
<h1 class="w3">bearTracks<br><span class="gametitle">CRESCENDO</span></h1>
<div class="VStack" style="width: 80vw; align-items: baseline;">
<fieldset>
<label>Event Code&emsp;<span id="bad_event" style="color: red; display: none;"></span></label>
<select name="event" id="event_code"></select>
<label>Event Code&emsp;<span id="selected_event_code">XXXX</span>&emsp;<span><a style="all: unset; color: #0a84ff;" href="/settings">change</a></span></label>
</fieldset><br>
<fieldset>
<label>Match Number&emsp;</label>
Expand All @@ -49,10 +48,10 @@ <h1 class="w3">bearTracks<br><span class="gametitle">CRESCENDO</span></h1>
</select>
</fieldset><br>
</div>
<button type="button" class="continue_button" disabled><h2>continue</h2></button>
</div>
<div class="VStack" style="align-items: center;">
<div class="VStack" style="height: 80vh; width: 80vw;">
<br><br><br>
<div class="VStack form_pages" style="align-items: center; display: none; overflow: hidden;">
<div class="VStack" style="height: 100vh; width: 80vw;">
<div class="HStack">
<div class="VStack">
<h1 class="counter">0.0</h1>
Expand All @@ -67,11 +66,16 @@ <h1 class="counter">0.0</h1>
<button class="time_button" type="button"><h1>out</h1></button>
</div>
</div>
<button class="cycle_button" type="button" style="margin-top: 3vh; margin-bottom: 1vh"><h1>speaker</h1></button>
<button class="cycle_button" type="button"><h1>amplifier</h1></button><br><br><br>
<div class="HStack">
<button class="cycle_button" type="button"><h1>speaker</h1></button>
<button class="cycle_button" type="button"><h1>amplifier</h1></button>
<button class="cycle_button" type="button" style="min-width: 10vw; color: #fe8019; margin: none;"><h2>other</h2></button>
</div>
<button type="button" class="continue_button"><h2>continue</h2></button>
</div>
</div>
<div class="VStack" style="align-items: center;">
<div class="VStack form_pages" style="align-items: center; display: none;">
<h1 class="w3">bearTracks<br><span class="gametitle">CRESCENDO</span></h1>
<div class="HStack">
<p style="width: 9em; margin-top: 5px; text-align: left;">Trap note</p>
<div style="width: calc(80vw - 9em - 46px);"></div>
Expand Down Expand Up @@ -99,13 +103,13 @@ <h1 class="counter">0.0</h1>
<label style="text-align: left;">Provide an overall description of the team's performance in this match</label>
<textarea rows="6" style="resize: none; margin-top: 1%; width: 80vw;" name="overall"></textarea>
</div>
<br><button class="continue_button" type="button" disabled><h2>submit</h2></button><br><br><br>
</div>
<br><button class="continue_button" type="button"><h2>submit</h2></button><br><br><br>
</form>
<div id="submit_page" style="display: none; align-items: center;">
<h1 style="padding-top: 25vh" id="submit_text">Submitting...</h1>
<progress style="min-width: 75vw;" id="submit_progress"></progress><br>
<br><button type="button" class="continue_button" onclick="window.location.reload()" id="scout_again"><h2>scout again</h2></button><br><br>
<br><button type="button" class="continue_button" id="scout_again"><h2>scout again</h2></button><br><br>
<image src="static/assets/checkmark.seal.fill.png" style="display: none; width: 150px" id="success_seal"></image>
<image src="static/assets/xmark.seal.fill.png" style="display: none; width: 150px" id="failure_seal"></image>
</div>
Expand Down
6 changes: 5 additions & 1 deletion static/public/css/main_form.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
.continue_button:active, .time_button:active, .cycle_button:active {
background-color: rgba(0, 0, 0, 0.45);
}
.continue_button:disabled {
color: gray;
}
.continue_button, .time_button {
color: #0a84ff;
min-width: 20vw;
Expand All @@ -33,14 +36,15 @@
align-self: center;
min-width: 15vw;
max-width: 70vw;
min-height: 5vh;
}
.time_button {
min-height: 30vh;
}
.cycle_button {
align-self: center;
color: #32d74b;
min-width: 50vw;
min-width: 30vw;
min-height: 10vh;
}
.counter {
Expand Down
2 changes: 1 addition & 1 deletion static/public/css/main_form.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 68 additions & 18 deletions static/public/js/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,38 @@ const API_MATCHES = ["/api/v1/events/matches/", /* season */ "/", /* event */ "/
const API_WHOAMI = "/api/v1/whoami";
const API_SUBMIT = "/api/v1/data/submit";
var match_schedule;
function getEventCookie() {
var cookieString = RegExp("92bdcf1af0a0a23d" + "=[^;]+").exec(document.cookie);
return decodeURIComponent(!!cookieString ? cookieString.toString().replace(/^[^=]+./, "") : "");
}
async function init() {
if (getEventCookie() == "") {
document.cookie = `92bdcf1af0a0a23d=CAFR; expires=Fri, 31 Dec 9999 23:59:59 GMT; Secure; SameSite=Lax`;
}
document.getElementById("selected_event_code").innerText = getEventCookie();
_get(API_WHOAMI, null).then((result) => {
console.info(result);
}).catch((error) => {
console.error(error);
window.location.href = "/login";
});
await load_data();
document.getElementById("event_code").addEventListener("change", () => {
load_matches(document.getElementById("event_code").value);
});
await load_matches(getEventCookie());
document.getElementById("match_num_input").addEventListener("change", () => {
match_num_entry(document.getElementById("match_num_input").value);
});
}
async function load_data() {
_get(API_META, null).then((result) => {
result.events.forEach(event_code => {
document.getElementById("event_code").insertAdjacentHTML("beforeend", `<option value="${event_code}">${event_code}</option>`);
});
document.getElementById("event_code").value = "CAFR";
load_matches("CAFR");
}).catch((error) => {
alert(`failed to load valid event codes. ${error}`);
});
}
function load_matches(event = "CAFR") {
_get(API_MATCHES[0] + "2023" + API_MATCHES[1] + event + API_MATCHES[2], null).then((result) => {
document.getElementsByClassName("continue_button")[0].disabled = true;
_get(API_MATCHES[0] + "2024" + API_MATCHES[1] + event + API_MATCHES[2], null).then((result) => {
if (result.Schedule.length != 0) {
match_schedule = result.Schedule;
document.getElementById("match_num_input").innerHTML = "";
result.Schedule.forEach(match => {
document.getElementById("match_num_input").insertAdjacentHTML("beforeend", `<option value="${match.matchNumber}">${match.matchNumber}</option>`);
});
match_num_entry("1");
document.getElementById("match_num_input").value = "";
document.getElementById("team_number").value = "";
}
else {
alert("match schedule is not yet posted");
Expand All @@ -55,6 +52,14 @@ function set_option(element, value) {
element.innerText = value;
element.value = value;
}
document.getElementById("team_number").onchange = () => {
if (document.getElementById("team_number").value == "") {
document.getElementsByClassName("continue_button")[0].disabled = true;
}
else {
document.getElementsByClassName("continue_button")[0].disabled = false;
}
};
function match_num_entry(entry) {
let entry_num = Number(entry);
let select_elements = document.getElementsByClassName("teamNumOption");
Expand Down Expand Up @@ -111,6 +116,20 @@ function end_cycle(type) {
}
cycle_buttons[0].addEventListener("click", () => { end_cycle(0); });
cycle_buttons[1].addEventListener("click", () => { end_cycle(1); });
cycle_buttons[2].addEventListener("click", () => { end_cycle(9); });
document.querySelector("[name=defense]").onchange = check_responses;
document.querySelector("[name=driving]").onchange = check_responses;
document.querySelector("[name=overall]").onchange = check_responses;
function check_responses() {
if (document.querySelector("[name=defense]").value.length > 0 &&
document.querySelector("[name=driving]").value.length > 0 &&
document.querySelector("[name=overall]").value.length > 0) {
document.getElementsByClassName("continue_button")[2].disabled = false;
}
else {
document.getElementsByClassName("continue_button")[2].disabled = true;
}
}
function submit() {
if (document.querySelector("[name=defense]").value
.length == 0 ||
Expand All @@ -132,7 +151,7 @@ function submit() {
cycle_data.push({ id: cycle_data.length, score_type: 4, intake: Number(document.querySelector("[name=buddy_climb]").checked), travel: Number(document.querySelector("[name=buddy_climb]").checked), outtake: Number(document.querySelector("[name=buddy_climb]").checked) });
const data = {
season: 2024,
event: document.getElementById("event_code").value,
event: getEventCookie(),
match_num: Number(document.getElementById("match_num_input").value),
level: "Qualification",
team: Number(document.getElementById("team_number").value),
Expand All @@ -152,4 +171,35 @@ function submit() {
submit_text.innerHTML = `Error!<br>${error}`;
});
}
document.getElementsByClassName("continue_button")[0].addEventListener("click", submit);
function reset() {
clearInterval(timer_id[0]);
clearInterval(timer_id[1]);
clearInterval(timer_id[2]);
timer_id = [0, 0, 0];
timer_times = [0, 0, 0];
cycle_data = [];
document.querySelector("[name=defense]").value = "";
document.querySelector("[name=driving]").value = "";
document.querySelector("[name=overall]").value = "";
document.getElementById("team_number").value = "";
document.querySelector("[name=trap_note]").checked = false;
document.querySelector("[name=climb]").checked = false;
document.querySelector("[name=buddy_climb]").checked = false;
document.getElementById("submit_page").style.display = "none";
document.getElementById("form_content").style.display = "block";
let pages = Array.from(document.getElementsByClassName("form_pages"));
document.getElementsByClassName("continue_button")[0].disabled = true;
document.getElementsByClassName("continue_button")[2].disabled = true;
pages[1].style.display = "none";
pages[2].style.display = "none";
pages[0].style.display = "flex";
}
document.getElementById("scout_again").onclick = reset;
document.getElementsByClassName("continue_button")[2].addEventListener("click", submit);
function advance_page(current) {
let pages = Array.from(document.getElementsByClassName("form_pages"));
pages[current].style.display = "none";
pages[current + 1].style.display = "flex";
}
document.getElementsByClassName("continue_button")[0].addEventListener("click", () => { advance_page(0); });
document.getElementsByClassName("continue_button")[1].addEventListener("click", () => { advance_page(1); });
Loading

0 comments on commit a8e991b

Please sign in to comment.