Skip to content

Commit

Permalink
Add GDPR export
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometrically committed Sep 27, 2024
1 parent 2713f0e commit 2ba9ea1
Showing 1 changed file with 52 additions and 6 deletions.
58 changes: 52 additions & 6 deletions apps/frontend/src/pages/settings/account.vue
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,22 @@
</div>
</section>

<section id="data-export" class="universal-card">
<h2>Data export</h2>
<p>
Request a copy of all your personal data you have uploaded to Modrinth. This may take
several minutes to complete.
</p>
<a v-if="generated" class="iconified-button" :href="generated" download="export.json">
<DownloadIcon />
Download export
</a>
<button v-else class="iconified-button" :disabled="generatingExport" @click="exportData">
<template v-if="generatingExport"> <UpdatedIcon /> Generating export... </template>
<template v-else> <UpdatedIcon /> Generate export </template>
</button>
</section>

<section id="delete-account" class="universal-card">
<h2>Delete account</h2>
<p>
Expand All @@ -391,16 +407,18 @@

<script setup>
import {
CheckIcon,
EditIcon,
SaveIcon,
TrashIcon,
ExternalIcon,
LeftArrowIcon,
PlusIcon,
RightArrowIcon,
SaveIcon,
SettingsIcon,
TrashIcon,
UpdatedIcon,
XIcon,
LeftArrowIcon,
RightArrowIcon,
CheckIcon,
ExternalIcon,
DownloadIcon,
} from "@modrinth/assets";
import QrcodeVue from "qrcode.vue";
import GitHubIcon from "assets/icons/auth/sso-github.svg";
Expand Down Expand Up @@ -614,6 +632,34 @@ async function deleteAccount() {
stopLoading();
}
const generatingExport = ref(false);
const generated = ref();
async function exportData() {
startLoading();
generatingExport.value = true;
try {
const res = await useBaseFetch("gdpr/export", {
method: "POST",
internal: true,
});
const jsonString = JSON.stringify(res, null, 2);
const blob = new Blob([jsonString], { type: "application/json" });
generated.value = URL.createObjectURL(blob);
} catch (err) {
data.$notify({
group: "main",
title: "An error occurred",
text: err.data.description,
type: "error",
});
}
generatingExport.value = false;
stopLoading();
}
</script>
<style lang="scss" scoped>
canvas {
Expand Down

0 comments on commit 2ba9ea1

Please sign in to comment.