This commit is contained in:
Michał 2023-04-03 03:17:34 +00:00
parent d33585afca
commit e2bf5ed4e2
2 changed files with 6 additions and 35 deletions

View file

@ -53,7 +53,7 @@
{% endif %}
</div>
<form id="modifyGroup">
<form id="modifyGroup" action="/api/group/modify" method="post">
<input type="text" name="group" placeholder="group id" value="{{ group.id }}">
<input type="text" name="image" placeholder="image id">
<input type="text" name="action" placeholder="add/remove" value="add">
@ -83,32 +83,3 @@
</div>
{% endif %}
{% endblock %}
{% block script %}
<script>
// /api/group/modify
modForm = document.querySelector('#modifyGroup');
modForm.addEventListener('submit', function (event) {
event.preventDefault();
const formData = new FormData();
formData.append('group', modForm.group.value);
formData.append('image', modForm.image.value);
formData.append('action', modForm.action.value);
$.ajax({
url: '/api/group/modify',
type: 'POST',
data: formData,
processData: false,
contentType: false,
success: function (data) {
addNotification('Image added to group', 1);
}
})
})
</script>
{% endblock %}

View file

@ -29,6 +29,10 @@
<script type="text/javascript" src="{{ ASSET_URL }}"></script>
{% endassets %}
{% assets "js_post" %}
<script type="text/javascript" src="{{ ASSET_URL }}" defer></script>
{% endassets %}
{% assets "styles" %}
<link rel="stylesheet" href="{{ ASSET_URL }}" type="text/css" defer>
{% endassets %}
@ -150,11 +154,7 @@
{% for message in get_flashed_messages() %}
addNotification('{{ message[0] }}', {{ message[1] }});
{% endfor %}
</>
{% assets "js_post" %}
<script type="text/javascript" src="{{ ASSET_URL }}"></script>
{% endassets %}
</script>
{% block script %}{% endblock %}
</body>