diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2018-05-22 19:53:30 +0300 |
---|---|---|
committer | diosmosis <diosmosis@users.noreply.github.com> | 2018-05-22 19:53:30 +0300 |
commit | 8ecd0f1c9a116beaa4f646b692ade35913d8cd09 (patch) | |
tree | a9bb5f3880639836dd062f85ab46f8f12d0fec8e /plugins/PrivacyManager | |
parent | c806d33ff4d25a0658680c3627a8d95da1a3331a (diff) |
make sendContentAsDownload method reusable (#12952)
Diffstat (limited to 'plugins/PrivacyManager')
-rw-r--r-- | plugins/PrivacyManager/angularjs/manage-gdpr/managegdpr.controller.js | 38 |
1 files changed, 1 insertions, 37 deletions
diff --git a/plugins/PrivacyManager/angularjs/manage-gdpr/managegdpr.controller.js b/plugins/PrivacyManager/angularjs/manage-gdpr/managegdpr.controller.js index 2a717aa4d5..5f09ccd03a 100644 --- a/plugins/PrivacyManager/angularjs/manage-gdpr/managegdpr.controller.js +++ b/plugins/PrivacyManager/angularjs/manage-gdpr/managegdpr.controller.js @@ -68,42 +68,6 @@ }; this.exportDataSubject = function () { - function sendContentAsDownload(filename, content) { - var mimeType = 'text/plain'; - function downloadFile(content) - { - var node = document.createElement('a'); - node.style.display = 'none'; - if ('string' === typeof content) { - node.setAttribute('href', 'data:' + mimeType + ';charset=utf-8,' + encodeURIComponent(content)); - } else { - node.href = window.URL.createObjectURL(blob); - } - node.setAttribute('download', filename); - document.body.appendChild(node); - node.click(); - document.body.removeChild(node); - } - - var node; - if ('function' === typeof Blob) { - // browser supports blob - try { - var blob = new Blob([content], {type: mimeType}); - if (window.navigator.msSaveOrOpenBlob) { - window.navigator.msSaveBlob(blob, filename); - return; - } else { - downloadFile(blob); - return; - } - } catch (e) { - downloadFile(content); - } - } - downloadFile(content); - } - var visitsToDelete = this.getActivatedDataSubjects(); piwikApi.post({ module: 'API', @@ -112,7 +76,7 @@ filter_limit: -1, }, {visits: visitsToDelete}).then(function (visits) { showSuccessNotification('Visits were successfully exported'); - sendContentAsDownload('exported_data_subjects.json', JSON.stringify(visits)); + piwik.helper.sendContentAsDownload('exported_data_subjects.json', JSON.stringify(visits)); }); }; |