set filter dates for server stats
This commit is contained in:
@@ -79,9 +79,7 @@ import axios from 'axios'
|
|||||||
|
|
||||||
const dateSelect = ref(-1)
|
const dateSelect = ref(-1)
|
||||||
|
|
||||||
const dateItems = [
|
const dateItems = buildDateItems()
|
||||||
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24
|
|
||||||
]
|
|
||||||
|
|
||||||
const gameStats = ref({})
|
const gameStats = ref({})
|
||||||
|
|
||||||
@@ -99,11 +97,38 @@ async function loadData() {
|
|||||||
roleStats.value = roleStatsResponse.data
|
roleStats.value = roleStatsResponse.data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildDateItems() {
|
||||||
|
const items = [{title: "All Time", value: -1}]
|
||||||
|
|
||||||
|
const date = new Date()
|
||||||
|
while (date.getUTCFullYear() != 2023 || date.getUTCMonth() != 0) {
|
||||||
|
console.log(buildDateEntry(date))
|
||||||
|
items.push(buildDateEntry(date))
|
||||||
|
date.setUTCMonth(date.getUTCMonth() - 1)
|
||||||
|
}
|
||||||
|
items.push(buildDateEntry(date))
|
||||||
|
|
||||||
|
return items
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildDateEntry(date: Date) {
|
||||||
|
const monthId = dateToMonthId(date)
|
||||||
|
return {
|
||||||
|
title: date.toLocaleString('en-us',{month:'short', year:'numeric'}),
|
||||||
|
value: monthId
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function dateToMonthId(date: Date) {
|
||||||
|
return (((date.getUTCFullYear() - 2023) * 12) + (date.getUTCMonth()))
|
||||||
|
}
|
||||||
|
|
||||||
watch(dateSelect, async (newValue, oldValue) => {
|
watch(dateSelect, async (newValue, oldValue) => {
|
||||||
loadData()
|
loadData()
|
||||||
})
|
})
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
loadData()
|
loadData()
|
||||||
|
console.log(buildDateItems())
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user