Skip to content

Commit

Permalink
feat(admin): make user activity more legible (pypi#14748)
Browse files Browse the repository at this point in the history
  • Loading branch information
miketheman authored Oct 16, 2023
1 parent c6d9dd3 commit 85a5f17
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
5 changes: 5 additions & 0 deletions warehouse/admin/static/css/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@

@charset "utf-8";
@import "@fortawesome/fontawesome-free/css/all.min.css";

@import "admin-lte/plugins/datatables-bs4/css/dataTables.bootstrap4.css";
@import "admin-lte/plugins/datatables-responsive/css/responsive.bootstrap4.css";
@import "admin-lte/plugins/datatables-buttons/css/buttons.bootstrap4.css";

@import "admin-lte/dist/css/adminlte.css";

/* Admin styles for the Warehouse project (PyPI) */
Expand Down
31 changes: 27 additions & 4 deletions warehouse/admin/static/js/warehouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,19 @@
* limitations under the License.
*/

// Import the AdminLTE version of Bootstrap JS (4.x) to avoid namespace
// conflicts with other bootstrap packages.
// Related: https://github.com/ColorlibHQ/AdminLTE/commit/4f1546acb25dc73b034cb15a598171f4c2b3d835
import "admin-lte/node_modules/bootstrap";
import "admin-lte/plugins/jquery/jquery";
import "admin-lte/plugins/bootstrap/js/bootstrap.bundle";

// Import DataTables JS
import "admin-lte/plugins/datatables/jquery.dataTables";
import "admin-lte/plugins/datatables-bs4/js/dataTables.bootstrap4";
import "admin-lte/plugins/datatables-responsive/js/dataTables.responsive";
import "admin-lte/plugins/datatables-responsive/js/responsive.bootstrap4";
import "admin-lte/plugins/datatables-buttons/js/dataTables.buttons";
import "admin-lte/plugins/datatables-buttons/js/buttons.bootstrap4";
import "admin-lte/plugins/datatables-buttons/js/buttons.html5";
import "admin-lte/plugins/datatables-buttons/js/buttons.colVis";

// Import AdminLTE JS
import "admin-lte/build/js/AdminLTE";

Expand Down Expand Up @@ -100,3 +109,17 @@ document.querySelectorAll(".copy-text").forEach(function (element) {
copy(element.dataset.copyText, element);
});
});

// Activate Datatables https://datatables.net/
// User Account Activity
let table = $("#account-activity").DataTable({
responsive: true,
lengthChange: false,
});
// sort by time
table.column(".time").order("desc").draw();
// Hide some columns we don't need to see all the time
table.columns([".ip_address", ".hashed_ip"]).visible(false);
// add column visibility button
new $.fn.dataTable.Buttons(table, {buttons: ["copy", "csv", "colvis"]});
table.buttons().container().appendTo($(".col-md-6:eq(0)", table.table().container()));
16 changes: 8 additions & 8 deletions warehouse/admin/templates/admin/users/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -527,16 +527,16 @@ <h3 class="card-title">Pending OpenID Connect Publishers</h3>
<h3 class="card-title">Account activity</h3>
</div>
<div class="card-body">
<table class="table table-hover">
<table id="account-activity" class="table table-striped table-hover">
<thead>
<tr>
<th scope="col">Event</th>
<th scope="col">Time</th>
<th scope="col">IP address</th>
<th scope="col">Hashed IP address</th>
<th scope="col">Location info</th>
<th scope="col">User-Agent</th>
<th scope="col">Additional information</th>
<th scope="col" class="event">Event</th>
<th scope="col" class="time">Time</th>
<th scope="col" class="ip_address">IP address</th>
<th scope="col" class="hashed_ip">Hashed IP address</th>
<th scope="col" class="location_info">Location info</th>
<th scope="col" class="user_agent">User-Agent</th>
<th scope="col" class="additional_info">Additional information</th>
</tr>
</thead>
<tbody>
Expand Down

0 comments on commit 85a5f17

Please sign in to comment.