Skip to content

Commit

Permalink
add remove label func
Browse files Browse the repository at this point in the history
  • Loading branch information
BenediktMKuehne committed Feb 28, 2024
1 parent b7ddc6b commit 1ab2f55
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
6 changes: 4 additions & 2 deletions embark/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -294,7 +294,9 @@ def rm_label(request, analysis_id, label_name):
logger.info("User %s tryied to rm label %s", request.user.username, label_name)
# get analysis obj
analysis = FirmwareAnalysis.objects.get(id=analysis_id)
analysis.label.remove(label_name)
# 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('..')
10 changes: 9 additions & 1 deletion embark/static/content/css/reportDashboard.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,12 @@ table.dataTable td, table.dataTable th {

.buttonRowElem {
margin: 2px;
}
}

.hidden {
display: none;
}

.label:hover form button, .label:focus form button {
display: block;
}
11 changes: 5 additions & 6 deletions embark/templates/dashboard/reportDashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,13 @@
{% if firmware.label.all is not None %}
{% for label in firmware.label.all %}
<div class="col-sm">
<button onclick="onclick_label('label={{ label.label_name }}');" class="label badge rounded-pill bg-info">{{ label.label_name }}</button>
<!-- TODO add hover and remove -->

<form action="{% url 'embark-dashboard-remove-label' firmware.id label.label_name %}" method="post" id="form">
<a onclick="onclick_label('label={{ label.label_name }}');" class="badge label bg-info position-relative" role="button">
{{ label.label_name }}
<form action={% url 'embark-dashboard-remove-label' firmware.id label.label_name %} method="post" id="remove-label-{{ label.label_name }}-{{ firmware.id }}">
{% csrf_token %}
<button type="submit" class="hidden position-absolute top-0 start-100 translate-middle badge rounded-pill bg-danger">x</button>
</form>

{{ label.label_name }}
</a>
</div>
{% endfor %}
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion embark/uploader/boundedexecutor.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
semaphore = BoundedSemaphore(MAX_QUEUE)

# emba directories
EMBA_SCRIPT_LOCATION = f"cd {settings.EMBA_ROOT} && sudo ./emba"
EMBA_SCRIPT_LOCATION = f"cd {settings.EMBA_ROOT} && sudo -E ./emba"


class BoundedException(Exception):
Expand Down
4 changes: 3 additions & 1 deletion installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,14 @@ install_embark_dev(){
# install pipenv
pip3 install pipenv

#Add user nosudo
# Add user nosudo
echo "${SUDO_USER:-${USER}}"" ALL=(ALL) NOPASSWD: ""${PWD}""/emba/emba" | EDITOR='tee -a' visudo
echo "${SUDO_USER:-${USER}}"" ALL=(ALL) NOPASSWD: /bin/pkill" | EDITOR='tee -a' visudo
echo "root ALL=(ALL) NOPASSWD: ""${PWD}""/emba/emba" | EDITOR='tee -a' visudo
echo "root ALL=(ALL) NOPASSWD: /bin/pkill" | EDITOR='tee -a' visudo

# Set some globals
echo "NO_UPDATE_CHECK=1" >> /etc/environment

#pipenv
MYSQLCLIENT_LDFLAGS='-L/usr/mysql/lib -lmysqlclient -lssl -lcrypto -lresolv' MYSQLCLIENT_CFLAGS='-I/usr/include/mysql/' PIPENV_VENV_IN_PROJECT=1 pipenv install --dev
Expand Down

0 comments on commit 1ab2f55

Please sign in to comment.