Skip to content

Commit

Permalink
This thing is what you show people to make the write functional code...
Browse files Browse the repository at this point in the history
Maneged to pass the start and end dates to the statistics components, but had its own pandora's box abd came with the problem that I had to call the events function twice.

Thinking to pass the events data to statics comp, but that would mean having to calculate the statics in the "front", not that there really is a front, so maybe that isn't a problem.

 Just want to get this over with so i never have to touch electron again.

 "Why should this Electron be saved? Doesn't it seem profoundly sick? Diseased? Like PWA has to be better, purely by the virtue that this is awful."
  • Loading branch information
MichielSaey committed Dec 31, 2023
1 parent 7ad583d commit 2fcc000
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 23 deletions.
17 changes: 10 additions & 7 deletions src/clickup-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,14 @@ export default {
* Get all time tracking entries within a given range
*/
getTimeTrackingRange(start, end, userId) {
if ((!start && start === undefined) || (!end && end === undefined)) return;
console.log("Getting time tracking entries for range " + start + " - " + end)

return new Promise((resolve, reject) => {

const params = {
start_date: start.valueOf(),
end_date: end.valueOf(),
start_date: start.getTime(),
end_date: end.getTime(),
include_location_names: true,
}

Expand Down Expand Up @@ -456,12 +458,13 @@ export default {
/*
* Function to build a dataset for the charts in the statistics view
*/
async getTimeTrackingData(start, end, userid) {
let time_tracking_entries = await this.getTimeTrackingRange(start, end, userid)
async getTimeTrackingData(start, end, userid = null) {
console.log("Getting time tracking data for range " + start + " - " + end)

console.log("Building dataset")
time_tracking_entries.forEach(entry => {
print(entry)
// let data_by_day = new Map()

this.getTimeTrackingData(start, end, userid).then((data) => {
console.log(data)
})
}
}
27 changes: 13 additions & 14 deletions src/components/TimeTrackingStatistics.vue
Original file line number Diff line number Diff line change
@@ -1,27 +1,18 @@
<script setup>
import {ref, watch, onMounted} from "vue"
import {onMounted, ref, watch} from "vue"
import clickupService from '@/clickup-service';
const props = defineProps({
open: Boolean,
active: String
events: [],
})
let loading = ref(true);
// Start point
onMounted(() => fetchData())
function fetchData() {
loading.value = true
clickupService.getTimeTrackingData()
.then(result => {
loading.value = false
console.log('result', result)
})
}
onMounted(() => {
// TODO: Turn events into statistics
})
watch(() => props.open, open => {
console.log('props.open', props.open)
Expand All @@ -38,6 +29,14 @@ watch(() => props.open, open => {
return vueCalRoots[0].classList.remove('vuecal--time-tracking-statistics-open')
})
function fetchData(start, end) {
loading.value = true
clickupService.getTimeTrackingData(start, end).then(() => {
loading.value = false
})
}
</script>

<template>
Expand Down
14 changes: 12 additions & 2 deletions src/views/TimeTracker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<time-tracking-statistics
v-if="store.get('settings.enable_statistics')"
:open="statisticsOpen"
:start="start_date"
:end="end_date"
/>

<!-- START | Calendar view -->
Expand All @@ -33,8 +35,8 @@
:watch-real-time="true"
active-view="week"
today-button
@ready="fetchEvents"
@view-change="fetchEvents"
@ready="handleDateChange"
@view-change="handleDateChange"
@event-drop="updateTimeTrackingEntry"
@event-duration-change="updateTimeTrackingEntry"
@keydown.meta.delete.exact="deleteSelectedTask()"
Expand Down Expand Up @@ -394,6 +396,14 @@ export default {
| FETCH TIME TRACKING ENTRIES
|--------------------------------------------------------------------------
*/
async handleDateChange({startDate, endDate}) {
if ((!startDate && startDate === undefined) || (!endDate && endDate === undefined)) return;
this.start_date = startDate
this.end_date = endDate
// Add any functions here that should be called when the date range changes
await this.fetchEvents({startDate, endDate})
},
async fetchEvents({startDate, endDate}) {
let customColorEnabled = false
Expand Down

0 comments on commit 2fcc000

Please sign in to comment.