Renamed downloadResponse to proper downloadSchema

This commit is contained in:
Andrew Bastin
2020-06-02 23:31:08 -04:00
parent 1f9222ad04
commit 8dc662d27e

View File

@@ -118,8 +118,8 @@
</button> </button>
<button <button
class="icon" class="icon"
@click="downloadResponse" @click="downloadSchema"
ref="downloadResponse" ref="downloadSchema"
v-tooltip="$t('download_file')" v-tooltip="$t('download_file')"
> >
<i class="material-icons">get_app</i> <i class="material-icons">get_app</i>
@@ -666,7 +666,7 @@ export default {
this.expandResponse = !this.expandResponse this.expandResponse = !this.expandResponse
this.responseBodyMaxLines = this.responseBodyMaxLines == Infinity ? 16 : Infinity this.responseBodyMaxLines = this.responseBodyMaxLines == Infinity ? 16 : Infinity
}, },
downloadResponse() { downloadSchema() {
const dataToWrite = JSON.stringify(this.schema, null, 2) const dataToWrite = JSON.stringify(this.schema, null, 2)
const file = new Blob([dataToWrite], { type: "application/json" }) const file = new Blob([dataToWrite], { type: "application/json" })
const a = document.createElement("a") const a = document.createElement("a")
@@ -675,14 +675,14 @@ export default {
a.download = `${this.url} on ${Date()}.graphql`.replace(/\./g, "[dot]") a.download = `${this.url} on ${Date()}.graphql`.replace(/\./g, "[dot]")
document.body.appendChild(a) document.body.appendChild(a)
a.click() a.click()
this.$refs.downloadResponse.innerHTML = this.doneButton this.$refs.downloadSchema.innerHTML = this.doneButton
this.$toast.success(this.$t("download_started"), { this.$toast.success(this.$t("download_started"), {
icon: "done", icon: "done",
}) })
setTimeout(() => { setTimeout(() => {
document.body.removeChild(a) document.body.removeChild(a)
window.URL.revokeObjectURL(url) window.URL.revokeObjectURL(url)
this.$refs.downloadResponse.innerHTML = this.downloadButton this.$refs.downloadSchema.innerHTML = this.downloadButton
}, 1000) }, 1000)
}, },
addRequestHeader(index) { addRequestHeader(index) {