diff --git a/admin/main.py b/admin/main.py index c1e339b..8c22c74 100644 --- a/admin/main.py +++ b/admin/main.py @@ -2,7 +2,7 @@ import json import PIL import PIL.Image import boto3.session -from flask import Flask, render_template, request, Response +from flask import Flask, render_template, request, Response, redirect, url_for from werkzeug.utils import secure_filename from dotenv import load_dotenv import os @@ -63,7 +63,7 @@ def Home(): objects.append({"name": name, "img": img, **obj, "date": date}) - return render_template("Index.html", objects=objects, page_title="Home") + return render_template("Index.html", objects=objects, page_title="Home", s3_endpoint=os.getenv("AWS_ENDPOINT"), s3_bucket=os.getenv("AWS_BUCKET")) @app.route("/upload/") @@ -217,3 +217,19 @@ def ApiUpload(): os.remove(os.path.join(app.config["UPLOAD_FOLDER"], f"{file_path}-24px.{file_ext}")) return {"status": "ok", "message": "Uploaded"} + + +@app.route("/edit/", methods=["GET"]) +def Edit(id): + document = db.collection(os.getenv("PREFIX")).document(id).get() + if document.exists: + name = document.id + img = f"{document.id.split(".")[0]}/{document.id}" + + obj = document.to_dict() + tags = obj["tags"] + urls = obj["urls"] + date = datetime.fromtimestamp(float(float(str(obj['date'])[:10]))).strftime("%d/%m/%Y") + return render_template("edit.html", name=name, img=img, tags=":".join(tags), urls=urls, date=date, page_title=f"Edit - {name}", s3_endpoint=os.getenv("AWS_ENDPOINT"), s3_bucket=os.getenv("AWS_BUCKET")) + else: + return redirect(url_for("Home")) \ No newline at end of file diff --git a/admin/static/tailwind.css b/admin/static/tailwind.css index 23daf4d..c928fbf 100644 --- a/admin/static/tailwind.css +++ b/admin/static/tailwind.css @@ -1140,6 +1140,9 @@ .static { position: static; } + .sticky { + position: sticky; + } .inset-0 { inset: calc(var(--spacing) * 0); } @@ -1492,6 +1495,9 @@ margin-left: e !important; } } + .mr-2 { + margin-right: calc(var(--spacing) * 2); + } .apexcharts-tooltip-title { .apexcharts-canvas .apexcharts-tooltip & { padding-top: 0.5rem !important; @@ -1741,6 +1747,9 @@ .w-128 { width: calc(var(--spacing) * 128); } + .w-\[296px\] { + width: 296px; + } .w-full { width: 100%; } @@ -1950,6 +1959,9 @@ .overflow-y-auto { overflow-y: auto; } + .rounded { + border-radius: 0.25rem; + } .rounded-full { border-radius: calc(infinity * 1px); } @@ -2214,6 +2226,9 @@ .bg-black\/75 { background-color: color-mix(in oklab, var(--color-black) 75%, transparent); } + .bg-blue-100 { + background-color: var(--color-blue-100); + } .bg-blue-700 { background-color: var(--color-blue-700); } @@ -2443,9 +2458,15 @@ .px-2 { padding-inline: calc(var(--spacing) * 2); } + .px-2\.5 { + padding-inline: calc(var(--spacing) * 2.5); + } .px-5 { padding-inline: calc(var(--spacing) * 5); } + .py-0\.5 { + padding-block: calc(var(--spacing) * 0.5); + } .py-1 { padding-block: calc(var(--spacing) * 1); } @@ -2665,6 +2686,9 @@ .text-blue-600 { color: var(--color-blue-600); } + .text-blue-800 { + color: var(--color-blue-800); + } .text-gray-200 { color: var(--color-gray-200); } @@ -2961,6 +2985,11 @@ border-color: transparent; } } + .dark\:bg-blue-200 { + @media (prefers-color-scheme: dark) { + background-color: var(--color-blue-200); + } + } .dark\:bg-blue-600 { @media (prefers-color-scheme: dark) { background-color: var(--color-blue-600); @@ -3006,6 +3035,11 @@ color: var(--color-blue-500); } } + .dark\:text-blue-800 { + @media (prefers-color-scheme: dark) { + color: var(--color-blue-800); + } + } .dark\:text-gray-300 { @media (prefers-color-scheme: dark) { color: var(--color-gray-300); diff --git a/admin/templates/Index.html b/admin/templates/Index.html index f1c6904..31cfd47 100644 --- a/admin/templates/Index.html +++ b/admin/templates/Index.html @@ -68,7 +68,7 @@
+ src="{{ s3_endpoint }}/{{ s3_bucket }}/{{ object.img }}" alt="" />
diff --git a/admin/templates/edit.html b/admin/templates/edit.html new file mode 100644 index 0000000..f3823cb --- /dev/null +++ b/admin/templates/edit.html @@ -0,0 +1,233 @@ +{% extends 'base.html' %} +{% block content %} + + +
+ +
+ +
+
+
+ +
+ + +
+
+
+ +
+ + +
+ {% for url in urls %} + + {% endfor %} +
+
+ +
+ + +
+
+
+ + + + +{% endblock %} \ No newline at end of file