Chart dropdown finished

This commit is contained in:
Martin Araneda 2023-02-15 15:31:17 -03:00
parent 3b03b4ba31
commit 674c8b5f0a

View File

@ -13,6 +13,8 @@ let textColorSecondary = documentStyle.getPropertyValue('--text-color-secondary'
let surfaceBorder = documentStyle.getPropertyValue('--surface-border'); let surfaceBorder = documentStyle.getPropertyValue('--surface-border');
const time_elapsed = ref([]); const time_elapsed = ref([]);
const coins = ref([]); const coins = ref([]);
const games = ref([]);
const selectedGames = ref();
const lineData = ref(null); const lineData = ref(null);
const lineOptions = ref(null); const lineOptions = ref(null);
@ -23,9 +25,29 @@ const setColorOptions = () => {
textColorSecondary = documentStyle.getPropertyValue('--text-color-secondary'); textColorSecondary = documentStyle.getPropertyValue('--text-color-secondary');
surfaceBorder = documentStyle.getPropertyValue('--surface-border'); surfaceBorder = documentStyle.getPropertyValue('--surface-border');
}; };
const probando = () => {
console.log(selectedGames.value)
}
async function getGames() {
try {
const response = await axios.get(`http://localhost:3001/game?limit=5000`);
games.value = response.data.map(game_id => {
return game_id.ID;
});
}
catch (error) {
console.error(error);
}
}
async function setChart() { async function setChart() {
try { try {
const response = await axios.get(`http://localhost:3001/frame?limit=5000&game_id=4`); if (selectedGames.value === undefined) {
return;
}
const response = await axios.get(`http://localhost:3001/frame?limit=5000&game_id=` + selectedGames.value);
time_elapsed.value = response.data.map(frame => { time_elapsed.value = response.data.map(frame => {
return Math.floor(frame.elapsed_time / 1000); return Math.floor(frame.elapsed_time / 1000);
}); });
@ -104,6 +126,7 @@ watch(
onMounted(() => { onMounted(() => {
checkAuth(); checkAuth();
setChart(); setChart();
getGames();
}) })
const checkAuth = () => { const checkAuth = () => {
@ -116,6 +139,8 @@ const checkAuth = () => {
<div class="grid p-fluid"> <div class="grid p-fluid">
<div class="col-12 xl:col-2"> <div class="col-12 xl:col-2">
<span class="p-float-label"> <span class="p-float-label">
<Dropdown v-model="selectedGames" :options="games" optionLabel="" optionValue=""
placeholder="Select a game session" @change="setChart" />
</span> </span>
</div> </div>
</div> </div>