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!" "success": "Konto erfolgreich gelöscht!"
}, },
"download": { "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", "json": "als JSON",
"name": "Daten herunterladen", "name": "Daten herunterladen"
"xml": "als XML"
}, },
"email": { "email": {
"change-successful": "Deine E-Mail-Adresse wurde erfolgreich geändert.", "change-successful": "Deine E-Mail-Adresse wurde erfolgreich geändert.",

View File

@ -648,9 +648,9 @@
"success": "Account successfully deleted!" "success": "Account successfully deleted!"
}, },
"download": { "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", "json": "as JSON",
"name": "Download Data", "name": "Download Data"
"xml": "as XML"
}, },
"email": { "email": {
"change-successful": "Your e-mail address has been changed successfully.", "change-successful": "Your e-mail address has been changed successfully.",

View File

@ -93,7 +93,6 @@
"vue-scrollto": "^2.17.1", "vue-scrollto": "^2.17.1",
"vue-sweetalert-icons": "~4.2.0", "vue-sweetalert-icons": "~4.2.0",
"vuex-i18n": "~1.13.1", "vuex-i18n": "~1.13.1",
"xml-js": "^1.6.11",
"xregexp": "^4.3.0", "xregexp": "^4.3.0",
"zxcvbn": "^4.4.2" "zxcvbn": "^4.4.2"
}, },

View File

@ -4,9 +4,13 @@
<base-button @click="onClick(jsonData)" icon="download" secondary filled> <base-button @click="onClick(jsonData)" icon="download" secondary filled>
{{ $t('settings.download.json') }} {{ $t('settings.download.json') }}
</base-button> </base-button>
<base-button @click="onClick(xmlData)" icon="download" secondary filled> <ds-space margin="large" />
{{ $t('settings.download.xml') }} <ds-text>{{ $t('settings.download.description') }}</ds-text>
</base-button> <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> </base-card>
</template> </template>
@ -14,7 +18,7 @@
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { userDataQuery } from '~/graphql/User' import { userDataQuery } from '~/graphql/User'
import BaseButton from '~/components/_new/generic/BaseButton/BaseButton.vue' import BaseButton from '~/components/_new/generic/BaseButton/BaseButton.vue'
import { json2xml } from 'xml-js' import isEmpty from 'lodash/isEmpty'
export default { export default {
components: { components: {
@ -32,14 +36,19 @@ export default {
jsonData() { jsonData() {
return { data: JSON.stringify(this.userData, null, 2), type: 'json' } return { data: JSON.stringify(this.userData, null, 2), type: 'json' }
}, },
xmlData() { imageList() {
return { if (isEmpty(this.userData)) return null
data: json2xml( const userId = this.userData.user.id
{ userData: this.userData }, if (isEmpty(userId)) return null
{ compact: true, ignoreComment: true, spaces: 2 }, return this.userData.posts
), .filter((post) => post.author.id === userId)
type: 'xml', .map((post) => {
} const obj = {}
obj.key = post.id
obj.url = post.image.url
obj.title = post.title
return obj
})
}, },
}, },
methods: { 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" resolved "https://registry.yarnpkg.com/xdg-basedir/-/xdg-basedir-3.0.0.tgz#496b2cc109eca8dbacfe2dc72b603c17c5870ad4"
integrity sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ= 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: xml-name-validator@^3.0.0:
version "3.0.0" version "3.0.0"
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a"