Removed XML download. Added image download and description

This commit is contained in:
Moriz Wahl 2020-10-13 17:36:53 +02:00
parent 9b2bf64db5
commit 4a79fffa5b
5 changed files with 25 additions and 24 deletions

View File

@ -648,9 +648,9 @@
"success": "Konto erfolgreich gelöscht!"
},
"download": {
"description": "Klicke auf den Knopf oben, um den Inhalt deiner Posts und Kommentare herunterzuladen. Um die Bilder der posts herunterzuladen, musst du auf den jeweiligen Link unten klicken.",
"json": "als JSON",
"name": "Daten herunterladen",
"xml": "als XML"
"name": "Daten herunterladen"
},
"email": {
"change-successful": "Deine E-Mail-Adresse wurde erfolgreich geändert.",

View File

@ -648,9 +648,9 @@
"success": "Account successfully deleted!"
},
"download": {
"description": "Click on the button above to download the content of your posts and comments. To download the images of your posts, you have to click on the corresponding link below.",
"json": "as JSON",
"name": "Download Data",
"xml": "as XML"
"name": "Download Data"
},
"email": {
"change-successful": "Your e-mail address has been changed successfully.",

View File

@ -93,7 +93,6 @@
"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"
},

View File

@ -4,9 +4,13 @@
<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>
<ds-space margin="large" />
<ds-text>{{ $t('settings.download.description') }}</ds-text>
<ds-space margin="large" />
<base-card v-for="image in imageList" :key="image.key">
<a :href="image.url">{{ image.title }}</a>
<ds-space margin="xxx-small" />
</base-card>
</base-card>
</template>
@ -14,7 +18,7 @@
import { mapGetters } from 'vuex'
import { userDataQuery } from '~/graphql/User'
import BaseButton from '~/components/_new/generic/BaseButton/BaseButton.vue'
import { json2xml } from 'xml-js'
import isEmpty from 'lodash/isEmpty'
export default {
components: {
@ -32,14 +36,19 @@ export default {
jsonData() {
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',
}
imageList() {
if (isEmpty(this.userData)) return null
const userId = this.userData.user.id
if (isEmpty(userId)) return null
return this.userData.posts
.filter((post) => post.author.id === userId)
.map((post) => {
const obj = {}
obj.key = post.id
obj.url = post.image.url
obj.title = post.title
return obj
})
},
},
methods: {

View File

@ -17423,13 +17423,6 @@ 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"