mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Export of user data as XML
This commit is contained in:
parent
0e678a5559
commit
f0354c337f
5
webapp/assets/_new/icons/svgs/download.svg
Normal file
5
webapp/assets/_new/icons/svgs/download.svg
Normal file
@ -0,0 +1,5 @@
|
||||
<!-- Generated by IcoMoon.io -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
|
||||
<title>download</title>
|
||||
<path d="M15 4h2v16.563l5.281-5.281 1.438 1.438-7 7-0.719 0.688-0.719-0.688-7-7 1.438-1.438 5.281 5.281v-16.563zM7 26h18v2h-18v-2z"></path>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 302 B |
@ -306,6 +306,9 @@ export const userDataQuery = (i18n) => {
|
||||
posts {
|
||||
...post
|
||||
comments {
|
||||
author {
|
||||
slug
|
||||
}
|
||||
...comment
|
||||
}
|
||||
}
|
||||
|
||||
@ -648,7 +648,9 @@
|
||||
"success": "Konto erfolgreich gelöscht!"
|
||||
},
|
||||
"download": {
|
||||
"name": "Daten herunterladen"
|
||||
"json": "als JSON",
|
||||
"name": "Daten herunterladen",
|
||||
"xml": "als XML"
|
||||
},
|
||||
"email": {
|
||||
"change-successful": "Deine E-Mail-Adresse wurde erfolgreich geändert.",
|
||||
|
||||
@ -648,7 +648,9 @@
|
||||
"success": "Account successfully deleted!"
|
||||
},
|
||||
"download": {
|
||||
"name": "Download Data"
|
||||
"json": "as JSON",
|
||||
"name": "Download Data",
|
||||
"xml": "as XML"
|
||||
},
|
||||
"email": {
|
||||
"change-successful": "Your e-mail address has been changed successfully.",
|
||||
|
||||
@ -93,6 +93,7 @@
|
||||
"vue-scrollto": "^2.17.1",
|
||||
"vue-sweetalert-icons": "~4.2.0",
|
||||
"vuex-i18n": "~1.13.1",
|
||||
"xml-js": "^1.6.11",
|
||||
"xregexp": "^4.3.0",
|
||||
"zxcvbn": "^4.4.2"
|
||||
},
|
||||
|
||||
@ -1,15 +1,25 @@
|
||||
<template>
|
||||
<base-card>
|
||||
<h2 class="title">{{ $t('settings.download.name') }}</h2>
|
||||
<button @click="onClick">Download data</button>
|
||||
<base-button @click="onClick(jsonData)" icon="download" secondary filled>
|
||||
{{ $t('settings.download.json') }}
|
||||
</base-button>
|
||||
<base-button @click="onClick(xmlData)" icon="download" secondary filled>
|
||||
{{ $t('settings.download.xml') }}
|
||||
</base-button>
|
||||
</base-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex'
|
||||
import { userDataQuery } from '~/graphql/User'
|
||||
import BaseButton from '~/components/_new/generic/BaseButton/BaseButton.vue'
|
||||
import { json2xml } from 'xml-js'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
BaseButton,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
userData: {},
|
||||
@ -20,15 +30,24 @@ export default {
|
||||
user: 'auth/user',
|
||||
}),
|
||||
jsonData() {
|
||||
return JSON.stringify(this.userData)
|
||||
return { data: JSON.stringify(this.userData, null, 2), type: 'json' }
|
||||
},
|
||||
xmlData() {
|
||||
return {
|
||||
data: json2xml(
|
||||
{ userData: this.userData },
|
||||
{ compact: true, ignoreComment: true, spaces: 2 },
|
||||
),
|
||||
type: 'xml',
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
onClick() {
|
||||
var fileURL = window.URL.createObjectURL(new Blob([this.jsonData]))
|
||||
onClick(method) {
|
||||
var fileURL = window.URL.createObjectURL(new Blob([method.data]))
|
||||
var fileLink = document.createElement('a')
|
||||
fileLink.href = fileURL
|
||||
fileLink.setAttribute('download', 'userData.json')
|
||||
fileLink.setAttribute('download', 'userData.' + method.type)
|
||||
document.body.appendChild(fileLink)
|
||||
fileLink.click()
|
||||
},
|
||||
|
||||
@ -17423,6 +17423,13 @@ xdg-basedir@^3.0.0:
|
||||
resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4"
|
||||
integrity sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ=
|
||||
|
||||
xml-js@^1.6.11:
|
||||
version "1.6.11"
|
||||
resolved "https://registry.yarnpkg.com/xml-js/-/xml-js-1.6.11.tgz#927d2f6947f7f1c19a316dd8eea3614e8b18f8e9"
|
||||
integrity sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g==
|
||||
dependencies:
|
||||
sax "^1.2.4"
|
||||
|
||||
xml-name-validator@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user