Updated filtering to support or (||) for every filter box, added styling for focus event on column input placeholders

This commit is contained in:
rain
2023-06-19 19:37:53 -05:00
parent ef551766d1
commit 2aee897e8a
3 changed files with 25 additions and 6 deletions
+14
View File
@@ -111,6 +111,20 @@ input[type=text]{
color: var(--header-text);
}
/* Make em perty so that people can see what they are typing */
input[type=text]:focus::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
font-style: italic;
opacity: 0.3;
}
input[type=text]:focus:-ms-input-placeholder { /* Internet Explorer 10-11 */
font-style: italic;
opacity: 0.3;
}
input[type=text]:focus::-ms-input-placeholder { /* Microsoft Edge */
font-style: italic;
opacity: 0.3;
}
.result-count {
position: fixed;
right: 0;
+1 -1
View File
@@ -21,7 +21,7 @@
{% for target in targets %}
<tr>
<td class='{{target.os|lower}}'><img onerror="this.onerror=null;this.src='static/media/unsure.png';" title="{{target.os}}" alt="{{target.os}}" src='static/media/{{target.os|lower}}.png'></td>
<td class='{{target.os|lower}}'><img width="64px" height="64px" onerror="this.onerror=null;this.src='static/media/unsure.png';" title="{{target.os}}" alt="{{target.os}}" src='static/media/{{target.os|lower}}.png'></td>
<td>{{ target.hostname }}</td>
<td>{{ target.address }}</td>
<td>{{ target.ports[1:-1]|replace('|', ', ') }}</td>
+10 -5
View File
@@ -5,6 +5,12 @@ from sqlalchemy import func
from sqlalchemy import or_
from app import app, db
def targets_filter(targets, column, terms):
# Re-Usable Filtering For Columns, implicit AND with || operator support
for item in terms.replace(' ','').split(','):
targets = targets.filter(or_(*[column.like(item_or + '%') for item_or in item.split('||')]))
return targets
@app.route('/', methods=['GET'])
def get_home():
"""Render website's home page."""
@@ -25,22 +31,21 @@ def post_home():
os = request.form.get("os")
if os:
targets = targets.where(target.os == os)
targets = targets_filter(targets, target.os, os)
hostname = request.form.get("hostname")
if hostname:
targets = targets.filter(target.hostname.like('%'+hostname+'%'))
targets = targets_filter(targets, target.hostname, hostname)
address = request.form.get("address")
if address:
targets = targets.filter(target.address.like('%'+address+'%'))
targets = targets_filter(targets, target.address, address)
ports = request.form.get("ports")
if ports:
# I needed a non-default case to handle ports since they have a | separator in the DB
for port in ports.replace(' ','').split(','):
# Add additional indent to check for || case, I'm sorry for your eyes if you see this
targets = targets.filter(or_(*[target.ports.like('%|' + port_or + '|%') for port_or in port.split('||')]))
#targets = targets.filter(target.ports.like('%|'+port+'|%'))
return render_template('home.html', targets=targets.all(), os=os,hostname=hostname,address=address,ports=ports,clientId=clientId)