diff --git a/firebase.json b/firebase.json
index 356b592..b745c1e 100644
--- a/firebase.json
+++ b/firebase.json
@@ -3,7 +3,12 @@
{
"source": "functions",
"codebase": "default",
- "ignore": ["node_modules", ".git", "firebase-debug.log", "firebase-debug.*.log"],
+ "ignore": [
+ "node_modules",
+ ".git",
+ "firebase-debug.log",
+ "firebase-debug.*.log"
+ ],
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
@@ -11,12 +16,16 @@
}
],
"firestore": {
- "rules": "src/firebase/firestore.rules",
- "indexes": "src/firebase/firestore.indexes.json"
+ "rules": "firestore.rules",
+ "indexes": "firestore.indexes.json"
},
"hosting": {
"public": "dist",
- "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
+ "ignore": [
+ "firebase.json",
+ "**/.*",
+ "**/node_modules/**"
+ ],
"rewrites": [
{
"source": "**",
diff --git a/src/assets/base.css b/src/assets/base.css
index 8816868..d3de42e 100644
--- a/src/assets/base.css
+++ b/src/assets/base.css
@@ -62,23 +62,10 @@ body {
min-height: 100vh;
color: var(--color-text);
background: var(--color-background);
- transition:
- color 0.5s,
- background-color 0.5s;
+ transition: color 0.5s, background-color 0.5s;
line-height: 1.6;
- font-family:
- Inter,
- -apple-system,
- BlinkMacSystemFont,
- 'Segoe UI',
- Roboto,
- Oxygen,
- Ubuntu,
- Cantarell,
- 'Fira Sans',
- 'Droid Sans',
- 'Helvetica Neue',
- sans-serif;
+ font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
+ Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
font-size: 15px;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
diff --git a/src/components/Apikey.vue b/src/components/Apikey.vue
index 9c61cec..8a8c2a4 100644
--- a/src/components/Apikey.vue
+++ b/src/components/Apikey.vue
@@ -2,8 +2,8 @@
API Key
-
Your API key is: {{ apiKey }}
-
+
Your API key is: {{ apiKey }}
+
@@ -31,7 +31,6 @@ const rotateKey = () => {
store.rotateKey()
snackbarMessage.value = 'ApiKey rotated'
}
-
diff --git a/src/components/Header.vue b/src/components/Header.vue
index fc813f0..8bb63f0 100644
--- a/src/components/Header.vue
+++ b/src/components/Header.vue
@@ -29,7 +29,7 @@
diff --git a/src/components/StackedBarChart.vue b/src/components/StackedBarChart.vue
index 2f3408a..882b09e 100644
--- a/src/components/StackedBarChart.vue
+++ b/src/components/StackedBarChart.vue
@@ -3,45 +3,63 @@
\ No newline at end of file
+
diff --git a/src/firebase/data.ts b/src/firebase/data.ts
index 2eb8f29..915bfc0 100644
--- a/src/firebase/data.ts
+++ b/src/firebase/data.ts
@@ -17,10 +17,10 @@ import {
query,
where
} from 'firebase/firestore/lite'
-import { getFunctions, httpsCallable } from "firebase/functions";
+import { getFunctions, httpsCallable } from 'firebase/functions'
import type { ScreenTimeData, ScreenTimeSummary } from '@/types'
-const functions = getFunctions();
+const functions = getFunctions()
export function dataToSummary(data: ScreenTimeData): ScreenTimeSummary {
const total = data.events.reduce((acc, event) => acc + event.duration, 0)
@@ -133,18 +133,20 @@ export async function getApiKey(userId: string): Promise {
}
interface ApiResponse {
- apiKey: string;
+ apiKey: string
}
export async function rotateKey(userId: string): Promise {
// invoke a callable function to rotate the user's api key
// this function is defined in functions/src/index.ts
const rotateApiKey = httpsCallable(functions, 'rotateApiKey')
- const key = rotateApiKey({ userId: userId }).then((result) => {
- return (result.data as ApiResponse)?.apiKey;
- }).catch((error) => {
- console.error(error)
- return null
- })
+ const key = rotateApiKey({ userId: userId })
+ .then((result) => {
+ return (result.data as ApiResponse)?.apiKey
+ })
+ .catch((error) => {
+ console.error(error)
+ return null
+ })
return key
}
diff --git a/src/stores/apikey.ts b/src/stores/apikey.ts
index f67c344..4a26465 100644
--- a/src/stores/apikey.ts
+++ b/src/stores/apikey.ts
@@ -3,27 +3,29 @@ import { getApiKey, rotateKey as rotateKeyCallable } from '@/firebase/data'
import { useAuthStore } from './auth'
import { ref } from 'vue'
-export const useApiKeyStore = defineStore('apikey', () => {
- const apikey = ref(null as string | null)
- function fetchKey() {
- const userId = useAuthStore().user!.uid
- getApiKey(userId).then((key) => {
- if (key == apikey.value) return;
- apikey.value = key
- })
- }
- function rotateKey() {
- const userId = useAuthStore().user!.uid
- rotateKeyCallable(userId).then((key) => {
- console.log('Key is now', key)
- if (key != null) {
+export const useApiKeyStore = defineStore(
+ 'apikey',
+ () => {
+ const apikey = ref(null as string | null)
+ function fetchKey() {
+ const userId = useAuthStore().user!.uid
+ getApiKey(userId).then((key) => {
+ if (key == apikey.value) return
apikey.value = key
- }
- })
+ })
+ }
+ function rotateKey() {
+ const userId = useAuthStore().user!.uid
+ rotateKeyCallable(userId).then((key) => {
+ console.log('Key is now', key)
+ if (key != null) {
+ apikey.value = key
+ }
+ })
+ }
+ return { apikey, fetchKey, rotateKey }
+ },
+ {
+ persist: true
}
- return { apikey, fetchKey, rotateKey }
-},
-{
- persist: true
-}
)
diff --git a/src/stores/screentime.ts b/src/stores/screentime.ts
index 28119ba..dc49fe0 100644
--- a/src/stores/screentime.ts
+++ b/src/stores/screentime.ts
@@ -3,17 +3,19 @@ import { getScreenTimeData, dataToSummary } from '@/firebase/data'
import type { ScreenTimeSummary, ScreenTimeData } from '@/types'
import { useAuthStore } from './auth'
import { getFirestore, collection, onSnapshot } from 'firebase/firestore'
-import { ref,computed, type ComputedRef, watch } from 'vue'
+import { ref, computed, type ComputedRef, watch } from 'vue'
-export const useScreenTimeStore = defineStore('screentime', () => {
- const screenTimeData = ref([])
- const summary:ComputedRef = computed(
- () => screenTimeData.value.map((data) => dataToSummary(data))
- )
- const userId = useAuthStore().user!.uid
- const db = getFirestore()
- const colRef = collection(db, 'screentime/' + userId + '/' + userId)
- onSnapshot(colRef, (snapshot) => {
+export const useScreenTimeStore = defineStore(
+ 'screentime',
+ () => {
+ const screenTimeData = ref([])
+ const summary: ComputedRef = computed(() =>
+ screenTimeData.value.map((data) => dataToSummary(data))
+ )
+ const userId = useAuthStore().user!.uid
+ const db = getFirestore()
+ const colRef = collection(db, 'screentime/' + userId + '/' + userId)
+ onSnapshot(colRef, (snapshot) => {
const changes = snapshot.docChanges()
if (changes.length === 0) return
console.log('updated screenTimeData')
@@ -26,13 +28,18 @@ export const useScreenTimeStore = defineStore('screentime', () => {
}
})
})
-
- // resets the store on user logout
- watch(() => userId, () => {
- screenTimeData.value = []
- })
- return { screenTimeData, summary}
-}, {
- persist: true
-})
+ // resets the store on user logout
+ watch(
+ () => userId,
+ () => {
+ screenTimeData.value = []
+ }
+ )
+
+ return { screenTimeData, summary }
+ },
+ {
+ persist: true
+ }
+)
diff --git a/src/vue-material-design-icons.d.ts b/src/vue-material-design-icons.d.ts
index ddcfd69..4e2588a 100644
--- a/src/vue-material-design-icons.d.ts
+++ b/src/vue-material-design-icons.d.ts
@@ -1,10 +1,10 @@
declare module 'vue-material-design-icons/ContentCopy.vue' {
- import { DefineComponent } from 'vue';
- const component: DefineComponent<{}, {}, any>;
- export default component;
+ import { DefineComponent } from 'vue'
+ const component: DefineComponent<{}, {}, any>
+ export default component
}
declare module 'vue-material-design-icons/Logout.vue' {
- import { DefineComponent } from 'vue';
- const component: DefineComponent<{}, {}, any>;
- export default component;
+ import { DefineComponent } from 'vue'
+ const component: DefineComponent<{}, {}, any>
+ export default component
}