-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8741 from owncloud/gdpr-export
Implement GDPR export for users
- Loading branch information
Showing
15 changed files
with
836 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Enhancement: GDPR export | ||
|
||
Users can now request a GDPR export on their account page. Note that this is only supported when running oCIS as backend. | ||
|
||
https://github.com/owncloud/web/issues/8738 | ||
https://github.com/owncloud/web/pull/8741 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
6.3.0-SNAPSHOT | ||
6.5.0-SNAPSHOT |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
packages/web-runtime/src/components/Account/GdprExport.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
<template> | ||
<span v-if="loading"> | ||
<oc-spinner /> | ||
</span> | ||
<span v-else-if="exportInProgress" class="oc-flex oc-flex-middle" data-testid="export-in-process"> | ||
<oc-icon name="time" fill-type="line" size="small" class="oc-mr-s" /> | ||
<span v-text="$gettext('Export is being processed. This can take up to 24 hours.')" /> | ||
</span> | ||
<div v-else> | ||
<oc-button | ||
appearance="raw" | ||
variation="primary" | ||
data-testid="request-export-btn" | ||
@click="requestExport" | ||
> | ||
<span v-text="$gettext('Request new export')" /> | ||
</oc-button> | ||
<div v-if="exportFile" class="oc-flex oc-flex-middle"> | ||
<oc-button | ||
appearance="raw" | ||
variation="primary" | ||
data-testid="download-export-btn" | ||
@click="downloadExport" | ||
> | ||
<oc-icon name="download" fill-type="line" size="small" /> | ||
<span v-text="$gettext('Download export')" /> | ||
</oc-button> | ||
<span class="oc-ml-s" v-text="`(${exportDate})`" /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { computed, defineComponent, onMounted, onUnmounted, ref, unref } from 'vue' | ||
import { useTask } from 'vue-concurrency' | ||
import { useGettext } from 'vue3-gettext' | ||
import { Resource } from 'web-client' | ||
import { useClientService, useStore } from 'web-pkg/src/composables' | ||
import { useDownloadFile } from 'web-pkg/src/composables/download' | ||
import { formatDateFromJSDate } from 'web-pkg' | ||
import { isPersonalSpaceResource } from 'web-client/src/helpers' | ||
const GDPR_EXPORT_FILE_NAME = '.personal_data_export.json' | ||
const POLLING_INTERVAL = 30000 | ||
export default defineComponent({ | ||
name: 'GdprExport', | ||
setup() { | ||
const store = useStore() | ||
const { $gettext, current: currentLanguage } = useGettext() | ||
const { webdav, graphAuthenticated } = useClientService() | ||
const { downloadFile } = useDownloadFile() | ||
const loading = ref(true) | ||
const checkInterval = ref() | ||
const exportFile = ref<Resource>() | ||
const exportInProgress = ref(false) | ||
const personalSpace = computed(() => { | ||
return store.getters['runtime/spaces/spaces'].find((s) => isPersonalSpaceResource(s)) | ||
}) | ||
const loadExportTask = useTask(function* () { | ||
try { | ||
const resource = yield webdav.getFileInfo(unref(personalSpace), { | ||
path: `/${GDPR_EXPORT_FILE_NAME}` | ||
}) | ||
if (resource.processing) { | ||
exportInProgress.value = true | ||
if (!unref(checkInterval)) { | ||
checkInterval.value = setInterval(() => { | ||
loadExportTask.perform() | ||
}, POLLING_INTERVAL) | ||
} | ||
return | ||
} | ||
exportFile.value = resource | ||
exportInProgress.value = false | ||
if (unref(checkInterval)) { | ||
clearInterval(unref(checkInterval)) | ||
} | ||
} catch (e) { | ||
if (e.statusCode !== 404) { | ||
// resource seems to exist, but something else went wrong | ||
console.error(e) | ||
} | ||
} finally { | ||
loading.value = false | ||
} | ||
}).restartable() | ||
const requestExport = async () => { | ||
try { | ||
await graphAuthenticated.users.exportPersonalData(store.getters.user.uuid, { | ||
storageLocation: `/${GDPR_EXPORT_FILE_NAME}` | ||
}) | ||
await loadExportTask.perform() | ||
return store.dispatch('showMessage', { | ||
title: $gettext('GDPR export has been requested') | ||
}) | ||
} catch (e) { | ||
return store.dispatch('showMessage', { | ||
title: $gettext('GDPR export could not be requested. Please contact an administrator.'), | ||
status: 'danger' | ||
}) | ||
} | ||
} | ||
const downloadExport = () => { | ||
return downloadFile(unref(exportFile)) | ||
} | ||
const exportDate = computed(() => { | ||
return formatDateFromJSDate(new Date(unref(exportFile).mdate), currentLanguage) | ||
}) | ||
onMounted(() => { | ||
loadExportTask.perform() | ||
}) | ||
onUnmounted(() => { | ||
if (unref(checkInterval)) { | ||
clearInterval(unref(checkInterval)) | ||
} | ||
}) | ||
return { | ||
loading, | ||
loadExportTask, | ||
exportFile, | ||
exportInProgress, | ||
requestExport, | ||
downloadExport, | ||
exportDate | ||
} | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.