Updated filtering to support or (||) for every filter box, added styling for focus event on column input placeholders
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user