refactor: minor improvements (#343)

refactor: minor improvements
This commit is contained in:
Liyas Thomas
2019-11-26 17:44:11 +05:30
committed by GitHub
5 changed files with 26 additions and 27 deletions

View File

@@ -45,8 +45,7 @@
folderIndex,
requestIndex: index
})
"
></request>
"/>
</li>
<li v-if="folder.requests.length === 0">
<label>Folder is empty</label>

View File

@@ -8,19 +8,19 @@ TODO:
<addCollection
v-bind:show="showModalAdd"
v-on:hide-modal="displayModalAdd(false)"
></addCollection>
/>
<editCollection
v-bind:show="showModalEdit"
v-bind:editingCollection="editingCollection"
v-bind:editingCollectionIndex="editingCollectionIndex"
v-on:hide-modal="displayModalEdit(false)"
></editCollection>
/>
<addFolder
v-bind:show="showModalAddFolder"
v-bind:collection="editingCollection"
v-bind:collectionIndex="editingCollectionIndex"
v-on:hide-modal="displayModalAddFolder(false)"
></addFolder>
/>
<editFolder
v-bind:show="showModalEditFolder"
v-bind:collection="editingCollection"
@@ -28,7 +28,7 @@ TODO:
v-bind:folder="editingFolder"
v-bind:folderIndex="editingFolderIndex"
v-on:hide-modal="displayModalEditFolder(false)"
></editFolder>
/>
<editRequest
v-bind:show="showModalEditRequest"
v-bind:collectionIndex="editingCollectionIndex"
@@ -36,11 +36,11 @@ TODO:
v-bind:request="editingRequest"
v-bind:requestIndex="editingRequestIndex"
v-on:hide-modal="displayModalEditRequest(false)"
></editRequest>
/>
<importExportCollections
v-bind:show="showModalImportExport"
v-on:hide-modal="displayModalImportExport(false)"
></importExportCollections>
/>
<div class="flex-wrap">
<div>

View File

@@ -59,7 +59,7 @@
@change="
$store.commit('setGQLHeaderKey', {
index,
value: $event.target.value
value: $event.target.value
})
"
autofocus
@@ -424,9 +424,9 @@ export default {
this.responseBodyMaxLines = (this.responseBodyMaxLines == Infinity) ? 16 : Infinity;
},
downloadResponse() {
var dataToWrite = JSON.stringify(this.schemaString, null, 2)
var file = new Blob([dataToWrite], { type: "application/json" });
var a = document.createElement("a"),
const dataToWrite = JSON.stringify(this.schemaString, null, 2)
const file = new Blob([dataToWrite], { type: "application/json" });
const a = document.createElement("a"),
url = URL.createObjectURL(file);
a.href = url;
a.download = (

View File

@@ -109,7 +109,7 @@
<div
class="blue"
label="Request Body"
v-if="method === 'POST' || method === 'PUT' || method === 'PATCH'"
v-if="['POST', 'PUT', 'PATCH'].includes(method)"
>
<ul>
<li>
@@ -248,7 +248,7 @@
<button
class="icon"
id="code"
v-on:click="isHidden = !isHidden"
@click="isHidden = !isHidden"
:disabled="!isValidURL"
v-tooltip.bottom="{
content: isHidden ? 'Show Code' : 'Hide Code'
@@ -1205,7 +1205,7 @@ export default {
},
requestCode() {
if (this.requestType === "JavaScript XHR") {
var requestString = [];
const requestString = [];
requestString.push("const xhr = new XMLHttpRequest()");
const user = this.auth === "Basic" ? "'" + this.httpUser + "'" : null;
const pswd =
@@ -1259,14 +1259,14 @@ export default {
}
return requestString.join("\n");
} else if (this.requestType == "Fetch") {
var requestString = [];
var headers = [];
const requestString = [];
let headers = [];
requestString.push(
'fetch("' + this.url + this.pathName + this.queryString + '", {\n'
);
requestString.push(' method: "' + this.method + '",\n');
if (this.auth === "Basic") {
var basic = this.httpUser + ":" + this.httpPassword;
const basic = this.httpUser + ":" + this.httpPassword;
headers.push(
' "Authorization": "Basic ' +
window.btoa(unescape(encodeURIComponent(basic))) +
@@ -1308,13 +1308,13 @@ export default {
requestString.push("})");
return requestString.join("");
} else if (this.requestType === "cURL") {
var requestString = [];
const requestString = [];
requestString.push("curl -X " + this.method + " \\\n");
requestString.push(
" '" + this.url + this.pathName + this.queryString + "' \\\n"
);
if (this.auth === "Basic") {
var basic = this.httpUser + ":" + this.httpPassword;
const basic = this.httpUser + ":" + this.httpPassword;
requestString.push(
" -H 'Authorization: Basic " +
window.btoa(unescape(encodeURIComponent(basic))) +
@@ -1672,7 +1672,7 @@ export default {
.then(() => {})
.catch(console.error);
} else {
var dummy = document.createElement("input");
const dummy = document.createElement("input");
document.body.appendChild(dummy);
dummy.value = window.location.href;
dummy.select();
@@ -1709,8 +1709,8 @@ export default {
this.$toast.success("Copied to clipboard", {
icon: "done"
});
var aux = document.createElement("textarea");
var copy =
const aux = document.createElement("textarea");
const copy =
this.responseType == "application/json"
? JSON.stringify(this.response.body)
: this.response.body;
@@ -1725,9 +1725,9 @@ export default {
);
},
downloadResponse() {
var dataToWrite = JSON.stringify(this.response.body, null, 2);
var file = new Blob([dataToWrite], { type: this.responseType });
var a = document.createElement("a"),
const dataToWrite = JSON.stringify(this.response.body, null, 2);
const file = new Blob([dataToWrite], { type: this.responseType });
const a = document.createElement("a"),
url = URL.createObjectURL(file);
a.href = url;
a.download = (

View File

@@ -434,7 +434,7 @@ export default {
},
updated: function() {
this.$nextTick(function() {
var divLog = document.getElementById("log");
const divLog = document.getElementById("log");
divLog.scrollBy(0, divLog.scrollHeight + 100);
});
}