Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

:sparkles: Added preRequestScript and request duration to history entry

liyasthomasaae182a9f888
diff --git a/components/history.vue b/components/history.vue
index 96e850ffc..283447aac 100644
--- a/components/history.vue
+++ b/components/history.vue
@@ -37,6 +37,11 @@
Path
</label>
</li>
+ <li @click="sort_by_duration()">
+ <label>
+ Duration
+ </label>
+ </li>
<li></li>
</ul>
<virtual-list
@@ -88,11 +93,17 @@
>{{entry.status}}</span>
</li>
<li>
- <input aria-label="URL" type="text" readonly :value="entry.url" />
+ <input aria-label="URL" type="text" readonly :value="entry.url" placeholder="No URL" />
</li>
<li>
<input aria-label="Path" type="text" readonly :value="entry.path" placeholder="No path" />
</li>
+ <li>
+ <input aria-label="Duration" type="text" readonly :value="entry.duration" placeholder="No duration" />
+ </li>
+ <li>
+ <input aria-label="Pre Request Script" type="text" readonly :value="entry.preRequestScript" placeholder="No pre request script" />
+ </li>
<div class="show-on-small-screen">
<li>
<button
@@ -327,6 +338,16 @@
});
this.history = byPath;
this.reverse_sort_path = !this.reverse_sort_path;
+ },
+ sort_by_duration() {
+ let byDuration = this.history.slice(0);
+ byDuration.sort((a, b) => {
+ if (this.reverse_sort_duration)
+ return a.duration == b.duration ? 0 : +(a.duration < b.duration) || -1;
+ else return a.duration == b.duration ? 0 : +(a.duration > b.duration) || -1;
+ });
+ this.history = byDuration;
+ this.reverse_sort_duration = !this.reverse_sort_duration;
}
}
};
diff --git a/pages/index.vue b/pages/index.vue
index 1411528b3..eac293148 100644
--- a/pages/index.vue
+++ b/pages/index.vue
@@ -1185,11 +1185,12 @@ export default {
behavior: "smooth"
});
},
- handleUseHistory({ label, method, url, path }) {
+ handleUseHistory({ label, method, url, path, preRequestScript }) {
this.label = label;
this.method = method;
this.url = url;
this.path = path;
+ this.preRequestScript = preRequestScript;
this.scrollInto("request");
},
getVariablesFromPreRequestScript() {
@@ -1348,7 +1349,9 @@ export default {
method: this.method,
url: this.url,
path: this.path,
- usesScripts: Boolean(this.preRequestScript)
+ usesScripts: Boolean(this.preRequestScript),
+ preRequestScript: this.preRequestScript,
+ duration
};
this.$refs.historyComponent.addEntry(entry);
})();