From 39d958de86d930fd9fc067b9379b4d3dc3c581d9 Mon Sep 17 00:00:00 2001 From: lana-k Date: Tue, 13 Oct 2020 21:46:15 +0200 Subject: [PATCH] add export to file feature --- src/views/MyQueries.vue | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/views/MyQueries.vue b/src/views/MyQueries.vue index b0d9af1..ecee695 100644 --- a/src/views/MyQueries.vue +++ b/src/views/MyQueries.vue @@ -38,7 +38,7 @@
- +
@@ -92,6 +92,7 @@ + @@ -200,6 +201,20 @@ export default { findTabIndex (id) { return this.$store.state.tabs.findIndex(tab => tab.id === id) }, + exportQuery (index) { + this.currentQueryIndex = index + const downloader = this.$refs.downloader + const currentQuery = JSON.parse(JSON.stringify(this.queries[this.currentQueryIndex])) + delete currentQuery.id + delete currentQuery.createdAt + const json = JSON.stringify(currentQuery) + const blob = new Blob([json], { type: 'octet/stream' }) + const url = window.URL.createObjectURL(blob) + downloader.href = url + downloader.download = `${currentQuery.name}.json` + downloader.click() + window.URL.revokeObjectURL(url) + }, saveQueriesInLocalStorage () { localStorage.setItem('myQueries', JSON.stringify(this.queries)) } @@ -277,4 +292,7 @@ tbody tr:hover .icons-container { .dialog input { width: 100%; } +a { + display: none; +}