diff --git a/AIPscan/Reporter/templates/aips.html b/AIPscan/Reporter/templates/aips.html index f7f03aa8..2bba7e6b 100644 --- a/AIPscan/Reporter/templates/aips.html +++ b/AIPscan/Reporter/templates/aips.html @@ -10,6 +10,12 @@ {% if storage_services %} +
+
+ Search +
+
+
diff --git a/AIPscan/Reporter/views.py b/AIPscan/Reporter/views.py index a618026d..d11217a8 100644 --- a/AIPscan/Reporter/views.py +++ b/AIPscan/Reporter/views.py @@ -86,7 +86,7 @@ def storage_locations_with_aips(storage_locations): return [loc for loc in storage_locations if loc.aips] -def get_aip_pager(page, per_page, storage_service, storage_location): +def get_aip_pager(page, per_page, storage_service, storage_location, query): try: page = int(page) except ValueError: @@ -96,7 +96,16 @@ def get_aip_pager(page, per_page, storage_service, storage_location): if storage_service is not None: storage_service_id = storage_service.id - pager = AIP.query.filter_by(storage_service_id=storage_service_id).paginate( + if query is None: + query = "" + + pager = AIP.query.filter( + AIP.uuid.like("%" + query + "%") | + AIP.transfer_name.like("%" + query + "%") | + AIP.create_date.like("%" + query + "%") + ).filter_by( + storage_service_id=storage_service_id + ).paginate( page=page, per_page=per_page, error_out=False ) @@ -131,8 +140,12 @@ def view_aips(): except Exception as e: print(e) + query = request.args.get("query") + if query is None: + query = "" + page = request.args.get(request_params.PAGE, default="1") - pager = get_aip_pager(page, 10, storage_service, storage_location) + pager = get_aip_pager(page, 10, storage_service, storage_location, query) first_item, last_item = calculate_paging_window(pager) diff --git a/AIPscan/static/js/reporter/aips.js b/AIPscan/static/js/reporter/aips.js index fa46e552..9ff54b51 100644 --- a/AIPscan/static/js/reporter/aips.js +++ b/AIPscan/static/js/reporter/aips.js @@ -5,6 +5,7 @@ $(document).ready(function () { function reloadPage(ignoreLocation) { var storageServiceId = $("#ss").val(); var storageLocationId = $("#sl").val(); + var query = $("#query").val(); var url = new URL("reporter/aips", $("body").data("url-root")); var params = { @@ -15,6 +16,10 @@ $(document).ready(function () { params["storage_location"] = storageLocationId; } + if (query !== "") { + params["query"] = query; + } + url.search = new URLSearchParams(params).toString(); window.location.href = url.href; } @@ -26,4 +31,10 @@ $(document).ready(function () { $("#sl").on("change", function () { reloadPage(false); }); + + $("#queryform").on("submit", function () { + reloadPage(false); + + return false; + }); });