add and delete tags features

This commit is contained in:
Terrtia 2018-05-17 15:33:06 +02:00
parent 4fbbf8bbd2
commit b9eb3ed9ba
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0
3 changed files with 77 additions and 3 deletions

View file

@ -5,7 +5,7 @@
Flask functions and routes for the trending modules page
'''
import redis
from flask import Flask, render_template, jsonify, request, Blueprint
from flask import Flask, render_template, jsonify, request, Blueprint, redirect, url_for
import json
@ -146,5 +146,43 @@ def get_tagged_paste_res():
return render_template("res.html")
@Tags.route("/Tags/remove_tag")
def remove_tag():
#TODO verify input
path = request.args.get('paste')
tag = request.args.get('tag')
#remove tag
r_serv_metadata.srem('tag:'+path, tag)
r_serv_tags.srem(tag, path)
return redirect(url_for('showsavedpastes.showsavedpaste', paste=path))
@Tags.route("/Tags/confirm_tag")
def confirm_tag():
#TODO verify input
path = request.args.get('paste')
tag = request.args.get('tag')
if(tag[9:28] == 'automatic-detection'):
#remove automatic tag
r_serv_metadata.srem('tag:'+path, tag)
r_serv_tags.srem(tag, path)
tag = tag.replace('automatic-detection','analyst-detection', 1)
#add analyst tag
r_serv_metadata.sadd('tag:'+path, tag)
r_serv_tags.sadd(tag, path)
#add new tag in list of all used tags
r_serv_tags.sadd('list_tags', tag)
return redirect(url_for('showsavedpastes.showsavedpaste', paste=path))
return 'incompatible tag'
# ========= REGISTRATION =========
app.register_blueprint(Tags)

View file

@ -168,7 +168,7 @@ $(document).ready(function(){
var ltags = $('#ltags').tagSuggest({
data: data,
//value: slct_tags,
value: '["infoleak:automatic-detection=\"bitcoin-address\"","infoleak:automatic-detection=\"aws-key\""]',
sortOrder: 'name',
maxDropHeight: 200,
name: 'ltags'

View file

@ -24,8 +24,37 @@
<h2 class="page-header" >
<div>
{% for tag in list_tags %}
<span class="label label-{{ bootstrap_label[loop.index0 % 6] }} pull-left">{{ tag }}</span>
<span class="btn btn-{{ bootstrap_label[loop.index0 % 6] }} btn-lg pull-left" data-toggle="modal" data-target="#myModal_{{ loop.index0 }}">{{ tag }}</span>
<!-- Modal edit this tag -->
<div class="modal fade" id="myModal_{{ loop.index0 }}" role="dialog">
<div class="modal-dialog">
<div class="modal-content text-center">
<div class="modal-header" style="border-bottom: 4px solid #cccccc; background-color: #cccccc; color: #ffffff;">
<p class="heading">Edit this tag</p>
</div>
<div class="modal-body">
<span class="label label-{{ bootstrap_label[loop.index0 % 6] }}" >{{ tag }}</span>
</div>
<div class="modal-footer center">
<a href="{{ url_for('Tags.confirm_tag') }}?paste={{ request.args.get('paste') }}&tag={{ tag }}" class="btn btn-primary">
<span class="glyphicon glyphicon-ok "></span> Confirm this Tag
</a>
<a href="{{ url_for('Tags.remove_tag') }}?paste={{ request.args.get('paste') }}&tag={{ tag }}" class="btn btn-danger">
<span class="glyphicon glyphicon-trash "></span> Delete this Tag
</a>
</div>
</div>
</div>
</div>
{% endfor %}
<button type="button" class="btn btn-light btn-lg" data-toggle="tooltip" title="Add Tag">
<span class="glyphicon glyphicon-plus "></span>
</span>
</div>
</h2>
@ -55,6 +84,13 @@
</tr>
</tbody>
</table>
<button type="button" class="btn btn-success btn-lg" data-toggle="tooltip" title="Good Detection">
<span class="glyphicon glyphicon-thumbs-up "></span>
</span>
<button type="button" class="btn btn-danger btn-lg" data-toggle="tooltip" title="Bad Detection">
<span class="glyphicon glyphicon-thumbs-down "></span>
</span>
</div>
<div class="panel-body" id="panel-body">
{% if duplicate_list|length == 0 %}