mirror of https://github.com/CIRCL/AIL-framework
chg: [tags UI] edit object tags (delete tags)
parent
85d5770e80
commit
3a691a4af3
|
@ -64,6 +64,12 @@ def get_active_taxonomies():
|
|||
def get_active_galaxies():
|
||||
return r_serv_tags.smembers('active_galaxies')
|
||||
|
||||
def get_all_taxonomies_tags(): # # TODO: add + REMOVE + Update
|
||||
return r_serv_tags.smembers('active_taxonomies_tags')
|
||||
|
||||
def get_all_galaxies_tags(): # # TODO: add + REMOVE + Update
|
||||
return r_serv_tags.smembers('active_galaxies_tags')
|
||||
|
||||
def is_taxonomie_tag_enabled(taxonomie, tag):
|
||||
if tag in r_serv_tags.smembers('active_tag_' + taxonomie):
|
||||
return True
|
||||
|
@ -94,6 +100,7 @@ def enable_taxonomy(taxonomie, enable_tags=True):
|
|||
# activate taxonomie tags
|
||||
for tag in taxonomie_info.machinetags():
|
||||
r_serv_tags.sadd('active_tag_{}'.format(taxonomie), tag)
|
||||
#r_serv_tags.sadd('active_taxonomies_tags', tag)
|
||||
else:
|
||||
print('Error: {}, please update pytaxonomies'.format(taxonomie))
|
||||
|
||||
|
|
|
@ -43,28 +43,6 @@ tags_ui = Blueprint('tags_ui', __name__, template_folder=os.path.join(os.environ
|
|||
|
||||
|
||||
# ============= ROUTES ==============
|
||||
# @Tags.route("/Tags/addTags") # REVIEW: # used in showPaste
|
||||
# @login_required
|
||||
# @login_analyst
|
||||
# def addTags():
|
||||
#
|
||||
# tags = request.args.get('tags')
|
||||
# tagsgalaxies = request.args.get('tagsgalaxies')
|
||||
# path = request.args.get('path')
|
||||
#
|
||||
# list_tag = tags.split(',')
|
||||
# list_tag_galaxies = tagsgalaxies.split(',')
|
||||
#
|
||||
# res = Tag.add_items_tags(list_tag, list_tag_galaxies, item_id=path)
|
||||
# print(res)
|
||||
# # error
|
||||
# if res[1] != 200:
|
||||
# return str(res[0])
|
||||
# # success
|
||||
# return redirect(url_for('showsavedpastes.showsavedpaste', paste=path))
|
||||
|
||||
|
||||
|
||||
@tags_ui.route('/tag/add_tags')
|
||||
@login_required
|
||||
@login_analyst
|
||||
|
@ -72,8 +50,8 @@ def add_tags():
|
|||
|
||||
tags = request.args.get('tags')
|
||||
tagsgalaxies = request.args.get('tagsgalaxies')
|
||||
object_id = request.args.get('object_id') # old: item_id
|
||||
object_type = request.args.get('object_type') # old type
|
||||
object_id = request.args.get('object_id')
|
||||
object_type = request.args.get('object_type')
|
||||
|
||||
list_tag = tags.split(',')
|
||||
list_tag_galaxies = tagsgalaxies.split(',')
|
||||
|
@ -85,7 +63,19 @@ def add_tags():
|
|||
|
||||
return redirect(Correlate_object.get_item_url(object_type, object_id))
|
||||
|
||||
@tags_ui.route('/tag/delete_tag')
|
||||
@login_required
|
||||
@login_analyst
|
||||
def delete_tag():
|
||||
|
||||
object_type = request.args.get('object_type')
|
||||
object_id = request.args.get('object_id')
|
||||
tag = request.args.get('tag')
|
||||
|
||||
res = Tag.api_delete_obj_tags(tags=[tag], object_id=object_id, object_type=object_type)
|
||||
if res[1] != 200:
|
||||
return str(res[0])
|
||||
return redirect(Correlate_object.get_item_url(object_type, object_id))
|
||||
|
||||
# # add route : /crawlers/show_domain
|
||||
# @tags_ui.route('/tags/search/domain')
|
||||
|
|
|
@ -369,9 +369,8 @@ def get_tags_galaxy():
|
|||
@Tags.route("/Tags/remove_tag")
|
||||
@login_required
|
||||
@login_analyst
|
||||
def remove_tag():
|
||||
def remove_tag(): #TODO remove me , used by showpaste
|
||||
|
||||
#TODO verify input
|
||||
path = request.args.get('paste')
|
||||
tag = request.args.get('tag')
|
||||
|
||||
|
|
|
@ -79,10 +79,13 @@
|
|||
</table>
|
||||
|
||||
<div>
|
||||
{% include 'modals/edit_tag.html' %}
|
||||
{% for tag in dict_domain['tags'] %}
|
||||
<a href="{{ url_for('Tags.Tags_page') }}?ltags={{ tag }}">
|
||||
<span class="badge badge-{{ bootstrap_label[loop.index0 % 5] }} pull-left">{{ tag }}</span>
|
||||
</a>
|
||||
<button class="btn btn-{{ bootstrap_label[loop.index0 % 5] }}" data-toggle="modal" data-target="#edit_tags_modal"
|
||||
data-tagid="{{ tag }}" data-objtype="domain" data-objid="{{ dict_domain['domain'] }}">
|
||||
{{ tag }}
|
||||
</button>
|
||||
|
||||
{% endfor %}
|
||||
<br>
|
||||
{% include 'modals/add_tags.html' %}
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
<div id="edit_tags_modal" class="modal fade" role="dialog">
|
||||
<div class="modal-dialog modal-lg">
|
||||
|
||||
<div id="add_tags_modal_content" class="modal-content">
|
||||
<div class="modal-header" style="border-bottom: 4px solid #cccccc; background-color: #cccccc; color: #ffffff;">
|
||||
<h4>Edit Tag</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 badge-warning" id="modal_tag_edit_tag_id">Warning</span></h2>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
|
||||
<!-- <a href="{{ url_for('Tags.tag_validation') }}?object_id=rrrrr&tag=eeeeee&status=tp" class="btn btn-outline-success mr-0" data-toggle="tooltip" title="Good Detection">
|
||||
<i class="fas fa-thumbs-up"></i>
|
||||
</a>
|
||||
<a href="{{ url_for('Tags.tag_validation') }}?object_id=rrrrr&tag=eeeeee&status=fp" class="btn btn-outline-danger mr-auto" data-toggle="tooltip" title="Bad Detection">
|
||||
<i class="fas fa-thumbs-down"></i>
|
||||
</a>
|
||||
|
||||
<a href="{{ url_for('Tags.confirm_tag') }}?object_id=rrrrr&tag=eeeeee" class="btn btn-primary">
|
||||
<i class="fas fa-check"></i> Confirm this Tag
|
||||
</a> -->
|
||||
|
||||
<a href="#" class="btn btn-danger" id="modal_tag_edit_delete_tag">
|
||||
<i class="fas fa-trash-alt"></i> Delete this Tag
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// tagid + objtype + objid
|
||||
$('#edit_tags_modal').on('show.bs.modal', function (event) {
|
||||
var button = $(event.relatedTarget);
|
||||
var tagid = button.data('tagid')
|
||||
var objtype = button.data('objtype')
|
||||
var objid = button.data('objid')
|
||||
var modal = $(this)
|
||||
modal.find('#modal_tag_edit_tag_id').text(tagid)
|
||||
modal.find('#modal_tag_edit_delete_tag').prop("href", "{{ url_for('tags_ui.delete_tag') }}?object_type="+ objtype +"&object_id="+ objid +"&tag="+ tagid)
|
||||
})
|
||||
</script>
|
Loading…
Reference in New Issue