Added ability to copy GQL response

This commit is contained in:
Andrew Bastin
2019-11-26 16:55:43 -05:00
parent 9cbd6ea7b7
commit d2115ab004

View File

@@ -178,7 +178,19 @@
></textarea>
</pw-section>
<pw-section class="purple" label="Response" ref="response">
<label for="responseField"></label>
<div class="flex-wrap">
<label for="responseField">Response</label>
<div>
<button
class="icon"
@click="copyResponse"
ref="copyResponseButton"
v-tooltip="'Copy Response'"
>
<i class="material-icons">file_copy</i>
</button>
</div>
</div>
<Editor
:value="responseString"
:lang="'json'"
@@ -369,6 +381,22 @@ export default {
1000
);
},
copyResponse() {
this.$refs.copyResponseButton.innerHTML = this.doneButton;
const aux = document.createElement("textarea");
aux.innerText = this.responseString;
document.body.appendChild(aux);
aux.select();
document.execCommand("copy");
document.body.removeChild(aux);
this.$toast.success("Copied to clipboard", {
icon: "done"
});
setTimeout(
() => (this.$refs.copyResponseButton.innerHTML = this.copyButton),
1000
);
},
async runQuery() {
const startTime = Date.now();