Add GDPR export (#2461)

This commit is contained in:
Geometrically
2024-09-27 13:33:28 -07:00
committed by GitHub
parent 2713f0e610
commit 9708685506

View File

@@ -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>
@@ -391,16 +407,18 @@
<script setup>
import {
EditIcon,
SaveIcon,
TrashIcon,
PlusIcon,
SettingsIcon,
XIcon,
LeftArrowIcon,
RightArrowIcon,
CheckIcon,
EditIcon,
ExternalIcon,
LeftArrowIcon,
PlusIcon,
RightArrowIcon,
SaveIcon,
SettingsIcon,
TrashIcon,
UpdatedIcon,
XIcon,
DownloadIcon,
} from "@modrinth/assets";
import QrcodeVue from "qrcode.vue";
import GitHubIcon from "assets/icons/auth/sso-github.svg";
@@ -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 {