-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stats): add "delete all data" button
- Loading branch information
Showing
1 changed file
with
34 additions
and
1 deletion.
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 |
---|---|---|
@@ -1,6 +1,39 @@ | ||
<template> | ||
<v-card> | ||
<v-card-title>Stats</v-card-title> | ||
<v-card-text>TODO</v-card-text> | ||
<v-card-text | ||
>Stats aren't currently available. Check back later!</v-card-text | ||
> | ||
<v-card-actions> | ||
<v-spacer /> | ||
<v-btn class="error" @click="deleteAllData">Delete all data</v-btn> | ||
</v-card-actions> | ||
</v-card> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from "vue"; | ||
import Component from "vue-class-component"; | ||
import { commitSnackbarText } from "../store"; | ||
@Component | ||
export default class extends Vue { | ||
public deleteAllData(): void { | ||
let confirmation = prompt("Type 'delete' to confirm."); | ||
if (confirmation === null) { | ||
confirmation = ""; | ||
} | ||
confirmation = confirmation.toLowerCase().trim(); | ||
if (confirmation === "delete") { | ||
commitSnackbarText(this.$store, "Deleted all data."); | ||
localStorage.clear(); | ||
window.location.assign("/"); | ||
} else { | ||
commitSnackbarText( | ||
this.$store, | ||
"Confirmation failed — no data was deleted.", | ||
); | ||
} | ||
} | ||
} | ||
</script> |