✨ Added History support
This commit is contained in:
27
index.html
27
index.html
@@ -104,6 +104,33 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<fieldset class="history hidden">
|
||||||
|
<legend v-on:click="collapse">History ⭥</legend>
|
||||||
|
<div class="collapsible">
|
||||||
|
<ul v-for="entry in history">
|
||||||
|
<li>
|
||||||
|
<label for="use">{{entry.time}}</label>
|
||||||
|
<button name="use" @click="useHistory(entry)">Use</button>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<label for="name">Method</label>
|
||||||
|
<input name="name" type="text" readonly :value="entry.method">
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<label for="name">URL</label>
|
||||||
|
<input name="name" type="text" readonly :value="entry.url">
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<label for="name">Path</label>
|
||||||
|
<input name="name" type="text" readonly :value="entry.path">
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<label for="delete"> </label>
|
||||||
|
<button name="delete" @click="deleteHistory(entry)">Delete</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
<fieldset class="reqbody" v-if="method === 'POST' || method === 'PUT'">
|
<fieldset class="reqbody" v-if="method === 'POST' || method === 'PUT'">
|
||||||
<legend v-on:click="collapse">Request Body ⭥</legend>
|
<legend v-on:click="collapse">Request Body ⭥</legend>
|
||||||
<div class="collapsible">
|
<div class="collapsible">
|
||||||
|
|||||||
23
script.js
23
script.js
@@ -25,7 +25,8 @@ const app = new Vue({
|
|||||||
status: '',
|
status: '',
|
||||||
headers: '',
|
headers: '',
|
||||||
body: ''
|
body: ''
|
||||||
}
|
},
|
||||||
|
history: []
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
rawRequestBody() {
|
rawRequestBody() {
|
||||||
@@ -65,6 +66,18 @@ const app = new Vue({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
deleteHistory(entry) {
|
||||||
|
this.history.splice(this.history.indexOf(entry), 1)
|
||||||
|
},
|
||||||
|
useHistory({
|
||||||
|
method,
|
||||||
|
url,
|
||||||
|
path
|
||||||
|
}) {
|
||||||
|
this.method = method
|
||||||
|
this.url = url
|
||||||
|
this.path = path
|
||||||
|
},
|
||||||
collapse({
|
collapse({
|
||||||
target
|
target
|
||||||
}) {
|
}) {
|
||||||
@@ -72,6 +85,14 @@ const app = new Vue({
|
|||||||
document.getElementsByClassName(el)[0].classList.toggle('hidden')
|
document.getElementsByClassName(el)[0].classList.toggle('hidden')
|
||||||
},
|
},
|
||||||
sendRequest() {
|
sendRequest() {
|
||||||
|
const d = new Date()
|
||||||
|
const n = d.toLocaleTimeString()
|
||||||
|
this.history.push({
|
||||||
|
time: n,
|
||||||
|
method: this.method,
|
||||||
|
url: this.url,
|
||||||
|
path: this.path
|
||||||
|
})
|
||||||
this.$refs.response.scrollIntoView({
|
this.$refs.response.scrollIntoView({
|
||||||
behavior: 'smooth'
|
behavior: 'smooth'
|
||||||
})
|
})
|
||||||
|
|||||||
10
style.css
10
style.css
@@ -88,7 +88,7 @@ fieldset {
|
|||||||
}
|
}
|
||||||
|
|
||||||
legend {
|
legend {
|
||||||
color: #57b5f9;
|
color: var(--fg-color);
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
@@ -105,6 +105,14 @@ fieldset.request legend {
|
|||||||
color: #57b5f9;
|
color: #57b5f9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fieldset.history {
|
||||||
|
border-color: #9B9B9B;
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldset.history legend {
|
||||||
|
color: #9B9B9B;
|
||||||
|
}
|
||||||
|
|
||||||
fieldset.authentication {
|
fieldset.authentication {
|
||||||
border-color: #B8E986;
|
border-color: #B8E986;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user