mirror of
https://github.com/ail-project/ail-framework.git
synced 2024-11-14 02:28:23 +00:00
chg: [trackers] UI: remove object from tracker
This commit is contained in:
parent
3ecd3fd023
commit
ee563a79d3
4 changed files with 77 additions and 1 deletions
|
@ -385,7 +385,7 @@ class Tracker:
|
||||||
r_tracker.srem(f'obj:tracker:{obj_type}:{subtype}:{obj_id}:{self.uuid}', date)
|
r_tracker.srem(f'obj:tracker:{obj_type}:{subtype}:{obj_id}:{self.uuid}', date)
|
||||||
|
|
||||||
r_tracker.srem(f'obj:trackers:{obj_type}:{subtype}:{obj_id}', self.uuid)
|
r_tracker.srem(f'obj:trackers:{obj_type}:{subtype}:{obj_id}', self.uuid)
|
||||||
r_tracker.srem(f'tracker:objs:{self.uuid}', f'{obj_type}:{subtype}:{obj_id}')
|
r_tracker.srem(f'tracker:objs:{self.uuid}:{obj_type}', f'{subtype}:{obj_id}')
|
||||||
self.update_daterange()
|
self.update_daterange()
|
||||||
|
|
||||||
# TODO escape custom tags
|
# TODO escape custom tags
|
||||||
|
@ -1055,6 +1055,20 @@ def api_delete_tracker(data, user_id):
|
||||||
tracker = Tracker(tracker_uuid)
|
tracker = Tracker(tracker_uuid)
|
||||||
return tracker.delete(), 200
|
return tracker.delete(), 200
|
||||||
|
|
||||||
|
def api_tracker_remove_object(data, user_id):
|
||||||
|
tracker_uuid = data.get('uuid')
|
||||||
|
res = api_check_tracker_acl(tracker_uuid, user_id)
|
||||||
|
if res:
|
||||||
|
return res
|
||||||
|
|
||||||
|
tracker = Tracker(tracker_uuid)
|
||||||
|
object_gid = data.get('gid')
|
||||||
|
try:
|
||||||
|
obj_type, subtype, obj_id = object_gid.split(':', 2)
|
||||||
|
except (AttributeError, IndexError):
|
||||||
|
return {"status": "error", "reason": "Invalid Object"}, 400
|
||||||
|
return tracker.remove(obj_type, subtype, obj_id), 200
|
||||||
|
|
||||||
## -- CREATE TRACKER -- ##
|
## -- CREATE TRACKER -- ##
|
||||||
|
|
||||||
####################
|
####################
|
||||||
|
|
|
@ -372,6 +372,22 @@ def get_json_tracker_graph():
|
||||||
res = Tracker.get_trackers_graph_by_day([tracker_uuid])
|
res = Tracker.get_trackers_graph_by_day([tracker_uuid])
|
||||||
return jsonify(res)
|
return jsonify(res)
|
||||||
|
|
||||||
|
@hunters.route('/tracker/object/remove', methods=['GET'])
|
||||||
|
@login_required
|
||||||
|
@login_analyst
|
||||||
|
def tracker_object_remove():
|
||||||
|
user_id = current_user.get_id()
|
||||||
|
tracker_uuid = request.args.get('uuid')
|
||||||
|
object_global_id = request.args.get('gid')
|
||||||
|
res = Tracker.api_tracker_remove_object({'uuid': tracker_uuid, 'gid': object_global_id}, user_id)
|
||||||
|
if res[1] != 200:
|
||||||
|
return create_json_response(res[0], res[1])
|
||||||
|
else:
|
||||||
|
if request.referrer:
|
||||||
|
return redirect(request.referrer)
|
||||||
|
else:
|
||||||
|
return redirect(url_for('hunters.show_tracker', uuid=tracker_uuid))
|
||||||
|
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# RETRO HUNT #
|
# RETRO HUNT #
|
||||||
|
|
|
@ -44,6 +44,8 @@
|
||||||
|
|
||||||
{% include 'nav_bar.html' %}
|
{% include 'nav_bar.html' %}
|
||||||
|
|
||||||
|
{% include 'modals/tracker_remove_object.html' %}
|
||||||
|
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{% include 'hunter/menu_sidebar.html' %}
|
{% include 'hunter/menu_sidebar.html' %}
|
||||||
|
@ -295,6 +297,11 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
|
<button class="btn btn-outline-danger py-0 px-1"
|
||||||
|
data-toggle="modal" data-target="#modal_tracker_remove_object"
|
||||||
|
data-tracker_uuid="{{ meta['uuid'] }}" data-obj_gid="{{ object['type'] }}:{{ object['subtype'] }}:{{ object['id'] }}">
|
||||||
|
<i class="fas fa-trash-alt"></i></button>
|
||||||
|
</button>
|
||||||
{# <a href="{{ url_for('investigations_b.unregister_investigation') }}?uuid={{ meta['uuid']}}&type={{ object['type'] }}&subtype={{ object['subtype']}}&id={{ object['id']}}">#}
|
{# <a href="{{ url_for('investigations_b.unregister_investigation') }}?uuid={{ meta['uuid']}}&type={{ object['type'] }}&subtype={{ object['subtype']}}&id={{ object['id']}}">#}
|
||||||
{# <button type="button" class="btn btn-danger"><i class="fas fa-trash-alt"></i></button>#}
|
{# <button type="button" class="btn btn-danger"><i class="fas fa-trash-alt"></i></button>#}
|
||||||
{# </a>#}
|
{# </a>#}
|
||||||
|
|
39
var/www/templates/modals/tracker_remove_object.html
Normal file
39
var/www/templates/modals/tracker_remove_object.html
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
<div id="modal_tracker_remove_object" class="modal fade" role="dialog">
|
||||||
|
<div class="modal-dialog modal-lg">
|
||||||
|
|
||||||
|
<div id="modal_tracker_remove_object_content" class="modal-content">
|
||||||
|
<div class="modal-header" style="border-bottom: 4px solid #cccccc; background-color: #cccccc; color: #ffffff;">
|
||||||
|
<h4>Remove Object From Tracker</h4>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-body text-center">
|
||||||
|
<h2><span class="badge-warning" id="modal_tracker_remove_object_gid">Warning</span></h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-footer">
|
||||||
|
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal" >Close</button>
|
||||||
|
|
||||||
|
<a href="#" class="btn btn-danger" id="modal_tracker_remove_object_delete">
|
||||||
|
<i class="fas fa-trash-alt"></i> Remove
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// tagid + objtype + objid
|
||||||
|
$('#modal_tracker_remove_object').on('show.bs.modal', function (event) {
|
||||||
|
var button = $(event.relatedTarget);
|
||||||
|
let obj_gid = button.data('obj_gid')
|
||||||
|
let tracker_uuid = button.data('tracker_uuid')
|
||||||
|
let modal = $(this)
|
||||||
|
modal.find('#modal_tracker_remove_object_gid').text(obj_gid)
|
||||||
|
modal.find('#modal_tracker_remove_object_delete').prop("href", "{{ url_for('hunters.tracker_object_remove') }}?uuid="+ tracker_uuid +"&gid="+ obj_gid);
|
||||||
|
})
|
||||||
|
</script>
|
Loading…
Reference in a new issue