diff --git a/embark/dashboard/urls.py b/embark/dashboard/urls.py index 6c4b4d48..4742b7a9 100644 --- a/embark/dashboard/urls.py +++ b/embark/dashboard/urls.py @@ -16,5 +16,6 @@ path('dashboard/log/', views.show_log, name='embark-show-log'), path('dashboard/logviewer/', views.show_logviewer, name='embark-show-logviewer'), path('dashboard/report/createlabel/', views.create_label, name='embark-dashboard-create-label'), - path('dashboard/report/addlabel/', views.add_label, name='embark-dashboard-add-label') + path('dashboard/report/addlabel/', views.add_label, name='embark-dashboard-add-label'), + path('dashboard/report/rmlabel/', views.rm_label, name='embark-dashboard-remove-label'), ] diff --git a/embark/dashboard/views.py b/embark/dashboard/views.py index 2dbb38f0..287155bc 100644 --- a/embark/dashboard/views.py +++ b/embark/dashboard/views.py @@ -16,7 +16,7 @@ from uploader.boundedexecutor import BoundedExecutor from uploader.forms import LabelForm -from uploader.models import FirmwareAnalysis +from uploader.models import FirmwareAnalysis, Label from dashboard.models import Result from dashboard.forms import LabelSelectForm, StopAnalysisForm from porter.views import make_zip @@ -283,3 +283,20 @@ def add_label(request, analysis_id): logger.error("label form invalid %s ", request.POST) messages.error(request, 'Adding Label failed') return redirect('..') + + +@csrf_protect +@require_http_methods(["POST"]) +@login_required(login_url='/' + settings.LOGIN_URL) +def rm_label(request, analysis_id, label_name): + req_logger.info("User %s called rm label", request.user.username) + + logger.info("User %s tryied to rm label %s", request.user.username, label_name) + # get analysis obj + analysis = FirmwareAnalysis.objects.get(id=analysis_id) + # get lobel obj + label_obj = Label.objects.get(label_name=label_name) + analysis.label.remove(label_obj) + analysis.save() + messages.info(request, 'removing successful of ' + str(label_name)) + return redirect('..') diff --git a/embark/static/content/css/reportDashboard.css b/embark/static/content/css/reportDashboard.css index 44551b0c..aa8633a3 100644 --- a/embark/static/content/css/reportDashboard.css +++ b/embark/static/content/css/reportDashboard.css @@ -55,4 +55,12 @@ table.dataTable td, table.dataTable th { .buttonRowElem { margin: 2px; -} \ No newline at end of file +} + +.hidden { + display: none; +} + +.label:hover form button, .label:focus form button { + display: block; +} diff --git a/embark/templates/dashboard/label.html b/embark/templates/dashboard/label.html index 36c15249..37677ff7 100644 --- a/embark/templates/dashboard/label.html +++ b/embark/templates/dashboard/label.html @@ -1,5 +1,14 @@ {% load django_bootstrap5 %} +
+ {% csrf_token %} +
+ {% load filters %} + {% bootstrap_form label_select_form %} + {% bootstrap_button "Add" button_type="submit" button_class="btn-primary" %} +
+
+
{% csrf_token %}
@@ -7,4 +16,4 @@ {% bootstrap_form label_form layout='grid' %} {% bootstrap_button "Create" button_type="submit" button_class="btn-primary" %}
-
\ No newline at end of file + diff --git a/embark/templates/dashboard/reportDashboard.html b/embark/templates/dashboard/reportDashboard.html index 46881266..996ca366 100644 --- a/embark/templates/dashboard/reportDashboard.html +++ b/embark/templates/dashboard/reportDashboard.html @@ -60,7 +60,13 @@ {% if firmware.label.all is not None %} {% for label in firmware.label.all %} {% endfor %} {% endif %} @@ -194,15 +200,6 @@