Skip to content

Commit d64ae6c

Browse files
authored
Merge pull request #45 from gwleuverink/next
Next
2 parents 1261617 + 9b221c1 commit d64ae6c

7 files changed

Lines changed: 84 additions & 19 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"private": true,
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"name": "clickup-time-tracker",
55
"productName": "Time Tracker",
66
"description": "A tool for painlessly tracking time on ClickUp tasks",

src/background.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async function createWindow() {
4242
// Create the browser window.
4343
const win = new BrowserWindow({
4444
width: 1200,
45-
height: 700,
45+
height: 720,
4646
titleBarStyle: 'hidden',
4747
webPreferences: {
4848
// Use pluginOptions.nodeIntegration, leave this alone

src/cache.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ export default {
2626
? null
2727
: defaultValue;
2828

29-
if(expiresAt && expiresAt < Date.now()) {
29+
if(expiresAt && expiresAt < Date.now() / 1000) {
3030
return store.get(`cache.values.${key}`) || defaultValue;
3131
}
3232

3333
return defaultValue;
3434
},
3535

36-
put: function(key, value, expiresAt) {
36+
put: function(key, value, expiresAfterMinutes) {
37+
const expiresAt = (Date.now() / 1000) + expiresAfterMinutes
38+
3739
store.set(`cache.expires_at.${key}`, expiresAt)
3840
store.set(`cache.values.${key}`, value)
3941

@@ -43,5 +45,10 @@ export default {
4345
clear: function(key) {
4446
store.delete(`cache.expires_at.${key}`)
4547
store.delete(`cache.values.${key}`)
48+
},
49+
50+
flush: function() {
51+
store.delete('cache.expires_at')
52+
store.delete('cache.values')
4653
}
4754
}

src/clickup-service.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export default {
151151
return cache.put(
152152
TASKS_CACHE_KEY,
153153
tasks,
154-
Date.now() + 3600 * 6 // plus 6 hours
154+
3600 * 6 // plus 6 hours
155155
)
156156
},
157157

@@ -278,7 +278,7 @@ export default {
278278
return cache.put(
279279
USERS_CACHE_KEY,
280280
await this.getUsers(),
281-
Date.now() + 3600 * 6 // plus 6 hours
281+
3600 * 6 // plus 6 hours
282282
)
283283
}
284284
}

src/views/TeamMemberEntries.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,9 @@ export default {
207207
clickupService
208208
.getTimeTrackingRange(startDate, endDate, this.$route.params.userId)
209209
.then(entries => {
210-
this.events = entries.map((entry) => eventFactory.fromClickup(entry));
210+
this.events = entries
211+
.map((entry) => eventFactory.fromClickup(entry)) // Map into Event DTO
212+
.filter((entry) => entry); // Remove falsey entries
211213
})
212214
.catch(error => {
213215
if(error === 'You have no access') {

src/views/TimeTracker.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,12 @@
145145
<n-card
146146
:bordered="false"
147147
class="max-w-xl"
148-
title="Register new time entry"
148+
title="What did you work on?"
149149
size="huge"
150150
role="dialog"
151151
aria-modal="true"
152152
>
153-
<template #header> Log a new task </template>
153+
<template #header> What did you work on? </template>
154154

155155
<n-form :model="selectedTask" :rules="rules.task" ref="createForm" size="large">
156156
<div class="flex space-x-2">
@@ -211,7 +211,7 @@
211211
<n-card
212212
:bordered="false"
213213
class="max-w-xl"
214-
title="Log a new task"
214+
title="Edit tracking entry"
215215
size="huge"
216216
role="dialog"
217217
aria-modal="true"
@@ -386,7 +386,9 @@ export default {
386386
clickupService
387387
.getTimeTrackingRange(startDate, endDate)
388388
.then(entries => {
389-
this.events = entries.map((entry) => eventFactory.fromClickup(entry));
389+
this.events = entries
390+
.map((entry) => eventFactory.fromClickup(entry)) // Map into Event DTO
391+
.filter((entry) => entry); // Remove falsey entries
390392
})
391393
.catch(error => this.error({
392394
error,

src/views/UserSettings.vue

Lines changed: 62 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,57 @@
3737
<n-input v-model:value="model.background_image_url" clearable />
3838
</n-form-item>
3939

40-
<div class="flex space-x-4">
41-
<n-form-item label="Show weekends" path="show_weekend">
40+
41+
<!-- START | Feature toggles -->
42+
<div class="relative p-4 bg-white border rounded-lg shadow-sm">
43+
44+
<label class="absolute px-1.5 bg-white -left-0.5 -top-3">Optional features</label>
45+
46+
<n-form-item path="show_weekend" :show-label="false" :show-feedback="false">
4247
<n-switch v-model:value="model.show_weekend" :default-value="true" />
48+
<label class="ml-3 text-gray-800">Show weekends</label>
4349
</n-form-item>
4450

45-
<n-form-item label="Require description" path="require_description">
51+
<n-form-item path="require_description" :show-label="false" :show-feedback="false">
4652
<n-switch v-model:value="model.require_description" :default-value="false" />
53+
<label class="ml-3 text-gray-800">Require descriptions</label>
4754
</n-form-item>
4855

49-
<n-form-item label="Enable admin features" path="admin_features_enabled">
56+
<n-form-item path="admin_features_enabled" :show-label="false" :show-feedback="false">
5057
<n-switch v-model:value="model.admin_features_enabled" :default-value="false" />
58+
<label class="ml-3 text-gray-800">
59+
Enable admin features
60+
<div class="text-sm text-gray-500">You must be a CU admin to use this</div>
61+
</label>
5162
</n-form-item>
63+
64+
<hr class="my-6" />
65+
<label class="absolute px-1.5 bg-white -ml-4 -mt-9">Danger zone</label>
66+
67+
<n-popconfirm @positive-click="flushCaches" :show-icon="false">
68+
<template #activator>
69+
<n-button size="small" type="warning" secondary>
70+
Flush caches
71+
</n-button>
72+
</template>
73+
74+
This will clear all locally cached<br />
75+
ClickUp tasks & team members
76+
77+
</n-popconfirm>
78+
5279
</div>
80+
<!-- END | Feature toggles -->
81+
5382

54-
<div class="flex justify-end">
83+
<div class="flex justify-end mt-4 space-x-2">
84+
<n-button @click="cancel" round>Cancel</n-button>
5585
<n-button @click="persist" type="primary" round>Save</n-button>
5686
</div>
87+
5788
</n-form>
5889

59-
<div class="p-3 space-y-4 shadow-inner bg-gray-50">
90+
<div class="flex flex-col p-3 space-y-4 shadow-inner bg-gray-50">
6091
<h2 class="text-lg font-bold text-gray-700">Instructions</h2>
6192
<p>Click & drag in order to create a new tracking entry</p>
6293

@@ -99,27 +130,35 @@
99130
⌘ + D
100131
</kbd>
101132
</div>
133+
102134
</div>
103135
</div>
104136
</template>
105137

106138
<script>
107139
import { ref } from "vue";
108140
import { useRouter } from "vue-router";
109-
import { NForm, NFormItem, NInput, NTimePicker, NSwitch, NButton, useNotification } from "naive-ui";
141+
import { NForm, NFormItem, NInput, NTimePicker, NSwitch, NButton, NPopconfirm, useNotification } from "naive-ui";
110142
import { BackspaceIcon } from "@heroicons/vue/24/outline";
111143
import clickupService from '@/clickup-service';
112144
import store from "@/store";
145+
import cache from "@/cache";
113146
114147
export default {
115-
components: { NForm, NFormItem, NInput, NTimePicker, NSwitch, NButton, BackspaceIcon },
148+
components: { NForm, NFormItem, NInput, NTimePicker, NSwitch, NButton, NPopconfirm, BackspaceIcon },
116149
117150
setup() {
118151
const form = ref(null);
119152
const router = useRouter();
120153
const notification = useNotification();
121154
const model = ref(store.get("settings") || {});
122155
156+
function mustFlushCachesAfterPersist() {
157+
// Either the CU acces token or team id has changed
158+
return model.value.clickup_access_token !== store.get('settings.clickup_access_token')
159+
|| model.value.clickup_team_id !== store.get('settings.clickup_team_id')
160+
}
161+
123162
return {
124163
form,
125164
@@ -129,6 +168,11 @@ export default {
129168
form.value
130169
.validate()
131170
.then(() => {
171+
172+
if(mustFlushCachesAfterPersist()) {
173+
cache.flush();
174+
}
175+
132176
store.set({ settings: model.value });
133177
134178
router.replace({ name: "time-tracker" });
@@ -138,6 +182,16 @@ export default {
138182
.catch((errors) => console.error(errors));
139183
},
140184
185+
cancel() {
186+
router.replace({ name: "time-tracker" });
187+
},
188+
189+
flushCaches() {
190+
cache.flush()
191+
192+
notification.success({ title: "All caches flushed!", duration: 1500 });
193+
},
194+
141195
rules: {
142196
clickup_access_token: [
143197
{

0 commit comments

Comments
 (0)