mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
Display persistent summary interval into the front-end time picker
This commit is contained in:
parent
9586dbf781
commit
ba81c07345
@ -2,8 +2,15 @@ PetiteVue.createApp({
|
||||
$delimiters: ['${', '}'],
|
||||
get currentInterval() {
|
||||
const urlParams = new URLSearchParams(window.location.search)
|
||||
if (urlParams.has('interval')) return urlParams.get('interval')
|
||||
if (!urlParams.has('from') && !urlParams.has('to')) return 'today'
|
||||
const cookies = new URLSearchParams(document.cookie.replaceAll('; ', '&'))
|
||||
|
||||
if (urlParams.has('interval'))
|
||||
return urlParams.get('interval')
|
||||
if (cookies.has('wakapi_summary_interval'))
|
||||
return cookies.get('wakapi_summary_interval')
|
||||
if (!urlParams.has('from') && !urlParams.has('to'))
|
||||
return 'today'
|
||||
|
||||
return null
|
||||
}
|
||||
}).mount('#summary-page')
|
@ -23,8 +23,16 @@ function TimePicker({ fromDate, toDate, timeSelection }) {
|
||||
})
|
||||
|
||||
const query = new URLSearchParams(window.location.search)
|
||||
if (query.has('interval')) {
|
||||
const refEl = document.getElementById(`time-option-${query.get('interval')}`)
|
||||
const cookies = new URLSearchParams(document.cookie.replaceAll('; ', '&'))
|
||||
|
||||
let interval = undefined;
|
||||
if (query.has('interval'))
|
||||
interval = query.get('interval')
|
||||
else if (cookies.has('wakapi_summary_interval'))
|
||||
interval = cookies.get('wakapi_summary_interval')
|
||||
|
||||
if (interval) {
|
||||
const refEl = document.getElementById(`time-option-${interval}`)
|
||||
this.timeSelection = refEl ? refEl.innerText : 'Unknown'
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user