Add custom web search result count

* fixed confusing credentials prompt

* fix(setup): return status from create_default_admin function

* fix(setup): initialize admin creation status in main function

* fix(setup): enhance admin creation feedback and status handling

* Enhance admin user login messages with conditional feedback based on creation status

* Refine admin user creation feedback messages for clarity and actionability and formatted code

* Add fallback error message for admin creation failure in setup script

* Add run script for Uvicorn with dotenv integration

* Refactor server runner to use argparse for host and port configuration

* Remove captured output print statement from server runner

* Fix server runner to ensure cross-platform compatibility and improve log handling

* Remove run.py script to match main repo

* feat: add custom option for search result count in settings

* fix: enforce minimum and maximum values for custom search result count
This commit is contained in:
Boody
2026-06-02 06:55:15 +03:00
committed by GitHub
parent e2ba068cbc
commit 97528be0f4
2 changed files with 46 additions and 8 deletions

View File

@@ -1602,12 +1602,16 @@
</div>
<div class="settings-row">
<label class="settings-label">Results</label>
<select id="set-searchResultCount" class="settings-select">
<option value="3">3</option>
<option value="5" selected>5</option>
<option value="10">10</option>
<option value="20">20</option>
</select>
<div style="display:flex;gap:8px;flex:1;">
<select id="set-searchResultCount" class="settings-select" style="flex:1;">
<option value="3">3</option>
<option value="5" selected>5</option>
<option value="10">10</option>
<option value="20">20</option>
<option value="custom">Custom</option>
</select>
<input id="set-searchResultCountCustom" type="number" class="settings-select" placeholder="Enter custom value" style="flex:1;display:none;min-width:120px;" min="1" max="100">
</div>
</div>
<div id="set-searchUrlRow" class="settings-row">
<label class="settings-label">URL</label>

View File

@@ -1075,6 +1075,7 @@ var _searchKeyFields = {
async function initSearchSettings() {
var provSel = el('set-searchProvider');
var countSel = el('set-searchResultCount');
var countCustomInput = el('set-searchResultCountCustom');
var urlInput = el('set-searchUrl');
var urlRow = el('set-searchUrlRow');
var keyInput = el('set-searchApiKey');
@@ -1106,15 +1107,37 @@ async function initSearchSettings() {
loadKeyForProvider(prov);
}
function updateCountDisplay() {
var val = _settings.search_result_count || 5;
var presets = ['3', '5', '10', '20'];
if (presets.includes(String(val))) {
countSel.value = String(val);
countCustomInput.style.display = 'none';
} else {
countSel.value = 'custom';
countCustomInput.value = Math.max(1, Math.min(100, val));
countCustomInput.style.display = 'block';
}
}
try {
var res = await fetch('/api/auth/settings', { credentials: 'same-origin' });
_settings = await res.json();
if (_settings.search_provider) provSel.value = _settings.search_provider;
if (_settings.search_result_count) countSel.value = String(_settings.search_result_count);
updateCountDisplay();
if (_settings.search_url) urlInput.value = _settings.search_url;
if (_settings.google_pse_cx) cxInput.value = _settings.google_pse_cx;
} catch (e) { console.warn('Failed to load search settings', e); }
countSel.addEventListener('change', function() {
if (this.value === 'custom') {
countCustomInput.style.display = 'block';
countCustomInput.focus();
} else {
countCustomInput.style.display = 'none';
}
});
updateVisibility();
async function refreshStatus() {
@@ -1142,9 +1165,20 @@ async function initSearchSettings() {
async function saveSearch() {
try {
var prov = provSel.value;
var resultCount;
if (countSel.value === 'custom') {
var customVal = parseInt(countCustomInput.value, 10);
if (isNaN(customVal) || customVal < 1 || customVal > 100) {
resultCount = _settings.search_result_count || 5;
} else {
resultCount = customVal;
}
} else {
resultCount = parseInt(countSel.value, 10);
}
var payload = {
search_provider: prov,
search_result_count: parseInt(countSel.value, 10),
search_result_count: resultCount,
search_url: urlInput.value.trim(),
google_pse_cx: cxInput.value.trim(),
};