diff --git a/bin/lib/Tracker.py b/bin/lib/Tracker.py index 2e8254a3..f98ef5f8 100755 --- a/bin/lib/Tracker.py +++ b/bin/lib/Tracker.py @@ -1746,13 +1746,15 @@ def get_nb_objs(self): objs[obj_type] = nb return objs - def get_objs(self): + def get_objs(self, page=1, per_page=15): objs = [] for obj_type in get_objects_retro_hunted(): for obj in self.get_objs_by_type(obj_type): subtype, obj_id = obj.split(':', 1) objs.append((obj_type, subtype, obj_id)) - return objs + + paginated_objs = ail_core.paginate_iterator(objs, page=page, per_page=per_page) + return paginated_objs def add(self, obj_type, subtype, obj_id): # match by object type: diff --git a/var/www/blueprints/hunters.py b/var/www/blueprints/hunters.py index c2510348..64f3d637 100644 --- a/var/www/blueprints/hunters.py +++ b/var/www/blueprints/hunters.py @@ -562,6 +562,8 @@ def retro_hunt_show_task(): task_uuid = request.args.get('uuid', None) objs = request.args.get('objs', False) + page = request.args.get('page', 1, type=int) + per_page = 15 # date_from_item = request.args.get('date_from') # date_to_item = request.args.get('date_to') # if date_from_item: @@ -582,13 +584,16 @@ def retro_hunt_show_task(): dict_task['filters'] = json.dumps(dict_task['filters'], indent=4) if objs: - dict_task['objs'] = ail_objects.get_objects_meta(retro_hunt.get_objs(), options={'last_full_date'}, flask_context=True) + + pagination = retro_hunt.get_objs(page=page, per_page=per_page) + dict_task['objs'] = ail_objects.get_objects_meta(pagination.items, options={'last_full_date'}, flask_context=True) else: dict_task['objs'] = [] + pagination = None return render_template("show_retro_hunt.html", dict_task=dict_task, rule_content=rule_content, - bootstrap_label=bootstrap_label) + bootstrap_label=bootstrap_label, pagination=pagination) @hunters.route('/retro_hunt/add', methods=['GET', 'POST']) diff --git a/var/www/templates/hunter/show_retro_hunt.html b/var/www/templates/hunter/show_retro_hunt.html index 423be18b..1aa63528 100644 --- a/var/www/templates/hunter/show_retro_hunt.html +++ b/var/www/templates/hunter/show_retro_hunt.html @@ -247,6 +247,56 @@

+
+ {% if pagination %} + + {% endif %} +

{% endif %} @@ -286,13 +336,6 @@

} });*/ - {% if dict_task['objs'] %} - $('#objs_table').DataTable({ - "aLengthMenu": [[5, 10, 15, -1], [5, 10, 15, "All"]], - "iDisplayLength": 10, - "order": [[ 0, "asc" ]] - }); - {% endif%} }); @@ -313,8 +356,7 @@

function getItems() { var date_from = $('#date-range-from-input').val(); var date_to =$('#date-range-to-input').val(); - {#window.location.replace("{{ url_for('hunters.retro_hunt_show_task') }}?uuid={{ dict_task['uuid'] }}&date_from="+date_from+"&date_to="+date_to);#} - window.location.replace("{{ url_for('hunters.retro_hunt_show_task') }}?uuid={{ dict_task['uuid'] }}&objs=True"); + window.location.replace("{{ url_for('hunters.retro_hunt_show_task') }}?uuid={{ dict_task['uuid'] }}&objs=True&page=1"); }