1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-11-01 03:54:15 +00:00

rearrange search functionality

This commit is contained in:
catborise 2021-06-10 15:17:53 +03:00 committed by catborise
parent a47d006771
commit d7c0f9445d
10 changed files with 31 additions and 80 deletions

View file

@ -9,9 +9,7 @@
<a href="{% url 'admin:group_create' %}" class="btn btn-success btn-header float-right"> <a href="{% url 'admin:group_create' %}" class="btn btn-success btn-header float-right">
{% icon 'plus' %} {% icon 'plus' %}
</a> </a>
<div class="float-right search"> {% include 'search_block.html' %}
<input id="filter" class="form-control" type="text" placeholder="{% trans "Search" %}">
</div>
<h1 class="page-header">{% trans "Groups" %}</h1> <h1 class="page-header">{% trans "Groups" %}</h1>
</div> </div>
</div> </div>

View file

@ -12,9 +12,7 @@
<a href="{% url 'admin:user_create' %}" class="btn btn-success btn-header float-right"> <a href="{% url 'admin:user_create' %}" class="btn btn-success btn-header float-right">
{% icon 'plus' %} {% icon 'plus' %}
</a> </a>
<div class="float-right search"> {% include 'search_block.html' %}
<input id="filter" class="form-control" type="text" placeholder="{% trans "Search" %}">
</div>
{% endblock page_heading_extra %} {% endblock page_heading_extra %}
{% block content %} {% block content %}

View file

@ -14,9 +14,7 @@
{% icon 'plus' %} {% icon 'plus' %}
</a> </a>
{% if instances %} {% if instances %}
<div class="float-right search"> {% include 'search_block.html' %}
<input id="filter" class="form-control" type="text" placeholder="{% trans 'Search' %}">
</div>
{% endif %} {% endif %}
{% endblock page_heading_extra %} {% endblock page_heading_extra %}

View file

@ -22,9 +22,9 @@
</div> </div>
{% else %} {% else %}
<div class="col-lg-12"> <div class="col-lg-12">
<table class="table table-striped table-hover"> <table class="table table-striped table-hover sortable-theme-bootstrap" data-sortable>
<thead> <thead>
<tr class="d-flex"> <tr>
<th span="col" class="col-sm-3">{% trans "Name" %}</th> <th span="col" class="col-sm-3">{% trans "Name" %}</th>
<th span="col" class="col-sm-2">{% trans "Status" %}</th> <th span="col" class="col-sm-2">{% trans "Status" %}</th>
<th span="col" class="col-sm-5">{% trans "Details" %}</th> <th span="col" class="col-sm-5">{% trans "Details" %}</th>
@ -33,7 +33,7 @@
</thead> </thead>
<tbody class="searchable"> <tbody class="searchable">
{% for compute in computes %} {% for compute in computes %}
<tr class="d-flex"> <tr>
<td class="col-sm-3"> <td class="col-sm-3">
{{ compute.name }} {{ compute.name }}
</td> </td>
@ -64,5 +64,6 @@
{% endblock content %} {% endblock content %}
{% block script %} {% block script %}
<script src="{% static "js/filter-table.js" %}"></script> <script src="{% static 'js/sortable.min.js' %}"></script>
<script src="{% static 'js/filter-table.js' %}"></script>
{% endblock script %} {% endblock script %}

View file

@ -4,7 +4,7 @@
{% load staticfiles %} {% load staticfiles %}
{% block title %}{% trans "Instances" %}{% endblock %} {% block title %}{% trans "Instances" %}{% endblock %}
{% block style %} {% block style %}
<link rel="stylesheet" href="{% static "css/sortable-theme-bootstrap.css" %}" /> <link rel="stylesheet" href="{% static 'css/sortable-theme-bootstrap.css' %}" />
{% endblock %} {% endblock %}
{% block page_heading %}{% trans "Instances" %}{% endblock page_heading %} {% block page_heading %}{% trans "Instances" %}{% endblock page_heading %}
@ -12,9 +12,7 @@
{% if request.user.is_superuser %} {% if request.user.is_superuser %}
{% include 'create_inst_block.html' %} {% include 'create_inst_block.html' %}
{% endif %} {% endif %}
<div class="float-right search"> {% include 'search_block.html' %}
<input id="filter" class="form-control" type="text" placeholder="{% trans 'Search' %}">
</div>
{% endblock page_heading_extra %} {% endblock page_heading_extra %}
{% block content %} {% block content %}
@ -37,7 +35,7 @@
</div> </div>
{% endblock content %} {% endblock content %}
{% block script %} {% block script %}
<script src="{% static "js/sortable.min.js" %}"></script> <script src="{% static 'js/sortable.min.js' %}"></script>
<script src="{% static 'js/filter-table.js' %}"></script> <script src="{% static 'js/filter-table.js' %}"></script>
{% if request.user.is_superuser %} {% if request.user.is_superuser %}
<script> <script>

View file

@ -66,8 +66,6 @@
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-12">
<h5 class="page-header mr-auto">{% trans "Filter References" %} <h5 class="page-header mr-auto">{% trans "Filter References" %}
<form class="form-inline float-right" method="post" role="form" aria-label="Add NWFilter form">{% csrf_token %} <form class="form-inline float-right" method="post" role="form" aria-label="Add NWFilter form">{% csrf_token %}
<div class="form-group"> <div class="form-group">
<div class="input-group"> <div class="input-group">
@ -108,7 +106,7 @@
<td style="width:30px;"> <td style="width:30px;">
<form action="" method="post" role="form" aria-label="Delete NWFilter form">{% csrf_token %} <form action="" method="post" role="form" aria-label="Delete NWFilter form">{% csrf_token %}
<input type="hidden" name="ref" value="{{ ref }}"> <input type="hidden" name="ref" value="{{ ref }}">
<button type="submit" class="btn btn-sm btn-danger" name="del_nwfilter_ref" title="{% trans "Delete" %}" onclick="return confirm('{% trans "Are you sure?" %}')"> <button type="submit" class="btn btn-sm btn-danger" name="del_nwfilter_ref" title="{% trans "Delete" %}" onclick="return confirm('{% trans "Are you sure?" %}');">
<i class="fa fa-trash"></i> <i class="fa fa-trash"></i>
</button> </button>
</form> </form>
@ -148,7 +146,7 @@
<input type="hidden" name="action" value="{{ rule.action }}"> <input type="hidden" name="action" value="{{ rule.action }}">
<input type="hidden" name="direction" value="{{ rule.direction }}"> <input type="hidden" name="direction" value="{{ rule.direction }}">
<input type="hidden" name="priority" value="{{ rule.priority }}"> <input type="hidden" name="priority" value="{{ rule.priority }}">
<button type="submit" class="btn btn-sm btn-danger" name="del_nwfilter_rule" title="{% trans "Delete" %}" onclick="return confirm('{% trans "Are you sure?" %}')"> <button type="submit" class="btn btn-sm btn-danger" name="del_nwfilter_rule" title="{% trans 'Delete' %}" onclick="return confirm('{% trans "Are you sure?" %}');">
<i class="fa fa-trash"></i> <i class="fa fa-trash"></i>
</button> </button>
</form> </form>
@ -162,21 +160,8 @@
{% endblock %} {% endblock %}
{% block script %} {% block script %}
<script src="{% static "js/sortable.min.js" %}"></script> <script src="{% static 'js/sortable.min.js' %}"></script>
<script> <script src="{% static 'js/ace/ace.js' %}"></script>
$(document).ready(function () {
(function ($) {
$('#filter').keyup(function () {
var rex = new RegExp($(this).val(), 'i');
$('.searchable tr').hide();
$('.searchable tr').filter(function () {
return rex.test($(this).text());
}).show();
})
}(jQuery));
});
</script>
<script src="{% static "js/ace/ace.js" %}"></script>
<script> <script>
var editor = ace.edit("edit_editor"); var editor = ace.edit("edit_editor");
editor.getSession().setMode("ace/mode/xml"); editor.getSession().setMode("ace/mode/xml");

View file

@ -8,9 +8,7 @@
{% block page_heading_extra %} {% block page_heading_extra %}
{% include 'create_nwfilter_block.html' %} {% include 'create_nwfilter_block.html' %}
<div class="float-right search"> {% include 'search_block.html' %}
<input id="filter" class="form-control" type="text" placeholder="{% trans 'Search' %}">
</div>
{% endblock page_heading_extra %} {% endblock page_heading_extra %}
{% block content %} {% block content %}
@ -142,22 +140,9 @@
{% endblock %} {% endblock %}
{% block script %} {% block script %}
<script src="{% static "js/sortable.min.js" %}"></script> <script src="{% static 'js/sortable.min.js' %}"></script>
<script> <script src="{% static 'js/filter-table.js' %}"></script>
$(document).ready(function () { <script src="{% static 'js/ace/ace.js' %}"></script>
(function ($) {
$('#filter').keyup(function () {
var rex = new RegExp($(this).val(), 'i');
$('.searchable tr').hide();
$('.searchable tr').filter(function () {
return rex.test($(this).text());
}).show();
})
}(jQuery));
});
</script>
<script src="{% static "js/ace/ace.js" %}"></script>
<script> <script>
var editor = ace.edit("editor"); var editor = ace.edit("editor");
editor.getSession().setMode("ace/mode/xml"); editor.getSession().setMode("ace/mode/xml");

View file

@ -4,12 +4,12 @@ function filter_table() {
$('.searchable tr').filter(function () { $('.searchable tr').filter(function () {
return rex.test($(this).text()); return rex.test($(this).text());
}).show(); }).show();
Cookies.set("instances_filter", $(this).val(), { expires: 1 }); Cookies.set(document.title + "_filter", $(this).val(), { expires: 1 });
} }
$(document).ready(function () { $(document).ready(function () {
instances_filter_cookie = Cookies.get("instances_filter"); filter_cookie = Cookies.get(document.title + "_filter");
if (instances_filter_cookie) { if (filter_cookie) {
$('#filter').val(instances_filter_cookie); $('#filter').val(filter_cookie);
$('#filter').each(filter_table); $('#filter').each(filter_table);
} }
(function ($) { (function ($) {

View file

@ -81,10 +81,10 @@
</dl> </dl>
{% if state %} {% if state %}
<div class="container">
<div class="row"> <div class="row">
<h5 class="page-header mr-auto">{% trans "Volumes" %}</h5> <h5 class="page-header mr-auto">{% trans "Volumes" %}</h5>
<div class="col-3 "> {% include 'search_block.html' %}
<input id="filter" class="form-control" type="text" placeholder="{% trans 'Search' %}">
</div> </div>
</div> </div>
@ -194,7 +194,8 @@
{% include 'pleasewaitdialog.html' %} {% include 'pleasewaitdialog.html' %}
{% endblock %} {% endblock %}
{% block script %} {% block script %}
<script src="{% static "js/sortable.min.js" %}"></script> <script src="{% static 'js/sortable.min.js' %}"></script>
<script src="{% static 'js/filter-table.js' %}"></script>
<script> <script>
$('.format-convert').hide(); $('.format-convert').hide();
$(document).on('change', '.volume-convert', function () { $(document).on('change', '.volume-convert', function () {
@ -216,17 +217,4 @@
} }
}); });
</script> </script>
<script>
$(document).ready(function () {
(function ($) {
$('#filter').keyup(function () {
var rex = new RegExp($(this).val(), 'i');
$('.searchable tr').hide();
$('.searchable tr').filter(function () {
return rex.test($(this).text());
}).show();
})
}(jQuery));
});
</script>
{% endblock %} {% endblock %}

View file

@ -1,4 +1,4 @@
{% load i18n %} {% load i18n %}
<div class="float-right search"> <div class="float-right search">
<input id="filter" class="form-control" type="text" placeholder="{% trans "Search" %}"> <input id="filter" class="form-control" type="text" placeholder="{% trans 'Search' %}">
</div> </div>