Skip to content

Commit

Permalink
Merge pull request #713 from botpress/fix-logs-archive-download
Browse files Browse the repository at this point in the history
fix: restore log archive loading using axios
  • Loading branch information
emirotin committed Jul 9, 2018
2 parents fb3c9d4 + d088fc8 commit 0534fac
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion packages/core/botpress/src/web/views/Logs/index.jsx
Expand Up @@ -92,6 +92,21 @@ class LoggerView extends Component {
return this.state.logs.filter(x => _.isString(x.message)).map(this.renderLine)
}

downloadArchive = () => {
axios({
url: this.state.archiveUrl,
method: 'GET',
responseType: 'blob'
}).then(response => {
const url = window.URL.createObjectURL(new Blob([response.data]))
const link = document.createElement('a')
link.href = url
link.setAttribute('download', 'logs.txt')
document.body.appendChild(link)
link.click()
})
}

render() {
const logs = this.renderLines()
const logsPanelClassName = classnames('panel', 'panel-default', styles['logs-panel'])
Expand All @@ -115,7 +130,7 @@ class LoggerView extends Component {
</Checkbox>
</form>
<div className="pull-right">
<Button href={this.state.archiveUrl}>Export logs archive</Button>
<Button onClick={this.downloadArchive}>Export logs archive</Button>
</div>
</Panel.Body>
</Panel>
Expand Down

0 comments on commit 0534fac

Please sign in to comment.