Update public source
This commit is contained in:
+163
-41
@@ -27,14 +27,21 @@ MAP_STYLE_URL = (
|
||||
|
||||
def normalize_criteria(
|
||||
vendor=None,
|
||||
essid=None,
|
||||
bssid=None,
|
||||
):
|
||||
criteria = {}
|
||||
|
||||
if vendor is not None:
|
||||
vendor = str(vendor).strip()
|
||||
for key, value in (
|
||||
("vendor", vendor),
|
||||
("essid", essid),
|
||||
("bssid", bssid),
|
||||
):
|
||||
if value is not None:
|
||||
value = str(value).strip()
|
||||
|
||||
if vendor:
|
||||
criteria["vendor"] = vendor
|
||||
if value:
|
||||
criteria[key] = value
|
||||
|
||||
return criteria
|
||||
|
||||
@@ -103,6 +110,56 @@ def build_where_clause(criteria):
|
||||
vendor
|
||||
)
|
||||
|
||||
essid = criteria.get("essid")
|
||||
|
||||
if essid:
|
||||
conditions.append(
|
||||
"""
|
||||
LOWER(
|
||||
COALESCE(ap.essid, '')
|
||||
) LIKE '%' || LOWER(?) || '%'
|
||||
"""
|
||||
)
|
||||
|
||||
parameters.append(
|
||||
essid
|
||||
)
|
||||
|
||||
bssid = criteria.get("bssid")
|
||||
|
||||
if bssid:
|
||||
conditions.append(
|
||||
"""
|
||||
LOWER(
|
||||
REPLACE(
|
||||
REPLACE(
|
||||
COALESCE(ap.bssid, ''),
|
||||
':',
|
||||
''
|
||||
),
|
||||
'-',
|
||||
''
|
||||
)
|
||||
) LIKE '%' ||
|
||||
LOWER(
|
||||
REPLACE(
|
||||
REPLACE(
|
||||
?,
|
||||
':',
|
||||
''
|
||||
),
|
||||
'-',
|
||||
''
|
||||
)
|
||||
) ||
|
||||
'%'
|
||||
"""
|
||||
)
|
||||
|
||||
parameters.append(
|
||||
bssid
|
||||
)
|
||||
|
||||
if not conditions:
|
||||
raise ValueError(
|
||||
"At least one search criterion is required."
|
||||
@@ -1138,7 +1195,7 @@ def render_search_page(
|
||||
<section class="card search-card">
|
||||
|
||||
<h2>
|
||||
Search by Vendor
|
||||
Search Access Points
|
||||
</h2>
|
||||
|
||||
<form
|
||||
@@ -1146,24 +1203,72 @@ def render_search_page(
|
||||
class="search-form"
|
||||
>
|
||||
|
||||
<label
|
||||
for="search-vendor"
|
||||
class="search-label"
|
||||
>
|
||||
Vendor
|
||||
</label>
|
||||
<div class="search-fields">
|
||||
|
||||
<div class="search-field">
|
||||
|
||||
<label
|
||||
for="search-vendor"
|
||||
class="search-label"
|
||||
>
|
||||
Vendor
|
||||
</label>
|
||||
|
||||
<input
|
||||
id="search-vendor"
|
||||
name="vendor"
|
||||
type="text"
|
||||
class="search-input"
|
||||
autocomplete="off"
|
||||
placeholder="e.g. Intel Corporation"
|
||||
>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="search-field">
|
||||
|
||||
<label
|
||||
for="search-essid"
|
||||
class="search-label"
|
||||
>
|
||||
ESSID
|
||||
</label>
|
||||
|
||||
<input
|
||||
id="search-essid"
|
||||
name="essid"
|
||||
type="text"
|
||||
class="search-input"
|
||||
autocomplete="off"
|
||||
placeholder="e.g. MyWiFi"
|
||||
>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="search-field">
|
||||
|
||||
<label
|
||||
for="search-bssid"
|
||||
class="search-label"
|
||||
>
|
||||
BSSID
|
||||
</label>
|
||||
|
||||
<input
|
||||
id="search-bssid"
|
||||
name="bssid"
|
||||
type="text"
|
||||
class="search-input"
|
||||
autocomplete="off"
|
||||
placeholder="e.g. 00:11:22:33:44:55"
|
||||
>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="search-input-row">
|
||||
|
||||
<input
|
||||
id="search-vendor"
|
||||
name="vendor"
|
||||
type="text"
|
||||
class="search-input"
|
||||
autocomplete="off"
|
||||
placeholder="e.g. Intel Corporation"
|
||||
>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
class="button"
|
||||
@@ -1192,19 +1297,6 @@ def render_search_page(
|
||||
|
||||
</section>
|
||||
|
||||
<section class="card search-card search-future">
|
||||
|
||||
<h2>
|
||||
Search by Access Point
|
||||
</h2>
|
||||
|
||||
<div class="search-future-content">
|
||||
Reserved for future search criteria:
|
||||
ESSID, BSSID and other access point attributes.
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
<section
|
||||
id="search-results"
|
||||
class="card search-card search-results"
|
||||
@@ -1336,6 +1428,14 @@ def render_search_page(
|
||||
"search-vendor"
|
||||
);
|
||||
|
||||
const essidInput = document.getElementById(
|
||||
"search-essid"
|
||||
);
|
||||
|
||||
const bssidInput = document.getElementById(
|
||||
"search-bssid"
|
||||
);
|
||||
|
||||
const results = document.getElementById(
|
||||
"search-results"
|
||||
);
|
||||
@@ -1890,13 +1990,22 @@ def render_search_page(
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
const vendor =
|
||||
vendorInput.value.trim();
|
||||
const criteria = {
|
||||
vendor: vendorInput.value.trim(),
|
||||
essid: essidInput.value.trim(),
|
||||
bssid: bssidInput.value.trim()
|
||||
};
|
||||
|
||||
if (!vendor) {
|
||||
const activeCriteria = Object.entries(
|
||||
criteria
|
||||
).filter(
|
||||
([key, value]) => value
|
||||
);
|
||||
|
||||
if (!activeCriteria.length) {
|
||||
|
||||
setStatus(
|
||||
"Enter a vendor name."
|
||||
"Enter at least one search criterion."
|
||||
);
|
||||
|
||||
query.textContent = "";
|
||||
@@ -1908,6 +2017,8 @@ def render_search_page(
|
||||
|
||||
exportButton.disabled = true;
|
||||
|
||||
searchParams = null;
|
||||
|
||||
if (map) {
|
||||
map.remove();
|
||||
map = null;
|
||||
@@ -1923,11 +2034,22 @@ def render_search_page(
|
||||
searchParams =
|
||||
new URLSearchParams();
|
||||
|
||||
searchParams.set(
|
||||
"vendor",
|
||||
vendor
|
||||
activeCriteria.forEach(
|
||||
([key, value]) => {
|
||||
searchParams.set(
|
||||
key,
|
||||
value
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
const queryDescription = activeCriteria
|
||||
.map(
|
||||
([key, value]) =>
|
||||
key.toUpperCase() + ": " + value
|
||||
)
|
||||
.join(" | ");
|
||||
|
||||
results.hidden = false;
|
||||
|
||||
setStatus(
|
||||
@@ -1960,7 +2082,7 @@ def render_search_page(
|
||||
|
||||
query.textContent =
|
||||
"Query: " +
|
||||
vendor;
|
||||
queryDescription;
|
||||
|
||||
setStatus(
|
||||
"Matched "
|
||||
|
||||
Reference in New Issue
Block a user