Skip to content

Commit

Permalink
Merge branch 'master' into settings
Browse files Browse the repository at this point in the history
  • Loading branch information
emxsys committed Aug 20, 2020
2 parents 50e0951 + 84fcf11 commit 5902af5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
26 changes: 24 additions & 2 deletions src/userinterface/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,18 @@


<form class="form-inline my-2 my-lg-0" action="/calls" method="get">
<input class="form-control mr-sm-2" type="search" name="search" placeholder="Phone number" aria-label="Search">
<button class="btn btn-success my-2 my-sm-0" name="submit" type="submit">Search</button>
<input class="form-control mr-sm-2" type="search" name="search" id="input-search" placeholder="Phone number" aria-label="Search">
<div class="btn-group">
<button type="submit" class="btn btn-success my-2 my-sm-0" id="btn-search" name="submit" value="phone">Search</button>
<button type="button" class="btn btn-success my-2 my-sm-0 dropdown-toggle dropdown-toggle-split" data-toggle="dropdown">
<span class="caret"></span>
</button>
<div class="dropdown-menu">
<div class="dropdown-header">SEARCH TYPE</div>
<a class="dropdown-item" id="menu-phone" href="#">Phone Search</a>
<a class="dropdown-item" id="menu-name" href="#">Name Search</a>
</div>
</div>
</form>
<ul class="navbar-nav mr-2">
<li class="nav-item" id="settings">
Expand Down Expand Up @@ -98,6 +108,18 @@
{% block js %}{% endblock %}

<script>
// Set the search type
$('#menu-name').on('click', function() {
$('#btn-search').val('name')
$('#input-search').attr('placeholder',"Enter Text")
})
$('#menu-phone').on('click', function() {
$('#btn-search').val('phone')
$('#input-search').attr('placeholder',"Phone Number")
})



// Highlight the nav-item in the navbar with the matching "active_nav_item" id
$(document).ready( function () {
{% if active_nav_item %}
Expand Down
14 changes: 9 additions & 5 deletions src/userinterface/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,16 +271,20 @@ def calls():
# Get GET request args, if available
number = request.args.get('number')
search_text = request.args.get('search')
search_type = request.args.get('submit')

# Get search criteria, if applicable
search_criteria = ""
if search_text:
num_list = re.findall('[0-9]+', search_text)
number = "".join(num_list) # override GET arg if we're searching
search_criteria = "WHERE Number='{}'".format(number)
if search_type == "phone":
num_list = re.findall('[0-9]+', search_text)
number = "".join(num_list) # override GET arg if we're searching
search_criteria = "WHERE Number='{}'".format(number)
else:
search_criteria = "WHERE Caller LIKE '%{}%'".format(search_text)

# Get values used for pagination of the call log
sql = "SELECT COUNT(*) FROM CallLog {}".format(search_criteria)
sql = "SELECT COUNT(*), Number, Name Caller FROM CallLog {}".format(search_criteria)
g.cur.execute(sql)
total = g.cur.fetchone()[0]
page, per_page, offset = get_page_args(
Expand All @@ -294,7 +298,7 @@ def calls():
WHEN b.PhoneNo is not null then b.Name
WHEN c.PhoneNo is not null then c.Name
ELSE a.Name
END Name,
END Caller,
a.Number Number,
a.Date,
a.Time,
Expand Down

0 comments on commit 5902af5

Please sign in to comment.