From ace4faa81c4f723c608d10ba41a67755c496d492 Mon Sep 17 00:00:00 2001 From: "maximilian.lotz" Date: Fri, 27 Feb 2026 13:17:00 +0100 Subject: [PATCH 01/10] Create history obj in servershell --- .../js/servershell/autocomplete/history.js | 59 +++++++++++++++++++ .../static/js/servershell/history.js | 42 +++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 serveradmin/servershell/static/js/servershell/autocomplete/history.js create mode 100644 serveradmin/servershell/static/js/servershell/history.js diff --git a/serveradmin/servershell/static/js/servershell/autocomplete/history.js b/serveradmin/servershell/static/js/servershell/autocomplete/history.js new file mode 100644 index 00000000..09621196 --- /dev/null +++ b/serveradmin/servershell/static/js/servershell/autocomplete/history.js @@ -0,0 +1,59 @@ +/* + * Autocomplete History - Copyright (c) 2026 InnoGames GmbH + * + * This module ads auto complete while searching the query history + */ + +servershell.autocomplete_history_enabled = false; + +servershell.close_history_autocomplete = function () { + const autocomplete_search_input = $('#term'); + autocomplete_search_input.autocomplete('destroy'); + servershell.autocomplete_history_enabled = false; + servershell.enable_search_autocomplete(); + $('#history-toggle').removeClass('active'); +} + +servershell.open_history_autocomplete = function () { + const autocomplete_search_input = $('#term'); + autocomplete_search_input.autocomplete('destroy'); + autocomplete_search_input.autocomplete({ + source: function (request, response) { + const displayLimit = 20; + const search = request.term; + + const history = servershell.history.get() + const possibleChoices = history.filter((entry) => entry.search.toLowerCase().includes(search.toLowerCase())) + .map((entry) => entry.search); + response(possibleChoices.slice(0, Math.min(displayLimit, possibleChoices.length))); + }, + + select: function (_, ui) { + autocomplete_search_input.trigger('change', ui.item.value); + servershell.close_history_autocomplete() + } + }); + autocomplete_search_input.autocomplete('enable'); + autocomplete_search_input.autocomplete('option', 'autoFocus', $('#autoselect')[0].checked); + autocomplete_search_input.autocomplete('option', 'minLength', 0); + autocomplete_search_input.autocomplete('option', 'delay', 50); // Searching local storage is fast + autocomplete_search_input.autocomplete('search', ""); + autocomplete_search_input.focus(); + servershell.autocomplete_history_enabled = true; + $('#history-toggle').addClass('active'); +} + +$(document).ready(function () { + $(document).keydown(function (event) { + if (event.shiftKey && event.ctrlKey) { + if (event.key !== 'F') { + return; + } + if (servershell.autocomplete_history_enabled) { + servershell.close_history_autocomplete(); + return; + } + servershell.open_history_autocomplete(); + } + }); +}); \ No newline at end of file diff --git a/serveradmin/servershell/static/js/servershell/history.js b/serveradmin/servershell/static/js/servershell/history.js new file mode 100644 index 00000000..20022ab3 --- /dev/null +++ b/serveradmin/servershell/static/js/servershell/history.js @@ -0,0 +1,42 @@ +const storageKey = "servershell_history" + +servershell.history = { + /** + * @returns {[]} + */ + get: function () { + const history = localStorage.getItem(storageKey); + if (!history) { + return [] + } + + return JSON.parse(history); + }, + + storeEntry: function (entry) { + const history = servershell.history.get(); + + const matching = servershell.history.findMatchingEntry(entry) + if (matching !== -1) { + history.splice(matching, 1); + } + + // TODO: Dynamic max length + while (history.length >= 20) { + history.pop(); + } + + history.unshift(entry); + + localStorage.setItem(storageKey, JSON.stringify(history)) + }, + + clear: function () { + localStorage.setItem(storageKey, "[]"); + }, + + findMatchingEntry: function (entry) { + const history = servershell.history.get(); + return history.findIndex((i) => entry.search === i.search); + } +} \ No newline at end of file From 3a780a77ff9737da8452bd0918c24ebae39b8877 Mon Sep 17 00:00:00 2001 From: "maximilian.lotz" Date: Fri, 27 Feb 2026 16:12:30 +0100 Subject: [PATCH 02/10] Create history button --- .../servershell/static/css/servershell.css | 22 +++++++++++++++++++ .../templates/servershell/index.html | 11 +++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/serveradmin/servershell/static/css/servershell.css b/serveradmin/servershell/static/css/servershell.css index e3b2d984..293b7ce1 100644 --- a/serveradmin/servershell/static/css/servershell.css +++ b/serveradmin/servershell/static/css/servershell.css @@ -37,6 +37,28 @@ th:hover .attr-headericons { height: 29px; } +#history-toggle img { + width: 16px; + height: 16px; +} + +#history-toggle { + background-color: #fff; + background-clip: padding-box; + border: 1px solid #ced4da; +} + +#history-toggle { + background-color: #fff; + background-clip: padding-box; + border: 1px solid #ced4da; +} + +#history-toggle.active { + background: var(--background-primary); +} + + .input-controls > div:last-of-type { padding-left: 0; } diff --git a/serveradmin/servershell/templates/servershell/index.html b/serveradmin/servershell/templates/servershell/index.html index 2752c328..a87f76a2 100644 --- a/serveradmin/servershell/templates/servershell/index.html +++ b/serveradmin/servershell/templates/servershell/index.html @@ -30,7 +30,14 @@
{% csrf_token %} - +
+ +
+ +
+
@@ -193,9 +200,11 @@ + +