diff --git a/partitioncloud/modules/admin.py b/partitioncloud/modules/admin.py index 05ccae9..3480ee2 100644 --- a/partitioncloud/modules/admin.py +++ b/partitioncloud/modules/admin.py @@ -2,7 +2,8 @@ """ Admin Panel """ -from flask import Blueprint, render_template, session +import os +from flask import Blueprint, render_template, session, current_app, send_file from .db import get_db from .auth import admin_required @@ -35,3 +36,28 @@ def index(): users=users, user=current_user ) + + +@bp.route("/logs") +@admin_required +def logs(): + """ + Admin panel logs page + """ + user = User(user_id=session.get("user_id")) + + return render_template( + "admin/logs.html", + user=user + ) + + +@bp.route("/logs.txt") +@admin_required +def logs_txt(): + """ + Admin panel logs page + """ + return send_file( + os.path.join(current_app.instance_path, "logs.txt") + ) diff --git a/partitioncloud/static/scripts/logs.js b/partitioncloud/static/scripts/logs.js new file mode 100644 index 0000000..0ea48c5 --- /dev/null +++ b/partitioncloud/static/scripts/logs.js @@ -0,0 +1,20 @@ +let logsEmbed = document.getElementById("logs-embed"); + +logsEmbed.addEventListener("load", () => { + var cssLink = document.createElement("link"); + + cssLink.href = "/static/style/logs.css"; + cssLink.rel = "stylesheet"; + cssLink.type = "text/css"; + + // add css + logsEmbed.contentDocument.head.appendChild(cssLink); + + // Scroll to bottom + logsEmbed.contentWindow.scrollTo(0, logsEmbed.contentDocument.body.scrollHeight); +}); + +// check if the iframe is already loaded (happened with FF Android) +if (logsEmbed.contentDocument.readyState == "complete") { + logsEmbed.dispatchEvent(new Event("load")); +} \ No newline at end of file diff --git a/partitioncloud/static/main.js b/partitioncloud/static/scripts/main.js similarity index 100% rename from partitioncloud/static/main.js rename to partitioncloud/static/scripts/main.js diff --git a/partitioncloud/static/style/colors.css b/partitioncloud/static/style/colors.css new file mode 100644 index 0000000..6875de5 --- /dev/null +++ b/partitioncloud/static/style/colors.css @@ -0,0 +1,65 @@ +/** Color Schemes */ +/* Themes used: Catppuccin Latte & Moccha + * https://github.com/catppuccin/catppuccin */ + +/* Dark theme: Catpuccin Mocha */ +:root { + --color-rosewater: #f5e0dc; + --color-flamingo: #f2cdcd; + --color-pink: #f5c2e7; + --color-mauve: #cba6f7; + --color-red: #f38ba8; + --color-maroon: #eba0ac; + --color-peach: #fab387; + --color-yellow: #f9e2af; + --color-green: #a6e3a1; + --color-teal: #94e2d5; + --color-sky: #89dceb; + --color-sapphire: #74c7ec; + --color-blue: #89b4fa; + --color-lavender: #b4befe; + --color-text: #cdd6f4; + --color-subtext1: #bac2de; + --color-subtext0: #a6adc8; + --color-overlay2: #9399b2; + --color-overlay1: #7f849c; + --color-overlay0: #6c7086; + --color-surface2: #585b70; + --color-surface1: #45475a; + --color-surface0: #313244; + --color-base: #1e1e2e; + --color-mantle: #181825; + --color-crust: #11111b; +} + +/* Light theme: Catppuccin Latte */ +@media (prefers-color-scheme: light) { + :root { + --color-rosewater: #dc8a78; + --color-flamingo: #dd7878; + --color-pink: #ea76cb; + --color-mauve: #8839ef; + --color-red: #d20f39; + --color-maroon: #e64553; + --color-peach: #fe640b; + --color-yellow: #df8e1d; + --color-green: #40a02b; + --color-teal: #179299; + --color-sky: #04a5e5; + --color-sapphire: #209fb5; + --color-blue: #1e66f5; + --color-lavender: #7287fd; + --color-text: #4c4f69; + --color-subtext1: #5c5f77; + --color-subtext0: #6c6f85; + --color-overlay2: #7c7f93; + --color-overlay1: #8c8fa1; + --color-overlay0: #9ca0b0; + --color-surface2: #acb0be; + --color-surface1: #bcc0cc; + --color-surface0: #ccd0da; + --color-base: #eff1f5; + --color-mantle: #e6e9ef; + --color-crust: #dce0e8; + } +} \ No newline at end of file diff --git a/partitioncloud/static/style/logs.css b/partitioncloud/static/style/logs.css new file mode 100644 index 0000000..6c940d9 --- /dev/null +++ b/partitioncloud/static/style/logs.css @@ -0,0 +1,10 @@ +@import url('/static/style/colors.css'); + +body { + background-color: var(--color-crust); + color: var(--color-text); +} + +pre { + white-space: pre; +} \ No newline at end of file diff --git a/partitioncloud/static/mobile.css b/partitioncloud/static/style/mobile.css similarity index 100% rename from partitioncloud/static/mobile.css rename to partitioncloud/static/style/mobile.css diff --git a/partitioncloud/static/style.css b/partitioncloud/static/style/style.css similarity index 85% rename from partitioncloud/static/style.css rename to partitioncloud/static/style/style.css index 2466884..368c366 100644 --- a/partitioncloud/static/style.css +++ b/partitioncloud/static/style/style.css @@ -1,75 +1,7 @@ +@import url('/static/style/colors.css'); /** @import url('https://www.augustin64.fr/static/font/iosevka.css'); */ -/** Color Schemes */ -/* Themes used: Catppuccin Latte & Moccha - * https://github.com/catppuccin/catppuccin */ - -/* Dark theme: Catpuccin Mocha */ -:root { - --color-rosewater: #f5e0dc; - --color-flamingo: #f2cdcd; - --color-pink: #f5c2e7; - --color-mauve: #cba6f7; - --color-red: #f38ba8; - --color-maroon: #eba0ac; - --color-peach: #fab387; - --color-yellow: #f9e2af; - --color-green: #a6e3a1; - --color-teal: #94e2d5; - --color-sky: #89dceb; - --color-sapphire: #74c7ec; - --color-blue: #89b4fa; - --color-lavender: #b4befe; - --color-text: #cdd6f4; - --color-subtext1: #bac2de; - --color-subtext0: #a6adc8; - --color-overlay2: #9399b2; - --color-overlay1: #7f849c; - --color-overlay0: #6c7086; - --color-surface2: #585b70; - --color-surface1: #45475a; - --color-surface0: #313244; - --color-base: #1e1e2e; - --color-mantle: #181825; - --color-crust: #11111b; - - /* --font-family: Iosevka Web; /* Specify the font here */ -} - -/* Light theme: Catppuccin Latte */ -@media (prefers-color-scheme: light) { - :root { - --color-rosewater: #dc8a78; - --color-flamingo: #dd7878; - --color-pink: #ea76cb; - --color-mauve: #8839ef; - --color-red: #d20f39; - --color-maroon: #e64553; - --color-peach: #fe640b; - --color-yellow: #df8e1d; - --color-green: #40a02b; - --color-teal: #179299; - --color-sky: #04a5e5; - --color-sapphire: #209fb5; - --color-blue: #1e66f5; - --color-lavender: #7287fd; - --color-text: #4c4f69; - --color-subtext1: #5c5f77; - --color-subtext0: #6c6f85; - --color-overlay2: #7c7f93; - --color-overlay1: #8c8fa1; - --color-overlay0: #9ca0b0; - --color-surface2: #acb0be; - --color-surface1: #bcc0cc; - --color-surface0: #ccd0da; - --color-base: #eff1f5; - --color-mantle: #e6e9ef; - --color-crust: #dce0e8; - } -} - - /** Various settings (variables) */ :root { --sidebar-size: max(10vw, 160px); @@ -773,3 +705,12 @@ midi-player { margin-bottom: 100px; margin-top: 20px; } + +#logs-embed { + margin: auto; + height: 80vh; + width: 95%; + padding: 5px; + border-radius: 5px; + background-color: var(--color-crust); +} diff --git a/partitioncloud/templates/admin/index.html b/partitioncloud/templates/admin/index.html index 565e902..6dcb070 100644 --- a/partitioncloud/templates/admin/index.html +++ b/partitioncloud/templates/admin/index.html @@ -6,10 +6,13 @@
-
Ajouter un utilisateur
+
Nouvel utilisateur
-
Voir toutes les partitions
+
Voir les partitions
+
+ +
Voir les logs
diff --git a/partitioncloud/templates/admin/logs.html b/partitioncloud/templates/admin/logs.html new file mode 100644 index 0000000..308c0c3 --- /dev/null +++ b/partitioncloud/templates/admin/logs.html @@ -0,0 +1,10 @@ +{% set scripts=["scripts/logs.js"] %} +{% extends 'base.html' %} + +{% block header %} +

{% block title %}Logs{% endblock %}

+{% endblock %} + +{% block content %} + +{% endblock %} diff --git a/partitioncloud/templates/base.html b/partitioncloud/templates/base.html index 1ff01a6..7e92392 100644 --- a/partitioncloud/templates/base.html +++ b/partitioncloud/templates/base.html @@ -5,8 +5,8 @@ {% block title %}{% endblock %} - PartitionCloud - - + + @@ -185,5 +185,8 @@
- + +{% for script in scripts %} + +{% endfor %} \ No newline at end of file