diff --git a/spinner/lib/src/main/assets/query.hbs b/spinner/lib/src/main/assets/query.hbs
index 1d9d104bd9..75eb95e5e7 100644
--- a/spinner/lib/src/main/assets/query.hbs
+++ b/spinner/lib/src/main/assets/query.hbs
@@ -8,13 +8,17 @@
+
+ Query History
+
+
Data
{{#if queryResult}}
@@ -57,7 +61,47 @@
}
}
+ function onQuerySubmitted() {
+ const query = document.querySelector('.query-input').value;
+
+ let history = getQueryHistory();
+ history.unshift(query);
+ history = history.slice(0, 10);
+
+ localStorage.setItem('query-history', JSON.stringify(history));
+ }
+
+ function renderQueryHistory() {
+ const container = document.getElementById('history-container');
+
+ let history = getQueryHistory();
+
+ if (history.length > 0) {
+ for (let item of history) {
+ container.innerHTML += `
+
+ |
+ ${item} |
+
+ `
+ }
+ } else {
+ container.innerHTML = 'None'
+ }
+ }
+
+ function onHistoryItemClicked(item) {
+ document.querySelector('.query-input').value = item;
+ }
+
+ function getQueryHistory() {
+ const historyRaw = localStorage.getItem('query-history') || "[]";
+ return JSON.parse(historyRaw);
+ }
+
document.querySelector('.query-input').addEventListener("keypress", submitOnEnter);
+ renderQueryHistory();
+