WIP: Add light/dark theme with toggle in navbar (dark theme styling incomplete - dont care for now)

This commit is contained in:
Peter Stockings
2025-11-23 22:00:41 +11:00
parent fc494a9355
commit 89a17f68ab
15 changed files with 463 additions and 260 deletions

View File

@@ -2,6 +2,15 @@
{% block page %}
{{ render_partial('dashboard/http_functions/header.html', user_id=user_id, function_id=function_id,
active_tab='logs',
show_edit_form=True,
show_logs=True,
show_client=True,
{% extends 'dashboard.html' %}
{% block page %}
{{ render_partial('dashboard/http_functions/header.html', user_id=user_id, function_id=function_id,
active_tab='logs',
show_edit_form=True,
@@ -15,23 +24,25 @@ history_url=url_for('http.history', function_id=function_id)) }}
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
{{ render_partial('dashboard/analytics.html', invocations=http_function_invocations) }}
<div class="bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden">
<div
class="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700 overflow-hidden">
<!-- Headers -->
<div class="grid md:grid-cols-4 gap-4 bg-gray-50 p-4 border-b border-gray-200">
<div class="font-semibold text-gray-600 md:block hidden">Timestamp</div>
<div class="font-semibold text-gray-600 md:block hidden">Request</div>
<div class="font-semibold text-gray-600 md:block hidden">Response</div>
<div class="font-semibold text-gray-600 md:block hidden">Logs</div>
<div
class="grid md:grid-cols-4 gap-4 bg-gray-50 dark:bg-gray-700 p-4 border-b border-gray-200 dark:border-gray-600">
<div class="font-semibold text-gray-600 dark:text-gray-300 md:block hidden">Timestamp</div>
<div class="font-semibold text-gray-600 dark:text-gray-300 md:block hidden">Request</div>
<div class="font-semibold text-gray-600 dark:text-gray-300 md:block hidden">Response</div>
<div class="font-semibold text-gray-600 dark:text-gray-300 md:block hidden">Logs</div>
</div>
<!-- Data Rows -->
{% for invocation in http_function_invocations %}
<div
class="log-row grid md:grid-cols-4 gap-4 p-4 hover:bg-gray-50 transition-colors duration-150 border-b border-gray-200">
class="log-row grid md:grid-cols-4 gap-4 p-4 hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors duration-150 border-b border-gray-200 dark:border-gray-700">
<!-- Timestamp and Status -->
<div class="flex items-center space-x-2">
<div
class="{{ 'bg-green-100 text-green-700' if invocation.status == 'SUCCESS' else 'bg-red-100 text-red-700' }} p-2 rounded-full">
class="{{ 'bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-300' if invocation.status == 'SUCCESS' else 'bg-red-100 text-red-700 dark:bg-red-900/30 dark:text-red-300' }} p-2 rounded-full">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="{{ 'M5 13l4 4L19 7' if invocation.status == 'SUCCESS' else 'M6 18L18 6M6 6l12 12' }}">
@@ -39,28 +50,31 @@ history_url=url_for('http.history', function_id=function_id)) }}
</svg>
</div>
<div class="flex flex-col">
<span class="text-sm text-gray-900">{{ invocation.invocation_time.strftime('%Y-%m-%d %H:%M:%S')
<span class="text-sm text-gray-900 dark:text-gray-200">{{
invocation.invocation_time.strftime('%Y-%m-%d %H:%M:%S')
}}</span>
<span
class="inline-flex items-center w-fit px-2 py-1 text-xs font-medium bg-blue-100 text-blue-700 rounded-full">
class="inline-flex items-center w-fit px-2 py-1 text-xs font-medium bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-300 rounded-full">
v{{ invocation.version_number }}
</span>
</div>
</div>
<!-- Request Data -->
<div class="bg-gray-50 rounded-lg p-3 overflow-auto max-h-40">
<pre class="text-sm font-mono text-gray-600 whitespace-pre-wrap">{{ invocation.request_data }}</pre>
<div class="bg-gray-50 dark:bg-gray-900 rounded-lg p-3 overflow-auto max-h-40">
<pre
class="text-sm font-mono text-gray-600 dark:text-gray-300 whitespace-pre-wrap">{{ invocation.request_data }}</pre>
</div>
<!-- Response Data -->
<div class="bg-gray-50 rounded-lg p-3 overflow-auto max-h-40">
<pre class="text-sm font-mono text-gray-600 whitespace-pre-wrap">{{ invocation.response_data }}</pre>
<div class="bg-gray-50 dark:bg-gray-900 rounded-lg p-3 overflow-auto max-h-40">
<pre
class="text-sm font-mono text-gray-600 dark:text-gray-300 whitespace-pre-wrap">{{ invocation.response_data }}</pre>
</div>
<!-- Logs -->
<div class="bg-gray-50 rounded-lg p-3 overflow-auto max-h-40">
<pre class="text-sm font-mono text-gray-600 whitespace-pre-wrap">{% if invocation.logs and invocation.logs[0] is iterable and invocation.logs[0] is not string -%}
<div class="bg-gray-50 dark:bg-gray-900 rounded-lg p-3 overflow-auto max-h-40">
<pre class="text-sm font-mono text-gray-600 dark:text-gray-300 whitespace-pre-wrap">{% if invocation.logs and invocation.logs[0] is iterable and invocation.logs[0] is not string -%}
{{- invocation.logs | map('join', ' ') | join('\n') -}}
{%- elif invocation.logs is iterable and invocation.logs is not string -%}
{{- invocation.logs | join('\n') -}}
@@ -68,7 +82,7 @@ history_url=url_for('http.history', function_id=function_id)) }}
{{- invocation.logs | string -}}
{%- endif -%}</pre>
{% if not invocation.logs %}
<div class="text-sm text-gray-400 italic">No logs available</div>
<div class="text-sm text-gray-400 dark:text-gray-500 italic">No logs available</div>
{% endif %}
</div>
</div>
@@ -76,14 +90,14 @@ history_url=url_for('http.history', function_id=function_id)) }}
{% if not http_function_invocations %}
<div class="p-8 text-center">
<div class="text-gray-400">
<div class="text-gray-400 dark:text-gray-500">
<svg class="mx-auto h-12 w-12" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
</svg>
</div>
<h3 class="mt-2 text-sm font-medium text-gray-900">No logs found</h3>
<p class="mt-1 text-sm text-gray-500">No function invocations have been recorded yet.</p>
<h3 class="mt-2 text-sm font-medium text-gray-900 dark:text-white">No logs found</h3>
<p class="mt-1 text-sm text-gray-500 dark:text-gray-400">No function invocations have been recorded yet.</p>
</div>
{% endif %}
</div>