Skip to content

Commit

Permalink
improve information shown to user
Browse files Browse the repository at this point in the history
  • Loading branch information
kritzl committed Jul 12, 2024
1 parent 7df8ee1 commit 83a4952
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
29 changes: 26 additions & 3 deletions src/vinywaji/gui/templates/views/profile.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% extends "base.html" %}
{% load custom_filters %}
{% load static %}

{% block authorized-content %}
Expand All @@ -19,6 +20,11 @@ <h5 class="text-2xl leading-normal">Basic Information</h5>
<section class="mt-4">
<h5 class="text-2xl leading-normal">Webhooks</h5>

<p>
You can add webhooks for defined transactions.<br>
This gives you the ability to call them from custom clients e.g. in a smart home integration.
</p>

{% include "components/forms/add_webhook.html" %}

<hr class="border-gray-500 my-4">
Expand Down Expand Up @@ -54,12 +60,29 @@ <h5 class="text-2xl leading-normal">Webhooks</h5>
</dt>
<dd class="col-span-2 flex justify-between items-center">
<div>
<span class="min-w-12 inline-block">{{ webhook.amount }}</span>
<span>{{ webhook.transaction_description }}</span>

<span class="min-w-16 inline-block
{% if webhook.amount < 0 %}
bg-orange-300 dark:bg-orange-900
{% elif webhook.amount == 0 %}
bg-gray-300 dark:bg-gray-700
{% else %}
bg-lime-300 dark:bg-green-900
{% endif %}
text-center rounded-lg">
{{ webhook.amount|toeuro }} €
</span>


<span class="ml-4"><b>Description:</b> {{ webhook.transaction_description }}</span>
</div>
<div>
<button data-key="{{ webhook.trigger_key }}"
onclick="writeClipboardText(`{{ request.scheme }}://{{ request.META.HTTP_HOST }}{% url 'webhook-trigger' trigger=webhook.trigger_key %}`)"
onclick="writeClipboardText(`{{ request.scheme }}://
{{ request.META.HTTP_HOST }}{% url 'webhook-trigger' trigger=webhook.trigger_key %}`)"
class="text-center bg-primary-400 hover:bg-primary-500 dark:bg-primary-600 dark:hover:bg-primary-700 px-4 py-2 rounded-lg min-w-30">
Copy URL
</button>
Expand Down
Empty file.
13 changes: 13 additions & 0 deletions src/vinywaji/gui/templatetags/custom_filters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from django import template

register = template.Library()


@register.filter
def toeuro(value):
try:
value = int(value) / 100
return f"{value:.2f}"
except:
pass
return ""
2 changes: 1 addition & 1 deletion src/vinywaji/gui/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def get(self, request: HttpRequest, trigger: str):
webhook[0].trigger()
return HttpResponse("OK", status=200)
else:
return HttpResponse("Failed", status=404)
return HttpResponse("Webhook not found", status=404)


def manifest(request):
Expand Down

0 comments on commit 83a4952

Please sign in to comment.