From 435fe76d6cc6e86fd6f5ad5909a7bc8338e4714a Mon Sep 17 00:00:00 2001 From: Ryan Bauroth <25bauroth@da.org> Date: Thu, 27 Jun 2024 11:01:07 -0400 Subject: [PATCH] scout page documented --- pages/scout.vue | 200 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 136 insertions(+), 64 deletions(-) diff --git a/pages/scout.vue b/pages/scout.vue index 18a1264..82ac050 100644 --- a/pages/scout.vue +++ b/pages/scout.vue @@ -12,43 +12,17 @@ import type { UnwrapRef } from 'vue'; import { loginStateKey } from '~/utils/keys'; import { useEventKey } from '~/composables/useEventKey'; -//gets username and scouting database -const { - usernameState, -}: { - usernameState: Ref>; -} = inject(loginStateKey)!; -const { scoutingData: db } = databases.locals; - -//An enum of tabs on the scout page -enum GameTime { - Autonomous = 'Auto', - Teleoperated = 'Teleop', - Endgame = 'Endgame', - Notes = 'Notes', -} - -//The active tab used -let gameTime = ref(GameTime.Autonomous); - -//gets current event key -const currentEvent = useEventKey(); -watch(currentEvent, value => { - window.localStorage.setItem('currentEvent', value); -}); - -//gets the blue alliance data for what teams are at the current event and puts them in an array -const { data: tbaEventData, pending: tbaPending } = await useLazyFetch< - Array ->('/api/eventTeams/' + currentEvent.value); -watch(tbaPending, () => { - if (!tbaPending.value && tbaEventData.value != null) { - validTeamNums.value = tbaEventData.value.map(value => value.team_number); - } -}); -let validTeamNums = ref>(); +/* +START SEASONAL UPDATE AREA + */ -// Selectable options for the Multi-Select component +/* +The following are a bunch of configuration variables used for the 2024 season +Each is labeled with which component in the HTML below it corresponds with +Feel free to delete these when you update this page, +just make sure you understand how they are used in case you wish to use the same custom components we used + */ +//Endgame Multi-Select Component Options const endgameOptions = [ 'None', 'Parked', @@ -56,10 +30,32 @@ const endgameOptions = [ 'Onstage', 'Harmony', ]; -const connectedOptions = [1, 2, 2, 3, 3]; -let endgameIndex = [1, 0, 0, 0, 0]; +//Auto Modal Image +const isOpen = ref(false); + +/* +Configuration variables done + */ -//all the data collected on the scout page in the form of ScoutingData, a type found in the utils/databases.ts file +/** + * updateEndgameOptions updates the scoutData variable to match the currently selected option in the endgame multiselect + * @param value the currently selected option + */ +function updateEndgameOptions(value: Array) { + let arr = []; + for (let i = 0; i < value.length; i++) { + if (value[i] == 1) { + arr.push(endgameOptions[i]); + } + } + scoutData.value.endgame.endgame = arr; + if (scoutData.value.endgame.endgame.length < 1) { + scoutData.value.endgame.endgame = [endgameOptions[0]]; + } +} + +//all the data collected on the scout page in the form of a ScoutingData object, +// you can edit this in the utils/databases.ts file let scoutData = ref({ event: '', teamNumber: '', @@ -105,19 +101,49 @@ let scoutData = ref({ }, }); -function updateEndgameOptions(value: Array) { - let arr = []; - for (let i = 0; i < value.length; i++) { - if (value[i] == 1) { - arr.push(endgameOptions[i]); - } - } - scoutData.value.endgame.endgame = arr; - if (scoutData.value.endgame.endgame.length < 1) { - scoutData.value.endgame.endgame = [endgameOptions[0]]; - } +/* +END SEASON UPDATE AREA +NOTE: you must also update the HTML at the bottom of this page that defines how users will scout matches +to make your work easier we have implemented custom components in the /components directory that you can use just like other HTML objects + */ + +//gets username and scouting database +const { + usernameState, +}: { + usernameState: Ref>; +} = inject(loginStateKey)!; +const { scoutingData: db } = databases.locals; + +//An enum of tabs on the scout page +enum GameTime { + Autonomous = 'Auto', + Teleoperated = 'Teleop', + Endgame = 'Endgame', + Notes = 'Notes', } +//The active tab used +let gameTime = ref(GameTime.Autonomous); + +//gets current event key +const currentEvent = useEventKey(); +watch(currentEvent, value => { + window.localStorage.setItem('currentEvent', value); +}); + +//gets the blue alliance data for what teams are at the current event and puts them in an array +const { data: tbaEventData, pending: tbaPending } = await useLazyFetch< + Array +>('/api/eventTeams/' + currentEvent.value); +watch(tbaPending, () => { + if (!tbaPending.value && tbaEventData.value != null) { + validTeamNums.value = tbaEventData.value.map(value => value.team_number); + } +}); +let validTeamNums = ref>(); + +//a quick function to check if the team and match numbers a user enters are valid function isValidNum() { return ( scoutData.value.teamNumber != null && @@ -128,6 +154,10 @@ function isValidNum() { ); } +/*** + The function that submits the data a user inputs to the couchdb database (notice db.post) + also redirects the webpage to the /matches page (notice navigateTo) + */ async function submit() { scoutData.value.teamNumber = parseInt(scoutData.value.teamNumber); scoutData.value.matchNumber = parseInt(scoutData.value.matchNumber); @@ -141,13 +171,6 @@ async function submit() { await navigateTo('/matches'); } } - -const isOpen = ref(false); //prestons way of making the reference image modal open - -/* Good-looking square buttons but don't work horizontally why? - - - */