-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
29e9271
commit 218371e
Showing
1 changed file
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<template> | ||
<v-container> | ||
<p class="text-h2 dividerline mt-4 mb-8" style="color: #0080bc"> | ||
My progression | ||
</p> | ||
<v-btn @click="clear" class="my-4">Clear progression</v-btn> | ||
|
||
<p class="text-h4">Started</p> | ||
<template v-if="started.length != 0"> | ||
<template v-for="(c, kc) in started" :key="kc"> | ||
<CardSession :itemSession="c" /> | ||
<br /> | ||
</template> | ||
</template> | ||
<template v-else> | ||
<p>No session has been started</p> | ||
</template> | ||
|
||
<p class="text-h4">Finish</p> | ||
<template v-if="finish.length != 0"> | ||
<template v-for="(c, kc) in finish" :key="kc"> | ||
<CardSession :itemSession="c" /> | ||
<br /> | ||
</template> | ||
</template> | ||
<template v-else> | ||
<p>No session has been completed</p> | ||
</template> | ||
</v-container> | ||
</template> | ||
|
||
<script> | ||
import { useStorage } from "@vueuse/core"; | ||
export default { | ||
data() { | ||
return { | ||
started: [], | ||
finish: [], | ||
}; | ||
}, | ||
async created() { | ||
await this.getState(); | ||
}, | ||
methods: { | ||
async getState() { | ||
const theDefault = {}; | ||
const state = useStorage( | ||
"my-progression-store", | ||
theDefault, | ||
localStorage, | ||
{ | ||
mergeDefaults: true, | ||
} | ||
); | ||
for (const [key, value] of Object.entries(state.value)) { | ||
switch (value.status) { | ||
case "started": | ||
const tempStarted = await queryContent(key + "/_dir").findOne(); | ||
tempStarted["type"] = key.split("/")[2]; | ||
this.started.push(tempStarted); | ||
break; | ||
case "finish": | ||
const tempFinish = await queryContent(key + "/_dir").findOne(); | ||
tempFinish["type"] = key.split("/")[2]; | ||
this.finish.push(tempFinish); | ||
break; | ||
} | ||
} | ||
}, | ||
clear() { | ||
const theDefault = {}; | ||
const state = useStorage( | ||
"my-progression-store", | ||
theDefault, | ||
localStorage, | ||
{ | ||
mergeDefaults: true, | ||
} | ||
); | ||
state.value = null; | ||
this.started = []; | ||
this.finish = []; | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style> | ||
</style> |