mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2026-02-15 03:26:24 +01:00
Compare commits
1 Commits
a71914464f
...
b2d9844519
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2d9844519 |
@@ -179,34 +179,3 @@
|
|||||||
border-left-color: var(--bs-warning);
|
border-left-color: var(--bs-warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* DataTables 2
|
|
||||||
------------------------------------------------------------------------------------- */
|
|
||||||
@media all {
|
|
||||||
/* DataTables Processing Indicator
|
|
||||||
--------------------------------------------------------------------------------- */
|
|
||||||
div.dt-processing {
|
|
||||||
padding-top: 0.5rem !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.dt-processing > div {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
svg.aa-datatables-process-indicator {
|
|
||||||
width: 2rem;
|
|
||||||
height: 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* DataTables Extension: ColumnControl
|
|
||||||
--------------------------------------------------------------------------------- */
|
|
||||||
table.dataTable span.dtcc div.dtcc-search > div select {
|
|
||||||
background-color: var(--bs-body-bg);
|
|
||||||
color: var(--bs-body-color);
|
|
||||||
padding: 0.375rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
table.dataTable .dt-column-header div.dtcc-search-title {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
{% load i18n %}
|
|
||||||
|
|
||||||
<svg class="aa-datatables-process-indicator">
|
|
||||||
<use href="#aa-loading-spinner"></use>
|
|
||||||
</svg>
|
|
||||||
|
|
||||||
<p class="my-1">
|
|
||||||
{% translate "Loading …" %}
|
|
||||||
</p>
|
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
{% load sri %}
|
{% load sri %}
|
||||||
|
|
||||||
<!-- Start DataTables ColumnControl CSS -->
|
{% sri_static "allianceauth/libs/DataTables/Plugins/ColumnControl/1.2.0/css/columnControl.bootstrap5.min.css" %}
|
||||||
{% sri_static "allianceauth/libs/DataTables/Extensions/ColumnControl/1.2.0/css/columnControl.bootstrap5.min.css" %}
|
|
||||||
<!-- End DataTables ColumnControl CSS -->
|
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
{% load sri %}
|
{% load sri %}
|
||||||
|
|
||||||
<!-- Start DataTables ColumnControl JS -->
|
{% sri_static "allianceauth/libs/DataTables/Plugins/ColumnControl/1.2.0/js/dataTables.columnControl.min.js" %}
|
||||||
{% sri_static "allianceauth/libs/DataTables/Extensions/ColumnControl/1.2.0/js/dataTables.columnControl.min.js" %}
|
{% sri_static "allianceauth/libs/DataTables/Plugins/ColumnControl/1.2.0/js/columnControl.bootstrap5.min.js" %}
|
||||||
{% sri_static "allianceauth/libs/DataTables/Extensions/ColumnControl/1.2.0/js/columnControl.bootstrap5.min.js" %}
|
|
||||||
<!-- End DataTables ColumnControl JS -->
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
{% load sri %}
|
{% load sri %}
|
||||||
|
|
||||||
<!-- Start DataTables CSS -->
|
|
||||||
{% sri_static "allianceauth/libs/DataTables/2.3.6/css/dataTables.bootstrap5.min.css" %}
|
{% sri_static "allianceauth/libs/DataTables/2.3.6/css/dataTables.bootstrap5.min.css" %}
|
||||||
<!-- End DataTables CSS -->
|
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
{% load sri %}
|
{% load sri %}
|
||||||
|
|
||||||
<!-- Start DataTables JS -->
|
|
||||||
{% sri_static "allianceauth/libs/DataTables/2.3.6/js/dataTables.min.js" %}
|
{% sri_static "allianceauth/libs/DataTables/2.3.6/js/dataTables.min.js" %}
|
||||||
{% sri_static "allianceauth/libs/DataTables/2.3.6/js/dataTables.bootstrap5.min.js" %}
|
{% sri_static "allianceauth/libs/DataTables/2.3.6/js/dataTables.bootstrap5.min.js" %}
|
||||||
<!-- End DataTables JS -->
|
|
||||||
|
|||||||
@@ -37,14 +37,10 @@ Given the `EveCharacter` Model as our model of choice we would define our stubs
|
|||||||
|
|
||||||
```django
|
```django
|
||||||
{% extends "allianceauth/base-bs5.html" %}
|
{% extends "allianceauth/base-bs5.html" %}
|
||||||
|
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load aa_i18n %}
|
|
||||||
|
|
||||||
{% block page_title %}
|
{% block page_title %}
|
||||||
{% translate "App Name" %}
|
{% translate "App Name" %}
|
||||||
{% endblock page_title %}
|
{% endblock page_title %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<table class="table table-striped w-100" id="table">
|
<table class="table table-striped w-100" id="table">
|
||||||
<!-- Normal Header Rows -->
|
<!-- Normal Header Rows -->
|
||||||
@@ -58,54 +54,26 @@ Given the `EveCharacter` Model as our model of choice we would define our stubs
|
|||||||
</thead>
|
</thead>
|
||||||
</table>
|
</table>
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
||||||
{% block extra_css %}
|
{% block extra_css %}
|
||||||
{% include "bundles/datatables-2-css-bs5.html" %}
|
<link rel="stylesheet" href="https://cdn.datatables.net/2.3.6/css/dataTables.bootstrap5.css" />
|
||||||
|
<link href="https://cdn.datatables.net/columncontrol/1.2.0/css/columnControl.bootstrap5.min.css" rel="stylesheet">
|
||||||
{% comment %} If you don't use the ColumnControl Extension, remove the next line {% endcomment %}
|
|
||||||
{% include "bundles/datatables-2-columncontrol-css-bs5.html" %}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extra_javascript %}
|
{% block extra_javascript %}
|
||||||
{% get_datatables_language_static LANGUAGE_CODE as DT_LANG_PATH %}
|
<script src="https://cdn.datatables.net/2.3.6/js/dataTables.js"></script>
|
||||||
|
<script src="https://cdn.datatables.net/2.3.6/js/dataTables.bootstrap5.js"></script>
|
||||||
{% include "bundles/datatables-2-js-bs5.html" %}
|
<script src="https://cdn.datatables.net/columncontrol/1.2.0/js/dataTables.columnControl.min.js"></script>
|
||||||
|
|
||||||
{% comment %} If you don't use the ColumnControl Extension, remove the next line {% endcomment %}
|
|
||||||
{% include "bundles/datatables-2-columncontrol-js-bs5.html" %}
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(() => {
|
$(document).ready(function() {
|
||||||
// Assuming you have a table with the ID 'table'
|
$('#table').DataTable({
|
||||||
// A jQuery HTML Element `$('#table')` can also be passed instead of a selector string
|
serverSide: true,
|
||||||
const dt = new DataTable('#table', {
|
ajax: '{% url "appname:table" %}',
|
||||||
language: {
|
|
||||||
url: '{{ DT_LANG_PATH }}',
|
|
||||||
// Important: The value for `language.processing` must be passed
|
|
||||||
// as a JS template string, not as a normal string. This is to
|
|
||||||
// allow for Django template rendering inside the processing
|
|
||||||
// indicator.
|
|
||||||
processing: `{% include "framework/datatables/process-indicator.html" %}`
|
|
||||||
},
|
|
||||||
layout: { // See: https://datatables.net/reference/option/layout
|
|
||||||
topStart: 'pageLength',
|
|
||||||
topEnd: 'search',
|
|
||||||
bottomStart: 'info',
|
|
||||||
bottomEnd: 'paging'
|
|
||||||
},
|
|
||||||
ordering: { // See: https://datatables.net/reference/option/ordering
|
|
||||||
handler: true, // Enable ordering by clicking on column headers
|
|
||||||
indicators: false, // Disable ordering indicators on column headers (important when ColumnControl is used)
|
|
||||||
},
|
|
||||||
processing: true, // Show processing indicator when loading data
|
|
||||||
serverSide: true, // Enable server-side processing
|
|
||||||
ajax: '{% url "appname:data_table_view" %}',
|
|
||||||
columnDefs: [
|
columnDefs: [
|
||||||
{
|
{
|
||||||
targets: [0],
|
targets: [0],
|
||||||
columnControl: [],
|
columnControl: [],
|
||||||
sortable: false,
|
sortable: false,
|
||||||
searchable: false
|
searchable: false
|
||||||
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
targets: [1,2,3],
|
targets: [1,2,3],
|
||||||
@@ -124,12 +92,13 @@ Given the `EveCharacter` Model as our model of choice we would define our stubs
|
|||||||
order: [
|
order: [
|
||||||
[1, "asc"]
|
[1, "asc"]
|
||||||
],
|
],
|
||||||
pageLength: 10, // Override default page length if desired
|
pageLength: 10,
|
||||||
responsive : true
|
responsive : true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endblock extra_javascript %}
|
{% endblock extra_javascript %}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Add our Views
|
## Add our Views
|
||||||
@@ -179,13 +148,11 @@ class EveCharacterTable(DataTablesView):
|
|||||||
# if you need to do some prefetch or pre-filtering you can overide this function
|
# if you need to do some prefetch or pre-filtering you can overide this function
|
||||||
def get_model_qs(self, request: HttpRequest):
|
def get_model_qs(self, request: HttpRequest):
|
||||||
qs = self.model.objects
|
qs = self.model.objects
|
||||||
|
|
||||||
if not request.user.is_superuser:
|
if not request.user.is_superuser:
|
||||||
# eg only show unlinked characters to non-superusers
|
# eg only show unlinked characters to non-superusers
|
||||||
# just an example
|
# just an example
|
||||||
# filtering here will prevent people searching things that may not be visible to them
|
# filtering here will prevent people searching things that may not be visible to them
|
||||||
qs = qs.filter(character_ownership__isnull=True)
|
qs = qs.filter(character_ownership__isnull=True)
|
||||||
|
|
||||||
# maybe some character ownership select related for performance?
|
# maybe some character ownership select related for performance?
|
||||||
return qs.select_related("character_ownership", "character_ownership__user")
|
return qs.select_related("character_ownership", "character_ownership__user")
|
||||||
|
|
||||||
@@ -207,7 +174,7 @@ app_name = 'appname'
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("list/", views.EveCharacterTable.as_view(), name='eve_character_table'),
|
path("list/", views.EveCharacterTable.as_view(), name='eve_character_table'),
|
||||||
path("tables/data_table", views.show_table, name='data_table_view')
|
path("tables/data_table", views.show_table, name='table')
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user