Added web ui with templates

This commit is contained in:
Manuel Forcén Muñoz 2024-02-19 23:51:18 +01:00
parent d2cb5b3031
commit 90b02eef79
24 changed files with 1403 additions and 78 deletions

25
templates/accounts.html Normal file
View file

@ -0,0 +1,25 @@
{% extends "base.html" %}
{% block title %}Account {{account.account_name}}{% endblock title %}
{% block body %}
<div>{{account.account_name}}</div>
<div>
<table>
<tr>
<th>Descripción</th>
<th>Fecha</th>
<th>Cantidad</th>
<th>Categoría</th>
</tr>
{% for tx in transactions %}
<tr>
<td>{{tx.description}}</td>
<td>{{tx.transaction_timestamp}}</td>
<td>{{tx.amount/100}}</td>
<td>{{tx.category}}</td>
</tr>
{% endfor %}
</table>
<p>Cargados {{n_txs}} movimientos</p>
</div>
{% endblock body %}

38
templates/base.html Normal file
View file

@ -0,0 +1,38 @@
<!doctype html>
<html>
<head>
<title>{% block title %}{% endblock title %}</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="/static/styles.css">
<style>
html, body {
height: 100%;
margin: 0;
background:
}
.sidebar {
max-width: 12rem;
flex-grow: 1;
}
.sidebar a {
padding: 0.5rem;
border-radius: 3px;
}
</style>
</head>
<body>
<div class="flex h-full">
<aside class="sidebar bg-stone-300 p-4 flex flex-col">
<a class="hover:bg-stone-400" href="/">Inicio</a>
<a class="hover:bg-stone-400" href="/rules">Reglas</a>
</aside>
<div class="p-4 grow">
{% block body %}
{% endblock body %}
</div>
</div>
</body>
</html>

7
templates/index.html Normal file
View file

@ -0,0 +1,7 @@
{% extends "base.html" %}
{% block title %}Index{% endblock title %}
{% block body %}
{% for account in accounts %}
<a href="/accounts/id/{{account.account_id}}">{{account.account_name}}({{account.account_id}})</a>
{% endfor %}
{% endblock body %}

23
templates/rules_list.html Normal file
View file

@ -0,0 +1,23 @@
{% extends "base.html" %}
{% block title %}Rules{% endblock title %}
{% block body %}
<div>
<a href="/rules/new">New</a>
</div>
<table>
<thead>
<tr>
<th>Categoría</th>
<th>Regla</th>
</tr>
</thead>
<tbody>
{% for rule in rules %}
<tr>
<td>{{rule.category}}</td>
<td>{{rule.regex}}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock body %}

36
templates/rules_new.html Normal file
View file

@ -0,0 +1,36 @@
{% extends "base.html" %}
{% block title %}Create rule{% endblock title %}
{% block body %}
<form action="/rules/new" method="post" class="flex flex-col">
<label class="grow">
Description
<input type="text" name="description" />
</label>
<label class="grow">
Regex
<input type="text" name="regex" />
</label>
<label class="grow">
Category
<select name="category">
<option></option>
{% for cat in categories %}
<option value={{cat.category_id}}>{{cat.name}}</option>
{% endfor %}
</select>
</label>
<button type="submit">Submit</button>
</form>
<style>
label {
width: 100%;
}
input {
width: 100%;
border: 1px solid black;
border-radius: 3px;
padding: 0.25rem;
margin: 0.25rem;
}
{% endblock body %}

View file

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Rule created</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="refresh" content="3;url=.." />
</head>
<body>
Rule created successfully
</body>
</html>