From 4a79fffa5b11c074d7d9f70ce4763422ee942c10 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Tue, 13 Oct 2020 17:36:53 +0200 Subject: [PATCH] Removed XML download. Added image download and description --- webapp/locales/de.json | 4 +-- webapp/locales/en.json | 4 +-- webapp/package.json | 1 - webapp/pages/settings/data-download.vue | 33 ++++++++++++++++--------- webapp/yarn.lock | 7 ------ 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/webapp/locales/de.json b/webapp/locales/de.json index ecba2d516..78d4bf365 100644 --- a/webapp/locales/de.json +++ b/webapp/locales/de.json @@ -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.", diff --git a/webapp/locales/en.json b/webapp/locales/en.json index aae5d3bec..bbb779d2d 100644 --- a/webapp/locales/en.json +++ b/webapp/locales/en.json @@ -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.", diff --git a/webapp/package.json b/webapp/package.json index 6ebfe8338..d2c7c9678 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -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" }, diff --git a/webapp/pages/settings/data-download.vue b/webapp/pages/settings/data-download.vue index ae130c822..1c6472bf3 100644 --- a/webapp/pages/settings/data-download.vue +++ b/webapp/pages/settings/data-download.vue @@ -4,9 +4,13 @@ {{ $t('settings.download.json') }} - - {{ $t('settings.download.xml') }} - + + {{ $t('settings.download.description') }} + + + {{ image.title }} + + @@ -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: { diff --git a/webapp/yarn.lock b/webapp/yarn.lock index 2763fd548..eba52d9cc 100644 --- a/webapp/yarn.lock +++ b/webapp/yarn.lock @@ -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"