From d7c4b4a16bfbb848aa87836f8bdac04899be8462 Mon Sep 17 00:00:00 2001 From: Robson Sobral Date: Wed, 2 Sep 2020 18:58:01 -0300 Subject: [PATCH] Download log response --- source/scripts/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/source/scripts/index.js b/source/scripts/index.js index 9632f6cf..6244c84d 100644 --- a/source/scripts/index.js +++ b/source/scripts/index.js @@ -153,6 +153,15 @@ window.$vue = new Vue({ }).then((response) => { if (response.body.request_url) { window.location = response.body.request_url; + } else if (response.headers.get('content-type') + && response.headers.get('content-type').indexOf('application/octet-stream') !== -1 + ) { + const url = window.URL.createObjectURL(new Blob([response.body])); + const link = document.createElement('a'); + link.href = url; + link.setAttribute('download', ''); + document.body.appendChild(link); + link.click(); } else { if (response.body.metadata.error) { window.alert(response.body.metadata.error); // eslint-disable-line no-alert @@ -198,6 +207,8 @@ window.$vue = new Vue({ this.metadata.loading = false; } } + + this.metadata.loading = false; }, (error) => { console.log('error', error); // eslint-disable-line no-console this.cancelRequest(); @@ -288,6 +299,7 @@ window.$vue = new Vue({ if (this.metadata.query.verbose) { params.verbose = this.metadata.query.verbose; + params.responseType = 'blob'; } if (this.metadata.query.search_for === 'profile') {