-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filtering now refreshes as you type. #52
Open
Aksiznarf-Uar
wants to merge
2
commits into
main
Choose a base branch
from
50-change-device-list-filter-to-filter-on-input
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const search_form = $("#search_form") | ||
const results_div = $('#results') | ||
const endpoint = '/devices/' | ||
const delay_by_in_ms = 700 | ||
let scheduled_function = false | ||
|
||
let ajax_call = function (endpoint, request_parameters) { | ||
$.getJSON(endpoint, request_parameters) | ||
.done(response => { | ||
// replace the HTML contents | ||
results_div.html(response['html']) | ||
}) | ||
} | ||
|
||
search_form.on('input', function () { | ||
|
||
const request_parameters = { | ||
search_string: $('#id_search_string').val(), | ||
device_role_prod: $('#id_device_role_prod').val(), | ||
authorization_group: $('#id_authorization_group').val() | ||
} | ||
|
||
// if scheduled_function is NOT false, cancel the execution of the function | ||
if (scheduled_function) { | ||
clearTimeout(scheduled_function) | ||
} | ||
|
||
// setTimeout returns the ID of the function to be executed | ||
scheduled_function = setTimeout(ajax_call, delay_by_in_ms, endpoint, request_parameters); | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,10 @@ | |
<link rel="icon" href="{% static 'icons/favicon.svg' %}" sizes="any" type="image/svg+xml"> | ||
|
||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script> | ||
|
||
|
||
<!-- JQuery --> | ||
<script src="https://code.jquery.com/jquery-3.7.1.js" integrity="sha256-eKhayi8LEQwp4NKxN+CfCh+3qOVUtJn3QNZ0TciWLP4=" crossorigin="anonymous"></script> | ||
|
||
|
||
{% block head %}{% endblock %} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
{% block content %} | ||
<div class="container"> | ||
<h1>Devices</h1> | ||
<form action="{% url 'devices' %}" method="get"> | ||
<form id="search_form" action="{% url 'devices' %}" method="get"> | ||
<div class="row"> | ||
{% for field in search_form %} | ||
<div class="col-md-4 "> | ||
|
@@ -15,68 +15,12 @@ <h1>Devices</h1> | |
</div> | ||
<button type="submit" class="btn btn-secondary btn-sm">Filter</button> | ||
</form> | ||
<table class="table table-striped"> | ||
<thead> | ||
<tr> | ||
<th scope="col">Name</th> | ||
<th scope="col">Status</th> | ||
<th scope="col">FQDN</th> | ||
<th scope="col">Device Role Prod</th> | ||
<th scope="col">MAC</th> | ||
<th scope="col" width="60"></th> | ||
</tr> | ||
</thead> | ||
|
||
{% for device in device_list %} | ||
<tr> | ||
<td> | ||
<a href="{% url 'device_detail' device.pk %}">{{ device.name }}</a> | ||
</td> | ||
<td> | ||
{% if device.appl_NAC_Active %} | ||
<span class="icon-desc" desc="Active Device"><img src="{% static 'icons/check-lg.svg' %}" alt="appl_NAC_Active_True" height="25" width="25" class="icon-zoom" /></span> | ||
{% else %} | ||
<span class="icon-desc" desc="Inactive Device"><img src="{% static 'icons/x-lg.svg' %}" alt="appl_NAC_Active_False" height="25" width="25" class="icon-zoom" /></span> | ||
{% endif %} | ||
{% if device.appl_NAC_Install %} | ||
<span class="icon-desc" desc="Install"><img src="{% static 'icons/wrench.svg' %}" alt="appl_NAC_Install" height="25" width="25" class="icon-zoom"/></span> | ||
{% endif %} | ||
</td> | ||
<td> | ||
{{ device.appl_NAC_FQDN }} | ||
</td> | ||
<td> | ||
{{ device.appl_NAC_DeviceRoleProd }} | ||
</td> | ||
<td> | ||
{% for mac in device.get_appl_NAC_macAddressAIR %} | ||
<b> | ||
{% if mac != None %} | ||
<span class="icon-desc" desc="macAddressAIR"><img src="{% static 'icons/wifi.svg' %}" alt="appl_NAC_macAddressAIR" height="14" width="14" class="icon-zoom"/></span> | ||
<b> {{mac}}</b> <br /> | ||
{% endif %} | ||
</b> | ||
{% endfor %} | ||
{% for mac in device.get_appl_NAC_macAddressCAB %} | ||
<b> | ||
{% if mac != None %} | ||
<span class="icon-desc" desc="macAddressCAB"><img src="{% static 'icons/ethernet.svg' %}" alt="appl_NAC_macAddressCAB" height="14" width="14" class="icon-zoom"/></span> | ||
<b> {{mac}}</b> <br /> | ||
{% endif %} | ||
</b> | ||
{% endfor %} | ||
</td> | ||
<td> | ||
<a href="{% url 'device_edit' device.pk %}"> | ||
<span class="icon-desc" desc="edit"><img src="{% static 'icons/pencil-square.svg' %}" alt="edit" height="16" width="16" class="icon-zoom"/></span> | ||
|
||
</a> | ||
<a href="{% url 'device_delete' device.pk %}"> | ||
<span class="icon-desc" desc="delete"><img src="{% static 'icons/trash.svg' %}" alt="delete" height="16" width="16" class="icon-zoom"/></span> | ||
</a> | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</table> | ||
<div id="results"> | ||
{% include "devices_results.html" %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. device_results.html seems to be missing in the git repository. |
||
</div> | ||
</div> | ||
{% endblock content %} | ||
|
||
<script type="text/javascript" src="{% static 'device_filtering.js' %}"></script> | ||
|
||
{% endblock content %} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
devices_results.html seems to be missing in the git repository. It would be good to have a test, to check if this site can be rendered ;)